Class DistributedLockBuilder<T>

java.lang.Object
com.coditory.sherlock.DistributedLockBuilder<T>
Type Parameters:
T - lock type

public final class DistributedLockBuilder<T> extends Object
Builds a distributed lock of type T.
  • Method Details

    • withLockId

      public DistributedLockBuilder<T> withLockId(String lockId)
      Set up lock identifier. Lock identifier distinguishes locks in a distributed system.
      Parameters:
      lockId - the lock identifier
      Returns:
      the builder
    • withLockDuration

      public DistributedLockBuilder<T> withLockDuration(Duration duration)
      Overrides the default lock duration. Lock duration is the amount time that must pass to lock expire the lock. Expired lock is treated as released.
      Parameters:
      duration - lock duration.
      Returns:
      the builder
    • withPermanentLockDuration

      public DistributedLockBuilder<T> withPermanentLockDuration()
      Overrides the default lock duration so the lock never expires.
      Returns:
      the builder
    • withOwnerId

      public DistributedLockBuilder<T> withOwnerId(String ownerId)
      Overrides the default owner id used to distinguish who acquired the lock.
      Parameters:
      ownerId - owner identifier
      Returns:
      the builder
    • withUniqueOwnerId

      public DistributedLockBuilder<T> withUniqueOwnerId()
      Overrides the default owner id policy. Created lock will have random and unique id.
      Returns:
      the builder
    • withStaticUniqueOwnerId

      public DistributedLockBuilder<T> withStaticUniqueOwnerId()
      Overrides the default owner id policy. Created lock will have random identifier shared by all lock instances created in this JVM. Think of it as a static random value.
      Returns:
      the builder
    • build

      public T build()
      Builds the lock.
      Returns:
      the lock