KeyedBatchCoordinator

class KeyedBatchCoordinator<T : Any, K : Any>(val name: String, val options: BatchOptions, val laneCount: Int, keySelector: (T) -> K, writer: BatchWriter<T>) : GracefullyStoppable

Partitions submissions into a fixed number of serial batch lanes.

Equal ordering keys are assigned to the same lane. Batch writer invocations inside one lane are serial, while different lanes may invoke writer concurrently. The coordinator keeps one global admission bound and one lifecycle across all lanes.

Multiple items with the same key may be included in one native batch. This type does not impose an item execution order inside a protocol-specific batch; a writer that requires such an order must provide it.

When laneCount is greater than one, keySelector runs during lazy submission and must be deterministic and non-blocking. A selector failure rejects only that submission. Ordering keys must obey the usual equality/hash-code contract.

Constructors

Link copied to clipboard
constructor(name: String, options: BatchOptions, laneCount: Int, keySelector: (T) -> K, writer: BatchWriter<T>)

Properties

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard

Functions

Link copied to clipboard
open override fun close()

Closes this resource by performing a graceful shutdown with a 30-second timeout.

fun close(timeout: Duration)
Link copied to clipboard
open fun stop()

Synchronously stops this resource with a 30-second timeout.

open fun stop(timeout: Duration)

Synchronously stops this resource within the specified timeout.

Link copied to clipboard
open override fun stopGracefully(): Mono<Void>

Asynchronously closes this resource with graceful shutdown.

Link copied to clipboard
fun submit(item: T): Mono<Void>
fun submit(itemFactory: () -> T): Mono<Void>