Package com.coditory.sherlock.rxjava
Interface Sherlock
- All Known Implementing Classes:
SherlockStub
public interface Sherlock
Manages distributed locks using Kotlin Coroutines API.
-
Method Summary
Modifier and TypeMethodDescription@NotNull com.coditory.sherlock.DistributedLockBuilder<DistributedLock> Creates a distributed single-entrant lock builder.default @NotNull DistributedLockcreateLock(@NotNull String lockId) Creates a single-entrant lock with default configuration.@NotNull com.coditory.sherlock.DistributedLockBuilder<DistributedLock> Create a distributed overriding lock.default @NotNull DistributedLockcreateOverridingLock(@NotNull String lockId) Creates an overriding lock with default configuration.@NotNull com.coditory.sherlock.DistributedLockBuilder<DistributedLock> Creates a distributed reentrant lock.default @NotNull DistributedLockcreateReentrantLock(@NotNull String lockId) Creates a reentrant lock with default configuration.@NotNull io.reactivex.rxjava3.core.Single<com.coditory.sherlock.connector.ReleaseResult> Force releases all acquired locks.default @NotNull io.reactivex.rxjava3.core.Single<com.coditory.sherlock.connector.ReleaseResult> forceReleaseLock(@NotNull String lockId) Force releases a lock.@NotNull io.reactivex.rxjava3.core.Single<com.coditory.sherlock.connector.InitializationResult> Initializes underlying infrastructure.
-
Method Details
-
initialize
@NotNull @NotNull io.reactivex.rxjava3.core.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.Initialization creates indexes and tables.
- Returns:
InitializationResult
-
createLock
Creates a distributed single-entrant lock builder. Single-entrant lock can be acquired only once. Even the same owner cannot acquire the same lock again.assert lock.acquire() == true assert lock.acquire() == false- Returns:
- the lock builder
-
createLock
Creates a single-entrant lock with default configuration.- Parameters:
lockId- lock identifier- Returns:
- the lock
- See Also:
-
createReentrantLock
@NotNull @NotNull com.coditory.sherlock.DistributedLockBuilder<DistributedLock> 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
@NotNull @NotNull com.coditory.sherlock.DistributedLockBuilder<DistributedLock> 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
@NotNull @NotNull io.reactivex.rxjava3.core.Single<com.coditory.sherlock.connector.ReleaseResult> forceReleaseAllLocks()Force releases all acquired locks.It could be used for administrative actions.
- Returns:
ReleaseResult
-
forceReleaseLock
@NotNull default @NotNull io.reactivex.rxjava3.core.Single<com.coditory.sherlock.connector.ReleaseResult> forceReleaseLock(@NotNull @NotNull String lockId) Force releases a lock.It could be used for administrative actions.
- Parameters:
lockId- lock identifier- Returns:
ReleaseResult
-