gitlab-org--gitlab-foss/app/workers/reactive_caching_worker.rb
Reuben Pereira 5caced3650 Allow reactive caching to be used in services
Add support for defining a reactive_cache_worker_finder function
that will be used by the reactive_caching_worker to generate/initialize
the calling object. This allows reactive caching to work with Services
where the object cannot be obtained from DB but a new object can be
initialized.
2019-04-04 17:27:29 +00:00

19 lines
370 B
Ruby

# frozen_string_literal: true
class ReactiveCachingWorker
include ApplicationWorker
def perform(class_name, id, *args)
klass = begin
class_name.constantize
rescue NameError
nil
end
return unless klass
klass
.reactive_cache_worker_finder
.call(id, *args)
.try(:exclusively_update_reactive_cache!, *args)
end
end