Package-level declarations

Types

Link copied to clipboard

The failure ledger of one service (documentation/designs/04-subscriptions.md §2).

Link copied to clipboard
class ParkedAggregate @InternalWowApi constructor(val subscription: SubscriptionId, val ref: AggregateRef, val partition: Int, val fromVersion: Int, val reason: String, val failedAt: Long, val fromPosition: Long? = null, val skipOnly: Boolean = false, val retries: Int = 0, val lastRetryAt: Long? = null, val retrySpec: ParkedRetrySpec? = null, val recoverable: Recoverable = Recoverable.UNKNOWN, val request: LedgerRequest? = null, val nextAttemptAt: Long? = null, val revision: Long = 0, val fromIncarnation: String? = null)

One parked aggregate: subscription stopped handling ref, in its source's partition, at its stream fromVersion, at failedAt (epoch milliseconds), because of reason. The owner of partition retries it.

Link copied to clipboard
sealed interface ParkedAmendment

A change of a parked entry's retry state (FailureLedger.amend), or, for Restate alone, of why it is parked and its retry state at once.

Link copied to clipboard
class ParkedRetrySpec @InternalWowApi constructor(val maxRetries: Int = DEFAULT_MAX_RETRIES, val initialBackoff: Duration = DEFAULT_INITIAL_BACKOFF, val claimTtl: Duration = DEFAULT_CLAIM_TTL)

How a parked entry is retried over the long horizon (9.x RetrySpec): at most maxRetries automatic retries, the first initialBackoff after the failure and each next one twice as long after the previous one started; claimTtl is how long a claim on the entry holds before another owner may act on it, such as the partition's next owner: a retry's claim, before another retry may start, and the claim of an operator's request the owner took (ParkedAmendment.ClaimRequest), before it is run again. It cancels nothing: the run goes on. A maxRetries of 0 turns automatic retries off.

Functions

Link copied to clipboard
suspend fun amendByRevision(amendment: ParkedAmendment, read: suspend () -> ParkedAggregate?, replace: suspend (amended: ParkedAggregate, revision: Long) -> Boolean): ParkedAggregate?

FailureLedger.amend's generic path, for an amendment a ledger has no statement of its own for: reads the entry (read), applies amendment to it (amended) and stores the result (replace) only while the stored entry is still at the revision read. A write that finds another revision lost to a writer that changed the entry since the read: the entry is read again and the amendment applied to what that writer left, so no write is lost, and the loop ends, each turn it takes being another writer's progress.

Link copied to clipboard

This entry with amendment applied at the next revision, or null when the amendment names a revision read that the entry is no longer at, or an operator's parking (ParkedAmendment.MarkRecoverable.failedAt and the like) that is not this entry's: the reference semantics of FailureLedger.amend, for a backend that changes the entry in memory. Every amendment but a ParkedAmendment.Schedule and a ParkedAmendment.ClaimRequest, which set it, and a ParkedAmendment.TakeRequest clears ParkedAggregate.nextAttemptAt, so the owner looks at the entry again on its next scan.

Link copied to clipboard

Whether this entry is due at now in one of partitions (FailureLedger.due): the reference semantics, for a backend that filters in memory.

Link copied to clipboard

This entry where entry parks the aggregate (its partition, from version, position and the incarnation of the topic it is of, and whether it can only be skipped) and why (its reason and failure time), with this entry's retry state, at the next revision and no longer scheduled; an operator's request is kept only while the failure time is: one left for another parking is cleared. The reference semantics of a FailureLedger.repark, and of a FailureLedger.park that replaces an entry.