Module: Aerospike::Cluster::CreateConnection

Defined in:
lib/aerospike/cluster/create_connection.rb

Overview

Create connection based on cluster config and authenticate if needed

Class Method Summary collapse

Class Method Details

.call(cluster, host) ⇒ Object



25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/aerospike/cluster/create_connection.rb', line 25

def call(cluster, host)
  ::Aerospike::Connection::Create.(
    host.name,
    host.port,
    tls_name: host.tls_name,
    timeout: cluster.connection_timeout,
    tls_options: cluster.tls_options
  ).tap do |conn|
    if cluster.credentials_given?
      # Authenticate will raise and close connection if invalid credentials
      Connection::AuthenticateNew.(conn, cluster)
    end
  end
end