2018-06-27 03:31:41 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2016-10-21 12:13:41 -04:00
|
|
|
# Concern that sets various Sidekiq settings for workers executed using a
|
|
|
|
# cronjob.
|
|
|
|
module CronjobQueue
|
|
|
|
extend ActiveSupport::Concern
|
|
|
|
|
|
|
|
included do
|
2017-11-28 11:16:50 -05:00
|
|
|
queue_namespace :cronjob
|
|
|
|
sidekiq_options retry: false
|
2020-01-24 07:09:01 -05:00
|
|
|
worker_context project: nil, namespace: nil, user: nil
|
2016-10-21 12:13:41 -04:00
|
|
|
end
|
2020-04-15 14:09:36 -04:00
|
|
|
|
|
|
|
class_methods do
|
|
|
|
# Cronjobs never get scheduled with arguments, so this is safe to
|
|
|
|
# override
|
|
|
|
def context_for_arguments(_args)
|
2021-03-16 17:11:53 -04:00
|
|
|
return if Gitlab::ApplicationContext.current_context_include?(:caller_id)
|
2020-04-15 14:09:36 -04:00
|
|
|
|
|
|
|
Gitlab::ApplicationContext.new(caller_id: "Cronjob")
|
|
|
|
end
|
|
|
|
end
|
2016-10-21 12:13:41 -04:00
|
|
|
end
|