Class: Fluent::UdpEventInput::UdpHandler

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

Overview

Class to handle the UDP layer

Instance Method Summary collapse

Constructor Details

#initialize(io, max_message_size, callback) ⇒ UdpHandler

Returns a new instance of UdpHandler.



109
110
111
112
113
114
# File 'lib/fluent/plugin/in_udp_event.rb', line 109

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

Instance Method Details

#on_readableObject



116
117
118
119
120
121
# File 'lib/fluent/plugin/in_udp_event.rb', line 116

def on_readable
  msg, _ = @io.recvfrom_nonblock(@max_message_size)
  @callback.call(msg)
rescue Exception => e
  $log.error e.message, error: e.message
end