Class: Sidekiq::Ultimate::Configuration

Inherits:
Object
  • Object
show all
Includes:
Singleton
Defined in:
lib/sidekiq/ultimate/configuration.rb

Overview

Configuration options.

Constant Summary collapse

DEFAULT_EMPTY_QUEUES_CACHE_REFRESH_INTERVAL_SEC =
30
DEFAULT_THROTTLED_FETCH_TIMEOUT_SEC =
15

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



44
45
46
47
48
# File 'lib/sidekiq/ultimate/configuration.rb', line 44

def initialize
  @empty_queues_cache_refresh_interval_sec = DEFAULT_EMPTY_QUEUES_CACHE_REFRESH_INTERVAL_SEC
  @throttled_fetch_timeout_sec = DEFAULT_THROTTLED_FETCH_TIMEOUT_SEC
  super
end

Instance Attribute Details

#empty_queues_cache_refresh_interval_secNumeric

It specifies how often the cache of empty queues should be refreshed. In a nutshell, it specifies the maximum possible delay between a job was pushed to previously empty queue and the moment when that new job is picked up. Note that every sidekiq process needs to maintain its own local cache of empty queues. Setting this interval to a low values will increase the number of redis calls and will increase the load on redis.

Returns:

  • (Numeric)

    interval in seconds to refresh the cache of empty queues



33
34
35
# File 'lib/sidekiq/ultimate/configuration.rb', line 33

def empty_queues_cache_refresh_interval_sec
  @empty_queues_cache_refresh_interval_sec
end

#enable_resurrection_counterBoolean

If ‘enable_resurrection_counter` setting is enabled, on each resurrection event, a counter is increased. This is useful for telemetry purposes in order to understand how often jobs are resurrected Counter value is stored in redis by jid and has expiration time 24 hours.

Returns:

  • (Boolean)


25
26
27
# File 'lib/sidekiq/ultimate/configuration.rb', line 25

def enable_resurrection_counter
  @enable_resurrection_counter
end

#on_resurrection {|queue_name, jobs_count| ... } ⇒ Proc

Returns callback to be called when job is resurrected.

Examples:

Sidekiq::Ultimate::Configuration.instance.on_resurrection = ->(queue_name, jobs_count) do
  puts "Resurrected #{jobs_count} jobs from #{queue_name}"
end

Yield Parameters:

  • queue_name (String)

    name of the queue

  • jobs_count (Integer)

    number of jobs resurrected

Yield Returns:

  • (void)

Returns:

  • (Proc)

    callback to be called when job is resurrected



19
20
21
# File 'lib/sidekiq/ultimate/configuration.rb', line 19

def on_resurrection
  @on_resurrection
end

#throttled_fetch_timeout_secObject



58
59
60
61
62
63
64
# File 'lib/sidekiq/ultimate/configuration.rb', line 58

def throttled_fetch_timeout_sec
  if @throttled_fetch_timeout_sec.respond_to?(:call)
    @throttled_fetch_timeout_sec.call.to_f
  else
    @throttled_fetch_timeout_sec.to_f
  end
end