Class: ArchiveStorage::Jobs::SidekiqQueueWorker

Inherits:
Object
  • Object
show all
Includes:
Sidekiq::Worker
Defined in:
lib/archive_storage/jobs/sidekiq_queue_worker.rb

Instance Method Summary collapse

Instance Method Details

#perform(options = {}) ⇒ Object



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/archive_storage/jobs/sidekiq_queue_worker.rb', line 21

def perform(options = {})
  options = symbolize_keys(options)
  remaining = migration_limit(options)
  total = 0

  planner_options(options).each do |planner_options|
    break if remaining && remaining <= 0

    planner = Planner.new(**planner_options.merge(limit: remaining))
    count = Migrator.new(planner: planner).enqueue_or_migrate!
    remaining -= count if remaining
    total += count
  end

  total
end