Class ReactiveMongoSherlock


  • public class ReactiveMongoSherlock
    extends java.lang.Object
    Builds ReactiveSherlock that uses MongoDB for locking mechanism.
    • Method Detail

      • 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