2018-06-27 03:23:28 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2020-02-19 13:09:10 -05:00
|
|
|
class ReactiveCachingWorker # rubocop:disable Scalability/IdempotentWorker
|
2017-11-28 11:08:30 -05:00
|
|
|
include ApplicationWorker
|
2016-12-16 23:09:50 -05:00
|
|
|
|
2019-10-18 07:11:44 -04:00
|
|
|
feature_category_not_owned!
|
|
|
|
|
2019-10-30 11:14:17 -04:00
|
|
|
# TODO: The reactive caching worker should be split into
|
2020-03-02 13:07:42 -05:00
|
|
|
# two different workers, one for high urgency jobs without external dependencies
|
|
|
|
# and another worker without high urgency, but with external dependencies
|
2019-10-30 11:14:17 -04:00
|
|
|
# https://gitlab.com/gitlab-com/gl-infra/scalability/issues/34
|
|
|
|
# This worker should also have `worker_has_external_dependencies!` enabled
|
2020-03-02 13:07:42 -05:00
|
|
|
urgency :high
|
2019-10-30 11:14:17 -04:00
|
|
|
worker_resource_boundary :cpu
|
|
|
|
|
2017-01-12 17:31:02 -05:00
|
|
|
def perform(class_name, id, *args)
|
2016-12-16 23:09:50 -05:00
|
|
|
klass = begin
|
2019-02-14 13:05:35 -05:00
|
|
|
class_name.constantize
|
2016-12-16 23:09:50 -05:00
|
|
|
rescue NameError
|
|
|
|
nil
|
|
|
|
end
|
|
|
|
return unless klass
|
|
|
|
|
2019-04-04 13:27:29 -04:00
|
|
|
klass
|
|
|
|
.reactive_cache_worker_finder
|
|
|
|
.call(id, *args)
|
|
|
|
.try(:exclusively_update_reactive_cache!, *args)
|
2020-02-10 10:08:54 -05:00
|
|
|
rescue ReactiveCaching::ExceededReactiveCacheLimit => e
|
|
|
|
Gitlab::ErrorTracking.track_exception(e)
|
2016-12-16 23:09:50 -05:00
|
|
|
end
|
|
|
|
end
|