Class: Sidekiq::Ultimate::EmptyQueues::RefreshTimerTask

Inherits:
Object
  • Object
show all
Defined in:
lib/sidekiq/ultimate/empty_queues/refresh_timer_task.rb

Overview

Timer task that periodically refreshes empty queues. Also adds jitter to the execution interval.

Constant Summary collapse

TASK_CLASS =
Class.new(Concurrent::TimerTask)

Class Method Summary collapse

Class Method Details

.setup!(empty_queues_class) ⇒ Object



14
15
16
17
18
19
20
21
# File 'lib/sidekiq/ultimate/empty_queues/refresh_timer_task.rb', line 14

def setup!(empty_queues_class)
  interval = Sidekiq::Ultimate::Configuration.instance.empty_queues_cache_refresh_interval_sec
  task = TASK_CLASS.new({
    :run_now            => true,
    :execution_interval => Sidekiq::Ultimate::IntervalWithJitter.call(interval)
  }) { empty_queues_class.instance.refresh! }
  task.execute
end