Class: Fluent::ForwardOutput::HeartbeatHandler

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

Instance Method Summary collapse

Constructor Details

#initialize(io, callback) ⇒ HeartbeatHandler

Returns a new instance of HeartbeatHandler.



396
397
398
399
400
# File 'lib/fluent/plugin/out_forward.rb', line 396

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

Instance Method Details

#on_readableObject



402
403
404
405
406
407
408
409
410
411
412
413
414
# File 'lib/fluent/plugin/out_forward.rb', line 402

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