Class: Remotus::Pool
- Inherits:
-
Object
- Object
- Remotus::Pool
- Defined in:
- lib/remotus/pool.rb
Overview
Class representing a connection pool containing many host-specific pools
Class Method Summary collapse
-
.clear ⇒ Integer
Removes all host pools from the pool in a thread-safe manner.
-
.connect(host, **options) ⇒ Remotus::HostPool
Attempts to get the host pool for a given host.
-
.count ⇒ Integer
Number of host pools in the pool.
-
.reap ⇒ Integer
Reaps (removes) expired host pools from the pool in a thread-safe manner.
Class Method Details
.clear ⇒ Integer
Removes all host pools from the pool in a thread-safe manner
58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/remotus/pool.rb', line 58 def clear @lock.synchronize do Remotus.logger.debug { "Removing all host pools" } return 0 unless @pool num_pools = count # Force connection close @pool.each { |_hostname, host_pool| host_pool.close } @pool = {} return num_pools end end |
.connect(host, **options) ⇒ Remotus::HostPool
Attempts to get the host pool for a given host
29 30 31 |
# File 'lib/remotus/pool.rb', line 29 def connect(host, **) host_pool(host, **) end |
.count ⇒ Integer
Number of host pools in the pool
38 39 40 |
# File 'lib/remotus/pool.rb', line 38 def count pool.keys.count end |
.reap ⇒ Integer
Reaps (removes) expired host pools from the pool in a thread-safe manner
47 48 49 50 51 |
# File 'lib/remotus/pool.rb', line 47 def reap @lock.synchronize do return reap_host_pools end end |