Class: Fluent::ReemitOutput::V12EventRouter
- Inherits:
-
Object
- Object
- Fluent::ReemitOutput::V12EventRouter
- Defined in:
- lib/fluent/plugin/out_reemit/v12_event_router.rb
Direct Known Subclasses
Instance Method Summary collapse
-
#emit_stream(tag, es) ⇒ Object
copy from fluentd.
- #filter_class ⇒ Object
- #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.
11 12 13 14 15 16 17 18 19 20 |
# File 'lib/fluent/plugin/out_reemit/v12_event_router.rb', line 11 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 = ::Fluent::EventRouter::MatchCache.new # need to use a different cache end |
Instance Method Details
#emit_stream(tag, es) ⇒ Object
copy from fluentd
23 24 25 26 27 |
# File 'lib/fluent/plugin/out_reemit/v12_event_router.rb', line 23 def emit_stream(tag, es) match(tag).emit(tag, es, @chain) rescue => e @emit_error_handler.handle_emits_error(tag, es, e) end |
#filter_class ⇒ Object
7 8 9 |
# File 'lib/fluent/plugin/out_reemit/v12_event_router.rb', line 7 def filter_class ::Fluent::Filter end |
#find(tag) ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/fluent/plugin/out_reemit/v12_event_router.rb', line 37 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_class) pipeline ||= ::Fluent::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
30 31 32 33 34 35 |
# File 'lib/fluent/plugin/out_reemit/v12_event_router.rb', line 30 def match(tag) collector = @match_cache.get(tag) { c = find(tag) || @default_collector } collector end |