Class: Synapse::Repository::PessimisticLockManager
- Inherits:
-
LockManager
- Object
- LockManager
- Synapse::Repository::PessimisticLockManager
- Defined in:
- lib/synapse/repository/pessimistic_lock_manager.rb
Overview
Implementation of a lock manager that blocks until a lock can be obtained
Instance Method Summary collapse
-
#initialize ⇒ PessimisticLockManager
constructor
A new instance of PessimisticLockManager.
- #obtain_lock(aggregate_id) ⇒ undefined
- #release_lock(aggregate_id) ⇒ undefined
- #validate_lock(aggregate) ⇒ Boolean
Constructor Details
#initialize ⇒ PessimisticLockManager
Returns a new instance of PessimisticLockManager.
5 6 7 |
# File 'lib/synapse/repository/pessimistic_lock_manager.rb', line 5 def initialize @aggregates = IdentifierLock.new end |
Instance Method Details
#obtain_lock(aggregate_id) ⇒ undefined
17 18 19 |
# File 'lib/synapse/repository/pessimistic_lock_manager.rb', line 17 def obtain_lock(aggregate_id) @aggregates.obtain_lock aggregate_id end |
#release_lock(aggregate_id) ⇒ undefined
23 24 25 |
# File 'lib/synapse/repository/pessimistic_lock_manager.rb', line 23 def release_lock(aggregate_id) @aggregates.release_lock aggregate_id end |
#validate_lock(aggregate) ⇒ Boolean
11 12 13 |
# File 'lib/synapse/repository/pessimistic_lock_manager.rb', line 11 def validate_lock(aggregate) @aggregates.owned? aggregate.id end |