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