Class: Fluent::Plugin::MapOutput

Inherits:
Output
  • Object
show all
Includes:
Fluent::ParseMap::Mixin, MapConfigParam
Defined in:
lib/fluent/plugin/out_map.rb

Constant Summary

Constants included from Fluent::ParseMap::Mixin

Fluent::ParseMap::Mixin::MMAP_MAX_NUM

Instance Method Summary collapse

Methods included from Fluent::ParseMap::Mixin

#check_mmap_range, #parse_map, #parse_multimap

Methods included from MapConfigParam

included

Instance Method Details

#configure(conf) ⇒ Object



38
39
40
41
42
43
44
45
# File 'lib/fluent/plugin/out_map.rb', line 38

def configure(conf)
  log.warn "out_map is now deprecated. It will be removed in a future release. Please consider to use filter_map."
  super
  @format = determine_format()
  configure_format()
  @map = create_map(conf)
  @map_support = Fluent::Plugin::MapSupport.new(@map, self)
end

#configure_formatObject



65
66
67
68
69
70
71
72
73
74
75
76
77
# File 'lib/fluent/plugin/out_map.rb', line 65

def configure_format()
  case @format
  when "map"
    # pass
  when "record"
    @tag ||= @key
    raise Fluent::ConfigError, "multi and 3 parameters(tag, time, and record) are not compatible" if @multi
  when "multimap"
    # pass.
  else
    raise Fluent::ConfigError, "format #{@format} is invalid."
  end
end

#create_map(conf) ⇒ Object



79
80
81
82
83
84
85
86
87
88
89
# File 'lib/fluent/plugin/out_map.rb', line 79

def create_map(conf)
  # return string like double array.
  case @format
  when "map"
    parse_map()
  when "record"
    "[[#{@tag}, #{@time}, #{@record}]]"
  when "multimap"
    parse_multimap(conf)
  end
end

#determine_formatObject



53
54
55
56
57
58
59
60
61
62
63
# File 'lib/fluent/plugin/out_map.rb', line 53

def determine_format()
  if @format
    @format
  elsif @map
    "map"
  elsif (@tag || @key) && @time && @record
    "record"
  else
    raise Fluent::ConfigError, "Any of map, 3 parameters(tag, time, and record) or format is required "
  end
end

#multi_workers_ready?Boolean

Returns:

  • (Boolean)


34
35
36
# File 'lib/fluent/plugin/out_map.rb', line 34

def multi_workers_ready?
  true
end

#process(tag, es) ⇒ Object



91
92
93
94
95
96
97
98
99
100
101
102
# File 'lib/fluent/plugin/out_map.rb', line 91

def process(tag, es)
  begin
    tag_output_es = @map_support.do_map(tag, es)
    tag_output_es.each_pair do |tag, output_es|
      router.emit_stream(tag, output_es)
    end
    tag_output_es
  rescue SyntaxError => e
    log.error "map command is syntax error: #{@map}"
    e #for test
  end
end

#stopObject



47
48
49
50
51
# File 'lib/fluent/plugin/out_map.rb', line 47

def stop
  @map_support.stop

  super
end