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
copy from fluentd.
- #find(tag) ⇒ Object
-
#initialize(reemit) ⇒ V12EventRouter
constructor
A new instance of V12EventRouter.
-
#match(tag) ⇒ Object
copy from fluentd.
Constructor Details
#initialize(reemit) ⇒ V12EventRouter
Returns a new instance of V12EventRouter.
54 55 56 57 58 59 60 61 62 63 |
# File 'lib/fluent/plugin/out_reemit.rb', line 54 def initialize(reemit) @reemit = reemit @event_router = Engine.root_agent.event_router @chain = @event_router.instance_variable_get(:@chain) # only v0.12 @emit_error_handler = @event_router.emit_error_handler @match_rules = @event_router.instance_variable_get(:@match_rules) @default_collector = @event_router.default_collector # @match_cache = @event_router.match_cache @match_cache = EventRouter::MatchCache.new # need to use a different cache end |
Instance Method Details
#emit_stream(tag, es) ⇒ Object
copy from fluentd
66 67 68 69 70 |
# File 'lib/fluent/plugin/out_reemit.rb', line 66 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
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 110 111 112 113 |
# File 'lib/fluent/plugin/out_reemit.rb', line 80 def find(tag) # We want to reemit messages to the **next** `<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
copy from fluentd
73 74 75 76 77 78 |
# File 'lib/fluent/plugin/out_reemit.rb', line 73 def match(tag) collector = @match_cache.get(tag) { c = find(tag) || @default_collector } collector end |