Class: FileWatch::TailMode::Handlers::Base

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

Direct Known Subclasses

Create, CreateInitial, Delete, Grow, Shrink, Timeout, Unignore

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(processor, sincedb_collection, observer, settings) ⇒ Base

Returns a new instance of Base.



9
10
11
12
13
14
# File 'lib/filewatch/tail_mode/handlers/base.rb', line 9

def initialize(processor, sincedb_collection, observer, settings)
  @settings = settings
  @processor = processor
  @sincedb_collection = sincedb_collection
  @observer = observer
end

Instance Attribute Details

#sincedb_collectionObject (readonly)

Returns the value of attribute sincedb_collection.



7
8
9
# File 'lib/filewatch/tail_mode/handlers/base.rb', line 7

def sincedb_collection
  @sincedb_collection
end

Instance Method Details

#handle(watched_file) ⇒ Object



20
21
22
23
24
25
26
# File 'lib/filewatch/tail_mode/handlers/base.rb', line 20

def handle(watched_file)
  logger.trace? && logger.trace("handling:", :path => watched_file.path)
  unless watched_file.has_listener?
    watched_file.set_listener(@observer)
  end
  handle_specifically(watched_file)
end

#handle_specifically(watched_file) ⇒ Object



28
29
30
# File 'lib/filewatch/tail_mode/handlers/base.rb', line 28

def handle_specifically(watched_file)
  # some handlers don't need to define this method
end

#quit?Boolean

Returns:

  • (Boolean)


16
17
18
# File 'lib/filewatch/tail_mode/handlers/base.rb', line 16

def quit?
  @processor.watch.quit?
end

#update_existing_specifically(watched_file, sincedb_value) ⇒ Object



32
33
34
# File 'lib/filewatch/tail_mode/handlers/base.rb', line 32

def update_existing_specifically(watched_file, sincedb_value)
  # when a handler subclass does not implement this then do nothing
end