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

Public Instance methods

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 the connection from the database.

[Source]

    # File lib/sequel/connection_pool/single.rb, line 17
17:   def disconnect(opts=nil)
18:     return unless @conn
19:     db.disconnect_connection(@conn)
20:     @conn = nil
21:   end

Yield the connection to the block.

[Source]

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

[Source]

    # File lib/sequel/connection_pool/single.rb, line 33
33:   def pool_type
34:     :single
35:   end

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]