class Fluent::Plugin::UdpInput

Public Instance Methods

configure(conf) click to toggle source
Calls superclass method Fluent::PluginLoggerMixin#configure
# File lib/fluent/plugin/in_udp.rb, line 48
def configure(conf)
  compat_parameters_convert(conf, :parser)
  super
  @_event_loop_blocking_timeout = @blocking_timeout
  @source_hostname_key ||= @source_host_key if @source_host_key
  @message_length_limit = @body_size_limit if @body_size_limit

  @parser = parser_create
end
multi_workers_ready?() click to toggle source
# File lib/fluent/plugin/in_udp.rb, line 58
def multi_workers_ready?
  true
end
start() click to toggle source
Calls superclass method Fluent::Compat::Input#start
# File lib/fluent/plugin/in_udp.rb, line 62
def start
  super

  log.info "listening udp socket", bind: @bind, port: @port
  server_create(:in_udp_server, @port, proto: :udp, bind: @bind, resolve_name: !!@source_hostname_key, max_bytes: @message_length_limit, receive_buffer_size: @receive_buffer_size) do |data, sock|
    data.chomp! if @remove_newline
    begin
      @parser.parse(data) do |time, record|
        unless time && record
          log.warn "pattern not match", data: data
          next
        end

        tag = extract_tag_from_record(record)
        tag ||= @tag
        time ||= extract_time_from_record(record) || Fluent::EventTime.now
        record[@source_hostname_key] = sock.remote_host if @source_hostname_key
        router.emit(tag, time, record)
      end
    end
  end
end