Class: Gitlab::SidekiqMiddleware::Throttling::RecoveryTask
- Inherits:
-
Object
- Object
- Gitlab::SidekiqMiddleware::Throttling::RecoveryTask
- 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
- #call ⇒ Object
-
#initialize ⇒ RecoveryTask
constructor
A new instance of RecoveryTask.
- #stop ⇒ Object
Methods included from ExclusiveLeaseGuard
#exclusive_lease, #lease_taken_message, #log_lease_taken, #release_lease, #renew_lease!, #try_obtain_lease
Constructor Details
#initialize ⇒ RecoveryTask
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
#call ⇒ Object
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 |
#stop ⇒ Object
27 28 29 |
# File 'lib/gitlab/sidekiq_middleware/throttling/recovery_task.rb', line 27 def stop @alive = false end |