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 8 8: def all_connections 9: yield @conn if @conn 10: end
Disconnect the connection from the database.
# 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.
# 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.
# File lib/sequel/connection_pool/single.rb, line 30 30: def max_size 31: 1 32: end
The SingleConnectionPool always has a size of 1 if connected and 0 if not.
# File lib/sequel/connection_pool/single.rb, line 40 40: def size 41: @conn ? 1 : 0 42: end