lib/fluent/plugin/out_map.rb in fluent-plugin-map-0.0.5 vs lib/fluent/plugin/out_map.rb in fluent-plugin-map-0.0.6
- old
+ new
@@ -1,13 +1,18 @@
module Fluent
class MapOutput < Fluent::Output
Fluent::Plugin.register_output('map', self)
+ # Define `router` method of v0.12 to support v0.10 or earlier
+ unless method_defined?(:router)
+ define_method("router") { Fluent::Engine }
+ end
+
config_param :map, :string, :default => nil
config_param :tag, :string, :default => nil
- config_param :key, :string, :default => nil #deprected
+ config_param :key, :string, :default => nil #deprecated
config_param :time, :string, :default => nil
config_param :record, :string, :default => nil
config_param :multi, :bool, :default => false
config_param :timeout, :time, :default => 1
config_param :format, :string, :default => nil
@@ -27,11 +32,11 @@
elsif @map
"map"
elsif (@tag || @key) && @time && @record
"record"
else
- raise ConfigError, "Any of map, 3 parameters(key, time, and record) or format is required "
+ raise ConfigError, "Any of map, 3 parameters(tag, time, and record) or format is required "
end
end
def configure_format()
case @format
@@ -67,11 +72,11 @@
end
end
def parse_multimap(conf)
check_mmap_range(conf)
-
+
prev_mmap = nil
result_mmaps = (1..MMAP_MAX_NUM).map { |i|
mmap = conf["mmap#{i}"]
if (i > 1) && prev_mmap.nil? && !mmap.nil?
raise ConfigError, "Jump of mmap index found. mmap#{i - 1} is missing."
@@ -97,10 +102,10 @@
def emit(tag, es, chain)
begin
tag_output_es = do_map(tag, es)
tag_output_es.each_pair do |tag, output_es|
- Fluent::Engine::emit_stream(tag, output_es)
+ router.emit_stream(tag, output_es)
end
chain.next
tag_output_es
rescue SyntaxError => e
chain.next