Class: Aerospike::ConnectionPool
- Defined in:
- lib/aerospike/utils/connection_pool.rb
Instance Attribute Summary collapse
-
#cluster ⇒ Object
Returns the value of attribute cluster.
-
#host ⇒ Object
Returns the value of attribute host.
Attributes inherited from Pool
#check_proc, #cleanup_proc, #create_proc, #max_size
Instance Method Summary collapse
- #check(conn) ⇒ Object
- #cleanup(conn) ⇒ Object
- #create ⇒ Object
-
#initialize(cluster, host) ⇒ ConnectionPool
constructor
A new instance of ConnectionPool.
Methods inherited from Pool
#empty?, #inspect, #length, #offer, #poll
Constructor Details
#initialize(cluster, host) ⇒ ConnectionPool
Returns a new instance of ConnectionPool.
22 23 24 25 26 |
# File 'lib/aerospike/utils/connection_pool.rb', line 22 def initialize(cluster, host) self.cluster = cluster self.host = host super(cluster.connection_queue_size) end |
Instance Attribute Details
#cluster ⇒ Object
Returns the value of attribute cluster.
20 21 22 |
# File 'lib/aerospike/utils/connection_pool.rb', line 20 def cluster @cluster end |
#host ⇒ Object
Returns the value of attribute host.
20 21 22 |
# File 'lib/aerospike/utils/connection_pool.rb', line 20 def host @host end |
Instance Method Details
#check(conn) ⇒ Object
37 38 39 |
# File 'lib/aerospike/utils/connection_pool.rb', line 37 def check(conn) conn.alive? end |
#cleanup(conn) ⇒ Object
41 42 43 |
# File 'lib/aerospike/utils/connection_pool.rb', line 41 def cleanup(conn) conn.close if conn end |
#create ⇒ Object
28 29 30 31 32 33 34 35 |
# File 'lib/aerospike/utils/connection_pool.rb', line 28 def create conn = nil loop do conn = cluster.create_connection(host) break if conn.connected? end conn end |