Sha256: 7d6c8c9ad86b7024c237d7a7e716a0fb9ef6d0034d51ce3bf73aee11ba8cfff9

Contents?: true

Size: 779 Bytes

Versions: 2

Compression:

Stored size: 779 Bytes

Contents

# This is the fastest connection pool, since it isn't a connection pool at all.
# It is just a wrapper around a single connection that uses the connection pool
# API.
class Sequel::SingleConnectionPool < Sequel::ConnectionPool  
  # The SingleConnectionPool always has a size of 1 if connected
  # and 0 if not.
  def size
    @conn ? 1 : 0
  end
  
  # Disconnect the connection from the database.
  def disconnect(opts=nil, &block)
    block ||= @disconnection_proc
    block.call(@conn) if block
    @conn = nil
  end
  
  # Yield the connection to the block.
  def hold(server=nil)
    begin
      yield(@conn ||= make_new(DEFAULT_SERVER))
    rescue Sequel::DatabaseDisconnectError
      disconnect
      raise
    end
  end

  CONNECTION_POOL_MAP[[true, false]] = self
end

Version data entries

2 entries across 2 versions & 2 rubygems

Version Path
viking-sequel-3.10.0 lib/sequel/connection_pool/single.rb
sequel-3.10.0 lib/sequel/connection_pool/single.rb