def within.ceiling

cswap-bend-cli@0.1.0.0 · policy/usage.bend:156

import cswap-bend-cli@0.1.0.0/policy/usage.bend as Usage
import Base
import cswap-bend-cli@0.1.0.0/policy/types.bend as T

156# How long a failing row's reading may be trusted. After an http-429 the
157# account's windows did not move, so the reading is a valid lower bound until
158# the soonest window resets: now < min(earliest reset, fetched_at + 7200 s).
159# Any other failure is no evidence the reading still holds: at most 3600 s.
160def within.ceiling(+e: T.ErrKind, +age: Nat, +now: Nat, +soonest: Maybe<&2, Nat>) -> Bool:
161  match e:
162    case T.ErrHttp429{}:
163      Nat.is_lt(age, 7200n) && soon.ok(now, soonest)
164    case o:
165      Nat.is_le(age, 3600n)

Uses (8)

Used by (1)