Class: Gitlab::SidekiqConfig::Worker
- Inherits:
-
Object
- Object
- Gitlab::SidekiqConfig::Worker
- Includes:
- Comparable
- Defined in:
- lib/gitlab/sidekiq_config/worker.rb
Instance Attribute Summary collapse
-
#klass ⇒ Object
readonly
Returns the value of attribute klass.
Instance Method Summary collapse
- #<=>(other) ⇒ Object
- #==(other) ⇒ Object
- #ee? ⇒ Boolean
-
#encode_with(coder) ⇒ Object
YAML representation.
-
#initialize(klass, ee:, jh: false) ⇒ Worker
constructor
A new instance of Worker.
- #jh? ⇒ Boolean
- #namespace_and_weight ⇒ Object
- #queue_and_weight ⇒ Object
- #retries ⇒ Object
-
#to_sort ⇒ Object
Put namespaced queues first.
- #to_yaml ⇒ Object
Constructor Details
#initialize(klass, ee:, jh: false) ⇒ Worker
Returns a new instance of Worker.
16 17 18 19 20 |
# File 'lib/gitlab/sidekiq_config/worker.rb', line 16 def initialize(klass, ee:, jh: false) @klass = klass @ee = ee @jh = jh end |
Instance Attribute Details
#klass ⇒ Object (readonly)
Returns the value of attribute klass.
8 9 10 |
# File 'lib/gitlab/sidekiq_config/worker.rb', line 8 def klass @klass end |
Instance Method Details
#<=>(other) ⇒ Object
39 40 41 |
# File 'lib/gitlab/sidekiq_config/worker.rb', line 39 def <=>(other) to_sort <=> other.to_sort end |
#==(other) ⇒ Object
30 31 32 33 34 35 36 37 |
# File 'lib/gitlab/sidekiq_config/worker.rb', line 30 def ==(other) to_yaml == case other when self.class other.to_yaml else other end end |
#ee? ⇒ Boolean
22 23 24 |
# File 'lib/gitlab/sidekiq_config/worker.rb', line 22 def ee? @ee end |
#encode_with(coder) ⇒ Object
YAML representation
49 50 51 |
# File 'lib/gitlab/sidekiq_config/worker.rb', line 49 def encode_with(coder) coder.represent_map(nil, to_yaml) end |
#jh? ⇒ Boolean
26 27 28 |
# File 'lib/gitlab/sidekiq_config/worker.rb', line 26 def jh? @jh end |
#namespace_and_weight ⇒ Object
67 68 69 |
# File 'lib/gitlab/sidekiq_config/worker.rb', line 67 def namespace_and_weight [queue_namespace, get_weight] end |
#queue_and_weight ⇒ Object
71 72 73 |
# File 'lib/gitlab/sidekiq_config/worker.rb', line 71 def queue_and_weight [generated_queue_name, get_weight] end |
#retries ⇒ Object
75 76 77 |
# File 'lib/gitlab/sidekiq_config/worker.rb', line 75 def retries ['retry'] end |
#to_sort ⇒ Object
Put namespaced queues first
44 45 46 |
# File 'lib/gitlab/sidekiq_config/worker.rb', line 44 def to_sort [queue_namespace ? 0 : 1, generated_queue_name] end |
#to_yaml ⇒ Object
53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/gitlab/sidekiq_config/worker.rb', line 53 def to_yaml { name: generated_queue_name, worker_name: klass.name, feature_category: get_feature_category, has_external_dependencies: worker_has_external_dependencies?, urgency: get_urgency, resource_boundary: get_worker_resource_boundary, weight: get_weight, idempotent: idempotent?, tags: } end |