diff options
author | Douwe Maan <douwe@gitlab.com> | 2017-08-22 11:05:14 +0000 |
---|---|---|
committer | Douwe Maan <douwe@gitlab.com> | 2017-08-22 11:05:14 +0000 |
commit | 78a0d27e98cea4ed1b59377edc93588127b297fe (patch) | |
tree | 626ddaa692571518058e4d4f48a627cecba04f4f /app/workers | |
parent | 28501691da41e1593a822061549d29a6a946d7a3 (diff) | |
parent | 6e8d0b78ebbde2eada151649fc7d1040b902e28f (diff) | |
download | gitlab-ce-78a0d27e98cea4ed1b59377edc93588127b297fe.tar.gz |
Merge branch '34533-inline-single-authorized-projects' into 'master'
Use an event-based system when waiting for AuthorizedProjectsWorker to complete
See merge request !13564
Diffstat (limited to 'app/workers')
-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 |