Method: Sequel::ThreadedConnectionPool#initialize
- Defined in:
- lib/sequel/connection_pool/threaded.rb
#initialize(opts = {}, &block) ⇒ ThreadedConnectionPool
The following additional options are respected:
-
:max_connections - The maximum number of connections the connection pool will open (default 4)
-
:pool_sleep_time - The amount of time to sleep before attempting to acquire a connection again (default 0.001)
-
:pool_timeout - The amount of seconds to wait to acquire a connection before raising a PoolTimeoutError (default 5)
22 23 24 25 26 27 28 29 30 31 |
# File 'lib/sequel/connection_pool/threaded.rb', line 22 def initialize(opts = {}, &block) super @max_size = Integer(opts[:max_connections] || 4) raise(Sequel::Error, ':max_connections must be positive') if @max_size < 1 @mutex = Mutex.new @available_connections = [] @allocated = {} @timeout = Integer(opts[:pool_timeout] || 5) @sleep_time = Float(opts[:pool_sleep_time] || 0.001) end |