2020-04-24 09:09:44 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module ReactiveCacheableWorker
|
|
|
|
extend ActiveSupport::Concern
|
|
|
|
|
|
|
|
included do
|
|
|
|
include ApplicationWorker
|
|
|
|
|
2021-04-30 18:10:09 +00:00
|
|
|
sidekiq_options retry: 3
|
|
|
|
|
2020-04-24 09:09:44 +00:00
|
|
|
feature_category_not_owned!
|
2020-06-12 12:08:56 +00:00
|
|
|
loggable_arguments 0
|
2020-04-24 09:09:44 +00:00
|
|
|
|
|
|
|
def self.context_for_arguments(arguments)
|
|
|
|
class_name, *_other_args = arguments
|
|
|
|
Gitlab::ApplicationContext.new(related_class: class_name.to_s)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def perform(class_name, id, *args)
|
|
|
|
klass = begin
|
2021-03-17 21:11:29 +00:00
|
|
|
class_name.constantize
|
|
|
|
rescue NameError
|
|
|
|
nil
|
|
|
|
end
|
2020-04-24 09:09:44 +00:00
|
|
|
|
|
|
|
return unless klass
|
|
|
|
|
|
|
|
klass
|
|
|
|
.reactive_cache_worker_finder
|
|
|
|
.call(id, *args)
|
|
|
|
.try(:exclusively_update_reactive_cache!, *args)
|
|
|
|
rescue ReactiveCaching::ExceededReactiveCacheLimit => e
|
|
|
|
Gitlab::ErrorTracking.track_exception(e)
|
|
|
|
end
|
|
|
|
end
|