Class: Fluent::Plugin::ValuesParser

Inherits:
Parser show all
Includes:
Compat::TypeConverter
Defined in:
lib/fluent/plugin/parser.rb

Constant Summary

Constants included from Compat::TypeConverter

Compat::TypeConverter::Converters

Constants inherited from Parser

Parser::TimeParser

Constants included from Configurable

Configurable::CONFIG_TYPE_REGISTRY

Instance Attribute Summary

Attributes inherited from Parser

#estimate_current_event

Attributes inherited from Base

#under_plugin_development

Instance Method Summary collapse

Methods included from Compat::TypeConverter

included

Methods inherited from Parser

#call, #initialize, #parse

Methods included from TimeMixin::Parser

included, #time_parser_create

Methods included from OwnedByMixin

#log, #owner, #owner=

Methods inherited from Base

#after_shutdown, #after_shutdown?, #after_start, #after_started?, #before_shutdown, #before_shutdown?, #close, #closed?, #configured?, #has_router?, #initialize, #inspect, #shutdown, #shutdown?, #start, #started?, #stop, #stopped?, #terminate, #terminated?

Methods included from SystemConfig::Mixin

#system_config, #system_config_override

Methods included from Configurable

#config, included, #initialize, lookup_type, register_type

Constructor Details

This class inherits a constructor from Fluent::Plugin::Parser

Instance Method Details

#configure(conf) ⇒ Object



65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
# File 'lib/fluent/plugin/parser.rb', line 65

def configure(conf)
  super

  if @time_key && !@keys.include?(@time_key) && @estimate_current_event
    raise Fluent::ConfigError, "time_key (#{@time_key.inspect}) is not included in keys (#{@keys.inspect})"
  end

  if @time_format && !@time_key
    raise Fluent::ConfigError, "time_format parameter is ignored because time_key parameter is not set. at #{conf.inspect}"
  end

  @time_parser = time_parser_create

  if @null_value_pattern
    @null_value_pattern = Regexp.new(@null_value_pattern)
  end

  @mutex = Mutex.new
end

#values_map(values) ⇒ Object



85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
# File 'lib/fluent/plugin/parser.rb', line 85

def values_map(values)
  record = Hash[keys.zip(values.map { |value| convert_value_to_nil(value) })]

  if @time_key
    value = @keep_time_key ? record[@time_key] : record.delete(@time_key)
    time = if value.nil?
             if @estimate_current_event
               Fluent::EventTime.now
             else
               nil
             end
           else
             @mutex.synchronize { @time_parser.parse(value) }
           end
  elsif @estimate_current_event
    time = Fluent::EventTime.now
  else
    time = nil
  end

  convert_field_type!(record) if @type_converters

  return time, record
end