1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
|
# frozen_string_literal: true
module Gitlab
module SidekiqConfig
class Worker
include Comparable
attr_reader :klass
delegate :feature_category_not_owned?, :generated_queue_name, :get_feature_category,
:get_sidekiq_options, :get_tags, :get_urgency, :get_weight,
:get_worker_resource_boundary, :idempotent?, :queue_namespace,
:worker_has_external_dependencies?,
to: :klass
def initialize(klass, ee:, jh: false)
@klass = klass
@ee = ee
@jh = jh
end
def ee?
@ee
end
def jh?
@jh
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_namespace ? 0 : 1, generated_queue_name]
end
# YAML representation
def encode_with(coder)
coder.represent_map(nil, to_yaml)
end
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: get_tags
}
end
def namespace_and_weight
[queue_namespace, get_weight]
end
def queue_and_weight
[generated_queue_name, get_weight]
end
def retries
get_sidekiq_options['retry']
end
end
end
end
|