Interface ReactiveSherlock


  • public interface ReactiveSherlock
    Creates and manages reactive distributed locks.
    • Method Detail

      • initialize

        java.util.concurrent.Flow.Publisher<InitializationResult> initialize()
        Initializes underlying infrastructure. If it's database then indexes and tables are created. If this method is not invoked directly then it is invoked implicitly when acquiring or releasing a lock for the first time.
      • createLock

        ReactiveDistributedLock createLock​(java.lang.String lockId,
                                           java.time.Duration duration)
        Create a lock. Created lock may be acquired only once by the same application instance:
        
         assert reentrantLock.acquire() == true
         assert reentrantLock.acquire() == false
         
        Parameters:
        lockId - the lock id
        duration - after that time lock expires and is released
        Returns:
        the lock
      • createReentrantLock

        ReactiveDistributedLock createReentrantLock​(java.lang.String lockId,
                                                    java.time.Duration duration)
        Create a distributed reentrant lock. Reentrant lock maybe acquired multiple times by the same application instance:
        
         assert reentrantLock.acquire() == true
         assert reentrantLock.acquire() == true
         
        Parameters:
        lockId - the lock id
        duration - after that time lock expires and is released
        Returns:
        the reentrant lock
      • createOverridingLock

        ReactiveDistributedLock createOverridingLock​(java.lang.String lockId,
                                                     java.time.Duration duration)
        Create a distributed overriding lock. Returned lock overrides lock state without checking if it was released.
        Parameters:
        lockId - the lock id
        duration - after that time lock expires and is released
        Returns:
        the reentrant lock
      • map

        default <T> T map​(java.util.function.Function<ReactiveSherlock,​T> mapper)