Class: Gitlab::SidekiqMiddleware::PauseControl::WorkersMap

Inherits:
Object
  • Object
show all
Defined in:
lib/gitlab/sidekiq_middleware/pause_control/workers_map.rb

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.workersObject (readonly)

Returns the value of attribute workers.



8
9
10
# File 'lib/gitlab/sidekiq_middleware/pause_control/workers_map.rb', line 8

def workers
  @workers
end

Class Method Details

.set_strategy_for(strategy:, worker:) ⇒ Object

Raises:

  • (ArgumentError)


10
11
12
13
14
15
# File 'lib/gitlab/sidekiq_middleware/pause_control/workers_map.rb', line 10

def set_strategy_for(strategy:, worker:)
  raise ArgumentError, "Unknown strategy: #{strategy}" unless PauseControl::STRATEGIES.key?(strategy)

  @workers ||= Hash.new { |h, k| h[k] = [] }
  @workers[strategy].push(worker)
end

.strategy_for(worker:) ⇒ Object



17
18
19
20
21
# File 'lib/gitlab/sidekiq_middleware/pause_control/workers_map.rb', line 17

def strategy_for(worker:)
  return unless @workers

  @workers.find { |_, v| v.include?(worker) }&.first
end