Class: Gitlab::SidekiqConfig::Worker

Inherits:
Object
  • Object
show all
Includes:
Comparable
Defined in:
lib/gitlab/sidekiq_config/worker.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#klassObject (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

Returns:

  • (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

Returns:

  • (Boolean)


26
27
28
# File 'lib/gitlab/sidekiq_config/worker.rb', line 26

def jh?
  @jh
end

#namespace_and_weightObject



67
68
69
# File 'lib/gitlab/sidekiq_config/worker.rb', line 67

def namespace_and_weight
  [queue_namespace, get_weight]
end

#queue_and_weightObject



71
72
73
# File 'lib/gitlab/sidekiq_config/worker.rb', line 71

def queue_and_weight
  [generated_queue_name, get_weight]
end

#retriesObject



75
76
77
# File 'lib/gitlab/sidekiq_config/worker.rb', line 75

def retries
  get_sidekiq_options['retry']
end

#to_sortObject

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_yamlObject



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: get_tags
  }
end