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.



309
310
311
312
313
# File 'lib/fluent/plugin/out_forward.rb', line 309

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

Instance Method Details

#on_readableObject



315
316
317
318
319
320
321
322
323
324
325
326
327
# File 'lib/fluent/plugin/out_forward.rb', line 315

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