module Sequel::ServerBlock

Public Class Methods

extended(db) click to toggle source

Enable the server block on the connection pool, choosing the correct extension depending on whether the connection pool is threaded or not. Also defines the #with_server method on the receiver for easy use.

# File lib/sequel/extensions/server_block.rb, line 46
def self.extended(db)
  pool = db.pool
  if defined?(ShardedThreadedConnectionPool) && pool.is_a?(ShardedThreadedConnectionPool)
    pool.extend(ThreadedServerBlock)
    pool.instance_variable_set(:@default_servers, {})
  else
    pool.extend(UnthreadedServerBlock)
    pool.instance_variable_set(:@default_servers, [])
  end
end

Public Instance Methods

with_server(server, &block) click to toggle source

Delegate to the connection pool

# File lib/sequel/extensions/server_block.rb, line 58
def with_server(server, &block)
  pool.with_server(server, &block)
end