debian-mirror-gitlab/app/workers/concerns/reactive_cacheable_worker.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

40 lines
983 B
Ruby
Raw Normal View History

2020-05-24 23:13:21 +05:30
# frozen_string_literal: true
module ReactiveCacheableWorker
extend ActiveSupport::Concern
included do
include ApplicationWorker
2021-06-08 01:23:25 +05:30
sidekiq_options retry: 3
2022-06-21 17:19:12 +05:30
# Feature category is different depending on the model that is using the
# reactive cache. Identified by the `related_class` attribute.
feature_category :not_owned # rubocop:todo Gitlab/AvoidFeatureCategoryNotOwned
2020-06-23 00:09:42 +05:30
loggable_arguments 0
2020-05-24 23:13:21 +05:30
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-04-29 21:17:54 +05:30
class_name.constantize
rescue NameError
nil
end
2020-05-24 23:13:21 +05:30
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