Module: Gitlab::SidekiqConfig::CliMethods
- Extended by:
- CliMethods
- Included in:
- Gitlab::SidekiqConfig, CliMethods
- Defined in:
- lib/gitlab/sidekiq_config/cli_methods.rb
Constant Summary collapse
- QUEUE_CONFIG_PATHS =
The file names are misleading. Those files contain the metadata of the workers. They should be renamed to all_workers instead. gitlab.com/gitlab-com/gl-infra/scalability/-/issues/1018
begin result = %w[app/workers/all_queues.yml] result << 'ee/app/workers/all_queues.yml' if Gitlab.ee? result << 'jh/app/workers/all_queues.yml' if Gitlab.jh? result end.freeze
Instance Method Summary collapse
- #clear_memoization! ⇒ Object
- #expand_queues(queues, all_queues = self.worker_queues) ⇒ Object
- #query_queues(query_string, worker_metadatas) ⇒ Object
- #worker_metadatas(rails_path = Rails.root.to_s) ⇒ Object
-
#worker_queues(rails_path = Rails.root.to_s) ⇒ Object
rubocop:enable Gitlab/ModuleWithInstanceVariables.
Instance Method Details
#clear_memoization! ⇒ Object
58 59 60 61 62 |
# File 'lib/gitlab/sidekiq_config/cli_methods.rb', line 58 def clear_memoization! if instance_variable_defined?(:@worker_metadatas) remove_instance_variable(:@worker_metadatas) end end |
#expand_queues(queues, all_queues = self.worker_queues) ⇒ Object
39 40 41 42 43 44 45 46 47 |
# File 'lib/gitlab/sidekiq_config/cli_methods.rb', line 39 def (queues, all_queues = self.worker_queues) return [] if queues.empty? queues_set = all_queues.to_set queues.flat_map do |queue| [queue, *queues_set.grep(/\A#{queue}:/)] end end |
#query_queues(query_string, worker_metadatas) ⇒ Object
49 50 51 52 53 54 55 56 |
# File 'lib/gitlab/sidekiq_config/cli_methods.rb', line 49 def query_queues(query_string, ) matcher = SidekiqConfig::WorkerMatcher.new(query_string) = .select do || matcher.match?() end worker_names() end |
#worker_metadatas(rails_path = Rails.root.to_s) ⇒ Object
24 25 26 27 28 29 30 31 32 |
# File 'lib/gitlab/sidekiq_config/cli_methods.rb', line 24 def (rails_path = Rails.root.to_s) @worker_metadatas ||= {} @worker_metadatas[rails_path] ||= QUEUE_CONFIG_PATHS.flat_map do |path| full_path = File.join(rails_path, path) File.exist?(full_path) ? YAML.load_file(full_path) : [] end end |
#worker_queues(rails_path = Rails.root.to_s) ⇒ Object
rubocop:enable Gitlab/ModuleWithInstanceVariables
35 36 37 |
# File 'lib/gitlab/sidekiq_config/cli_methods.rb', line 35 def worker_queues(rails_path = Rails.root.to_s) worker_names((rails_path)) end |