Class: Fluent::Plugin::TailInput::LineFeeder::FileFeed
- Inherits:
-
Object
- Object
- Fluent::Plugin::TailInput::LineFeeder::FileFeed
- Defined in:
- lib/fluent/plugin/in_tail/line_feeder.rb
Overview
Per-file state replacing TailWatcher::LineBufferTimerFlusher.
Instance Attribute Summary collapse
-
#line_buffer ⇒ Object
Returns the value of attribute line_buffer.
Instance Method Summary collapse
- #close(tail_watcher) ⇒ Object
-
#feed_lines(lines, tail_watcher) ⇒ Object
True if no error or unrecoverable error happens in emit action.
- #flush_buffer(buf, tail_watcher) ⇒ Object
-
#initialize(line_feeder, flush_interval:, flush_handler:) ⇒ FileFeed
constructor
A new instance of FileFeed.
- #on_notify(tail_watcher) ⇒ Object
-
#reset_timer ⇒ Object
Starts the flush deadline.
Constructor Details
#initialize(line_feeder, flush_interval:, flush_handler:) ⇒ FileFeed
Returns a new instance of FileFeed.
105 106 107 108 109 110 111 |
# File 'lib/fluent/plugin/in_tail/line_feeder.rb', line 105 def initialize(line_feeder, flush_interval:, flush_handler:) @line_feeder = line_feeder @flush_interval = flush_interval @flush_handler = flush_handler @line_buffer = nil @start = nil end |
Instance Attribute Details
#line_buffer ⇒ Object
Returns the value of attribute line_buffer.
103 104 105 |
# File 'lib/fluent/plugin/in_tail/line_feeder.rb', line 103 def line_buffer @line_buffer end |
Instance Method Details
#close(tail_watcher) ⇒ Object
128 129 130 131 132 133 |
# File 'lib/fluent/plugin/in_tail/line_feeder.rb', line 128 def close(tail_watcher) return unless @line_buffer flush_buffer(@line_buffer, tail_watcher) @line_buffer = nil end |
#feed_lines(lines, tail_watcher) ⇒ Object
Returns true if no error or unrecoverable error happens in emit action. false if got BufferOverflowError.
114 115 116 |
# File 'lib/fluent/plugin/in_tail/line_feeder.rb', line 114 def feed_lines(lines, tail_watcher) @line_feeder.feed_lines(lines, tail_watcher) end |
#flush_buffer(buf, tail_watcher) ⇒ Object
135 136 137 |
# File 'lib/fluent/plugin/in_tail/line_feeder.rb', line 135 def flush_buffer(buf, tail_watcher) @flush_handler.call(tail_watcher, buf) end |
#on_notify(tail_watcher) ⇒ Object
118 119 120 121 122 123 124 125 126 |
# File 'lib/fluent/plugin/in_tail/line_feeder.rb', line 118 def on_notify(tail_watcher) return unless @start if Fluent::Clock.now - @start >= @flush_interval flush_buffer(@line_buffer, tail_watcher) if @line_buffer @line_buffer = nil @start = nil end end |