Module: LlmCostTracker::Ingestion::Pool

Defined in:
lib/llm_cost_tracker/ingestion/pool.rb

Constant Summary collapse

DEFAULT_POOL_SIZE =
2
MUTEX =
Mutex.new

Class Method Summary collapse

Class Method Details

.poolObject



14
15
16
# File 'lib/llm_cost_tracker/ingestion/pool.rb', line 14

def pool
  @pool || MUTEX.synchronize { @pool ||= connect! }
end

.reset!Object



18
19
20
21
22
23
24
# File 'lib/llm_cost_tracker/ingestion/pool.rb', line 18

def reset!
  MUTEX.synchronize do
    @pool&.disconnect!
    @pool = nil
    @handler = nil
  end
end

.with_connectionObject



10
11
12
# File 'lib/llm_cost_tracker/ingestion/pool.rb', line 10

def with_connection(&)
  pool.with_connection(&)
end