aerospike-client-kotlin

Build

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.

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 `Scan partitions`(): Unit = runBlocking {
    val flow = asyncClient.scanPartitions(null, PartitionFilter.all(), namespace, set)
    val recordsNumber = flow.toList().size
    assertEquals(keysSize, recordsNumber)
}

License

Licensed under the Apache 2.0 License.

GitHub

View Github