2018-11-08 19:23:39 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2018-03-27 19:54:05 +05:30
|
|
|
module WaitableWorker
|
|
|
|
extend ActiveSupport::Concern
|
|
|
|
|
2018-11-20 20:47:30 +05:30
|
|
|
class_methods do
|
2018-03-27 19:54:05 +05:30
|
|
|
# Schedules multiple jobs and waits for them to be completed.
|
2022-08-13 15:12:31 +05:30
|
|
|
def bulk_perform_and_wait(args_list)
|
|
|
|
bulk_perform_async(args_list)
|
2018-03-27 19:54:05 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def perform(*args)
|
|
|
|
notify_key = args.pop if Gitlab::JobWaiter.key?(args.last)
|
|
|
|
|
|
|
|
super(*args)
|
|
|
|
ensure
|
|
|
|
Gitlab::JobWaiter.notify(notify_key, jid) if notify_key
|
|
|
|
end
|
|
|
|
end
|