Module quotas

Module quotas 

Source
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.
QuotaOutcome
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-After seconds: whole seconds until reset_epoch_s, rounded up, minimum 1 (a denied request inside the last partial second must still advertise a wait, never 0).