Package com.coditory.sherlock
Interface ReactiveDistributedLock
-
public interface ReactiveDistributedLock
A distributed lock with reactive api.- See Also:
ReactiveSherlock
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description java.util.concurrent.Flow.Publisher<AcquireResult>
acquire()
Try to acquire the lock.java.util.concurrent.Flow.Publisher<AcquireResult>
acquire(java.time.Duration duration)
Try to acquire the lock for a given duration.java.util.concurrent.Flow.Publisher<AcquireResult>
acquireForever()
Try to acquire the lock without expiring date.java.lang.String
getId()
Return the lock id.java.util.concurrent.Flow.Publisher<ReleaseResult>
release()
Try to release the lock.
-
-
-
Method Detail
-
getId
java.lang.String getId()
Return the lock id.- Returns:
- the lock id
-
acquire
java.util.concurrent.Flow.Publisher<AcquireResult> acquire()
Try to acquire the lock. Lock is acquired for a pre configured duration.- Returns:
AcquireResult.SUCCESS
if lock is acquired
-
acquire
java.util.concurrent.Flow.Publisher<AcquireResult> 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:
AcquireResult.SUCCESS
if lock is acquired
-
acquireForever
java.util.concurrent.Flow.Publisher<AcquireResult> acquireForever()
Try to acquire the lock without expiring date.It is potentially dangerous. Lookout for a situation when the lock owning instance goes down with out releasing the lock.
- Returns:
AcquireResult.SUCCESS
if lock is acquired
-
release
java.util.concurrent.Flow.Publisher<ReleaseResult> release()
Try to release the lock.- Returns:
ReleaseResult.SUCCESS
if lock was released by this method invocation. If lock has expired or was released earlier thenReleaseResult.FAILURE
is returned.
-
-