~/bend-docscommunity

pollrow.bend relies on unsafe/foreign

raw source on the hub · import cswap-bend-cli@0.1.0.0/pollrow.bend as Pollrow

6 imports
import Base
import ./json.bend as Json
import ./clock.bend as Clock
import ./policy/usage.bend as PUsage
import ./policy/types.bend as PT
import ./poll.bend as Poll

Types

type Row source · line 12 · raw

Data

The fields of one usage.json row that planning and display read.

Definitions

def is_err source · line 18 · raw

@m:Maybe<&2, String> -> @+s:String -> Bool

def recent_429.anchor source · line 27 · raw

@+l:U32 -> @bu:Maybe<&2, U32> -> @is429:Bool -> U32

A 429 on this token is recent enough to keep the post-429 cadence: measured from when the honoured backoff lifts, for one hour.

def recent.of source · line 34 · raw

@l:Maybe<&2, U32> -> @bu:Maybe<&2, U32> -> @is429:Bool -> @+now:U32 -> Bool

def recent_429 source · line 41 · raw

@+r:Row -> @+now:U32 -> Bool

def num.int source · line 46 · raw

@ps:List<&2, String> -> Maybe<&2, U32>

def num.u source · line 54 · raw

@j:0x0717344745a30ebad1f19045228e8f18/json.Json -> Maybe<&2, U32>

An integer second count from a JSON number (1792740000.1 -> 1792740000).

def jget source · line 61 · raw

@+k:String -> @+row:0x0717344745a30ebad1f19045228e8f18/json.Json -> 0x0717344745a30ebad1f19045228e8f18/json.Json

def num.field source · line 64 · raw

@+k:String -> @+row:0x0717344745a30ebad1f19045228e8f18/json.Json -> Maybe<&2, U32>

def str.field source · line 67 · raw

@+k:String -> @+row:0x0717344745a30ebad1f19045228e8f18/json.Json -> Maybe<&2, String>

def obj_or_null source · line 70 · raw

@j:0x0717344745a30ebad1f19045228e8f18/json.Json -> 0x0717344745a30ebad1f19045228e8f18/json.Json

def last_good.of source · line 77 · raw

@+row:0x0717344745a30ebad1f19045228e8f18/json.Json -> 0x0717344745a30ebad1f19045228e8f18/json.Json

def row.of source · line 80 · raw

@+row:0x0717344745a30ebad1f19045228e8f18/json.Json -> Row

def before.m source · line 87 · raw

@m:Maybe<&2, U32> -> @+now:U32 -> Bool

def legacy_claim source · line 94 · raw

@m:Maybe<&2, U32> -> @+now:U32 -> Bool

def live_claim source · line 103 · raw

@claim_until:Maybe<&2, U32> -> @last_attempt:Maybe<&2, U32> -> @+now:U32 -> Bool

A fetch lease is live: claimUntil when present, else the legacy 10 s after lastAttemptAt.

def age_le source · line 110 · raw

@age:Maybe<&2, U32> -> @+max:U32 -> Bool

def age_of source · line 117 · raw

@fetched:Maybe<&2, U32> -> @+now:U32 -> Maybe<&2, U32>

def err_kind source · line 124 · raw

@rl:Bool -> 0x0717344745a30ebad1f19045228e8f18/policy/types.ErrKind

def failure_backoff source · line 133 · raw

@+failures:U32 -> @retry_after:Maybe<&2, U32> -> @rate_limited:Bool -> U32

Seconds to stay in backoff after the n-th failure: src/policy's backoff_for (30 s * 2^(n-1) capped at 600 s; a Retry-After raises it).

def nat_of source · line 136 · raw

@m:Maybe<&2, U32> -> @+d:U32 -> Nat

def blocked source · line 139 · raw

@r:Row -> @+now:U32 -> Bool

def mode.pick source · line 144 · raw

@+respect:Bool -> @+repair:Bool -> @+stale:Bool -> @+due:Bool -> @+none:Bool -> @+over:Bool -> Bool

def mode.go source · line 153 · raw

@+respect:Bool -> @+repair:Bool -> @+fa:Maybe<&2, Nat> -> @+np:Maybe<&2, Nat> -> @+pi:Nat -> @+now:Nat -> Bool

def mode.row source · line 156 · raw

@r:Row -> @+now:U32 -> @+respect:Bool -> @+repair:Bool -> Bool

def row_eligible source · line 164 · raw

@+r:Row -> @+now:U32 -> @+respect_plans:Bool -> @+repair:Bool -> Bool

Whether a stored row may be fetched now: not dead, in backoff, held or claimed, then by caller mode (on-demand respect = stale and due; the scheduled tick is policy's poll_due).

def nat0 source · line 167 · raw

@m:Maybe<&2, U32> -> Nat

def err_pick source · line 174 · raw

@rl:Bool -> 0x0717344745a30ebad1f19045228e8f18/policy/types.ErrKind

def kind_of_err source · line 181 · raw

@m:Maybe<&2, String> -> 0x0717344745a30ebad1f19045228e8f18/policy/types.ErrKind

def legacy_until source · line 188 · raw

@la:Maybe<&2, U32> -> Nat

def lease_until source · line 196 · raw

@cu:Maybe<&2, U32> -> @la:Maybe<&2, U32> -> Nat

A claim lease: claimUntil, else the legacy 10 s after lastAttemptAt.

def policy_with source · line 203 · raw

@+u:0x0717344745a30ebad1f19045228e8f18/policy/types.Usage -> @+fetched:Maybe<&2, U32> -> @+bu:Maybe<&2, U32> -> @+le:Maybe<&2, String> -> @+nf:U32 -> @+np:Maybe<&2, U32> -> @+iv:Maybe<&2, U32> -> @+st:U32 -> @+hu:Maybe<&2, U32> -> @+lease:Nat -> 0x0717344745a30ebad1f19045228e8f18/policy/types.Usage

def policy_row source · line 209 · raw

@+r:Row -> 0x0717344745a30ebad1f19045228e8f18/policy/types.Usage

The policy core's view of a stored row: its windows, freshness and holds.

def decision.pick source · line 214 · raw

@ok:Bool -> @lg:0x0717344745a30ebad1f19045228e8f18/json.Json -> 0x0717344745a30ebad1f19045228e8f18/json.Json

def last_good_of source · line 221 · raw

@+r:Row -> 0x0717344745a30ebad1f19045228e8f18/json.Json

def decision_usage source · line 228 · raw

@+r:Row -> @models:List<&2, String> -> @+now:U32 -> 0x0717344745a30ebad1f19045228e8f18/json.Json

The value switch decisions run on: last-good while policy trusts it (at most 300 s old, or deliberately stale and inside the cap), JNull when unknown.