Package com.coditory.sherlock
Class MongoSherlock
- java.lang.Object
-
- com.coditory.sherlock.MongoSherlock
-
public class MongoSherlock extends java.lang.Object
BuildsSherlock
that uses MongoDB for locking mechanism.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description com.coditory.sherlock.Sherlock
build()
static MongoSherlock
builder()
MongoSherlock
withClock(java.time.Clock clock)
MongoSherlock
withCollectionName(java.lang.String collectionName)
MongoSherlock
withDatabaseName(java.lang.String databaseName)
MongoSherlock
withLockDuration(java.time.Duration duration)
MongoSherlock
withMongoClient(com.mongodb.client.MongoClient mongoClient)
MongoSherlock
withOwnerId(java.lang.String ownerId)
-
-
-
Method Detail
-
builder
public static MongoSherlock builder()
- Returns:
- new instance of the builder
-
withMongoClient
public MongoSherlock withMongoClient(com.mongodb.client.MongoClient mongoClient)
- Parameters:
mongoClient
- mongo client to be used for locking- Returns:
- the instance
-
withDatabaseName
public MongoSherlock withDatabaseName(java.lang.String databaseName)
- Parameters:
databaseName
- database name where locks will be stored- Returns:
- the instance
-
withCollectionName
public MongoSherlock 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 MongoSherlock 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 MongoSherlock 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 MongoSherlock 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.Sherlock build()
- Returns:
- sherlock instance
- Throws:
java.lang.IllegalArgumentException
- when some required values are missing
-
-