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 8
 8:   def all_connections
 9:     yield @conn if @conn
10:   end

Disconnect the connection from the database.

[Source]

    # File lib/sequel/connection_pool/single.rb, line 13
13:   def disconnect(opts=nil)
14:     return unless @conn
15:     disconnect_connection(@conn)
16:     @conn = nil
17:   end

Yield the connection to the block.

[Source]

    # File lib/sequel/connection_pool/single.rb, line 20
20:   def hold(server=nil)
21:     begin
22:       yield(@conn ||= make_new(DEFAULT_SERVER))
23:     rescue Sequel::DatabaseDisconnectError, *@error_classes => e
24:       disconnect if disconnect_error?(e)
25:       raise
26:     end
27:   end

The SingleConnectionPool always has a maximum size of 1.

[Source]

    # File lib/sequel/connection_pool/single.rb, line 30
30:   def max_size
31:     1
32:   end

[Source]

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

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

[Source]

    # File lib/sequel/connection_pool/single.rb, line 40
40:   def size
41:     @conn ? 1 : 0
42:   end

[Validate]