Class: Fluent::ForwardInput::HeartbeatRequestHandler

Inherits:
Coolio::IO
  • Object
show all
Defined in:
lib/fluent/plugin/in_forward.rb

Instance Method Summary collapse

Constructor Details

#initialize(io, callback) ⇒ HeartbeatRequestHandler

Returns a new instance of HeartbeatRequestHandler.



589
590
591
592
593
# File 'lib/fluent/plugin/in_forward.rb', line 589

def initialize(io, callback)
  super(io)
  @io = io
  @callback = callback
end

Instance Method Details

#on_readableObject



595
596
597
598
599
600
601
602
603
604
605
606
# File 'lib/fluent/plugin/in_forward.rb', line 595

def on_readable
  begin
    msg, addr = @io.recvfrom(1024)
  rescue Errno::EAGAIN, Errno::EWOULDBLOCK, Errno::EINTR
    return
  end
  host = addr[3]
  port = addr[1]
  @callback.call(host, port, msg)
rescue
  # TODO log?
end