Class | Sequel::SingleConnectionPool
In: | lib/sequel/connection_pool/single.rb
Parent: | Sequel::ConnectionPool

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.

### Methods

all_connections disconnect hold size

### Public Instance methods

all_connections() {|@conn if @conn| ...}

Yield the connection if one has been made.

[Source]

        # File lib/sequel/connection_pool/single.rb, line 12
    12:   def all_connections
    13:     yield @conn if @conn
    14:   end

disconnect(opts=nil, &block)

Disconnect the connection from the database.

[Source]

        # File lib/sequel/connection_pool/single.rb, line 17
    17:   def disconnect(opts=nil, &block)
    18:     return unless @conn
    19:     block ||= @disconnection_proc
    20:     block.call(@conn) if block
    21:     @conn = nil
    22:   end

hold(server=nil) {|@conn ||= make_new(DEFAULT_SERVER)| ...}

Yield the connection to the block.

[Source]

        # File lib/sequel/connection_pool/single.rb, line 25
    25:   def hold(server=nil)
    26:     begin
    27:       yield(@conn ||= make_new(DEFAULT_SERVER))
    28:     rescue Sequel::DatabaseDisconnectError
    29:       disconnect
    30:       raise
    31:     end
    32:   end

size()

The SingleConnectionPool always has a size of 1 if connected and 0 if not.

[Source]

       # File lib/sequel/connection_pool/single.rb, line 7
    7:   def size
    8:     @conn ? 1 : 0
    9:   end

[Validate]