WindowUtilisation

class WindowUtilisation(val name: String, val used: Int, val queued: Int, val limit: Int, val published: Int, val windowStartEpochMillis: Long, val resetsAtEpochMillis: Long, val hard: Boolean, val elapsedFraction: Double)(source)

One window's current period. used is the count charged against the window this period, in cost units (a call of cost 3 adds 3), not calls: what was granted in this process, what was restored from the store, any rise a server reading forced (see BudgetEvent.Reconciled) and any count a backward wall-clock step copied into the period; queued is the count reserved for waiters; remaining = max(0, limit - used - queued); fraction = used / limit. A consumer that wants to stretch polling intervals needs the burn ratio, not the raw fraction: worked example — 40 of 50 at second 55 of a minute (fraction 0.8, elapsedFraction 0.92) is slack, 40 of 50 at second 10 (0.8 over 0.17) is not; fraction / elapsedFraction is the projected end-of-period usage, and the threshold is the consumer's policy.

Stable Core. Public constructor so an implementer of the port can build one. Equality is on every property; toString() prints them.

Parameters

name

the window's name; not blank.

used

the count charged against the window this period, in cost units; not negative.

queued

the count reserved for waiters; not negative.

limit

the enforced limit; at least 1.

published

the provider's documented limit; at least limit.

windowStartEpochMillis

the start of the current period, in epoch milliseconds.

resetsAtEpochMillis

the end of the current period, in epoch milliseconds.

hard

whether the window is hard.

elapsedFraction

how far the period has run, in [0, 1].

Throws

if name is blank, used or queued is negative, limit is below 1, published is below limit, or elapsedFraction is outside [0, 1] (NaN included).

Constructors

Link copied to clipboard
constructor(name: String, used: Int, queued: Int, limit: Int, published: Int, windowStartEpochMillis: Long, resetsAtEpochMillis: Long, hard: Boolean, elapsedFraction: Double)

Properties

Link copied to clipboard

How far the period has run, in [0, 1].

Link copied to clipboard

The raw usage, used / limit; may exceed 1.0 when a server reading raised the count above the limit.

Link copied to clipboard

Whether the window is hard.

Link copied to clipboard
val limit: Int

The enforced limit.

Link copied to clipboard

The window's name.

Link copied to clipboard

The provider's documented limit.

Link copied to clipboard
val queued: Int

The count reserved for waiters.

Link copied to clipboard

What is left for a call now: max(0, limit - used - queued).

Link copied to clipboard

The end of the current period, in epoch milliseconds.

Link copied to clipboard
val used: Int

The count charged against the window this period, in cost units.

Link copied to clipboard

The start of the current period, in epoch milliseconds.

Functions

Link copied to clipboard
open operator override fun equals(other: Any?): Boolean
Link copied to clipboard
open override fun hashCode(): Int

Returns a hash code consistent with equals: it is computed from the same properties.

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

A diagnostic string for logs: name, used, queued, limit, published, windowStartEpochMillis, resetsAtEpochMillis, hard and elapsedFraction. Its format is not part of the API and may change.