Class: Fluent::ReemitOutput::V10EventRouter

Inherits:
Object
  • Object
show all
Defined in:
lib/fluent/plugin/out_reemit/v10_event_router.rb

Instance Method Summary collapse

Constructor Details

#initialize(reemit) ⇒ V10EventRouter

Returns a new instance of V10EventRouter.



4
5
6
7
8
# File 'lib/fluent/plugin/out_reemit/v10_event_router.rb', line 4

def initialize(reemit)
  @reemit = reemit
  @matches = Engine.matches
  @match_cache = {}
end

Instance Method Details

#emit_stream(tag, es) ⇒ Object



10
11
12
13
14
15
16
17
# File 'lib/fluent/plugin/out_reemit/v10_event_router.rb', line 10

def emit_stream(tag, es)
  target = @match_cache[tag]
  unless target
    target = match(tag) || Fluent::EngineClass::NoMatchMatch.new
    @match_cache[tag] = target
  end
  target.emit(tag, es)
end

#match(tag) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/fluent/plugin/out_reemit/v10_event_router.rb', line 19

def match(tag)
  # We want to reemit messages to the **next** `<match>`
  found_reemit = false
  @matches.find do |m|
    if m.match(tag)
      if found_reemit && !@reemit.included?(m.output)
        true
      elsif !found_reemit && @reemit.included?(m.output)
        found_reemit = true
        false
      end
    end
  end
end