summaryrefslogtreecommitdiff
path: root/app/workers
diff options
context:
space:
mode:
authorNick Thomas <nick@gitlab.com>2017-08-15 13:56:04 +0100
committerNick Thomas <nick@gitlab.com>2017-08-22 09:54:46 +0100
commit6e8d0b78ebbde2eada151649fc7d1040b902e28f (patch)
tree51e1665f62fa4d78e64d26e13c00e07c4ca5605a /app/workers
parent6509833cfa211804048ec4711572e3b44a5be21c (diff)
downloadgitlab-ce-6e8d0b78ebbde2eada151649fc7d1040b902e28f.tar.gz
Use event-based waiting in Gitlab::JobWaiter
Diffstat (limited to 'app/workers')
-rw-r--r--app/workers/authorized_projects_worker.rb13
1 files changed, 10 insertions, 3 deletions
diff --git a/app/workers/authorized_projects_worker.rb b/app/workers/authorized_projects_worker.rb
index 13207a8bc71..be4c77503bb 100644
--- a/app/workers/authorized_projects_worker.rb
+++ b/app/workers/authorized_projects_worker.rb
@@ -4,18 +4,25 @@ class AuthorizedProjectsWorker
# Schedules multiple jobs and waits for them to be completed.
def self.bulk_perform_and_wait(args_list)
- job_ids = bulk_perform_async(args_list)
+ waiter = Gitlab::JobWaiter.new(args_list.size)
- Gitlab::JobWaiter.new(job_ids).wait
+ # Point all the bulk jobs at the same JobWaiter. Converts, [[1], [2], [3]]
+ # into [[1, "key"], [2, "key"], [3, "key"]]
+ waiting_args_list = args_list.map { |args| args << waiter.key }
+ bulk_perform_async(waiting_args_list)
+
+ waiter.wait
end
def self.bulk_perform_async(args_list)
Sidekiq::Client.push_bulk('class' => self, 'queue' => sidekiq_options['queue'], 'args' => args_list)
end
- def perform(user_id)
+ def perform(user_id, notify_key = nil)
user = User.find_by(id: user_id)
user&.refresh_authorized_projects
+ ensure
+ Gitlab::JobWaiter.notify(notify_key, jid) if notify_key
end
end