Method: Sequel::ConnectionPool#initialize

Defined in:
lib/sequel/connection_pool.rb

#initialize(db, opts = OPTS) ⇒ ConnectionPool

Instantiates a connection pool with the given options. The block is called with a single symbol (specifying the server/shard to use) every time a new connection is needed. The following options are respected for all connection pools:

:after_connect

A callable object called after each new connection is made, with the connection object (and server argument if the callable accepts 2 arguments), useful for customizations that you want to apply to all connections.

:preconnect

Automatically create the maximum number of connections, so that they don’t need to be created as needed. This is useful when connecting takes a long time and you want to avoid possible latency during runtime. Set to :concurrently to create the connections in separate threads. Otherwise they’ll be created sequentially.



84
85
86
87
88
# File 'lib/sequel/connection_pool.rb', line 84

def initialize(db, opts=OPTS)
  @db = db
  @after_connect = opts[:after_connect]
  @error_classes = db.send(:database_error_classes).dup.freeze
end