Package com.coditory.sherlock
Class DistributedLockBuilder<T>
java.lang.Object
com.coditory.sherlock.DistributedLockBuilder<T>
- Type Parameters:
T
- lock type
Builds a distributed lock of type T.
-
Method Summary
Modifier and TypeMethodDescriptionbuild()
Builds the lock.withLockDuration
(Duration duration) Overrides the default lock duration.withLockId
(String lockId) Set up lock identifier.withOwnerId
(String ownerId) Overrides the default owner id used to distinguish who acquired the lock.Overrides the default lock duration so the lock never expires.Overrides the default owner id policy.Overrides the default owner id policy.
-
Method Details
-
withLockId
Set up lock identifier. Lock identifier distinguishes locks in a distributed system.- Parameters:
lockId
- the lock identifier- Returns:
- the builder
-
withLockDuration
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
Overrides the default lock duration so the lock never expires.- Returns:
- the builder
-
withOwnerId
Overrides the default owner id used to distinguish who acquired the lock.- Parameters:
ownerId
- owner identifier- Returns:
- the builder
-
withUniqueOwnerId
Overrides the default owner id policy. Created lock will have random and unique id.- Returns:
- the builder
-
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
Builds the lock.- Returns:
- the lock
-