new(pool_config)
public
Creates a new
ConnectionPool object. pool_config is a PoolConfig object which
describes database connection
information (e.g. adapter, host name, username, password, etc), as well as
the maximum size for this ConnectionPool.
The default ConnectionPool maximum size is 5.
Show source
def initialize(pool_config)
super()
@pool_config = pool_config
@db_config = pool_config.db_config
@role = pool_config.role
@shard = pool_config.shard
@checkout_timeout = db_config.checkout_timeout
@idle_timeout = db_config.idle_timeout
@size = db_config.pool
@thread_cached_conns = Concurrent::Map.new(initial_capacity: @size)
@connections = []
@automatic_reconnect = true
@now_connecting = 0
@threads_blocking_new_connections = 0
@available = ConnectionLeasingQueue.new self
@lock_thread = false
@async_executor = build_async_executor
@reaper = Reaper.new(self, db_config.reaping_frequency)
@reaper.run
end