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.



1276
1277
1278
1279
1280
1281
1282
# File 'lib/fluent/plugin/in_tail.rb', line 1276

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.



1274
1275
1276
# File 'lib/fluent/plugin/in_tail.rb', line 1274

def line_buffer
  @line_buffer
end

Instance Method Details

#close(tw) ⇒ Object



1296
1297
1298
1299
1300
1301
# File 'lib/fluent/plugin/in_tail.rb', line 1296

def close(tw)
  return unless @line_buffer

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

#on_notify(tw) ⇒ Object



1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
# File 'lib/fluent/plugin/in_tail.rb', line 1284

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



1303
1304
1305
1306
1307
# File 'lib/fluent/plugin/in_tail.rb', line 1303

def reset_timer
  return unless @flush_interval

  @start = Time.now
end