class Fluent::ReemitOutput::EventRouter

Public Class Methods

new(reemit) click to toggle source
# File lib/fluent/plugin/out_reemit/v10_event_router.rb, line 4
def initialize(reemit)
  @reemit = reemit
  @matches = Engine.matches
  @match_cache = {}
end

Public Instance Methods

emit_stream(tag, es) click to toggle source
# 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) click to toggle source
# 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