BudgetEvent

abstract class BudgetEvent(source)

Something the budget did, delivered to a BudgetObserver and logged. Every event describes itself, so an observer need not rely on order.

Experimental (subclass). Subclassing needs @OptIn(ExperimentalForInheritanceWebToolsApi::class); reading and matching an event are Stable Core, and the seven leaves are final. The set grows in feature releases: match the leaves you care about and keep an else. No leaf prints a header value, a body, a credential or a store exception's message. Equality is identity.

Inheritors

Types

Link copied to clipboard
class Granted(val lane: Lane, val cost: Int, val waited: Duration) : BudgetEvent

A call was granted after waiting waited (zero for an immediate grant).

Link copied to clipboard
class HardStop(val window: String, val resetsAtEpochMillis: Long) : BudgetEvent

A hard window is full for its current period; it refuses until resetsAtEpochMillis. Raised once per window and period.

Link copied to clipboard
class Paused(val untilEpochMillis: Long, val length: Duration, val source: PauseSource) : BudgetEvent

The budget is paused until untilEpochMillis, length from now, because of the hint source (PauseSource.RetryAfter, PauseSource.ResetIn, PauseSource.Boundary, or PauseSource.Snapshot for a restored pause). Emitted when a pause begins or is extended, never when a hint is shorter than the pause in force.

Link copied to clipboard
class Reconciled(val window: String, val serverUsed: Int, val raisedBy: Int) : BudgetEvent

A server reading raised the local count of window to serverUsed, by raisedBy (at least 1).

Link copied to clipboard
class Refused(val lane: Lane, val cost: Int, val wait: Duration, val reason: ExhaustedReason, val window: String?) : BudgetEvent

A call was refused (or a waiter failed after a re-plan): wait is what it would have waited, Duration.INFINITE for CostExceedsLimit.

Link copied to clipboard
class Restored(val windowsRestored: Int, val windowsDropped: Int, val ignoredForSkew: Boolean) : BudgetEvent

The restore ran: windowsRestored snapshot windows were merged, windowsDropped were stale or unknown, and ignoredForSkew says the snapshot was stamped further ahead than maxRestoreSkew (its stamp and pause ignored, its counts kept).

Link copied to clipboard
class StoreFailed(val operation: StoreOperation, val cause: Throwable) : BudgetEvent

A store call failed: operation is StoreOperation.Load or StoreOperation.Save; cause is for diagnostics (the log prints its class name only).