EventBatchWriter

class EventBatchWriter(store: EventStore, scope: CoroutineScope, capacity: Int = DEFAULT_CAPACITY, maxBatchSize: Int = DEFAULT_BATCH_SIZE, flushIntervalMs: Long = DEFAULT_FLUSH_INTERVAL_MS, onDrop: (StoredEvent, EventBatchDropReason) -> Unit = { _, _ -> }, onStored: suspend (List<StoredEvent>) -> Unit = {})

Bounded persistence worker. It receives only EventEnvelope values emitted after the redaction boundary and commits 100 events or the pending batch every 250 ms.

Constructors

Link copied to clipboard
constructor(store: EventStore, scope: CoroutineScope, capacity: Int = DEFAULT_CAPACITY, maxBatchSize: Int = DEFAULT_BATCH_SIZE, flushIntervalMs: Long = DEFAULT_FLUSH_INTERVAL_MS, onDrop: (StoredEvent, EventBatchDropReason) -> Unit = { _, _ -> }, onStored: suspend (List<StoredEvent>) -> Unit = {})

Types

Link copied to clipboard
object Companion

Functions

Link copied to clipboard
suspend fun flushAndStop()

Gracefully drains the current queue and persists its final partial batch.

Link copied to clipboard
fun start()
Link copied to clipboard
fun stop()
Link copied to clipboard
fun submit(event: EventEnvelope): Boolean

fun submit(event: StoredEvent): Boolean

For callers that already hold a redacted StoredEvent, such as the timeline appender.

Link copied to clipboard