Sha256: cb29674f0a1133dbf4e867694709b93a93570704b999dbeb6ada603009e76640

Contents?: true

Size: 1.33 KB

Versions: 6

Compression:

Stored size: 1.33 KB

Contents

# frozen_string_literal: true

module Sidekiq
  module Throttled
    # Configuration object.
    class Config
      # Period in seconds to exclude queue from polling in case it returned
      # {#cooldown_threshold} amount of throttled jobs in a row.
      #
      # Set this to `nil` to disable cooldown completely.
      #
      # @return [Float, nil]
      attr_reader :cooldown_period

      # Amount of throttled jobs returned from the queue subsequently after
      # which queue will be excluded from polling for the durations of
      # {#cooldown_period}.
      #
      # @return [Integer]
      attr_reader :cooldown_threshold

      def initialize
        @cooldown_period    = 2.0
        @cooldown_threshold = 1
      end

      # @!attribute [w] cooldown_period
      def cooldown_period=(value)
        raise TypeError, "unexpected type #{value.class}" unless value.nil? || value.is_a?(Float)
        raise ArgumentError, "period must be positive"    unless value.nil? || value.positive?

        @cooldown_period = value
      end

      # @!attribute [w] cooldown_threshold
      def cooldown_threshold=(value)
        raise TypeError, "unexpected type #{value.class}" unless value.is_a?(Integer)
        raise ArgumentError, "threshold must be positive" unless value.positive?

        @cooldown_threshold = value
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
sidekiq-throttled-1.4.0 lib/sidekiq/throttled/config.rb
sidekiq-throttled-1.3.0 lib/sidekiq/throttled/config.rb
sidekiq-throttled-1.2.0 lib/sidekiq/throttled/config.rb
sidekiq-throttled-1.1.0 lib/sidekiq/throttled/config.rb
sidekiq-throttled-1.0.1 lib/sidekiq/throttled/config.rb
sidekiq-throttled-1.0.0 lib/sidekiq/throttled/config.rb