Class: PauseControl::ResumeWorker

Inherits:
Object
  • Object
show all
Includes:
ApplicationWorker, CronjobQueue
Defined in:
app/workers/pause_control/resume_worker.rb

Constant Summary collapse

RESCHEDULE_DELAY =
1.second

Constants included from ApplicationWorker

ApplicationWorker::LOGGING_EXTRA_KEY, ApplicationWorker::SAFE_PUSH_BULK_LIMIT

Constants included from Gitlab::Loggable

Gitlab::Loggable::ANONYMOUS

Constants included from WorkerAttributes

WorkerAttributes::DEFAULT_DATA_CONSISTENCY, WorkerAttributes::DEFAULT_DEFER_DELAY, WorkerAttributes::NAMESPACE_WEIGHTS, WorkerAttributes::VALID_DATA_CONSISTENCIES, WorkerAttributes::VALID_RESOURCE_BOUNDARIES, WorkerAttributes::VALID_URGENCIES

Instance Method Summary collapse

Methods included from Gitlab::Loggable

#build_structured_payload

Methods included from Gitlab::SidekiqVersioning::Worker

#job_version

Methods included from WorkerContext

#with_context

Instance Method Details

#performObject



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'app/workers/pause_control/resume_worker.rb', line 17

def perform
  reschedule_job = false

  pause_strategies_workers.each do |strategy, workers|
    strategy_klass = Gitlab::SidekiqMiddleware::PauseControl.for(strategy)

    next if strategy_klass.should_pause?

    workers.each do |worker|
      next unless jobs_in_the_queue?(worker)

      queue_size = resume_processing!(worker)
      reschedule_job = true if queue_size.to_i > 0
    end
  end

  self.class.perform_in(RESCHEDULE_DELAY) if reschedule_job
end