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.



415
416
417
418
419
# File 'lib/fluent/plugin/out_forward.rb', line 415

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

Instance Method Details

#on_readableObject



421
422
423
424
425
426
427
428
429
430
431
432
433
# File 'lib/fluent/plugin/out_forward.rb', line 421

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