MaintenanceSkips

class MaintenanceSkips(val context: String, val work: ObservedEvent.MaintenanceSkipped.Work, ledgers: (AggregateType) -> SkipLedger?, classification: FailureClassification = RuntimeFailures.DEFAULT, observer: Observer = Observer.NONE, clock: Clock = Clock.systemUTC())

Where one bounded context's background work on its aggregates' histories, its access walks or its snapshot rewrites, records an aggregate it cannot read, so it goes on with the others instead of failing at that aggregate on every run: in the failure ledger of the aggregate's log group (ledgers), under the subscription subscription (wow.access.walk, wow.snapshot.rewrite). No worker handles it and nothing retries it automatically: a history that does not replay does not replay again without a new deployment, so an entry waits for an operator, who retries or skips it as any parked entry (me.ahoo.wow.runtime.node.ParkedOps), on any node.

What is skipped, by the phase that failed (attempt):

  • The replay of the aggregate's history (replaying): computation over its own data alone, with no store, so it fails again whenever it runs: an event the kernel cannot read, a sourcing function that throws. Skipped at once.

  • A read or a write: only a failure the node's classification calls FailureClass.UNRECOVERABLE, one no retry changes. Any other, a store that is down or busy, a timeout, a failure nothing classifies, stops the work, which resumes where its cursor is on its next run: a store's outage never becomes a run of skips.

An aggregate is parked once: the warning, the observer's ObservedEvent.MaintenanceSkipped and its count come with the ledger's change alone. A later success on the same aggregate, a rebuild at a new revision or a walk of a new schema, resolves its entry (attempt). Without a ledger for the aggregate's type, nothing is skipped: the failure stops the work, as it would with no ledger at all.

Constructors

Link copied to clipboard
constructor(context: String, work: ObservedEvent.MaintenanceSkipped.Work, ledgers: (AggregateType) -> SkipLedger?, classification: FailureClassification = RuntimeFailures.DEFAULT, observer: Observer = Observer.NONE, clock: Clock = Clock.systemUTC())

Types

Link copied to clipboard

Properties

Link copied to clipboard
Link copied to clipboard

What the ledger parks the skipped aggregates under: ACCESS_WALK or SNAPSHOT_REWRITE.

Link copied to clipboard

Functions

Link copied to clipboard
suspend fun absent(ref: AggregateRef): Boolean

Parks ref, whose log holds no stream of it while the work has something of it to rewrite (a snapshot the log has nothing of): true when it is parked, false without a ledger for its type.

Link copied to clipboard
suspend fun attempt(ref: AggregateRef, work: suspend () -> Unit): Boolean

Runs work on ref: true when it succeeded, after which an entry parking ref is resolved; false when it failed in a way that skips the aggregate (skippable), which is then parked; any other failure is thrown, and the work stops there. A failure is not skipped without its entry: one the ledger does not take stops the work.

Link copied to clipboard
fun refresh()

Forgets which aggregates are parked, so the next success lists them anew: a run of the work calls it first.

Link copied to clipboard
suspend fun retry(ref: AggregateRef, work: suspend () -> Boolean): Boolean

An operator's retry of ref: runs work, which answers whether it did all of it here; true when it did, and the entry is resolved. False when it did not (a snapshot left for the node of its table's revision, whose rewrite resolves the entry), or failed again in a way that skips the aggregate: its entry stays as it was parked. Any other failure is thrown.

Link copied to clipboard
suspend fun skip(ref: AggregateRef, failedAt: Long? = null): Boolean

An operator's skip of ref: its entry is resolved, and what the work could not do stays undone. One that names the parking at failedAt resolves nothing unless the entry is that parking (#7422), resolved since or resolved and parked again by the work: false then. The entry is read just before the resolve, with no lock across the nodes.

Link copied to clipboard
fun skippable(failure: Throwable): Boolean

Whether failure skips its aggregate: its history did not replay, or the node classifies it unrecoverable.

Link copied to clipboard
open override fun toString(): String