Module: Stoplight::Domain::_RecoveryLockStore
- Included in:
- Infrastructure::Memory::Storage::RecoveryLock, Infrastructure::Redis::Storage::RecoveryLock, Infrastructure::Storage::CompatibilityRecoveryLock
- Defined in:
- sig/_private/stoplight/domain/ports/recovery_lock_store.rbs
Overview
Encapsulates recovery lock management for coordinating recovery probes.
When a circuit enters YELLOW state (half-open), it begins sending "recovery probes" - test requests to check if the protected service has recovered. In distributed deployments with multiple instances, recovery locks ensure only ONE instance sends probes at a time.
Without coordination, all instances would simultaneously:
- Detect the circuit is YELLOW
- Send recovery probes to the struggling service
- Potentially overwhelm it with "test" traffic
Lock Lifecycle:
Instance A: acquire_lock -> probe -> release_lock
Instance B: acquire_lock -> nil (already held) -> skip probe
Instance C: acquire_lock -> nil (already held) -> skip probe
Lock Semantics:
- Returns
nilif lock is already held. Never blocks waiting for lock availability - Locks must automatically expire when persisted storage is used
- Failed releases are acceptable (timeout provides safety)
Instance Method Summary collapse
-
#acquire_lock ⇒ Object
Attempts to acquire recovery lock for exclusive probe execution.
-
#release_lock ⇒ void
Releases a previously acquired lock.
Instance Method Details
#acquire_lock ⇒ Object
Attempts to acquire recovery lock for exclusive probe execution.
This method tries to acquire a lock that serializes recovery probe
execution across multiple instances. If the lock is already held by
another instance, returns nil immediately without blocking.
40 |
# File 'sig/_private/stoplight/domain/ports/recovery_lock_store.rbs', line 40
def acquire_lock: -> Storage::RecoveryLockToken?
|
#release_lock ⇒ void
This method returns an undefined value.
Releases a previously acquired lock.
This method releases the lock token returned by #acquire_lock,
allowing other instances to acquire it. Release should be called
in an ensure block to guarantee cleanup even if probe fails.
49 |
# File 'sig/_private/stoplight/domain/ports/recovery_lock_store.rbs', line 49
def release_lock: (Storage::RecoveryLockToken) -> void
|