lib/serfx/connection.rb
# takes raw RPC command name and an optional request body
# and convert them to msgpack encoded data and then send
# over tcp
#
# @param command [String] RPC command name
# @param body [Hash] request body of the RPC command
#
# @return [Integer]
takes raw RPC command name and an optional request body
and convert them to msgpack encoded data and then send
over tcp
takes raw RPC command name and an optional request body and convert them to msgpack encoded data and then send over tcp
def tcp_send(command, body = nil)
      @seq += 1
      header = {
        'Command' => command.to_s.gsub('_', '-'),
        'Seq' => seq
      }
      Log.info("#{__method__}|Header: #{header.inspect}")
      buff = MessagePack::Buffer.new
      buff << header.to_msgpack
      buff << body.to_msgpack unless body.nil?
      res = socket.send(buff.to_str, 0)
      Log.info("#{__method__}|Res: #{res.inspect}")
      @requests[seq] = { header: header, ack?: false }
      seq
    end
def tcp_send ( command , body = nil ) @seq += 1 header = { 'Command' => command . to_s . gsub ( '_' , '-' ) , 'Seq' => seq } Log . info ( "#{__method__}|Header: #{header.inspect}" ) buff = MessagePack :: Buffer . new buff << header . to_msgpack buff << body . to_msgpack unless body . nil? res = socket . send ( buff . to_str , 0 ) Log . info ( "#{__method__}|Res: #{res.inspect}" ) @requests [ seq ] = { header : header , ack? : false } seq end
takes raw RPC command name and an optional request body
and convert them to msgpack encoded data and then send
over tcp
takes raw RPC command name and an optional request body and convert them to msgpack encoded data and then send over tcp
None
Integer
command
RPC command name
RPC command name
body
request body of the RPC command
request body of the RPC command