Method: Sequel::ShardedTimedQueueConnectionPool#initialize

Defined in:
lib/sequel/connection_pool/sharded_timed_queue.rb

#initialize(db, opts = OPTS) ⇒ ShardedTimedQueueConnectionPool

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 (default 5)

:servers

A hash of servers to use. Keys should be symbols. If not present, will use a single :default server.

:servers_hash

The base hash to use for the servers. By default, Sequel uses Hash.new(:default). You can use a hash with a default proc that raises an error if you want to catch all cases where a nonexistent server is used.

Raises:

[View source]

24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/sequel/connection_pool/sharded_timed_queue.rb', line 24

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  
  @timeout = Float(opts[:pool_timeout] || 5)

  @allocated = {}
  @sizes = {}
  @queues = {}
  @servers = opts.fetch(:servers_hash, Hash.new(:default))

  add_servers([:default])
  add_servers(opts[:servers].keys) if opts[:servers]
end