Class: DLogReader::RotaterReader

Inherits:
DistributedLogReader show all
Defined in:
lib/distributed_logreader/distributed_log_reader/rotater_reader.rb

Instance Attribute Summary collapse

Attributes inherited from DistributedLogReader

#distributer, #filename

Instance Method Summary collapse

Methods inherited from DistributedLogReader

#pre_process, #process

Constructor Details

#initialize(filename, backupdir, worker, num_threads = 10) ⇒ RotaterReader

Returns a new instance of RotaterReader.



5
6
7
8
9
# File 'lib/distributed_logreader/distributed_log_reader/rotater_reader.rb', line 5

def initialize(filename, backupdir, worker, num_threads = 10)
  super(filename, worker, num_threads)
  self.selector = RotatingLog.new
  self.archiver = DateDir.new(backupdir)
end

Instance Attribute Details

#archiverObject

Returns the value of attribute archiver.



3
4
5
# File 'lib/distributed_logreader/distributed_log_reader/rotater_reader.rb', line 3

def archiver
  @archiver
end

#log_readerObject (readonly)

Returns the value of attribute log_reader.



4
5
6
# File 'lib/distributed_logreader/distributed_log_reader/rotater_reader.rb', line 4

def log_reader
  @log_reader
end

#selectorObject

Returns the value of attribute selector.



3
4
5
# File 'lib/distributed_logreader/distributed_log_reader/rotater_reader.rb', line 3

def selector
  @selector
end

Instance Method Details

#log_fileObject



11
12
13
14
15
# File 'lib/distributed_logreader/distributed_log_reader/rotater_reader.rb', line 11

def log_file
  @log_file ||= begin
    selector.file_to_process(filename)
  end
end

#post_processObject



17
18
19
# File 'lib/distributed_logreader/distributed_log_reader/rotater_reader.rb', line 17

def post_process
  self.archiver.archive(log_file)
end