Class: Fluent::ReemitOutput::V12EventRouter
- Inherits:
-
Object
- Object
- Fluent::ReemitOutput::V12EventRouter
- Defined in:
- lib/fluent/plugin/out_reemit.rb
Direct Known Subclasses
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.
61 62 63 64 65 66 67 68 69 70 |
# File 'lib/fluent/plugin/out_reemit.rb', line 61 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
73 74 75 76 77 |
# File 'lib/fluent/plugin/out_reemit.rb', line 73 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
87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 |
# File 'lib/fluent/plugin/out_reemit.rb', line 87 def find(tag) # We want to reemit messages to the next `<match>` below this `type reemit` # to avoid reemiting back to an above or current `<match>` 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
80 81 82 83 84 85 |
# File 'lib/fluent/plugin/out_reemit.rb', line 80 def match(tag) collector = @match_cache.get(tag) { c = find(tag) || @default_collector } collector end |