BatchEngine

class BatchEngine(session: CqlSession, statementBuilder: StatementBuilder, scope: CoroutineScope, eventListener: KandraEventListener? = null, retryConfig: RetryConfig = RetryConfig(), debugConfig: DebugConfig = DebugConfig(), codec: KandraCodec = KandraCodec.default)

Executes save, update, delete, and saveAll operations using LOGGED batch statements.

BATCH-consistency lookups are included in the atomic batch. EVENTUAL-consistency lookups fire asynchronously via scope after the batch commits; failures are forwarded to eventListener (if set) then logged.

Transient failures listed in retryConfig.retryOn are retried with linear backoff. When isShuttingDown is set, all new queries are rejected with KandraQueryException.

Constructors

Link copied to clipboard
constructor(session: CqlSession, statementBuilder: StatementBuilder, scope: CoroutineScope, eventListener: KandraEventListener? = null, retryConfig: RetryConfig = RetryConfig(), debugConfig: DebugConfig = DebugConfig(), codec: KandraCodec = KandraCodec.default)

Properties

Link copied to clipboard

Tracks queries currently executing — used by graceful shutdown drain.

Link copied to clipboard

Set to true by the shutdown hook to stop accepting new queries.

Functions

Link copied to clipboard
fun configureBatchLimits(warnThresholdKb: Int, maxChunkSize: Int, autoChunk: Boolean, tombstoneWarnThreshold: Int = 1000)
Link copied to clipboard
fun delete(schema: TableSchema, entity: Any)
Link copied to clipboard
fun deleteAll(schema: TableSchema, entities: List<Any>)
Link copied to clipboard
suspend fun deleteAllSuspend(schema: TableSchema, entities: List<Any>)
Link copied to clipboard
suspend fun deleteSuspend(schema: TableSchema, entity: Any)
Link copied to clipboard
fun <T : Any> registerValidator(klass: KClass<T>, validator: KandraValidator<T>)
Link copied to clipboard
fun save(schema: TableSchema, entity: Any, ttlSeconds: Int? = null, timestampMicros: Long? = null, consistency: KandraConsistency? = null)
Link copied to clipboard
fun saveAll(schema: TableSchema, entities: List<Any>, ttlSeconds: Int? = null, useBatch: Boolean = true)
Link copied to clipboard
suspend fun saveAllSuspend(schema: TableSchema, entities: List<Any>, ttlSeconds: Int? = null, useBatch: Boolean = true)
Link copied to clipboard
fun saveIfNotExists(schema: TableSchema, entity: Any, serialConsistency: KandraConsistency = KandraConsistency.LOCAL_SERIAL): Boolean
Link copied to clipboard
suspend fun saveIfNotExistsSuspend(schema: TableSchema, entity: Any, serialConsistency: KandraConsistency = KandraConsistency.LOCAL_SERIAL): Boolean
Link copied to clipboard
suspend fun saveSuspend(schema: TableSchema, entity: Any, ttlSeconds: Int? = null, timestampMicros: Long? = null, consistency: KandraConsistency? = null)
Link copied to clipboard
fun saveWithNulls(schema: TableSchema, entity: Any, ttlSeconds: Int? = null)
Link copied to clipboard
suspend fun saveWithNullsSuspend(schema: TableSchema, entity: Any, ttlSeconds: Int? = null)
Link copied to clipboard
fun setMetrics(recorder: KandraMetrics)
Link copied to clipboard
fun update(schema: TableSchema, old: Any, new: Any)
Link copied to clipboard
fun updateForce(schema: TableSchema, entity: Any)
Link copied to clipboard
suspend fun updateForceSuspend(schema: TableSchema, entity: Any)
Link copied to clipboard
suspend fun updateSuspend(schema: TableSchema, old: Any, new: Any)