diff options
author | Nick Thomas <nick@gitlab.com> | 2017-08-15 15:56:04 +0300 |
---|---|---|
committer | Nick Thomas <nick@gitlab.com> | 2017-08-22 11:54:46 +0300 |
commit | 6e8d0b78ebbde2eada151649fc7d1040b902e28f (patch) | |
tree | 51e1665f62fa4d78e64d26e13c00e07c4ca5605a /app/workers/authorized_projects_worker.rb | |
parent | 6509833cfa211804048ec4711572e3b44a5be21c (diff) |
Use event-based waiting in Gitlab::JobWaiter
Diffstat (limited to 'app/workers/authorized_projects_worker.rb')
-rw-r--r-- | app/workers/authorized_projects_worker.rb | 13 |
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 |