Skip to content

Commit

Permalink
Use constant instead of interger values
Browse files Browse the repository at this point in the history
Signed-off-by: Hiroshi Hatake <hatake@clear-code.com>
  • Loading branch information
cosmo0920 committed Jan 7, 2021
1 parent a82336a commit 8d26d11
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lib/fluent/plugin/in_tail.rb
Expand Up @@ -930,6 +930,8 @@ def bytesize
end

class IOHandler
BYTES_TO_READ = 8192

def initialize(watcher, path:, read_lines_limit:, read_bytes_limit_per_second:, log:, open_on_every_update:, from_encoding: nil, encoding: nil, &receive_lines)
@watcher = watcher
@path = path
Expand Down Expand Up @@ -974,10 +976,10 @@ def handle_notify
if !io.nil? && @lines.empty?
begin
while true
@fifo << io.readpartial(8192, @iobuf)
@fifo << io.readpartial(BYTES_TO_READ, @iobuf)
@fifo.read_lines(@lines)

number_bytes_read += 8192
number_bytes_read += BYTES_TO_READ
limit_bytes_per_second_reached = (number_bytes_read >= @read_bytes_limit_per_second && @read_bytes_limit_per_second > 0)
@log.debug("reading file: #{@path}")
if @lines.size >= @read_lines_limit || limit_bytes_per_second_reached
Expand Down

0 comments on commit 8d26d11

Please sign in to comment.