Class: Stoplight::Infrastructure::Memory::Storage::RecoveryLock
- Inherits:
-
Object
- Object
- Stoplight::Infrastructure::Memory::Storage::RecoveryLock
- Defined in:
- lib/stoplight/infrastructure/memory/storage/recovery_lock.rb
Overview
Process-local recovery lock using Ruby’s Thread::Mutex.
This only serializes recovery within a single Ruby process. Multiple processes/servers will NOT coordinate - each process can send probes independently.
Instance Method Summary collapse
- #acquire_lock ⇒ Object
-
#initialize ⇒ RecoveryLock
constructor
A new instance of RecoveryLock.
- #release_lock(_recovery_lock_token) ⇒ Object
Constructor Details
#initialize ⇒ RecoveryLock
Returns a new instance of RecoveryLock.
14 15 16 |
# File 'lib/stoplight/infrastructure/memory/storage/recovery_lock.rb', line 14 def initialize @lock = Thread::Mutex.new end |
Instance Method Details
#acquire_lock ⇒ Object
18 19 20 21 22 |
# File 'lib/stoplight/infrastructure/memory/storage/recovery_lock.rb', line 18 def acquire_lock if lock.try_lock Domain::Storage::RecoveryLockToken.new end end |
#release_lock(_recovery_lock_token) ⇒ Object
24 25 26 |
# File 'lib/stoplight/infrastructure/memory/storage/recovery_lock.rb', line 24 def release_lock(_recovery_lock_token) lock.unlock end |