Class: Aerospike::ConnectionPool

Inherits:
Pool
  • Object
show all
Defined in:
lib/aerospike/utils/connection_pool.rb

Instance Attribute Summary collapse

Attributes inherited from Pool

#check_proc, #cleanup_proc, #create_proc, #max_size

Instance Method Summary collapse

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

#clusterObject

Returns the value of attribute cluster.



20
21
22
# File 'lib/aerospike/utils/connection_pool.rb', line 20

def cluster
  @cluster
end

#hostObject

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

#createObject



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