Package com.coditory.sherlock.reactor
Interface ReactorSherlock
-
- All Known Implementing Classes:
ReactorSherlockStub
public interface ReactorSherlock
Creates and manages reactive distributed locks with reactor api.
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Modifier and Type Method Description ReactorDistributedLock
createLock(java.lang.String lockId)
Create a distributed lock.ReactorDistributedLock
createLock(java.lang.String lockId, java.time.Duration duration)
Create a lock.ReactorDistributedLock
createOverridingLock(java.lang.String lockId)
Create a distributed overriding lock.ReactorDistributedLock
createOverridingLock(java.lang.String lockId, java.time.Duration duration)
Create a distributed overriding lock.ReactorDistributedLock
createReentrantLock(java.lang.String lockId)
Create a distributed reentrant lock.ReactorDistributedLock
createReentrantLock(java.lang.String lockId, java.time.Duration duration)
Create a distributed reentrant lock.java.time.Duration
getLockDuration()
java.lang.String
getOwnerId()
static ReactorSherlock
reactorSherlock(com.coditory.sherlock.reactive.ReactiveSherlock locks)
Maps reactive sherlock to a one using Reactor'sMono
andFlux
-
-
-
Method Detail
-
reactorSherlock
static ReactorSherlock reactorSherlock(com.coditory.sherlock.reactive.ReactiveSherlock locks)
Maps reactive sherlock to a one using Reactor'sMono
andFlux
- Parameters:
locks
- reactive locks to be wrapped in Reactor api- Returns:
- reactor version of sherlock locks
-
getOwnerId
java.lang.String getOwnerId()
- Returns:
- owner id is most often the application instance id
-
getLockDuration
java.time.Duration getLockDuration()
- Returns:
- the default lock duration
-
createLock
ReactorDistributedLock createLock(java.lang.String lockId)
Create a distributed lock. Lock expires aftergetLockDuration()
.- Parameters:
lockId
- the lock id- Returns:
- the lock
- See Also:
createLock(String, Duration)
-
createLock
ReactorDistributedLock createLock(java.lang.String lockId, java.time.Duration duration)
Create a lock. Created lock may be acquired only once by the same application instance:assert reentrantLock.acquire() == true assert reentrantLock.acquire() == false
- Parameters:
lockId
- the lock idduration
- after that time lock expires and is released- Returns:
- the lock
-
createReentrantLock
ReactorDistributedLock createReentrantLock(java.lang.String lockId)
Create a distributed reentrant lock. Lock expires aftergetLockDuration()
.- Parameters:
lockId
- the lock id- Returns:
- the reentrant lock
- See Also:
createReentrantLock(String, Duration)
-
createReentrantLock
ReactorDistributedLock createReentrantLock(java.lang.String lockId, java.time.Duration duration)
Create a distributed reentrant lock. Reentrant lock maybe acquired multiple times by the same application instance:assert reentrantLock.acquire() == true assert reentrantLock.acquire() == true
- Parameters:
lockId
- the lock idduration
- after that time lock expires and is released- Returns:
- the reentrant lock
-
createOverridingLock
ReactorDistributedLock createOverridingLock(java.lang.String lockId)
Create a distributed overriding lock. Lock expires aftergetLockDuration()
.- Parameters:
lockId
- the lock id- Returns:
- the reentrant lock
- See Also:
createOverridingLock(String, Duration)
-
createOverridingLock
ReactorDistributedLock createOverridingLock(java.lang.String lockId, java.time.Duration duration)
Create a distributed overriding lock. Returned lock overrides lock state without checking if it was released.- Parameters:
lockId
- the lock idduration
- after that time lock expires and is released- Returns:
- the reentrant lock
-
-