check

Function check 

Source
pub fn check(
    store: &StateStore,
    consumer_id: i64,
    quotas: &ConsumerQuotas,
    now_epoch_s: i64,
) -> QuotaOutcome
Expand description

Check-and-reserve one request against every configured budget of quotas for consumer row consumer_id (DW-033). Pure policy over StateStore::incr_quota; see the module docs for the evaluation order, the stacking consumption trade, and the failure model.

Evaluation STOPS at the first denying budget (the GCRA stacking rule: a refused request never consumes a longer window’s budget), but every REMAINING budget is then PEEKED (read-only) for a would-deny — when a later budget is also exhausted, the reported Retry-After stretches to the LATER reset so a client honoring the hint never retries out of the daily wall straight into the monthly one (the DW-017 max-wait rule, implemented without reservation).

now_epoch_s is the request time (injected so tests are deterministic; the caller passes wall-clock seconds).