Class: ShareDataWatcher::Type::Watch

Inherits:
Base
  • Object
show all
Defined in:
lib/share-data-watcher/type/watch.rb

Overview

Watch Type Watch key changes

Constant Summary collapse

DEFAULT_RETRY_INTERVAL =
30

Instance Attribute Summary collapse

Attributes inherited from Base

#key

Instance Method Summary collapse

Methods inherited from Base

#get, #restart, #to_h, #valid?

Methods included from Loggable

#debug, #error, #info, #warn

Constructor Details

#initialize(endpoints, key, opt = {}) ⇒ Watch



17
18
19
20
21
22
23
24
25
26
27
# File 'lib/share-data-watcher/type/watch.rb', line 17

def initialize(endpoints, key, opt = {})
  @retry_interval = opt[:retry_interval] || DEFAULT_RETRY_INTERVAL
  @after_change = opt[:after_change] || nil

  if after_change && !after_change.is_a?(Proc)
    raise ArgumentError, 'after_change must be proc'
  end

  @thread = nil
  super
end

Instance Attribute Details

#after_changeObject (readonly)

Returns the value of attribute after_change.



10
11
12
# File 'lib/share-data-watcher/type/watch.rb', line 10

def after_change
  @after_change
end

#retry_intervalObject (readonly)

Returns the value of attribute retry_interval.



9
10
11
# File 'lib/share-data-watcher/type/watch.rb', line 9

def retry_interval
  @retry_interval
end

#start_revisionObject (readonly)

Returns the value of attribute start_revision.



8
9
10
# File 'lib/share-data-watcher/type/watch.rb', line 8

def start_revision
  @start_revision
end

Instance Method Details

#shutdownObject



29
30
31
32
# File 'lib/share-data-watcher/type/watch.rb', line 29

def shutdown
  @thread.exit
  super
end