Class: Fluent::ReemitOutput::V12EventRouter
- Inherits:
-
Object
- Object
- Fluent::ReemitOutput::V12EventRouter
- Defined in:
- lib/fluent/plugin/out_reemit.rb
Instance Method Summary collapse
-
#emit_stream(tag, es) ⇒ Object
same.
- #find(tag) ⇒ Object
-
#initialize(reemit) ⇒ V12EventRouter
constructor
A new instance of V12EventRouter.
-
#match(tag) ⇒ Object
same.
Constructor Details
#initialize(reemit) ⇒ V12EventRouter
Returns a new instance of V12EventRouter.
48 49 50 51 52 53 54 55 56 57 |
# File 'lib/fluent/plugin/out_reemit.rb', line 48 def initialize(reemit) @reemit = reemit @event_router = Engine.instance_variable_get(:@event_router) @chain = @event_router.instance_variable_get(:@chain) @emit_error_handler = @event_router.instance_variable_get(:@emit_error_handler) @match_rules = @event_router.instance_variable_get(:@match_rules) @default_collector = @event_router.instance_variable_get(:@default_collector) # @match_cache = @event_router.instance_variable_get(:@match_cache) @match_cache = EventRouter::MatchCache.new # need to use a different cache end |
Instance Method Details
#emit_stream(tag, es) ⇒ Object
same
60 61 62 63 64 |
# File 'lib/fluent/plugin/out_reemit.rb', line 60 def emit_stream(tag, es) match(tag).emit(tag, es, @chain) rescue => e @emit_error_handler.handle_emits_error(tag, es, e) end |
#find(tag) ⇒ Object
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 |
# File 'lib/fluent/plugin/out_reemit.rb', line 74 def find(tag) # we want to reemit to the next match after this reemit # this avoids reemiting back to an earlier match that # itself did a reemit to the current match that is reemitting. pipeline = nil found_reemit = false @match_rules.each_with_index { |rule, i| # if rule.match?(tag) # this is the original if rule.match?(tag) if found_reemit && !@reemit.included?(rule.collector) if rule.collector.is_a?(Filter) pipeline ||= EventRouter::Pipeline.new pipeline.add_filter(rule.collector) else if pipeline pipeline.set_output(rule.collector) else # Use Output directly when filter is not matched pipeline = rule.collector end return pipeline end elsif !found_reemit && @reemit.included?(rule.collector) found_reemit = true end end } if pipeline # filter is matched but no match pipeline.set_output(@default_collector) pipeline else nil end end |
#match(tag) ⇒ Object
same
67 68 69 70 71 72 |
# File 'lib/fluent/plugin/out_reemit.rb', line 67 def match(tag) collector = @match_cache.get(tag) { c = find(tag) || @default_collector } collector end |