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, ConnectionPool::OPTS
Instance Attribute Summary
Attributes inherited from ConnectionPool
Instance Method Summary collapse
-
#all_connections {|@conn| ... } ⇒ Object
Yield the connection if one has been made.
-
#disconnect(opts = nil) ⇒ Object
Disconnect the connection from the database.
-
#hold(server = nil) ⇒ Object
Yield the connection to the block.
-
#max_size ⇒ Object
The SingleConnectionPool always has a maximum size of 1.
- #pool_type ⇒ Object
-
#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
#all_connections {|@conn| ... } ⇒ Object
Yield the connection if one has been made.
8 9 10 |
# File 'lib/sequel/connection_pool/single.rb', line 8 def all_connections yield @conn if @conn end |
#disconnect(opts = nil) ⇒ Object
Disconnect the connection from the database.
13 14 15 16 17 |
# File 'lib/sequel/connection_pool/single.rb', line 13 def disconnect(opts=nil) return unless @conn disconnect_connection(@conn) @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, *@error_classes => e disconnect if disconnect_error?(e) raise end end |
#max_size ⇒ Object
The SingleConnectionPool always has a maximum size of 1.
30 31 32 |
# File 'lib/sequel/connection_pool/single.rb', line 30 def max_size 1 end |
#pool_type ⇒ Object
34 35 36 |
# File 'lib/sequel/connection_pool/single.rb', line 34 def pool_type :single end |
#size ⇒ Object
The SingleConnectionPool always has a size of 1 if connected and 0 if not.
40 41 42 |
# File 'lib/sequel/connection_pool/single.rb', line 40 def size @conn ? 1 : 0 end |