def fetch_with

cswap-bend-cli@0.1.0.0 · usage.bend:197

import cswap-bend-cli@0.1.0.0/usage.bend as Usage
import Base
import cswap-bend-cli@0.1.0.0/clock.bend as Clock
import cswap-bend-cli@0.1.0.0/usage/cred.bend as UCred
import cswap-bend-cli@0.1.0.0/usage/gate.bend as UGate

197# fetch_usage plus the 401 refresh of try_fetch_usage_for_account, over the
198# credential JSON text. Refreshes only inactive accounts. The rotated
199# credential comes back in `Fetched.credential` for the store to persist.
200# `gate` picks the refresh path: NoGate{} posts directly (tests); Gate{slot,
201# email, root} runs it under the slot's consume lock.
202def fetch_with(gate: UGate.Gate, +credential: String, is_active: Bool) -> IO(Fetched):
203  do IO<Fetched>:
204    now : U32 <- Clock.now_s()
205    off : U32 <- local_offset()
206    fetch.start(UCred.access_token(UCred.oauth.of(credential)), gate, credential, UCred.oauth.of(credential), is_active, now, off)

Uses (12)

Used by (2)