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.



1350
1351
1352
1353
1354
1355
1356
# File 'lib/fluent/plugin/in_tail.rb', line 1350

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.



1348
1349
1350
# File 'lib/fluent/plugin/in_tail.rb', line 1348

def line_buffer
  @line_buffer
end

Instance Method Details

#close(tw) ⇒ Object



1370
1371
1372
1373
1374
1375
# File 'lib/fluent/plugin/in_tail.rb', line 1370

def close(tw)
  return unless @line_buffer

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

#on_notify(tw) ⇒ Object



1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
# File 'lib/fluent/plugin/in_tail.rb', line 1358

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



1377
1378
1379
1380
1381
# File 'lib/fluent/plugin/in_tail.rb', line 1377

def reset_timer
  return unless @flush_interval

  @start = Time.now
end