class Fluent::Plugin::MessagePackParser

Public Instance Methods

configure(conf) click to toggle source
Calls superclass method Fluent::Plugin::Parser#configure
# File lib/fluent/plugin/parser_msgpack.rb, line 25
def configure(conf)
  super
  @unpacker = Fluent::MessagePackFactory.engine_factory.unpacker
end
parse(data, &block) click to toggle source
# File lib/fluent/plugin/parser_msgpack.rb, line 34
def parse(data, &block)
  @unpacker.feed_each(data) do |obj|
    parse_unpacked_data(obj, &block)
  end
end
Also aliased as: parse_partial_data
parse_io(io, &block) click to toggle source
# File lib/fluent/plugin/parser_msgpack.rb, line 41
def parse_io(io, &block)
  u = Fluent::MessagePackFactory.engine_factory.unpacker(io)
  u.each do |obj|
    parse_unpacked_data(obj, &block)
  end
end
parse_partial_data(data, &block)
Alias for: parse
parse_unpacked_data(data) { |time, record| ... } click to toggle source
# File lib/fluent/plugin/parser_msgpack.rb, line 48
def parse_unpacked_data(data)
  if data.is_a?(Hash)
    time, record = convert_values(parse_time(data), data)
    yield time, record
    return
  end

  unless data.is_a?(Array)
    yield nil, nil
    return
  end

  data.each do |record|
    unless record.is_a?(Hash)
      yield nil, nil
      next
    end
    time, converted_record = convert_values(parse_time(record), record)
    yield time, converted_record
  end
end
parser_type() click to toggle source
# File lib/fluent/plugin/parser_msgpack.rb, line 30
def parser_type
  :binary
end