diff options
author | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2017-06-29 12:41:19 +0300 |
---|---|---|
committer | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2017-07-07 16:08:15 +0300 |
commit | 945cdf326edcafdcd7a1d2aeaef611d888a4828e (patch) | |
tree | 36c5f5e2dd14fa2afd3f8708886a1354254b1315 /app | |
parent | 07693b43745e31e47466a9f1f5b73de894323a5d (diff) |
Make it possible to schedule bg migrations in bulk
Diffstat (limited to 'app')
-rw-r--r-- | app/workers/background_migration_worker.rb | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/app/workers/background_migration_worker.rb b/app/workers/background_migration_worker.rb index e85e221d353..751f37a3c39 100644 --- a/app/workers/background_migration_worker.rb +++ b/app/workers/background_migration_worker.rb @@ -2,18 +2,32 @@ 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 a number of jobs in bulk, with a delay. + # + def self.perform_bulk_in(delay, jobs) + now = Time.now.to_f + schedule = now + delay.to_f + + raise ArgumentError if schedule <= now + + 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. |