Method: Sequel::ThreadedConnectionPool#initialize
- Defined in:
- lib/sequel/connection_pool/threaded.rb
#initialize(db, opts = OPTS) ⇒ ThreadedConnectionPool
The following additional options are respected:
- :max_connections
-
The maximum number of connections the connection pool will open (default 4)
- :pool_timeout
-
The amount of seconds to wait to acquire a connection before raising a PoolTimeout error (default 5)
26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/sequel/connection_pool/threaded.rb', line 26 def initialize(db, opts = OPTS) super @max_size = Integer(opts[:max_connections] || 4) raise(Sequel::Error, ':max_connections must be positive') if @max_size < 1 @mutex = Mutex.new @connection_handling = opts[:connection_handling] @available_connections = [] @allocated = {} @allocated.compare_by_identity @timeout = Float(opts[:pool_timeout] || 5) @waiter = ConditionVariable.new end |