Class: SidekiqAlive::Worker
- Inherits:
-
Object
- Object
- SidekiqAlive::Worker
- Includes:
- Sidekiq::Worker
- Defined in:
- lib/sidekiq_alive/worker.rb
Instance Method Summary collapse
- #config ⇒ Object
- #current_hostname ⇒ Object
- #hostname_registered?(hostname) ⇒ Boolean
- #perform(hostname = SidekiqAlive.hostname) ⇒ Object
- #write_living_probe ⇒ Object
Instance Method Details
#config ⇒ Object
31 32 33 |
# File 'lib/sidekiq_alive/worker.rb', line 31 def config SidekiqAlive.config end |
#current_hostname ⇒ Object
27 28 29 |
# File 'lib/sidekiq_alive/worker.rb', line 27 def current_hostname SidekiqAlive.hostname end |
#hostname_registered?(hostname) ⇒ Boolean
12 13 14 15 16 |
# File 'lib/sidekiq_alive/worker.rb', line 12 def hostname_registered?(hostname) SidekiqAlive.registered_instances.any? do |ri| /#{hostname}/ =~ ri end end |
#perform(hostname = SidekiqAlive.hostname) ⇒ Object
6 7 8 9 10 |
# File 'lib/sidekiq_alive/worker.rb', line 6 def perform(hostname = SidekiqAlive.hostname) write_living_probe # schedule next living probe self.class.perform_in(config.time_to_live / 2, current_hostname) end |
#write_living_probe ⇒ Object
18 19 20 21 22 23 24 25 |
# File 'lib/sidekiq_alive/worker.rb', line 18 def write_living_probe # Write liveness probe SidekiqAlive.store_alive_key # Increment ttl for current registered instance SidekiqAlive.register_current_instance # after callbacks config.callback.call() rescue nil end |