Class: Gitlab::SidekiqMiddleware::Throttling::RecoveryTask

Inherits:
Object
  • Object
show all
Includes:
ExclusiveLeaseGuard
Defined in:
lib/gitlab/sidekiq_middleware/throttling/recovery_task.rb

Constant Summary collapse

LEASE_TTL =
1.minute
MIN_SLEEP_INTERVAL =
20.seconds
MAX_SLEEP_INTERVAL =
40.seconds

Instance Method Summary collapse

Methods included from ExclusiveLeaseGuard

#exclusive_lease, #lease_taken_message, #log_lease_taken, #release_lease, #renew_lease!, #try_obtain_lease

Constructor Details

#initializeRecoveryTask

Returns a new instance of RecoveryTask.



13
14
15
# File 'lib/gitlab/sidekiq_middleware/throttling/recovery_task.rb', line 13

def initialize
  @alive = true
end

Instance Method Details

#callObject



17
18
19
20
21
22
23
24
25
# File 'lib/gitlab/sidekiq_middleware/throttling/recovery_task.rb', line 17

def call
  while @alive
    sleep(sleep_interval)

    next if ::Feature.disabled?(:sidekiq_throttling_middleware, :instance, type: :worker)

    try_obtain_lease { recover_workers }
  end
end

#stopObject



27
28
29
# File 'lib/gitlab/sidekiq_middleware/throttling/recovery_task.rb', line 27

def stop
  @alive = false
end