summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorGrzegorz Bizon <grzesiek.bizon@gmail.com>2017-06-29 11:41:19 +0200
committerGrzegorz Bizon <grzesiek.bizon@gmail.com>2017-06-29 11:41:19 +0200
commitaf2f2dc5ed588d33919d5db3f684c165d7427ab7 (patch)
tree4421eb0512d2bc4741a7d7af638dc10775b3ac64 /app
parent187dd1005cd92c530146d7f5b0a89b368b09c3e9 (diff)
downloadgitlab-ce-af2f2dc5ed588d33919d5db3f684c165d7427ab7.tar.gz
Make it possible to schedule bg migrations in bulk
Diffstat (limited to 'app')
-rw-r--r--app/workers/background_migration_worker.rb18
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.