Sha256: 7d3c65dd29d5312ac6808f88fc00c9db5df80e2261fba7dbcdf882f8ca214455

Contents?: true

Size: 650 Bytes

Versions: 6

Compression:

Stored size: 650 Bytes

Contents

# frozen_string_literal: true

module HttpHealthCheck
  module Probes
    class Sidekiq
      include ::HttpHealthCheck::Probe

      TTL_SEC = 3
      MAGIC_NUMBER = 42

      def initialize(sidekiq: ::Sidekiq)
        @sidekiq_module = sidekiq
      end

      def probe(_env)
        @sidekiq_module.redis do |conn|
          conn.setex(meta[:redis_key], TTL_SEC, MAGIC_NUMBER)
          probe_ok
        end
      end

      def meta
        @meta ||= { redis_key: redis_key }
      end

      private

      def redis_key
        @redis_key ||= ['sidekiq-healthcheck', ::Socket.gethostname, ::Process.pid].join('::')
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
http_health_check-0.4.1 lib/http_health_check/probes/sidekiq.rb
http_health_check-0.4.0 lib/http_health_check/probes/sidekiq.rb
http_health_check-0.3.1 lib/http_health_check/probes/sidekiq.rb
http_health_check-0.3.0 lib/http_health_check/probes/sidekiq.rb
http_health_check-0.2.1 lib/http_health_check/probes/sidekiq.rb
http_health_check-0.2.0 lib/http_health_check/probes/sidekiq.rb