Kotlin/JVM coroutine-based distributed locks
APACHE-2.0 License
Here should be some modern logo
Kotlin/JVM coroutine-based distributed locks
There are some simple advantages:
Disadvantages:
Library with modules are available only from jitpack
so far:
<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>
Usage as simple as is - just instantiate required provider and use it like this:
val lokkProvider = /*...*/
lokkProvider.withLokk(atLeastFor = Duration.ofMinutes(10), atMostFor = Duration.ofHours(1)) {
// do some magic
}
There are several jvm lokk implementations so far
Import a dep:
<dependency>
<groupId>com.github.sokomishalov</groupId>
<artifactId>lokk-redis-lettuce</artifactId>
<version>${lokk.version}</version>
</dependency>
Then use this implementation:
val lokkProvider = RedisLettuceLokkProvider(client = RedisClient.create())
Import a dep:
<dependency>
<groupId>com.github.sokomishalov</groupId>
<artifactId>lokk-mongo-reactive-streams</artifactId>
<version>${lokk.version}</version>
</dependency>
Then use this implementation:
val lokkProvider = MongoReactiveStreamsLokkProvider(client = MongoClients.create())