Module: ShareDataWatcher::InstanceMethods
- Included in:
- ShareDataWatcher
- Defined in:
- lib/share-data-watcher/instance_methods.rb
Overview
Instance Methods For Shard Data Watcher
Instance Attribute Summary collapse
-
#endpoints ⇒ Object
readonly
Returns the value of attribute endpoints.
-
#healthcheck_interval ⇒ Object
readonly
Returns the value of attribute healthcheck_interval.
Instance Method Summary collapse
- #initialize(endpoints = nil, **opt) ⇒ Object
- #restart ⇒ Object
- #shutdown ⇒ Object
- #start ⇒ Object
- #to_h ⇒ Object (also: #to_hash)
- #valid? ⇒ Boolean
Instance Attribute Details
#endpoints ⇒ Object (readonly)
Returns the value of attribute endpoints.
6 7 8 |
# File 'lib/share-data-watcher/instance_methods.rb', line 6 def endpoints @endpoints end |
#healthcheck_interval ⇒ Object (readonly)
Returns the value of attribute healthcheck_interval.
7 8 9 |
# File 'lib/share-data-watcher/instance_methods.rb', line 7 def healthcheck_interval @healthcheck_interval end |
Instance Method Details
#initialize(endpoints = nil, **opt) ⇒ Object
9 10 11 12 13 14 |
# File 'lib/share-data-watcher/instance_methods.rb', line 9 def initialize(endpoints = nil, **opt) @endpoints = endpoints || DEFAULT_ENDPOINT @healthcheck_thread = nil @healthcheck_interval = opt[:healthcheck_interval] || DEFAULT_HEALTHCHECK_INTERVAL @mutex = Mutex.new end |
#restart ⇒ Object
28 29 30 31 32 33 |
# File 'lib/share-data-watcher/instance_methods.rb', line 28 def restart shutdown start setup_healthcheck self end |
#shutdown ⇒ Object
35 36 37 38 39 40 |
# File 'lib/share-data-watcher/instance_methods.rb', line 35 def shutdown types.each_value(&:shutdown) types.clear @healthcheck_thread.exit self end |
#start ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/share-data-watcher/instance_methods.rb', line 16 def start @mutex.synchronize do self.class.types.each do |type| init_type(type) end end until valid?; sleep 1; end setup_healthcheck self end |
#to_h ⇒ Object Also known as: to_hash
49 50 51 52 53 |
# File 'lib/share-data-watcher/instance_methods.rb', line 49 def to_h types.each_with_object({}) do |(key, value), result| result[key] = value.to_h end end |
#valid? ⇒ Boolean
42 43 44 45 46 47 |
# File 'lib/share-data-watcher/instance_methods.rb', line 42 def valid? types.each do |_, value| return false unless value.valid? end true end |