diff options
author | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2017-08-22 13:47:20 +0300 |
---|---|---|
committer | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2017-08-22 13:47:20 +0300 |
commit | 193b199672f5229dd6d2cff30fc8c794bb774bbd (patch) | |
tree | c9d4f5975a5301451522563e61f8e7b62dfbc36c /lib/gitlab/database | |
parent | 73187801df9a128a73b36672c64fc69a87e3c519 (diff) |
Add Sidekiq migration helpers for migrating queues
Diffstat (limited to 'lib/gitlab/database')
-rw-r--r-- | lib/gitlab/database/migration_helpers.rb | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/lib/gitlab/database/migration_helpers.rb b/lib/gitlab/database/migration_helpers.rb index b83e633c7ed..ecb23e79e80 100644 --- a/lib/gitlab/database/migration_helpers.rb +++ b/lib/gitlab/database/migration_helpers.rb @@ -611,6 +611,20 @@ module Gitlab remove_foreign_key(*args) rescue ArgumentError end + + def sidekiq_queue_migrate(queue_from, to: queue_to) + while sidekiq_queue_length(queue_from) > 0 + Sidekiq.redis do |conn| + conn.rpoplpush "queue:#{queue_from}", "queue:#{to}" + end + end + end + + def sidekiq_queue_length(queue_name) + Sidekiq.redis do |conn| + conn.llen("queue:#{queue_name}") + end + end end end end |