Class: LogjamAgent::Receiver

Inherits:
Object
  • Object
show all
Defined in:
lib/logjam_agent/receiver.rb

Instance Method Summary collapse

Constructor Details

#initializeReceiver

Returns a new instance of Receiver.



3
4
5
6
7
8
9
10
# File 'lib/logjam_agent/receiver.rb', line 3

def initialize
  @socket = ZMQForwarder.context.socket(ZMQ::ROUTER)
  @socket.setsockopt(ZMQ::RCVTIMEO, 100)
  if @socket.bind("inproc://app") < 0
    raise "ZMQ error on binding: #{ZMQ::Util.error_string}"
  end
  at_exit { @socket.close }
end

Instance Method Details

#receiveObject



12
13
14
15
16
17
18
19
20
# File 'lib/logjam_agent/receiver.rb', line 12

def receive
  answer_parts = []
  if @socket.recv_strings(answer_parts) < 0
    raise "ZMQ error on receiving: #{ZMQ::Util.error_string}"
  end
  answer_parts.shift
  answer_parts[2] = JSON.parse(answer_parts[2])
  answer_parts
end