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.



338
339
340
341
342
# File 'lib/fluent/plugin/in_forward.rb', line 338

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

Instance Method Details

#on_readableObject



344
345
346
347
348
349
350
351
352
353
354
355
# File 'lib/fluent/plugin/in_forward.rb', line 344

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