class Sequel::SingleConnectionPool
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)
click to toggle source
Calls superclass method
Sequel::ConnectionPool.new
# File lib/sequel/connection_pool/single.rb, line 7 def initialize(db, opts=OPTS) super @conn = [] end
Public Instance Methods
all_connections() { |first| ... }
click to toggle source
Yield the connection if one has been made.
# File lib/sequel/connection_pool/single.rb, line 13 def all_connections yield @conn.first if @conn end
disconnect(opts=nil)
click to toggle source
Disconnect the connection from the database.
# File lib/sequel/connection_pool/single.rb, line 18 def disconnect(opts=nil) return unless @conn disconnect_connection(@conn.first) @conn.clear nil end
hold(server=nil) { |c| ... }
click to toggle source
Yield the connection to the block.
# File lib/sequel/connection_pool/single.rb, line 26 def hold(server=nil) begin unless c = @conn.first @conn.replace([c = make_new(DEFAULT_SERVER)]) end yield c rescue Sequel::DatabaseDisconnectError, *@error_classes => e disconnect if disconnect_error?(e) raise end end
max_size()
click to toggle source
The SingleConnectionPool always has a maximum size of 1.
# File lib/sequel/connection_pool/single.rb, line 39 def max_size 1 end
pool_type()
click to toggle source
# File lib/sequel/connection_pool/single.rb, line 43 def pool_type :single end
size()
click to toggle source
The SingleConnectionPool always has a size of 1 if connected and 0 if not.
# File lib/sequel/connection_pool/single.rb, line 49 def size @conn.empty? ? 0 : 1 end
Private Instance Methods
preconnect(concurrent = nil)
click to toggle source
Make sure there is a valid connection.
# File lib/sequel/connection_pool/single.rb, line 56 def preconnect(concurrent = nil) hold{} end