EventSubscriber

Application handler for ordered batches delivered by a SubscriptionRunner.

Delivery is at least once, so implementations must tolerate replay. Callbacks never overlap; subscriber-owned background work may run concurrently with them.

Inheritors

Properties

Link copied to clipboard

Functions

Link copied to clipboard
open suspend fun onCaughtUp()

Transitions to caught-up after the source is live and queued batches have been handled and checkpointed. This is consumer readiness, not an upstream effective-time watermark.

Link copied to clipboard
abstract suspend fun onEvents(events: SubscriptionBatch<EVENT, CHECKPOINT>)

Handles one ordered event batch. This must be replay-safe because duplicates are possible.

Link copied to clipboard
open suspend fun onFellBehind()

Leaves previously caught-up state before handling a new batch, or when the source is no longer live or the session ends. Repeated batches/status changes while behind do not repeat this callback.

Link copied to clipboard
open suspend fun onStarted(checkpoint: CHECKPOINT?, scope: CoroutineScope)

Starts an owned processing session before source delivery. checkpoint is its resume cut; initialization must complete before returning. Launch background work in scope, which is cancelled and joined before onStopped and ownership release. Each session starts uncaught-up.

Link copied to clipboard
open suspend fun onStopped()

Ends the session after delivery and owned work have stopped, before ownership release. Called once for each invocation of onStarted, even if it fails or is cancelled; cleanup runs in a non-cancellable context.