class FileProcessor

Attributes

filepath[RW]
line_processor[RW]

Public Class Methods

call(filepath) click to toggle source
# File lib/rforward/file_processor.rb, line 28
def self.call filepath
  processor = FileProcessor.new filepath, FFluentdLine.new
  processor.call
end
new(filepath, line_processor) click to toggle source
# File lib/rforward/file_processor.rb, line 4
def initialize filepath, line_processor
  @filepath, @line_processor = filepath, line_processor
end

Public Instance Methods

call() click to toggle source
# File lib/rforward/file_processor.rb, line 8
def call
  RLogger.instance.info "start working on #{filepath}"
  File.readlines(filepath).each do |line|
    line_processor.call line
  end
  Stat.instance.files_current += 1
  RLogger.instance.info "finish working on #{filepath}"
  RLogger.instance.stat
  delay
end
delay() click to toggle source
# File lib/rforward/file_processor.rb, line 20
def delay
  if Config.instance['flush_threshold'].to_i < Stat.instance.flush_counter
    RLogger.instance.info "Sleep for #{Config.instance['flush_delay']} seconds"
    sleep(Config.instance['flush_delay'].to_i)
    Stat.instance.flush_counter = 0
  end
end