Package com.coditory.sherlock
Interface RxSherlock
- All Known Implementing Classes:
RxSherlockStub
public interface RxSherlock
Manages distributed locks using RXJava API.
-
Method Summary
Modifier and TypeMethodDescriptioncom.coditory.sherlock.DistributedLockBuilder<RxDistributedLock>Creates a distributed lock.default RxDistributedLockcreateLock(String lockId) Creates a lock with default configuration.com.coditory.sherlock.DistributedLockBuilder<RxDistributedLock>Create a distributed overriding lock.default RxDistributedLockcreateOverridingLock(String lockId) Creates an overriding lock with default configuration.com.coditory.sherlock.DistributedLockBuilder<RxDistributedLock>Creates a distributed reentrant lock.default RxDistributedLockcreateReentrantLock(String lockId) Creates a reentrant lock with default configuration.io.reactivex.Single<com.coditory.sherlock.connector.ReleaseResult>Force releases all acquired locks.default io.reactivex.Single<com.coditory.sherlock.connector.ReleaseResult>forceReleaseLock(String lockId) Force releases a lock.io.reactivex.Single<com.coditory.sherlock.connector.InitializationResult>Initializes underlying infrastructure.static RxSherlockrxSherlock(com.coditory.sherlock.ReactiveSherlock locks) Maps reactive sherlock to a one using RxJava API
-
Method Details
-
rxSherlock
Maps reactive sherlock to a one using RxJava API- Parameters:
locks- reactive locks to be wrapped in RxJava api- Returns:
- RxJava version of sherlock locks
-
initialize
io.reactivex.Single<com.coditory.sherlock.connector.InitializationResult> initialize()Initializes underlying infrastructure. If this method is not invoked explicitly then it can be invoked implicitly when acquiring or releasing a lock for the first time.Most often initialization is related with creating indexes and tables.
- Returns:
InitializationResult.SUCCESSif initialization was successful, otherwiseInitializationResult.FAILUREis returned
-
createLock
com.coditory.sherlock.DistributedLockBuilder<RxDistributedLock> createLock()Creates a distributed lock. Created lock may be acquired only once by the same owner:assert lock.acquire() == true assert lock.acquire() == false- Returns:
- the lock builder
-
createLock
Creates a lock with default configuration.- Parameters:
lockId- lock identifier- Returns:
- the lock
- See Also:
-
createReentrantLock
com.coditory.sherlock.DistributedLockBuilder<RxDistributedLock> createReentrantLock()Creates a distributed reentrant lock. Reentrant lock may be acquired multiple times by the same owner:assert reentrantLock.acquire() == true assert reentrantLock.acquire() == true- Returns:
- the reentrant lock builder
-
createReentrantLock
Creates a reentrant lock with default configuration.- Parameters:
lockId- lock identifier- Returns:
- the reentrant lock
- See Also:
-
createOverridingLock
com.coditory.sherlock.DistributedLockBuilder<RxDistributedLock> createOverridingLock()Create a distributed overriding lock. Returned lock may acquire or release any other lock without checking its state:assert someLock.acquire() == true assert overridingLock.acquire() == trueIt could be used for administrative actions.
- Returns:
- the overriding lock builder
-
createOverridingLock
Creates an overriding lock with default configuration.- Parameters:
lockId- lock identifier- Returns:
- the overriding lock
- See Also:
-
forceReleaseAllLocks
io.reactivex.Single<com.coditory.sherlock.connector.ReleaseResult> forceReleaseAllLocks()Force releases all acquired locks.It could be used for administrative actions.
- Returns:
ReleaseResult.SUCCESSif lock was released, otherwiseReleaseResult.FAILUREis returned
-
forceReleaseLock
default io.reactivex.Single<com.coditory.sherlock.connector.ReleaseResult> forceReleaseLock(String lockId) Force releases a lock.It could be used for administrative actions.
- Parameters:
lockId- lock identifier- Returns:
ReleaseResult.SUCCESSif lock was released, otherwiseReleaseResult.FAILUREis returned
-