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.



325
326
327
328
329
# File 'lib/fluent/plugin/in_forward.rb', line 325

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

Instance Method Details

#on_readableObject



331
332
333
334
335
336
337
338
339
340
341
342
# File 'lib/fluent/plugin/in_forward.rb', line 331

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