Sha256: 7a66fed5540001b99a95c2f33e336b140ba3d0531b9715ad53cb8544ad42d65a
Contents?: true
Size: 1.04 KB
Versions: 16
Compression:
Stored size: 1.04 KB
Contents
# frozen_string_literal: true module SidekiqAlive class Worker include Sidekiq::Worker sidekiq_options retry: false 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 def hostname_registered?(hostname) SidekiqAlive.registered_instances.any? do |ri| /#{hostname}/ =~ ri end end 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 def current_hostname SidekiqAlive.hostname end def config SidekiqAlive.config end end end
Version data entries
16 entries across 16 versions & 2 rubygems