Class: Fluent::Plugin::TailInput::TailWatcher::LineBufferTimerFlusher

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

Instance Method Summary collapse

Constructor Details

#initialize(log, flush_interval, &flush_method) ⇒ LineBufferTimerFlusher



661
662
663
664
665
666
# File 'lib/fluent/plugin/in_tail.rb', line 661

def initialize(log, flush_interval, &flush_method)
  @log = log
  @flush_interval = flush_interval
  @flush_method = flush_method
  @start = nil
end

Instance Method Details

#on_notify(tw) ⇒ Object



668
669
670
671
672
673
674
675
676
# File 'lib/fluent/plugin/in_tail.rb', line 668

def on_notify(tw)
  if @start && @flush_interval
    if Time.now - @start >= @flush_interval
      @flush_method.call(tw)
      tw.line_buffer = nil
      @start = nil
    end
  end
end

#reset_timerObject



678
679
680
# File 'lib/fluent/plugin/in_tail.rb', line 678

def reset_timer
  @start = Time.now
end