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
-
#perform(_hostname = SidekiqAlive.hostname) ⇒ Object
Passing the hostname argument it’s only for debugging enqueued jobs.
- #write_living_probe ⇒ Object
Instance Method Details
#config ⇒ Object
36 37 38 |
# File 'lib/sidekiq_alive/worker.rb', line 36 def config SidekiqAlive.config end |
#current_hostname ⇒ Object
32 33 34 |
# File 'lib/sidekiq_alive/worker.rb', line 32 def current_hostname SidekiqAlive.hostname end |
#perform(_hostname = SidekiqAlive.hostname) ⇒ Object
Passing the hostname argument it’s only for debugging enqueued jobs
9 10 11 12 13 14 15 16 17 |
# File 'lib/sidekiq_alive/worker.rb', line 9 def perform(_hostname = SidekiqAlive.hostname) # Checks if custom liveness probe passes should fail or return false return unless config.custom_liveness_probe.call # Writes the liveness in Redis write_living_probe # schedules next living probe self.class.perform_in(config.time_to_live / 2, current_hostname) end |
#write_living_probe ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/sidekiq_alive/worker.rb', line 19 def write_living_probe # Write liveness probe SidekiqAlive.store_alive_key # Increment ttl for current registered instance SidekiqAlive.register_current_instance # after callbacks begin config.callback.call rescue StandardError nil end end |