Expand description
Pure quota types shared by the state-store and Redis-backed quota implementations (DW-033, DW-155).
This module lives in config (the lowest consuming domain) so both
state::quotas (the OSS local-counter implementation) and
extensions::redis_quotas (the Ent Redis-backed implementation) can
import it without violating the downward-only dependency direction.
The types here are pure: no I/O, no state store, no Redis. The
stateful logic lives in the consuming domains.
Enums§
- Budget
- One of the two budget kinds (DW-033). The set is closed: budgets are calendar windows, not arbitrary durations.
- Quota
Outcome - What the quota check decided for one request (DW-033). Shape mirrors the rate limiter’s outcome type (extensions::rate_limiter, named textually — a doc link would be an upward import) so the request path answers both with the same 429 builder.
Constants§
- DAILY_
KEY - Counter-key of the daily budget (
quota_counters.counter_key). - MONTHLY_
KEY - Counter-key of the monthly budget (
quota_counters.counter_key).
Functions§
- day_
window - The UTC day window containing
now_epoch_s: (window_start_epoch_s, next_reset_epoch_s). Pure; floor semantics for any input (negative epochs round toward the past, matching euclidean division). - month_
window - The UTC month window containing
now_epoch_s: (window_start_epoch_s, next_reset_epoch_s). Calendar-correct across month lengths and leap years (the standard civil-from-days algorithm; no calendar dependency). Pure. - retry_
after Retry-Afterseconds: whole seconds untilreset_epoch_s, rounded up, minimum 1 (a denied request inside the last partial second must still advertise a wait, never 0).