Class: Sequel::SingleConnectionPool
- Inherits:
-
ConnectionPool
- Object
- ConnectionPool
- Sequel::SingleConnectionPool
- Defined in:
- lib/sequel/connection_pool/single.rb
Overview
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.
Constant Summary
Constants inherited from ConnectionPool
ConnectionPool::CONNECTION_POOL_MAP, ConnectionPool::DEFAULT_SERVER
Instance Method Summary collapse
-
#disconnect(opts = nil, &block) ⇒ Object
Disconnect the connection from the database.
-
#hold(server = nil) ⇒ Object
Yield the connection to the block.
-
#size ⇒ Object
The SingleConnectionPool always has a size of 1 if connected and 0 if not.
Methods inherited from ConnectionPool
#created_count, #initialize, #servers
Methods included from ConnectionPool::ClassMethods
Constructor Details
This class inherits a constructor from Sequel::ConnectionPool
Instance Method Details
#disconnect(opts = nil, &block) ⇒ Object
Disconnect the connection from the database.
12 13 14 15 16 17 |
# File 'lib/sequel/connection_pool/single.rb', line 12 def disconnect(opts=nil, &block) return unless @conn block ||= @disconnection_proc block.call(@conn) if block @conn = nil end |
#hold(server = nil) ⇒ Object
Yield the connection to the block.
20 21 22 23 24 25 26 27 |
# File 'lib/sequel/connection_pool/single.rb', line 20 def hold(server=nil) begin yield(@conn ||= make_new(DEFAULT_SERVER)) rescue Sequel::DatabaseDisconnectError disconnect raise end end |
#size ⇒ Object
The SingleConnectionPool always has a size of 1 if connected and 0 if not.
7 8 9 |
# File 'lib/sequel/connection_pool/single.rb', line 7 def size @conn ? 1 : 0 end |