class Fluent::Plugin::TailInput::TailWatcher::LineBufferTimerFlusher

Attributes

line_buffer[RW]

Public Class Methods

new(log, flush_interval, &flush_method) click to toggle source
# File lib/fluent/plugin/in_tail.rb, line 1242
def initialize(log, flush_interval, &flush_method)
  @log = log
  @flush_interval = flush_interval
  @flush_method = flush_method
  @start = nil
  @line_buffer = nil
end

Public Instance Methods

close(tw) click to toggle source
# File lib/fluent/plugin/in_tail.rb, line 1262
def close(tw)
  return unless @line_buffer

  @flush_method.call(tw, @line_buffer)
  @line_buffer = nil
end
on_notify(tw) click to toggle source
# File lib/fluent/plugin/in_tail.rb, line 1250
def on_notify(tw)
  unless @start && @flush_method
    return
  end

  if Time.now - @start >= @flush_interval
    @flush_method.call(tw, @line_buffer) if @line_buffer
    @line_buffer = nil
    @start = nil
  end
end
reset_timer() click to toggle source
# File lib/fluent/plugin/in_tail.rb, line 1269
def reset_timer
  return unless @flush_interval

  @start = Time.now
end