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 Type
    Method
    Description
    @NotNull com.coditory.sherlock.Sherlock
     
    static @NotNull MongoSherlock
     
    static @NotNull com.coditory.sherlock.Sherlock
    create(@NotNull com.mongodb.client.MongoCollection<org.bson.Document> collection)
     
    @NotNull MongoSherlock
    withClock(@NotNull Clock clock)
     
    @NotNull MongoSherlock
    withLocksCollection(@NotNull com.mongodb.client.MongoCollection<org.bson.Document> collection)
     

    Methods inherited from class com.coditory.sherlock.SherlockWithConnectorBuilder

    withLockDuration, withOwnerId, withOwnerIdPolicy

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • builder

      @NotNull public static @NotNull MongoSherlock 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

      @NotNull public @NotNull MongoSherlock withClock(@NotNull @NotNull Clock clock)
      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:
      build in class com.coditory.sherlock.SherlockWithConnectorBuilder<MongoSherlock>
      Returns:
      sherlock instance
      Throws:
      IllegalArgumentException - when some required values are missing