/aerospike-client-kotlin

Aerospike Client for Kotlin

Primary LanguageKotlinApache License 2.0Apache-2.0

aerospike-client-kotlin

Build Maven Central

Aerospike Client for Kotlin wraps the Java client callback-based asynchronous methods and provides an idiomatic Kotlin API using coroutines and Flow.

The AerospikeAsyncClient takes the Java AerospikeClient as a constructor parameter and exposes it via the asJava() method. Make sure to set the ClientPolicy.eventLoops when creating the Java client.

Getting started

Add as a dependency

dependencies {
    implementation("io.github.reugn:aerospike-client-kotlin:<version>")
}

Build from source

./gradlew build

Examples

@Test
fun `Perform operations on a key`(): Unit = runBlocking {
    val record = asyncClient.operate(
        null, keys[0],
        Operation.put(Bin(intBin, 100)),
        Operation.get()
    )
    assertEquals(100, record?.getInt(intBin))
}

@Test
fun `Query all`(): Unit = runBlocking {
    val queryStatement = QueryStatement(namespace, setName = set)
    val flow = asyncClient.query(null, queryStatement)
    val recordsNumber = flow.toList().size
    assertEquals(keysSize, recordsNumber)
}

License

Licensed under the Apache 2.0 License.