class Sequel::SingleConnectionPool

  1. lib/sequel/connection_pool/single.rb
Superclass: 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 Class

  1. new

Public Instance

  1. all_connections
  2. disconnect
  3. hold
  4. max_size
  5. pool_type
  6. size

Public Class methods

new (db, opts=OPTS)
[show source]
   # File lib/sequel/connection_pool/single.rb
 7 def initialize(db, opts=OPTS)
 8   super
 9   @conn = []
10 end

Public Instance methods

all_connections ()

Yield the connection if one has been made.

[show source]
   # File lib/sequel/connection_pool/single.rb
13 def all_connections
14   yield @conn.first if @conn
15 end
disconnect (opts=nil)

Disconnect the connection from the database.

[show source]
   # File lib/sequel/connection_pool/single.rb
18 def disconnect(opts=nil)
19   return unless c = @conn.first
20   disconnect_connection(c)
21   @conn.clear
22   nil
23 end
hold (server=nil)

Yield the connection to the block.

[show source]
   # File lib/sequel/connection_pool/single.rb
26 def hold(server=nil)
27   begin
28     unless c = @conn.first
29       @conn.replace([c = make_new(:default)])
30     end
31     yield c
32   rescue Sequel::DatabaseDisconnectError, *@error_classes => e
33     disconnect if disconnect_error?(e)
34     raise
35   end
36 end
max_size ()

The SingleConnectionPool always has a maximum size of 1.

[show source]
   # File lib/sequel/connection_pool/single.rb
39 def max_size
40   1
41 end
pool_type ()
[show source]
   # File lib/sequel/connection_pool/single.rb
43 def pool_type
44   :single
45 end
size ()

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

[show source]
   # File lib/sequel/connection_pool/single.rb
49 def size
50   @conn.empty? ? 0 : 1
51 end