2020-03-13 15:44:24 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module Gitlab
|
|
|
|
module SidekiqConfig
|
|
|
|
# For queues that don't have explicit workers - default and mailers
|
|
|
|
class DummyWorker
|
|
|
|
ATTRIBUTE_METHODS = {
|
2021-06-08 01:23:25 +05:30
|
|
|
name: :name,
|
2020-03-13 15:44:24 +05:30
|
|
|
has_external_dependencies: :worker_has_external_dependencies?,
|
2020-04-08 14:13:33 +05:30
|
|
|
urgency: :get_urgency,
|
2020-03-13 15:44:24 +05:30
|
|
|
resource_boundary: :get_worker_resource_boundary,
|
2020-04-08 14:13:33 +05:30
|
|
|
idempotent: :idempotent?,
|
2020-06-23 00:09:42 +05:30
|
|
|
weight: :get_weight,
|
|
|
|
tags: :get_tags
|
2020-03-13 15:44:24 +05:30
|
|
|
}.freeze
|
|
|
|
|
2021-06-08 01:23:25 +05:30
|
|
|
def initialize(attributes = {})
|
2020-03-13 15:44:24 +05:30
|
|
|
@attributes = attributes
|
|
|
|
end
|
|
|
|
|
2021-10-27 15:23:28 +05:30
|
|
|
def generated_queue_name
|
|
|
|
@attributes[:queue]
|
|
|
|
end
|
|
|
|
|
2022-07-16 23:28:13 +05:30
|
|
|
def queue
|
|
|
|
@attributes[:queue]
|
|
|
|
end
|
|
|
|
|
2020-03-13 15:44:24 +05:30
|
|
|
def queue_namespace
|
|
|
|
nil
|
|
|
|
end
|
|
|
|
|
2021-11-18 22:05:49 +05:30
|
|
|
# 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
|
|
|
|
|
|
|
|
def feature_category_not_owned?
|
|
|
|
true
|
|
|
|
end
|
|
|
|
|
|
|
|
def get_worker_context
|
|
|
|
nil
|
|
|
|
end
|
|
|
|
|
|
|
|
def context_for_arguments(*)
|
|
|
|
nil
|
|
|
|
end
|
|
|
|
|
2020-03-13 15:44:24 +05:30
|
|
|
ATTRIBUTE_METHODS.each do |attribute, meth|
|
|
|
|
define_method meth do
|
|
|
|
@attributes[attribute]
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|