Sha256: ee1e8a480bfb2055daa07e8ef96614142d284fc581dd3d9ff8b56248c99e71e5

Contents?: true

Size: 1.12 KB

Versions: 5

Compression:

Stored size: 1.12 KB

Contents

# frozen_string_literal: true

module SidekiqAlive
  class Config
    include Singleton

    attr_accessor :host,
                  :port,
                  :path,
                  :liveness_key,
                  :time_to_live,
                  :callback,
                  :registered_instance_key,
                  :queue_prefix,
                  :server,
                  :custom_liveness_probe,
                  :logger,
                  :shutdown_callback

    def initialize
      set_defaults
    end

    def set_defaults
      @host = ENV.fetch("SIDEKIQ_ALIVE_HOST", "0.0.0.0")
      @port = ENV.fetch("SIDEKIQ_ALIVE_PORT", 7433)
      @path = ENV.fetch("SIDEKIQ_ALIVE_PATH", "/")
      @liveness_key = "SIDEKIQ::LIVENESS_PROBE_TIMESTAMP"
      @time_to_live = 10 * 60
      @callback = proc {}
      @registered_instance_key = "SIDEKIQ_REGISTERED_INSTANCE"
      @queue_prefix = :"sidekiq-alive"
      @server = ENV.fetch("SIDEKIQ_ALIVE_SERVER", "webrick")
      @custom_liveness_probe = proc { true }
      @shutdown_callback = proc {}
    end

    def registration_ttl
      @registration_ttl || time_to_live * 3
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
sidekiq_alive-2.3.0 lib/sidekiq_alive/config.rb
sidekiq_alive-2.2.3 lib/sidekiq_alive/config.rb
sidekiq_alive-2.2.2 lib/sidekiq_alive/config.rb
sidekiq_alive-2.2.1 lib/sidekiq_alive/config.rb
sidekiq_alive-2.2.0 lib/sidekiq_alive/config.rb