Method: Sequel::ShardedThreadedConnectionPool#initialize

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

#initialize(db, opts = OPTS) ⇒ ShardedThreadedConnectionPool

The following additional options are respected:

: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.



18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/sequel/connection_pool/sharded_threaded.rb', line 18

def initialize(db, opts = OPTS)
  super
  @available_connections = {}
  @connections_to_remove = []
  @connections_to_disconnect = []
  @servers = opts.fetch(:servers_hash, Hash.new(:default))
  remove_instance_variable(:@waiter)
  remove_instance_variable(:@allocated)
  @allocated = {}
  @waiters = {}

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