class Dalli::Elasticache::AutoDiscovery::BaseCommand

Base command class for configuration endpoint command. Contains the network logic.

Attributes

host[R]
port[R]

Public Class Methods

new(host, port) click to toggle source
# File lib/dalli/elasticache/auto_discovery/base_command.rb, line 13
def initialize(host, port)
  @host = host
  @port = port
end

Public Instance Methods

response_from_socket(socket) click to toggle source
# File lib/dalli/elasticache/auto_discovery/base_command.rb, line 31
def response_from_socket(socket)
  data = +''
  until (line = socket.readline).include?('END')
    data << line
  end

  data
end
send_command() click to toggle source

Send an ASCII command to the endpoint

Returns the raw response as a String

# File lib/dalli/elasticache/auto_discovery/base_command.rb, line 21
def send_command
  socket = TCPSocket.new(@host, @port)
  begin
    socket.puts command
    response_from_socket(socket)
  ensure
    socket.close
  end
end