Package com.coditory.sherlock.mongo
Class MongoSherlock
java.lang.Object
com.coditory.sherlock.SherlockWithConnectorBuilder<MongoSherlock>
com.coditory.sherlock.mongo.MongoSherlock
public final class MongoSherlock
extends com.coditory.sherlock.SherlockWithConnectorBuilder<MongoSherlock>
Builds
Sherlock that uses MongoDB for locking mechanism.-
Method Summary
Modifier and TypeMethodDescription@NotNull com.coditory.sherlock.Sherlockbuild()static @NotNull MongoSherlockbuilder()static @NotNull com.coditory.sherlock.Sherlockcreate(@NotNull com.mongodb.client.MongoCollection<org.bson.Document> collection) @NotNull MongoSherlock@NotNull MongoSherlockwithLocksCollection(@NotNull com.mongodb.client.MongoCollection<org.bson.Document> collection) Methods inherited from class com.coditory.sherlock.SherlockWithConnectorBuilder
withLockDuration, withOwnerId, withOwnerIdPolicy
-
Method Details
-
builder
- Returns:
- new instance of the builder
-
create
@NotNull public static @NotNull com.coditory.sherlock.Sherlock create(@NotNull @NotNull com.mongodb.client.MongoCollection<org.bson.Document> collection) - Parameters:
collection- mongo collection to be used for locking- Returns:
- new instance of mongo sherlock with default configuration
-
withLocksCollection
@NotNull public @NotNull MongoSherlock withLocksCollection(@NotNull @NotNull com.mongodb.client.MongoCollection<org.bson.Document> collection) - Parameters:
collection- mongo collection to be used for locking- Returns:
- the instance
-
withClock
- Parameters:
clock- time provider used in locking mechanism. Default:SherlockDefaults.DEFAULT_CLOCK- Returns:
- the instance
-
build
@NotNull public @NotNull com.coditory.sherlock.Sherlock build()- Specified by:
buildin classcom.coditory.sherlock.SherlockWithConnectorBuilder<MongoSherlock>- Returns:
- sherlock instance
- Throws:
IllegalArgumentException- when some required values are missing
-