diff options
author | Grzegorz Bizon <grzegorz@gitlab.com> | 2017-07-08 11:04:25 +0000 |
---|---|---|
committer | Grzegorz Bizon <grzegorz@gitlab.com> | 2017-07-08 11:04:25 +0000 |
commit | 420f6b5474e49e17226415250846e48fe514fe0d (patch) | |
tree | 95b707efe16f90b6eb4a87c9bee349cd1cd3b256 /app | |
parent | 43b9141c365930326d50c8c8566d67722172d2ec (diff) | |
parent | e36daa0fd95c93967708447b3b8f615c2a81e3b5 (diff) | |
download | gitlab-ce-420f6b5474e49e17226415250846e48fe514fe0d.tar.gz |
Merge branch 'fix/gb/stage-id-reference-background-migration' into 'master'
Add build stage_id reference background migration
Closes #34151
See merge request !12513
Diffstat (limited to 'app')
-rw-r--r-- | app/workers/background_migration_worker.rb | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/app/workers/background_migration_worker.rb b/app/workers/background_migration_worker.rb index e85e221d353..45ce49bb5c0 100644 --- a/app/workers/background_migration_worker.rb +++ b/app/workers/background_migration_worker.rb @@ -2,18 +2,34 @@ class BackgroundMigrationWorker include Sidekiq::Worker include DedicatedSidekiqQueue - # Schedules a number of jobs in bulk + # Enqueues a number of jobs in bulk. # # The `jobs` argument should be an Array of Arrays, each sub-array must be in # the form: # # [migration-class, [arg1, arg2, ...]] - def self.perform_bulk(*jobs) + def self.perform_bulk(jobs) Sidekiq::Client.push_bulk('class' => self, 'queue' => sidekiq_options['queue'], 'args' => jobs) end + # Schedules multiple jobs in bulk, with a delay. + # + def self.perform_bulk_in(delay, jobs) + now = Time.now.to_i + schedule = now + delay.to_i + + if schedule <= now + raise ArgumentError, 'The schedule time must be in the future!' + end + + Sidekiq::Client.push_bulk('class' => self, + 'queue' => sidekiq_options['queue'], + 'args' => jobs, + 'at' => schedule) + end + # Performs the background migration. # # See Gitlab::BackgroundMigration.perform for more information. |