2020-01-28 10:08:36 -05:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module Gitlab
|
|
|
|
module SidekiqConfig
|
|
|
|
# For queues that don't have explicit workers - default and mailers
|
|
|
|
class DummyWorker
|
|
|
|
ATTRIBUTE_METHODS = {
|
2021-04-28 14:10:12 -04:00
|
|
|
name: :name,
|
2020-01-28 10:08:36 -05:00
|
|
|
has_external_dependencies: :worker_has_external_dependencies?,
|
2020-03-02 13:07:42 -05:00
|
|
|
urgency: :get_urgency,
|
2020-01-28 10:08:36 -05:00
|
|
|
resource_boundary: :get_worker_resource_boundary,
|
2020-02-19 13:09:10 -05:00
|
|
|
idempotent: :idempotent?,
|
2020-05-25 23:08:02 -04:00
|
|
|
weight: :get_weight,
|
|
|
|
tags: :get_tags
|
2020-01-28 10:08:36 -05:00
|
|
|
}.freeze
|
|
|
|
|
2021-04-28 14:10:12 -04:00
|
|
|
def initialize(attributes = {})
|
2020-01-28 10:08:36 -05:00
|
|
|
@attributes = attributes
|
|
|
|
end
|
|
|
|
|
2021-07-20 08:10:29 -04:00
|
|
|
def generated_queue_name
|
|
|
|
@attributes[:queue]
|
|
|
|
end
|
|
|
|
|
2020-01-28 10:08:36 -05:00
|
|
|
def queue_namespace
|
|
|
|
nil
|
|
|
|
end
|
|
|
|
|
2021-09-20 20:09:28 -04:00
|
|
|
# All dummy workers are unowned; get the feature category from the
|
|
|
|
# context if available.
|
|
|
|
def get_feature_category
|
|
|
|
Gitlab::ApplicationContext.current_context_attribute('meta.feature_category') || :not_owned
|
|
|
|
end
|
|
|
|
|
2021-10-05 11:12:53 -04:00
|
|
|
def feature_category_not_owned?
|
|
|
|
true
|
|
|
|
end
|
|
|
|
|
2021-09-20 20:09:28 -04:00
|
|
|
def get_worker_context
|
|
|
|
nil
|
|
|
|
end
|
|
|
|
|
|
|
|
def context_for_arguments(*)
|
|
|
|
nil
|
|
|
|
end
|
|
|
|
|
2020-01-28 10:08:36 -05:00
|
|
|
ATTRIBUTE_METHODS.each do |attribute, meth|
|
|
|
|
define_method meth do
|
|
|
|
@attributes[attribute]
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|