class Sequel::ConnectionPool

  1. lib/sequel/connection_pool.rb
Superclass: Object

The base connection pool class, which all other connection pools are based on. This class is not instantiated directly, but subclasses should at the very least implement the following API:

initialize(Database, Hash)

Initialize using the passed Sequel::Database object and options hash.

hold(Symbol, &block)

Yield a connection object (obtained from calling the block passed to initialize) to the current block. For sharded connection pools, the Symbol passed is the shard/server to use.

disconnect(Symbol)

Disconnect the connection object. For sharded connection pools, the Symbol passed is the shard/server to use.

servers

An array of shard/server symbols for all shards/servers that this connection pool recognizes.

size

an integer representing the total number of connections in the pool, or for the given shard/server if sharding is supported.

max_size

an integer representing the maximum size of the connection pool, or the maximum size per shard/server if sharding is supported.

For sharded connection pools, the sharded API adds the following methods:

add_servers(Array of Symbols)

start recognizing all shards/servers specified by the array of symbols.

remove_servers(Array of Symbols)

no longer recognize all shards/servers specified by the array of symbols.

Methods

Public Class

  1. new

Public Instance

  1. after_connect
  2. after_connect=
  3. connect_sqls
  4. connect_sqls=
  5. db
  6. servers

Constants

OPTS = Sequel::OPTS  
POOL_CLASS_MAP = { :threaded => :ThreadedConnectionPool, :single => :SingleConnectionPool, :sharded_threaded => :ShardedThreadedConnectionPool, :sharded_single => :ShardedSingleConnectionPool, :timed_queue => :TimedQueueConnectionPool, :sharded_timed_queue => :ShardedTimedQueueConnectionPool, }  

Attributes

after_connect [R]

The after_connect proc used for this pool. This is called with each new connection made, and is usually used to set custom per-connection settings. Deprecated.

connect_sqls [R]

An array of sql strings to execute on each new connection. Deprecated.

db [RW]

The Sequel::Database object tied to this connection pool.

Public Class methods

new(db, opts=OPTS)

Instantiates a connection pool with the given Database and options.

[show source]
    # File lib/sequel/connection_pool.rb
113 def initialize(db, opts=OPTS) # SEQUEL6: Remove second argument, always use db.opts
114   @db = db
115   @use_old_connect_api = false # SEQUEL6: Remove
116   @after_connect = opts[:after_connect] # SEQUEL6: Remove
117   @connect_sqls = opts[:connect_sqls] # SEQUEL6: Remove
118   @error_classes = db.send(:database_error_classes).dup.freeze
119 end

Public Instance methods

after_connect=(v)

Override the after_connect proc for the connection pool. Deprecated. Disables support for shard-specific :after_connect and :connect_sqls if used.

[show source]
   # File lib/sequel/connection_pool.rb
94 def after_connect=(v) # SEQUEL6: Remove
95   @use_old_connect_api = true
96   @after_connect = v
97 end
connect_sqls=(v)

Override the connect_sqls for the connection pool. Deprecated. Disables support for shard-specific :after_connect and :connect_sqls if used.

[show source]
    # File lib/sequel/connection_pool.rb
104 def connect_sqls=(v) # SEQUEL6: Remove
105   @use_old_connect_api = true
106   @connect_sqls = v
107 end
servers()

An array of symbols for all shards/servers, which is a single :default by default.

[show source]
    # File lib/sequel/connection_pool.rb
122 def servers
123   [:default]
124 end