Class: Sync::EM::PG::Sequel::ConnectionPool
- Inherits:
-
Sequel::ConnectionPool
- Object
- Sequel::ConnectionPool
- Sync::EM::PG::Sequel::ConnectionPool
- Defined in:
- lib/sync-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.
33 34 35 36 37 38 39 |
# File 'lib/sync-em/pg/sequel.rb', line 33 def initialize(db, opts = {}) super size = opts[:max_connection] || DEFAULT_SIZE @pool = ReConnectionPool.new(size: size) do make_new(DEFAULT_SERVER) end end |
Instance Attribute Details
#pool ⇒ Object
Returns the value of attribute pool.
32 33 34 |
# File 'lib/sync-em/pg/sequel.rb', line 32 def pool @pool end |
Instance Method Details
#disconnect(server = nil) ⇒ Object
49 50 51 52 |
# File 'lib/sync-em/pg/sequel.rb', line 49 def disconnect(server = nil) @pool.available.each{ |conn| db.disconnect_connection(conn) } @pool.available.clear end |
#hold(server = nil, &blk) ⇒ Object
45 46 47 |
# File 'lib/sync-em/pg/sequel.rb', line 45 def hold(server = nil, &blk) @pool.execute(false, &blk) end |
#size ⇒ Object
41 42 43 |
# File 'lib/sync-em/pg/sequel.rb', line 41 def size @pool.available.size end |