Class: Sidekiq::Throttled::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/sidekiq/throttled/config.rb

Overview

Configuration object.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfig

Returns a new instance of Config.



32
33
34
# File 'lib/sidekiq/throttled/config.rb', line 32

def initialize
  reset!
end

Instance Attribute Details

#cooldown_periodFloat?

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.

Returns:

  • (Float, nil)


13
14
15
# File 'lib/sidekiq/throttled/config.rb', line 13

def cooldown_period
  @cooldown_period
end

#cooldown_thresholdInteger

Amount of throttled jobs returned from the queue subsequently after which queue will be excluded from polling for the durations of #cooldown_period.

Returns:

  • (Integer)


20
21
22
# File 'lib/sidekiq/throttled/config.rb', line 20

def cooldown_threshold
  @cooldown_threshold
end

#default_requeue_optionsHash

Specifies how we should return throttled jobs to the queue so they can be executed later. Expects a hash with keys that may include :with and :to For :with, options are ‘:enqueue` (put them on the end of the queue) and `:schedule` (schedule for later). For :to, the name of a sidekiq queue should be specified. If none is specified, jobs will by default be requeued to the same queue they were originally enqueued in. Default: `:enqueue`

Returns:

  • (Hash)


30
31
32
# File 'lib/sidekiq/throttled/config.rb', line 30

def default_requeue_options
  @default_requeue_options
end

Instance Method Details

#reset!Object



59
60
61
62
63
# File 'lib/sidekiq/throttled/config.rb', line 59

def reset!
  @cooldown_period    = 1.0
  @cooldown_threshold = 100
  @default_requeue_options = { with: :enqueue }
end