summaryrefslogtreecommitdiff
path: root/app/workers/background_migration_worker.rb
diff options
context:
space:
mode:
authorYorick Peterse <yorickpeterse@gmail.com>2017-06-02 17:12:36 +0200
committerYorick Peterse <yorickpeterse@gmail.com>2017-06-12 13:24:04 +0200
commitd83ee2bbd10d8fe2f2e9521bb3c266cf696aa98c (patch)
tree7cf1c328790afd76c13fd553eb30786a14928835 /app/workers/background_migration_worker.rb
parent5478ff6dc2ad59a7c7d91f61339e8acee9bbb434 (diff)
downloadgitlab-ce-d83ee2bbd10d8fe2f2e9521bb3c266cf696aa98c.tar.gz
Add the ability to perform background migrations
Background migrations can be used to perform long running data migrations without these blocking a deployment procedure. See MR https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/11854 for more information.
Diffstat (limited to 'app/workers/background_migration_worker.rb')
-rw-r--r--app/workers/background_migration_worker.rb23
1 files changed, 23 insertions, 0 deletions
diff --git a/app/workers/background_migration_worker.rb b/app/workers/background_migration_worker.rb
new file mode 100644
index 00000000000..e85e221d353
--- /dev/null
+++ b/app/workers/background_migration_worker.rb
@@ -0,0 +1,23 @@
+class BackgroundMigrationWorker
+ include Sidekiq::Worker
+ include DedicatedSidekiqQueue
+
+ # Schedules 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)
+ Sidekiq::Client.push_bulk('class' => self,
+ 'queue' => sidekiq_options['queue'],
+ 'args' => jobs)
+ end
+
+ # Performs the background migration.
+ #
+ # See Gitlab::BackgroundMigration.perform for more information.
+ def perform(class_name, arguments = [])
+ Gitlab::BackgroundMigration.perform(class_name, arguments)
+ end
+end