durability
Whether this bolt is meeting the durability level it promised.
A backend that promised nothing answers DurabilityState.AsPromised forever — see that type's KDoc for why the relative reading is the useful one, and why this is neither a shape of AppendResult nor a state of availability.
Ask it, do not infer it from an append. A flush covers a range, so the frames a failed one puts in doubt are everything since the last good flush, not the one that triggered it. This is sticky state precisely so a consumer can poll it — after a batch, before trimming its own live replica's window, on a timer — rather than having to catch the moment.
Samples
// ASK, don't infer from an append. A flush covers a RANGE, so the frames a failed one
// puts in doubt are everything since the last good flush — not the append that triggered
// it, whose result is already in your past.
when (val state = bolt.durability()) {
// Meeting the level IT promised, including where it promised nothing at all.
DurabilityState.AsPromised -> trimTheLiveReplicaWindow()
// Written and readable, but not confirmed durable. Trimming the live replica now
// would leave those records held nowhere but an unflushed page. Sticky and widening:
// it clears only when a later flush covers the whole range.
is DurabilityState.Degraded -> holdTheWindow(state.fromOffset, state.toOffset, state.reason)
}Content copied to clipboard