Class: FileWatch::Processor

Inherits:
Object
  • Object
show all
Includes:
LogStash::Util::Loggable
Defined in:
lib/filewatch/processor.rb

Direct Known Subclasses

ReadMode::Processor, TailMode::Processor

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(settings) ⇒ Processor

Returns a new instance of Processor.



11
12
13
14
# File 'lib/filewatch/processor.rb', line 11

def initialize(settings)
  @settings = settings
  @deletable_paths = Concurrent::AtomicReference.new []
end

Instance Attribute Details

#watchObject (readonly)

Returns the value of attribute watch.



9
10
11
# File 'lib/filewatch/processor.rb', line 9

def watch
  @watch
end

Instance Method Details

#add_deletable_path(path) ⇒ Object



25
26
27
# File 'lib/filewatch/processor.rb', line 25

def add_deletable_path(path)
  @deletable_paths.get << path
end

#add_watch(watch) ⇒ Object



16
17
18
19
# File 'lib/filewatch/processor.rb', line 16

def add_watch(watch)
  @watch = watch
  self
end

#clear_deletable_pathsObject



21
22
23
# File 'lib/filewatch/processor.rb', line 21

def clear_deletable_paths
  @deletable_paths.get_and_set []
end

#restat(watched_file) ⇒ Object



29
30
31
32
33
34
35
36
37
# File 'lib/filewatch/processor.rb', line 29

def restat(watched_file)
  changed = watched_file.restat!
  if changed
    # the collection (when sorted by modified_at) needs to re-sort every time watched-file is modified,
    # we can perform these update operation while processing files (stat interval) instead of having to
    # re-sort the whole collection every time an entry is accessed
    @watch.watched_files_collection.update(watched_file)
  end
end