Package com.coditory.sherlock.reactive
Class ReactiveMongoSherlock
- java.lang.Object
-
- com.coditory.sherlock.reactive.ReactiveMongoSherlock
-
public class ReactiveMongoSherlock extends java.lang.Object
BuildsReactiveSherlock
that uses MongoDB for locking mechanism.
-
-
Method Summary
Modifier and Type Method Description com.coditory.sherlock.reactive.ReactiveSherlock
build()
static ReactiveMongoSherlock
builder()
ReactiveMongoSherlock
withClock(java.time.Clock clock)
ReactiveMongoSherlock
withCollectionName(java.lang.String collectionName)
ReactiveMongoSherlock
withDatabaseName(java.lang.String databaseName)
ReactiveMongoSherlock
withLockDuration(java.time.Duration duration)
ReactiveMongoSherlock
withMongoClient(com.mongodb.reactivestreams.client.MongoClient mongoClient)
ReactiveMongoSherlock
withOwnerId(java.lang.String ownerId)
-
-
-
Method Detail
-
builder
public static ReactiveMongoSherlock builder()
- Returns:
- new instance of the builder
-
withMongoClient
public ReactiveMongoSherlock withMongoClient(com.mongodb.reactivestreams.client.MongoClient mongoClient)
- Parameters:
mongoClient
- mongo client to be used for locking- Returns:
- the instance
-
withDatabaseName
public ReactiveMongoSherlock withDatabaseName(java.lang.String databaseName)
- Parameters:
databaseName
- database name where locks will be stored- Returns:
- the instance
-
withCollectionName
public ReactiveMongoSherlock withCollectionName(java.lang.String collectionName)
- Parameters:
collectionName
- collection name where locks will be stored. Default:SherlockDefaults.DEFAULT_DB_TABLE_NAME
- Returns:
- the instance
-
withLockDuration
public ReactiveMongoSherlock withLockDuration(java.time.Duration duration)
- Parameters:
duration
- how much time a lock should be active. When time passes lock is expired and becomes released. Default:SherlockDefaults.DEFAULT_LOCK_DURATION
- Returns:
- the instance
-
withOwnerId
public ReactiveMongoSherlock withOwnerId(java.lang.String ownerId)
- Parameters:
ownerId
- owner id most often should be a unique application instance identifier. Default:SherlockDefaults.DEFAULT_INSTANCE_ID
- Returns:
- the instance
-
withClock
public ReactiveMongoSherlock withClock(java.time.Clock clock)
- Parameters:
clock
- time provider used in locking mechanism. Default:SherlockDefaults.DEFAULT_CLOCK
- Returns:
- the instance
-
build
public com.coditory.sherlock.reactive.ReactiveSherlock build()
- Returns:
- sherlock instance
- Throws:
java.lang.IllegalArgumentException
- when some required values are missing
-
-