diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-01-22 15:08:40 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-01-22 15:08:40 +0300 |
commit | be3e24ea3c9f497efde85900df298ce9bc42fce8 (patch) | |
tree | fd0de9443253a1b21ca9a2741dc34ba3aef795be /lib/gitlab/sidekiq_config | |
parent | 001243986195143c395a9811d8254bbf1b9ebfa1 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'lib/gitlab/sidekiq_config')
-rw-r--r-- | lib/gitlab/sidekiq_config/worker.rb | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/lib/gitlab/sidekiq_config/worker.rb b/lib/gitlab/sidekiq_config/worker.rb new file mode 100644 index 00000000000..313d9b17b16 --- /dev/null +++ b/lib/gitlab/sidekiq_config/worker.rb @@ -0,0 +1,51 @@ +# frozen_string_literal: true + +module Gitlab + module SidekiqConfig + class Worker + include Comparable + + attr_reader :klass + delegate :feature_category_not_owned?, :get_feature_category, + :get_worker_resource_boundary, :latency_sensitive_worker?, + :queue, :worker_has_external_dependencies?, + to: :klass + + def initialize(klass, ee:) + @klass = klass + @ee = ee + end + + def ee? + @ee + end + + def ==(other) + to_yaml == case other + when self.class + other.to_yaml + else + other + end + end + + def <=>(other) + to_sort <=> other.to_sort + end + + # Put namespaced queues first + def to_sort + [queue.include?(':') ? 0 : 1, queue] + end + + # YAML representation + def encode_with(coder) + coder.represent_scalar(nil, to_yaml) + end + + def to_yaml + queue + end + end + end +end |