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.
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 unless @conn.empty? 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 unless c = @conn.first 28 @conn.replace([c = make_new(:default)]) 29 end 30 yield c 31 rescue Sequel::DatabaseDisconnectError, *@error_classes => e 32 disconnect if disconnect_error?(e) 33 raise 34 end
max_size()
The SingleConnectionPool
always has a maximum size of 1.
[show source]
# File lib/sequel/connection_pool/single.rb 37 def max_size 38 1 39 end
pool_type()
[show source]
# File lib/sequel/connection_pool/single.rb 41 def pool_type 42 :single 43 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 47 def size 48 @conn.empty? ? 0 : 1 49 end