Module: SidekiqUtils::Deprioritize

Defined in:
lib/sidekiq_utils/deprioritize.rb

Class Method Summary collapse

Class Method Details

.workers(*workers) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/sidekiq_utils/deprioritize.rb', line 3

def self.workers(*workers)
  workers = workers.map do |worker|
    if worker.is_a?(Class)
      worker.name
    else
      worker
    end
  end

  old_deprioritized = Thread.current[:deprioritize_worker_classes]
  Thread.current[:deprioritize_worker_classes] ||= []
  Thread.current[:deprioritize_worker_classes] |= workers
  yield
  Thread.current[:deprioritize_worker_classes] = old_deprioritized
end