class Fluent::SocketUtil::UdpHandler

Public Class Methods

new(io, log, body_size_limit, callback) click to toggle source
Calls superclass method
# File lib/fluent/plugin/socket_util.rb, line 17
def initialize(io, log, body_size_limit, callback)
  super(io)
  @io = io
  @log = log
  @body_size_limit = body_size_limit
  @callback = callback
end

Public Instance Methods

on_readable() click to toggle source
# File lib/fluent/plugin/socket_util.rb, line 25
def on_readable
  msg, addr = @io.recvfrom_nonblock(@body_size_limit)
  msg.chomp!
  @callback.call(msg, addr)
rescue => e
  @log.error "unexpected error", :error => e, :error_class => e.class
end