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

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

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

Returns a new instance of LineBufferTimerFlusher.



1308
1309
1310
1311
1312
1313
1314
# File 'lib/fluent/plugin/in_tail.rb', line 1308

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

Instance Attribute Details

#line_bufferObject

Returns the value of attribute line_buffer.



1306
1307
1308
# File 'lib/fluent/plugin/in_tail.rb', line 1306

def line_buffer
  @line_buffer
end

Instance Method Details

#close(tw) ⇒ Object



1328
1329
1330
1331
1332
1333
# File 'lib/fluent/plugin/in_tail.rb', line 1328

def close(tw)
  return unless @line_buffer

  @flush_method.call(tw, @line_buffer)
  @line_buffer = nil
end

#on_notify(tw) ⇒ Object



1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
# File 'lib/fluent/plugin/in_tail.rb', line 1316

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_timerObject



1335
1336
1337
1338
1339
# File 'lib/fluent/plugin/in_tail.rb', line 1335

def reset_timer
  return unless @flush_interval

  @start = Time.now
end