Module: Moped::Connection::Manager
Overview
This class contains behaviour of connection pools for specific addresses.
Constant Summary collapse
- MUTEX =
Used for synchronization of pools access.
Mutex.new
- POOL_SIZE =
The default max size for the connection pool.
5
- TIMEOUT =
The default timeout for getting connections from the queue.
0.5
Instance Method Summary collapse
-
#pool(node) ⇒ Pool
Get a connection pool for the provided node.
-
#shutdown(node) ⇒ nil
Shutdown the connection pool for the provided node.
Instance Method Details
#pool(node) ⇒ Pool
Get a connection pool for the provided node.
32 33 34 35 36 |
# File 'lib/moped/connection/manager.rb', line 32 def pool(node) MUTEX.synchronize do pools[node.address.resolved] ||= create_pool(node) end end |
#shutdown(node) ⇒ nil
Shutdown the connection pool for the provided node. In the case of unresolved IP addresses the resolved address would be nil resulting in the same pool for all nodes that did not have IP resolved.
50 51 52 53 54 55 56 |
# File 'lib/moped/connection/manager.rb', line 50 def shutdown(node) MUTEX.synchronize do pool = pools.delete(node.address.resolved) pool.shutdown{ |conn| conn.disconnect } if pool nil end end |