Skip to main content

Limit

A Limit is the bound a spec enforces on a value (for example, a scope item's utilization in CapacitySpec). It is a shared building block used by many specs.

Different specs honor different subsets of its fields. Setting a field a spec does not support throws an error, so check the spec's own reference for the subset it uses.

Fields

FieldTypeDefaultDescription
typeLimitTypeRELATIVEWhether the limit is relative (a fraction) or absolute (a raw value). See LimitType.
globalLimitdouble1The limit applied to every entry by default.
scopeItemLimitsmap<string, double>Per-scope-item overrides, keyed by scope item name.
groupLimitsmap<string, double>Per-group overrides, keyed by group name (group-aware specs only).
scopeItemToGroupLimitsmap<string, map<string, double>>Per (scope item, group) overrides (group-aware specs only).
isDefaultLimitUnboundedboolfalseIf true, the fallback default is positive infinity (unbounded) instead of globalLimit.

Resolution order

A spec looks up the limit for a specific scope item (and, for group-aware specs, a specific group). It uses the first of these you have set, from most specific to least specific:

Set this......to limit
scopeItemToGroupLimitsa single (scope item, group) pair
scopeItemLimitsa single scope item
groupLimitsa single group
globalLimiteverything not covered above

Specs without groups only use scopeItemLimits, then globalLimit. Setting isDefaultLimitUnbounded replaces that fallback with positive infinity: globalLimit is then ignored, so any entry without an override is unbounded (per-scope-item and per-group overrides still apply).

LimitType

typeThe limit is...
RELATIVE (default)a fraction of a reference value the spec chooses
ABSOLUTEa raw value

What RELATIVE is measured against depends on the spec. For example, when CapacitySpec limits a scope item's utilization, the reference is that scope item's capacity (its same-named dimension): a RELATIVE limit of 0.8 means "at most 80% of the capacity", while an ABSOLUTE limit of 0.8 means "at most 0.8". If a spec divides by a scope item's dimension value that is not defined, that value defaults to 1, so RELATIVE then behaves like ABSOLUTE.

Applicability

Each spec documents which fields it honors. For example, CapacitySpec uses type, globalLimit, and scopeItemLimits; group-aware specs additionally use groupLimits / scopeItemToGroupLimits.

Source