class SidekiqAlive::Worker

Public Instance Methods

config() click to toggle source
# File lib/sidekiq_alive/worker.rb, line 41
def config
  SidekiqAlive.config
end
current_hostname() click to toggle source
# File lib/sidekiq_alive/worker.rb, line 37
def current_hostname
  SidekiqAlive.hostname
end
hostname_registered?(hostname) click to toggle source
# File lib/sidekiq_alive/worker.rb, line 18
def hostname_registered?(hostname)
  SidekiqAlive.registered_instances.any? do |ri|
    /#{hostname}/ =~ ri
  end
end
perform(_hostname = SidekiqAlive.hostname) click to toggle source
# File lib/sidekiq_alive/worker.rb, line 8
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() click to toggle source
# File lib/sidekiq_alive/worker.rb, line 24
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