Class: Fluent::DelayedOutput

Inherits:
Output
  • Object
show all
Defined in:
lib/fluent/plugin/out_delayed.rb

Instance Method Summary collapse

Constructor Details

#initializeDelayedOutput

Returns a new instance of DelayedOutput.



38
39
40
41
# File 'lib/fluent/plugin/out_delayed.rb', line 38

def initialize()
  @coolio = Coolio::Loop.default
  @thread = Thread.new(&method(:run))
end

Instance Method Details

#configure(conf) ⇒ Object



43
44
45
46
47
48
49
50
# File 'lib/fluent/plugin/out_delayed.rb', line 43

def configure(conf)
  conf.elements.select {|e|
    e.name == 'store'  
  }.each {|e|
    type = e['type']
    @output = Plugin.new_output(type)
  }
end

#emit(tag, es, chain) ⇒ Object



52
53
54
55
56
57
58
59
60
61
62
63
64
65
# File 'lib/fluent/plugin/out_delayed.rb', line 52

def emit(tag, es, chain)
  es.each {|time,record|
    now = Engine.now
    delay = time - now

    if delay < 0 then
      delay = 0
    end
    es2 = MultiEventStream.new
    es2.add(time,record)

    @coolio.attach DelayedEvent.new(tag, es2, chain, @output, delay)
  }
end