Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-01-28 18:08:36 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2020-01-28 18:08:36 +0300
commitfedf978f9aa1909ed7bb3fad767ad120a1c6bd7b (patch)
tree1bd0f0b301ad96feda1910abe34eb89c46cc55cd /lib/gitlab/sidekiq_config
parentdb24ab2b72dbff24c201410a0561e929ae7e8061 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'lib/gitlab/sidekiq_config')
-rw-r--r--lib/gitlab/sidekiq_config/cli_methods.rb10
-rw-r--r--lib/gitlab/sidekiq_config/dummy_worker.rb33
-rw-r--r--lib/gitlab/sidekiq_config/worker.rb11
3 files changed, 51 insertions, 3 deletions
diff --git a/lib/gitlab/sidekiq_config/cli_methods.rb b/lib/gitlab/sidekiq_config/cli_methods.rb
index 1ce46289e81..0676e9df9c5 100644
--- a/lib/gitlab/sidekiq_config/cli_methods.rb
+++ b/lib/gitlab/sidekiq_config/cli_methods.rb
@@ -23,8 +23,10 @@ module Gitlab
@worker_queues[rails_path] ||= QUEUE_CONFIG_PATHS.flat_map do |path|
full_path = File.join(rails_path, path)
+ queues = File.exist?(full_path) ? YAML.load_file(full_path) : []
- File.exist?(full_path) ? YAML.load_file(full_path) : []
+ # https://gitlab.com/gitlab-org/gitlab/issues/199230
+ queues.map { |queue| queue.is_a?(Hash) ? queue[:name] : queue }
end
end
@@ -37,6 +39,12 @@ module Gitlab
[queue, *queues_set.grep(/\A#{queue}:/)]
end
end
+
+ def clear_memoization!
+ if instance_variable_defined?('@worker_queues')
+ remove_instance_variable('@worker_queues')
+ end
+ end
# rubocop:enable Gitlab/ModuleWithInstanceVariables
end
end
diff --git a/lib/gitlab/sidekiq_config/dummy_worker.rb b/lib/gitlab/sidekiq_config/dummy_worker.rb
new file mode 100644
index 00000000000..858ff0db0c9
--- /dev/null
+++ b/lib/gitlab/sidekiq_config/dummy_worker.rb
@@ -0,0 +1,33 @@
+# frozen_string_literal: true
+
+module Gitlab
+ module SidekiqConfig
+ # For queues that don't have explicit workers - default and mailers
+ class DummyWorker
+ attr_accessor :queue
+
+ ATTRIBUTE_METHODS = {
+ feature_category: :get_feature_category,
+ has_external_dependencies: :worker_has_external_dependencies?,
+ latency_sensitive: :latency_sensitive_worker?,
+ resource_boundary: :get_worker_resource_boundary,
+ weight: :get_weight
+ }.freeze
+
+ def initialize(queue, attributes = {})
+ @queue = queue
+ @attributes = attributes
+ end
+
+ def queue_namespace
+ nil
+ end
+
+ ATTRIBUTE_METHODS.each do |attribute, meth|
+ define_method meth do
+ @attributes[attribute]
+ end
+ end
+ end
+ end
+end
diff --git a/lib/gitlab/sidekiq_config/worker.rb b/lib/gitlab/sidekiq_config/worker.rb
index ac94bab9a8f..6cbe327e6b2 100644
--- a/lib/gitlab/sidekiq_config/worker.rb
+++ b/lib/gitlab/sidekiq_config/worker.rb
@@ -41,11 +41,18 @@ module Gitlab
# YAML representation
def encode_with(coder)
- coder.represent_scalar(nil, to_yaml)
+ coder.represent_map(nil, to_yaml)
end
def to_yaml
- queue
+ {
+ name: queue,
+ feature_category: get_feature_category,
+ has_external_dependencies: worker_has_external_dependencies?,
+ latency_sensitive: latency_sensitive_worker?,
+ resource_boundary: get_worker_resource_boundary,
+ weight: get_weight
+ }
end
def namespace_and_weight