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 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