module Aerospike::Connection::AuthenticateNew

Constants

INVALID_SESSION_ERR

Public Class Methods

call(conn, cluster) click to toggle source
# File lib/aerospike/connection/authenticate.rb, line 39
def call(conn, cluster)
  command = LoginCommand.new
  if cluster.session_valid?
    begin
      command.authenticate_via_token(conn, cluster)
    rescue => ae
      # always reset session info on errors to be on the safe side
      cluster.reset_session_info
      if ae.is_a?(Exceptions::Aerospike)
        if INVALID_SESSION_ERR.include?(ae.result_code)
          command.authenticate_new(conn, cluster)
          return true
        end
      end
      raise ae
    end
  else
    command.authenticate_new(conn, cluster)
  end

  true
rescue ::Aerospike::Exceptions::Aerospike
  conn.close if conn
  raise ::Aerospike::Exceptions::InvalidCredentials
end