Package com.coditory.sherlock.reactive
Interface ReactiveDistributedLock
-
public interface ReactiveDistributedLock
A lock for distributed environment consisting of multiple application instances. Acquire a distributed lock when only one application instance should execute a specific action.- See Also:
ReactiveSherlock
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description java.util.concurrent.Flow.Publisher<LockResult>
acquire()
Try to acquire the lock.java.util.concurrent.Flow.Publisher<LockResult>
acquire(java.time.Duration duration)
Try to acquire the lock for a given duration.java.util.concurrent.Flow.Publisher<LockResult>
acquireForever()
Try to acquire the lock without expiring date.java.lang.String
getId()
Return the lock id.java.util.concurrent.Flow.Publisher<ReleaseResult>
release()
Release the lock
-
-
-
Method Detail
-
getId
java.lang.String getId()
Return the lock id.- Returns:
- the lock id
-
acquire
java.util.concurrent.Flow.Publisher<LockResult> acquire()
Try to acquire the lock. Lock is acquired for a configured duration.- Returns:
LockResult.SUCCESS
, if lock is acquired
-
acquire
java.util.concurrent.Flow.Publisher<LockResult> acquire(java.time.Duration duration)
Try to acquire the lock for a given duration.- Parameters:
duration
- how much time must pass for the acquired lock to expire- Returns:
LockResult.SUCCESS
, if lock is acquired
-
acquireForever
java.util.concurrent.Flow.Publisher<LockResult> acquireForever()
Try to acquire the lock without expiring date. It is potentially dangerous. Lookout for a situation where the lock owning instance goes down with out releasing the lock.- Returns:
LockResult.SUCCESS
, if lock is acquired
-
release
java.util.concurrent.Flow.Publisher<ReleaseResult> release()
Release the lock- Returns:
ReleaseResult.SUCCESS
, if lock was released in this call. If lock could not be released or was released by a different instance thenReleaseResult.FAILURE
is returned.
-
-