Class: Green::EM::PG::Sequel::ConnectionPool
- Inherits:
-
Sequel::ConnectionPool
- Object
- Sequel::ConnectionPool
- Green::EM::PG::Sequel::ConnectionPool
- Defined in:
- lib/green-em/pg/sequel.rb
Constant Summary collapse
- DEFAULT_SIZE =
4
Instance Attribute Summary collapse
-
#pool ⇒ Object
Returns the value of attribute pool.
Instance Method Summary collapse
- #disconnect(server = nil) ⇒ Object
- #hold(server = nil, &blk) ⇒ Object
-
#initialize(db, opts = {}) ⇒ ConnectionPool
constructor
A new instance of ConnectionPool.
- #size ⇒ Object
Constructor Details
#initialize(db, opts = {}) ⇒ ConnectionPool
Returns a new instance of ConnectionPool.
13 14 15 16 17 18 19 |
# File 'lib/green-em/pg/sequel.rb', line 13 def initialize(db, opts = {}) super @pool = Green::ConnectionPool.new size: opts[:max_connection] || DEFAULT_SIZE, disconnect_class: ::Sequel::DatabaseDisconnectError do make_new(DEFAULT_SERVER) end end |
Instance Attribute Details
#pool ⇒ Object
Returns the value of attribute pool.
12 13 14 |
# File 'lib/green-em/pg/sequel.rb', line 12 def pool @pool end |
Instance Method Details
#disconnect(server = nil) ⇒ Object
29 30 31 32 |
# File 'lib/green-em/pg/sequel.rb', line 29 def disconnect(server = nil) @pool.available.each{ |conn| db.disconnect_connection(conn) } @pool.available.clear end |
#hold(server = nil, &blk) ⇒ Object
25 26 27 |
# File 'lib/green-em/pg/sequel.rb', line 25 def hold(server = nil, &blk) @pool.execute(&blk) end |
#size ⇒ Object
21 22 23 |
# File 'lib/green-em/pg/sequel.rb', line 21 def size @pool.available.size end |