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.
Yield the connection if one has been made.
# 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.
# 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.
# 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
The SingleConnectionPool always has a size of 1 if connected and 0 if not.
# File lib/sequel/connection_pool/single.rb, line 7 7: def size 8: @conn ? 1 : 0 9: end