src/runtime.bend relies on unsafe/foreign
raw source on the hub · import bend-kube-runtime@0.3.0.0/src/runtime.bend as Runtime
15 imports
import Base import ./json.bend as J import ./utf8.bend as U import ./http.bend as H import ./core.bend as C import ./config.bend as K import ./net.bend as N import ./client.bend as Cl import ./watcher.bend as W import ./store.bend as S import ./queue.bend as Q import ./log.bend as L import ./control.bend as X import ./time.bend as T import ./sys.bend as Y
Types
type Msg source · line 31 · raw
Data
MOuts@src:U32 -> @outs:List<&2, 0xd9b268abd125fd306c83ea43554e4f2c/src/watcher.Out> -> Msg
MDone@key:String -> @act:0xd9b268abd125fd306c83ea43554e4f2c/src/queue.Action -> @ms:U32 -> Msg
MWake@key:String -> @at:U32 -> Msg
MStop@reply:Chan(Unit) -> Msg
MTickMsg
type Snap source · line 39 · raw
Data
The controller's state as the health server reports it.
Snap@name:String -> @ready:Bool -> @reconciles:U32 -> @errors:U32 -> @events:U32 -> @running:U32 -> @objects:U32 -> @queued:U32 -> @hist:List<&2, U32> -> @sum:Sum -> @cached:List<&2, U32> -> Snap
type SMsg source · line 46 · raw
Data
The status keeper's inbox: a controller's latest snapshot (by its index), or a query for all of them (none until a controller runs: a standby replica).
SPut@idx:U32 -> @snap:Snap -> SMsg
SGet@reply:Chan(List<&2, Snap>) -> SMsg
type Sum source · line 52 · raw
Data
A total of milliseconds, as whole seconds and the rest, so it lasts 136 years rather than 49 days.
Sum@secs:U32 -> @ms:U32 -> Sum
type Stats source · line 73 · raw
Data
Counters since start; hist counts reconciles by duration (Hist.bounds), sum is their total time.
Stats@reconciles:U32 -> @errors:U32 -> @events:U32 -> @hist:List<&2, U32> -> @sum:Sum -> Stats
type Sub source · line 87 · raw
Data
Who a watcher feeds: each subscriber's inbox, and the source number the outputs carry there (0 for a controller's primary, 1.. for its owned).
Sub@chan:Chan(Msg) -> @src:U32 -> Sub
type WCtx source · line 90 · raw
Data
WCtx@cfg:0xd9b268abd125fd306c83ea43554e4f2c/src/config.Config -> @api:0xd9b268abd125fd306c83ea43554e4f2c/src/core.Api -> @label:String -> @field:String -> @subs:List<&2, Sub> -> WCtx
type DEv source · line 94 · raw
Type
What the driver just saw.
DStartDEv
DListed@r:Result<&2, &2, 0xd9b268abd125fd306c83ea43554e4f2c/src/client.KErr, 0xd9b268abd125fd306c83ea43554e4f2c/src/json.Json> -> DEv
DOpened@r:Result<&1, &1, Pair(U32, String), 0xd9b268abd125fd306c83ea43554e4f2c/src/net.Tls> -> DEv
DRecv@sock:Socket -> @r:Result<&1, &1, Pair(U32, String), List<&2, U32>> -> DEv
DDig@sock:Socket -> @dig:Dig -> DEv
DStepped@step:0xd9b268abd125fd306c83ea43554e4f2c/src/watcher.Step -> @sock:Maybe<&1, Socket> -> @more:Bool -> DEv
DNext@sock:Maybe<&1, Socket> -> @wait:Bool -> @more:Bool -> DEv
type Dig source · line 131 · raw
Data
After a recv: the stream's state, and the step its whole lines make.
Dig@step:0xd9b268abd125fd306c83ea43554e4f2c/src/watcher.Step -> @resp:0xd9b268abd125fd306c83ea43554e4f2c/src/http.Resp -> @carry:List<&2, U32> -> @more:Bool -> Dig
type Tim source · line 367 · raw
Data
The controller's clock: each key's pending wake (its deadline in wall ms, and the queue generation it carries), the time of the message being handled, when a status snapshot was last published (and its readiness), whether anything happened since, and whether a publish tick is pending.
Tim@at:Map<&2, U32> -> @gen:Map<&2, U32> -> @now:U32 -> @snap:U32 -> @ready:Bool -> @dirty:Bool -> @tick:Bool -> Tim
type CState source · line 373 · raw
Data
CState@store:0xd9b268abd125fd306c83ea43554e4f2c/src/store.Store -> @caches:List<&2, 0xd9b268abd125fd306c83ea43554e4f2c/src/store.Store> -> @queue:0xd9b268abd125fd306c83ea43554e4f2c/src/queue.Queue -> @stats:Stats -> @stop:Maybe<&2, Chan(Unit)> -> @tim:Tim -> CState
type CCtx source · line 377 · raw
Data
CCtx@cfg:0xd9b268abd125fd306c83ea43554e4f2c/src/config.Config -> @spec:0xd9b268abd125fd306c83ea43554e4f2c/src/control.Spec -> @chan:Chan(Msg) -> @status:Chan(SMsg) -> @idx:U32 -> CCtx
type Job source · line 381 · raw
Data
A reconcile to start: the key and the object the store holds for it.
Job@key:String -> @obj:0xd9b268abd125fd306c83ea43554e4f2c/src/json.Json -> @fails:U32 -> Job
type CEv source · line 385 · raw
Type
What the controller loop just saw.
CMsg@m:Maybe<&1, Msg> -> CEv
CTimed@m:Msg -> @now:U32 -> CEv
CHandled@r:Pair(CState, List<&2, Sleep>) -> CEv
CDisp@r:Pair(CState, List<&2, Job>) -> CEv
CNext@halt:Maybe<&2, Chan(Unit)> -> CEv
CPeek@p:Poll<&1, &1, Maybe<&1, Msg>, Unit> -> CEv
type Disp source · line 575 · raw
Data
A dispatch pass: the queue, the jobs to start, and whether a popped key was gone from the store (its slot freed, so another pass may start more).
Disp@queue:0xd9b268abd125fd306c83ea43554e4f2c/src/queue.Queue -> @jobs:List<&2, Job> -> @dropped:Bool -> Disp
type Sleep source · line 593 · raw
Data
A sleeper to start: wake key after ms, naming its deadline.
Sleep@key:String -> @due:U32 -> @ms:U32 -> Sleep
type Idle source · line 764 · raw
Data
What an idle loop does about its status: publish now (a second has passed, or readiness changed), arm one tick to publish when the second is up, or nothing (nothing changed, or a tick is already armed).
IPubIdle
ITickIdle
INoneIdle
type Ctrl source · line 1068 · raw
Data
The older way to name a controller: a primary with a label selector, the kinds it owns, and how many reconciles run at once (X.Spec says more).
Ctrl@primary:0xd9b268abd125fd306c83ea43554e4f2c/src/core.Api -> @label:String -> @owned:List<&2, 0xd9b268abd125fd306c83ea43554e4f2c/src/core.Api> -> @max:U32 -> Ctrl
type Watch source · line 1091 · raw
Data
A watch: what, with which label and field selectors, for whom.
Watch@api:0xd9b268abd125fd306c83ea43554e4f2c/src/core.Api -> @label:String -> @field:String -> @subs:List<&2, Sub> -> Watch
Definitions
def Sum.add source · line 55 · raw
@x:Sum -> @+ms:U32 -> Sum
def Sum.sane.go source · line 60 · raw
@+ms:U32 -> @ok:Bool -> U32
def Sum.sane source · line 68 · raw
@+ms:U32 -> U32
A duration of a day or more (a sleeping laptop) counts as 0.
def Loop.spent source · line 78 · raw
@name:String -> IO(Unit)
A loop that used up its steps (2^64: never, in practice) exits, so the pod restarts, rather than leaving the process up and idle.
def DEv.recv source · line 103 · raw
@p:Pair(Socket, Result<&1, &1, Pair(U32, String), List<&2, U32>>) -> DEv
def Drv.inputs source · line 109 · raw
@ls:List<&2, List<&2, U32>> -> List<&2, 0xd9b268abd125fd306c83ea43554e4f2c/src/watcher.Input>
The inputs a run of watch lines makes; blank lines are skipped.
def Drv.inputs.par source · line 121 · raw
@+depth:Nat -> @+ls:List<&2, List<&2, U32>> -> List<&2, 0xd9b268abd125fd306c83ea43554e4f2c/src/watcher.Input>
The same, with the lines decoded and parsed in parallel: each line is its own JSON document, so the halves split (to depth levels, up to 2^depth tasks) run as Bend parallel calls, on every core.
def Drv.status source · line 134 · raw
@r:0xd9b268abd125fd306c83ea43554e4f2c/src/http.Resp -> U32
def Drv.ended source · line 141 · raw
@r:0xd9b268abd125fd306c83ea43554e4f2c/src/http.Resp -> Bool
def Drv.end_input source · line 156 · raw
@r:0xd9b268abd125fd306c83ea43554e4f2c/src/http.Resp -> 0xd9b268abd125fd306c83ea43554e4f2c/src/watcher.Input
How a watch stream ended: a whole response (the server's timeout) is an orderly end, resumed at once; a cut-off or broken one (a server or load balancer closing mid-stream or before answering) is a failure, which backs off, so a flapping server is not hammered.
def Drv.digest.end.go source · line 163 · raw
@st:0xd9b268abd125fd306c83ea43554e4f2c/src/watcher.WState -> @outs:List<&2, 0xd9b268abd125fd306c83ea43554e4f2c/src/watcher.Out> -> @+wait:Bool -> @+r:0xd9b268abd125fd306c83ea43554e4f2c/src/http.Resp -> @carry:List<&2, U32> -> @+end:Bool -> Dig
def Drv.digest.end source · line 176 · raw
@s:0xd9b268abd125fd306c83ea43554e4f2c/src/watcher.Step -> @r:0xd9b268abd125fd306c83ea43554e4f2c/src/http.Resp -> @carry:List<&2, U32> -> @+end:Bool -> Dig
A stream that ended cleanly is a watch timeout: the watcher resumes.
def Drv.digest.fin source · line 181 · raw
@st:0xd9b268abd125fd306c83ea43554e4f2c/src/watcher.WState -> @r:0xd9b268abd125fd306c83ea43554e4f2c/src/http.Resp -> @cl:Pair(List<&2, U32>, List<&2, List<&2, U32>>) -> @+end:Bool -> Dig
def Drv.digest.lines source · line 188 · raw
@st:0xd9b268abd125fd306c83ea43554e4f2c/src/watcher.WState -> @rb:Pair(0xd9b268abd125fd306c83ea43554e4f2c/src/http.Resp, List<&2, U32>) -> @carry:List<&2, U32> -> @+eof:Bool -> Dig
def Drv.digest.ok source · line 194 · raw
@st:0xd9b268abd125fd306c83ea43554e4f2c/src/watcher.WState -> @r:0xd9b268abd125fd306c83ea43554e4f2c/src/http.Resp -> @carry:List<&2, U32> -> @+eof:Bool -> @+code:U32 -> @ok:Bool -> Dig
def Drv.digest.go source · line 202 · raw
@st:0xd9b268abd125fd306c83ea43554e4f2c/src/watcher.WState -> @r:0xd9b268abd125fd306c83ea43554e4f2c/src/http.Resp -> @carry:List<&2, U32> -> @+eof:Bool -> @+code:U32 -> Dig
def Drv.digest source · line 205 · raw
@st:0xd9b268abd125fd306c83ea43554e4f2c/src/watcher.WState -> @+r:0xd9b268abd125fd306c83ea43554e4f2c/src/http.Resp -> @carry:List<&2, U32> -> @+eof:Bool -> Dig
def Drv.send source · line 208 · raw
@chan:Chan(Msg) -> @+src:U32 -> @outs:List<&2, 0xd9b268abd125fd306c83ea43554e4f2c/src/watcher.Out> -> IO(Unit)
def Drv.send_all source · line 217 · raw
@subs:List<&2, Sub> -> @+outs:List<&2, 0xd9b268abd125fd306c83ea43554e4f2c/src/watcher.Out> -> IO(Unit)
Hands the outputs to every subscriber (a shared watch fans out).
def Drv.jitter source · line 224 · raw
@+ms:U32 -> @r:Result<&1, &1, Pair(U32, String), U32> -> U32
def Drv.pause.go source · line 231 · raw
@+ms:U32 -> @+fails:U32 -> @path:String -> IO(Unit)
def Drv.pause source · line 237 · raw
@wait:Bool -> @+fails:U32 -> @path:String -> IO(Unit)
Sleeps the watcher's backoff, with up to 50% jitter, when asked to.
def Drv.note_list source · line 246 · raw
@first:Bool -> @path:String -> IO(Unit)
A list from its first page (startup, or a relist after 410 Gone).
def Drv.why source · line 253 · raw
@e:Pair(U32, String) -> String
def Drv.close source · line 258 · raw
@s:Maybe<&1, Socket> -> IO(Unit)
def WState.fails source · line 265 · raw
@s:0xd9b268abd125fd306c83ea43554e4f2c/src/watcher.WState -> U32
def WCtx.list_req source · line 270 · raw
@c:WCtx -> @cont:String -> 0xd9b268abd125fd306c83ea43554e4f2c/src/http.Req
def WCtx.watch_req source · line 275 · raw
@c:WCtx -> @rv:String -> 0xd9b268abd125fd306c83ea43554e4f2c/src/http.Req
def WCtx.path source · line 280 · raw
@c:WCtx -> String
def WCtx.cfg source · line 285 · raw
@c:WCtx -> 0xd9b268abd125fd306c83ea43554e4f2c/src/config.Config
def WCtx.subs source · line 290 · raw
@c:WCtx -> List<&2, Sub>
def Drv.run source · line 297 · raw
@outer:Nat -> @fuel:Nat -> @ev:DEv -> @+st:0xd9b268abd125fd306c83ea43554e4f2c/src/watcher.WState -> @+resp:0xd9b268abd125fd306c83ea43554e4f2c/src/http.Resp -> @+carry:List<&2, U32> -> @+ctx:WCtx -> IO(Unit)
The watcher's loop: list, then watch and stream, reconnecting and relisting as the state machine says, until the fuel or the channel ends.
def Tim.new source · line 370 · raw
Tim
def Caches.nth source · line 393 · raw
@cs:List<&2, 0xd9b268abd125fd306c83ea43554e4f2c/src/store.Store> -> @n:Nat -> 0xd9b268abd125fd306c83ea43554e4f2c/src/store.Store
def Caches.set source · line 402 · raw
@cs:List<&2, 0xd9b268abd125fd306c83ea43554e4f2c/src/store.Store> -> @n:Nat -> @x:0xd9b268abd125fd306c83ea43554e4f2c/src/store.Store -> List<&2, 0xd9b268abd125fd306c83ea43554e4f2c/src/store.Store>
def Caches.sizes source · line 411 · raw
@cs:List<&2, 0xd9b268abd125fd306c83ea43554e4f2c/src/store.Store> -> List<&2, U32>
def Caches.ready source · line 418 · raw
@cs:List<&2, 0xd9b268abd125fd306c83ea43554e4f2c/src/store.Store> -> Bool
def Secs.drop source · line 425 · raw
@ss:List<&2, 0xd9b268abd125fd306c83ea43554e4f2c/src/control.Sec> -> @n:Nat -> List<&2, String>
def Secs.rel source · line 434 · raw
@ss:List<&2, 0xd9b268abd125fd306c83ea43554e4f2c/src/control.Sec> -> @n:Nat -> 0xd9b268abd125fd306c83ea43554e4f2c/src/control.Rel
def Hist.bounds source · line 448 · raw
List<&2, U32>
Reconcile durations: upper bounds in ms, as Prometheus' default buckets (5ms to 10s); the last count is everything slower.
def Hist.zero source · line 451 · raw
List<&2, U32>
def Hist.fits source · line 455 · raw
@bs:List<&2, U32> -> @+ms:U32 -> Bool
Whether ms falls in the first bucket of bs (the overflow when none is left).
def Hist.bump.go source · line 462 · raw
@cs:List<&2, U32> -> @bs:List<&2, U32> -> @+ms:U32 -> @hit:Bool -> List<&2, U32>
def Hist.bump source · line 473 · raw
@cs:List<&2, U32> -> @+ms:U32 -> List<&2, U32>
def Stats.events source · line 479 · raw
@x:Stats -> @+n:U32 -> Stats
def Stats.done source · line 484 · raw
@x:Stats -> @a:0xd9b268abd125fd306c83ea43554e4f2c/src/queue.Action -> @+ms:U32 -> Stats
def Ctl.prim.put source · line 493 · raw
@cs:List<&2, 0xd9b268abd125fd306c83ea43554e4f2c/src/store.Store> -> @q:0xd9b268abd125fd306c83ea43554e4f2c/src/queue.Queue -> @x:Stats -> @p:Maybe<&2, Chan(Unit)> -> @tm:Tim -> @f:0xd9b268abd125fd306c83ea43554e4f2c/src/control.Fold -> CState
def Ctl.rel.put source · line 499 · raw
@+n:Nat -> @s:0xd9b268abd125fd306c83ea43554e4f2c/src/store.Store -> @cs:List<&2, 0xd9b268abd125fd306c83ea43554e4f2c/src/store.Store> -> @q:0xd9b268abd125fd306c83ea43554e4f2c/src/queue.Queue -> @x:Stats -> @p:Maybe<&2, Chan(Unit)> -> @tm:Tim -> @f:0xd9b268abd125fd306c83ea43554e4f2c/src/control.Fold -> CState
def Ctl.on_outs source · line 507 · raw
@st:CState -> @+src:U32 -> @+outs:List<&2, 0xd9b268abd125fd306c83ea43554e4f2c/src/watcher.Out> -> @+spec:0xd9b268abd125fd306c83ea43554e4f2c/src/control.Spec -> @own:Bool -> CState
Outputs of watch src: the primary's (0) through its predicates, a related watch's (n) through its relation.
def Ctl.on_done source · line 519 · raw
@s:0xd9b268abd125fd306c83ea43554e4f2c/src/store.Store -> @cs:List<&2, 0xd9b268abd125fd306c83ea43554e4f2c/src/store.Store> -> @x:Stats -> @p:Maybe<&2, Chan(Unit)> -> @tm:Tim -> @r:Pair(0xd9b268abd125fd306c83ea43554e4f2c/src/queue.Queue, List<&2, 0xd9b268abd125fd306c83ea43554e4f2c/src/queue.Timer>) -> Pair(CState, List<&2, 0xd9b268abd125fd306c83ea43554e4f2c/src/queue.Timer>)
def Ctl.forget_gone source · line 527 · raw
@r:Pair(0xd9b268abd125fd306c83ea43554e4f2c/src/queue.Queue, List<&2, 0xd9b268abd125fd306c83ea43554e4f2c/src/queue.Timer>) -> @+key:String -> @gone:Bool -> Pair(0xd9b268abd125fd306c83ea43554e4f2c/src/queue.Queue, List<&2, 0xd9b268abd125fd306c83ea43554e4f2c/src/queue.Timer>)
A finished key whose object is gone (deleted while it ran or waited) is forgotten, so the queue keeps nothing for it.
def Ctl.cached source · line 535 · raw
@m:Maybe<&2, 0xd9b268abd125fd306c83ea43554e4f2c/src/json.Json> -> Bool
def Ctl.on_done.st source · line 542 · raw
@st:CState -> @+key:String -> @+a:0xd9b268abd125fd306c83ea43554e4f2c/src/queue.Action -> @+ms:U32 -> Pair(CState, List<&2, 0xd9b268abd125fd306c83ea43554e4f2c/src/queue.Timer>)
def Ctl.on_wake.go source · line 549 · raw
@st:CState -> @+key:String -> @mine:Bool -> Pair(CState, List<&2, 0xd9b268abd125fd306c83ea43554e4f2c/src/queue.Timer>)
def Tim.at source · line 557 · raw
@st:CState -> Map<&2, U32>
def Ctl.on_wake source · line 565 · raw
@+st:CState -> @+key:String -> @+due:U32 -> Pair(CState, List<&2, 0xd9b268abd125fd306c83ea43554e4f2c/src/queue.Timer>)
A sleeper woke: if it is still the one for its key's pending wake (the same deadline), the wake fires with the latest generation; an older sleeper, outdone by an earlier wake, does nothing.
def Ctl.on_stop source · line 568 · raw
@st:CState -> @r:Chan(Unit) -> Pair(CState, List<&2, 0xd9b268abd125fd306c83ea43554e4f2c/src/queue.Timer>)
def Ctl.ticked source · line 578 · raw
@st:CState -> CState
def Ctl.on_msg source · line 597 · raw
@st:CState -> @m:Msg -> @+spec:0xd9b268abd125fd306c83ea43554e4f2c/src/control.Spec -> Pair(CState, List<&2, 0xd9b268abd125fd306c83ea43554e4f2c/src/queue.Timer>)
A message's effect on the state, and the timers it arms.
def Tim.sooner source · line 612 · raw
@+at:U32 -> @+now:U32 -> @+ms:U32 -> Bool
Whether a pending deadline at is no later than now + ms (an overdue one, whose sleeper is about to fire, is earlier).
def Tim.arm.go source · line 615 · raw
@t:Tim -> @+key:String -> @+g:U32 -> @+ms:U32 -> @pending:Bool -> @sooner:Bool -> @ss:List<&2, Sleep> -> Pair(Tim, List<&2, Sleep>)
def Tim.arm source · line 624 · raw
@t:Tim -> @tm:0xd9b268abd125fd306c83ea43554e4f2c/src/queue.Timer -> @ss:List<&2, Sleep> -> Pair(Tim, List<&2, Sleep>)
def Tim.arm.pair source · line 630 · raw
@r:Pair(Tim, List<&2, Sleep>) -> @t:0xd9b268abd125fd306c83ea43554e4f2c/src/queue.Timer -> Pair(Tim, List<&2, Sleep>)
def Tim.arm_all.go source · line 635 · raw
@ts:List<&2, 0xd9b268abd125fd306c83ea43554e4f2c/src/queue.Timer> -> @r:Pair(Tim, List<&2, Sleep>) -> Pair(Tim, List<&2, Sleep>)
def Ctl.plan.put source · line 642 · raw
@s:0xd9b268abd125fd306c83ea43554e4f2c/src/store.Store -> @cs:List<&2, 0xd9b268abd125fd306c83ea43554e4f2c/src/store.Store> -> @q:0xd9b268abd125fd306c83ea43554e4f2c/src/queue.Queue -> @x:Stats -> @p:Maybe<&2, Chan(Unit)> -> @r:Pair(Tim, List<&2, Sleep>) -> Pair(CState, List<&2, Sleep>)
def Ctl.plan source · line 649 · raw
@r:Pair(CState, List<&2, 0xd9b268abd125fd306c83ea43554e4f2c/src/queue.Timer>) -> Pair(CState, List<&2, Sleep>)
The queue's timers become the keys' wakes, and the sleepers to start.
def Ctl.at source · line 655 · raw
@st:CState -> @+now:U32 -> CState
The state at a message's arrival: the clock reads now.
def Ctl.dispatch.forget source · line 660 · raw
@r:Pair(0xd9b268abd125fd306c83ea43554e4f2c/src/queue.Queue, List<&2, 0xd9b268abd125fd306c83ea43554e4f2c/src/queue.Timer>) -> @+key:String -> 0xd9b268abd125fd306c83ea43554e4f2c/src/queue.Queue
def Ctl.dispatch.put source · line 665 · raw
@+key:String -> @m:Maybe<&2, 0xd9b268abd125fd306c83ea43554e4f2c/src/json.Json> -> @d:Disp -> Disp
def Ctl.dispatch.go source · line 673 · raw
@ks:List<&2, String> -> @+s:0xd9b268abd125fd306c83ea43554e4f2c/src/store.Store -> @d:Disp -> Disp
def Ctl.dispatch.pop source · line 680 · raw
@r:Pair(0xd9b268abd125fd306c83ea43554e4f2c/src/queue.Queue, List<&2, String>) -> @+s:0xd9b268abd125fd306c83ea43554e4f2c/src/store.Store -> @jobs:List<&2, Job> -> Disp
def Ctl.dispatch.loop source · line 688 · raw
@fuel:Nat -> @+s:0xd9b268abd125fd306c83ea43554e4f2c/src/store.Store -> @d:Disp -> Disp
Passes until one drops no key: a key whose object is gone frees its slot for the keys behind it. Every pass that continues dropped a waiting key, so as many passes as keys wait (plus one) always suffice.
def Ctl.dispatch.wrap source · line 697 · raw
@s:0xd9b268abd125fd306c83ea43554e4f2c/src/store.Store -> @cs:List<&2, 0xd9b268abd125fd306c83ea43554e4f2c/src/store.Store> -> @x:Stats -> @p:Maybe<&2, Chan(Unit)> -> @tm:Tim -> @d:Disp -> Pair(CState, List<&2, Job>)
def Ctl.dispatch.ready source · line 703 · raw
@+s:0xd9b268abd125fd306c83ea43554e4f2c/src/store.Store -> @cs:List<&2, 0xd9b268abd125fd306c83ea43554e4f2c/src/store.Store> -> @+q:0xd9b268abd125fd306c83ea43554e4f2c/src/queue.Queue -> @x:Stats -> @p:Maybe<&2, Chan(Unit)> -> @tm:Tim -> @ready:Bool -> Pair(CState, List<&2, Job>)
def Ctl.stopping source · line 712 · raw
@p:Maybe<&2, Chan(Unit)> -> Bool
def Ctl.dispatch source · line 721 · raw
@st:CState -> Pair(CState, List<&2, Job>)
The reconciles to start now: none until every cache has its first list, and none once stopping.
def Ctl.halt.go source · line 727 · raw
@p:Maybe<&2, Chan(Unit)> -> @idle:Bool -> Maybe<&2, Chan(Unit)>
def Ctl.halt source · line 735 · raw
@st:CState -> Maybe<&2, Chan(Unit)>
Whose stop request to answer: a stopping controller with nothing running.
def Ctl.ready source · line 740 · raw
@st:CState -> Bool
def Ctl.snap_due source · line 745 · raw
@st:CState -> Bool
def Ctl.ticking source · line 751 · raw
@st:CState -> CState
def Ctl.tick_pending source · line 756 · raw
@st:CState -> Bool
def Ctl.idle.go source · line 769 · raw
@dirty:Bool -> @due:Bool -> @pending:Bool -> Idle
def Ctl.dirty source · line 778 · raw
@st:CState -> Bool
def Ctl.idle source · line 783 · raw
@+st:CState -> Idle
def Ctl.snapped source · line 786 · raw
@st:CState -> CState
def Ctl.snap source · line 791 · raw
@st:CState -> @name:String -> Snap
def CCtx.status source · line 797 · raw
@c:CCtx -> Chan(SMsg)
def CCtx.idx source · line 802 · raw
@c:CCtx -> U32
def CCtx.spec source · line 807 · raw
@c:CCtx -> 0xd9b268abd125fd306c83ea43554e4f2c/src/control.Spec
def CCtx.kind source · line 812 · raw
@c:CCtx -> String
def Ctl.name source · line 815 · raw
@+c:CCtx -> String
def Ctl.publish source · line 821 · raw
@+st:CState -> @+ctx:CCtx -> @due:Bool -> IO(CState)
Publishes a status snapshot at most once a second, whenever readiness changes, and when the loop goes idle with changes unpublished (a snapshot walks the cache to count it).
def CCtx.chan source · line 830 · raw
@c:CCtx -> Chan(Msg)
def Ctl.at_idle source · line 836 · raw
@+st:CState -> @+ctx:CCtx -> @i:Idle -> IO(CState)
At idle: publish, or arm the tick, then wait for the next message.
def Ctl.jitter source · line 851 · raw
@+ms:U32 -> @r:Result<&1, &1, Pair(U32, String), U32> -> U32
Up to 10% more for a delay of a second or more, so requeues armed together (a relist, a restart) spread out.
def Ctl.delay source · line 858 · raw
@+ms:U32 -> @long:Bool -> IO(U32)
def Ctl.sleeps source · line 866 · raw
@ss:List<&2, Sleep> -> @+chan:Chan(Msg) -> IO(Unit)
def CCtx.cfg source · line 878 · raw
@c:CCtx -> 0xd9b268abd125fd306c83ea43554e4f2c/src/config.Config
def Ctl.ctx source · line 884 · raw
@st:CState -> @+c:CCtx -> 0xd9b268abd125fd306c83ea43554e4f2c/src/control.Ctx
What a reconcile sees: the config, the controller's index and the caches.
def Ctl.report source · line 889 · raw
@+key:String -> @+kind:String -> @a:0xd9b268abd125fd306c83ea43554e4f2c/src/queue.Action -> IO(Unit)
def Ctl.mono source · line 903 · raw
IO(U32)
The monotonic clock in ms (since boot, never stepped): requeue deadlines and reconcile durations are measured by it.
def Ctl.job.end source · line 906 · raw
@+key:String -> @+a:0xd9b268abd125fd306c83ea43554e4f2c/src/queue.Action -> @+t0:U32 -> @+kind:String -> @+chan:Chan(Msg) -> IO(Result<&1, &1, Msg, Unit>)
def Ctl.timed_out source · line 912 · raw
@+to:U32 -> @m:Maybe<&1, 0xd9b268abd125fd306c83ea43554e4f2c/src/queue.Action> -> 0xd9b268abd125fd306c83ea43554e4f2c/src/queue.Action
def Ctl.watch.subs source · line 992 · raw
@+cfg:0xd9b268abd125fd306c83ea43554e4f2c/src/config.Config -> @api:0xd9b268abd125fd306c83ea43554e4f2c/src/core.Api -> @label:String -> @field:String -> @subs:List<&2, Sub> -> IO(Unit)
def Api.kind source · line 997 · raw
@a:0xd9b268abd125fd306c83ea43554e4f2c/src/core.Api -> String
def Keeper.all.put source · line 1002 · raw
@r:Pair(Map<&2, Snap>, Snap) -> @rest:List<&2, Snap> -> List<&2, Snap>
def Keeper.all.go source · line 1007 · raw
@ks:List<&2, String> -> @+m:Map<&2, Snap> -> List<&2, Snap>
def Keeper.all source · line 1015 · raw
@+m:Map<&2, Snap> -> List<&2, Snap>
def Keeper.run source · line 1020 · raw
@outer:Nat -> @fuel:Nat -> @m:Maybe<&1, SMsg> -> @+last:Map<&2, Snap> -> @+inbox:Chan(SMsg) -> IO(Unit)
The status keeper: holds each controller's latest snapshot and answers queries at once.
def Keeper.start source · line 1037 · raw
IO(Chan(SMsg))
Starts a status keeper; answers its inbox.
def Controller.inbox source · line 1053 · raw
IO(Chan(Msg))
def Ctrl.owns source · line 1071 · raw
@os:List<&2, 0xd9b268abd125fd306c83ea43554e4f2c/src/core.Api> -> @s:0xd9b268abd125fd306c83ea43554e4f2c/src/control.Spec -> 0xd9b268abd125fd306c83ea43554e4f2c/src/control.Spec
def Ctrl.spec source · line 1078 · raw
@c:Ctrl -> 0xd9b268abd125fd306c83ea43554e4f2c/src/control.Spec
def Ctrl.specs source · line 1083 · raw
@cs:List<&2, Ctrl> -> List<&2, 0xd9b268abd125fd306c83ea43554e4f2c/src/control.Spec>
def Watch.key source · line 1094 · raw
@+api:0xd9b268abd125fd306c83ea43554e4f2c/src/core.Api -> @+label:String -> @+field:String -> String
def Plan.hit source · line 1097 · raw
@ws:List<&2, Watch> -> @+key:String -> Bool
def Plan.add source · line 1105 · raw
@ws:List<&2, Watch> -> @+api:0xd9b268abd125fd306c83ea43554e4f2c/src/core.Api -> @+label:String -> @+field:String -> @+sub:Sub -> @hit:Bool -> List<&2, Watch>
Adds a subscription: to the watch of the same key, or as a new watch.
def Plan.sub source · line 1115 · raw
@+ws:List<&2, Watch> -> @+api:0xd9b268abd125fd306c83ea43554e4f2c/src/core.Api -> @+label:String -> @+field:String -> @+sub:Sub -> List<&2, Watch>
def Plan.secs source · line 1119 · raw
@ss:List<&2, 0xd9b268abd125fd306c83ea43554e4f2c/src/control.Sec> -> @+ch:Chan(Msg) -> @+n:U32 -> @ws:List<&2, Watch> -> List<&2, Watch>
def Plan.build source · line 1127 · raw
@cs:List<&2, 0xd9b268abd125fd306c83ea43554e4f2c/src/control.Spec> -> @chs:List<&2, Chan(Msg)> -> @ws:List<&2, Watch> -> List<&2, Watch>
Every watch the controllers need, each once, with all its subscribers.
def Manager.inboxes source · line 1134 · raw
@+n:Nat -> IO(List<&2, Chan(Msg)>)
def Manager.watch source · line 1143 · raw
@+cfg:0xd9b268abd125fd306c83ea43554e4f2c/src/config.Config -> @ws:List<&2, Watch> -> IO(Unit)
def Manager.started source · line 1171 · raw
IO(Chan(Unit))
A channel that holds a token once the controllers have started (on a leader, once it leads), so shutdown knows whether there is anything to drain.
def Stop.ask.sent source · line 1177 · raw
@p:Poll<&1, &1, Result<&1, &1, Msg, Unit>, Msg> -> @+r:Chan(Unit) -> Maybe<&2, Chan(Unit)>
def Stop.ask.put source · line 1184 · raw
@m:Maybe<&2, Chan(Unit)> -> @rest:List<&2, Chan(Unit)> -> List<&2, Chan(Unit)>
def Stop.ask source · line 1193 · raw
@chs:List<&2, Chan(Msg)> -> IO(List<&2, Chan(Unit)>)
Asks each controller to stop; a controller whose inbox does not take the request within a second is not waited for.
def Stop.wait source · line 1204 · raw
@rs:List<&2, Chan(Unit)> -> IO(Unit)
def Stop.said source · line 1211 · raw
@m:Maybe<&1, Unit> -> IO(Unit)
def Stop.all source · line 1218 · raw
@chs:List<&2, Chan(Msg)> -> IO(Unit)
def Stop.drain source · line 1221 · raw
@chs:List<&2, Chan(Msg)> -> @+grace:U32 -> @p:Poll<&1, &1, Maybe<&1, Unit>, Unit> -> IO(Unit)
def Manager.stop source · line 1233 · raw
@chs:List<&2, Chan(Msg)> -> @+started:Chan(Unit) -> @+grace:U32 -> IO(Unit)
Asks every running controller to stop: no new reconciles start, and this returns once the running ones finish, or after grace ms. Nothing to do when the controllers never started (a standby replica).
Templates
template Ctl.call source · line 920 · raw
@-rec:(@_:0xd9b268abd125fd306c83ea43554e4f2c/src/json.Json -> @_:0xd9b268abd125fd306c83ea43554e4f2c/src/control.Ctx -> IO(0xd9b268abd125fd306c83ea43554e4f2c/src/queue.Action)) -> @o:0xd9b268abd125fd306c83ea43554e4f2c/src/json.Json -> @+ctx:0xd9b268abd125fd306c83ea43554e4f2c/src/control.Ctx -> @+to:U32 -> @unbounded:Bool -> IO(0xd9b268abd125fd306c83ea43554e4f2c/src/queue.Action)
The reconcile itself, raced against its timeout when it has one.
template Ctl.job.go source · line 929 · raw
@-rec:(@_:0xd9b268abd125fd306c83ea43554e4f2c/src/json.Json -> @_:0xd9b268abd125fd306c83ea43554e4f2c/src/control.Ctx -> IO(0xd9b268abd125fd306c83ea43554e4f2c/src/queue.Action)) -> @+key:String -> @o:0xd9b268abd125fd306c83ea43554e4f2c/src/json.Json -> @+ctx:0xd9b268abd125fd306c83ea43554e4f2c/src/control.Ctx -> @+kind:String -> @+chan:Chan(Msg) -> @+to:U32 -> @+t0:U32 -> IO(Result<&1, &1, Msg, Unit>)
template Ctl.job source · line 935 · raw
@-rec:(@_:0xd9b268abd125fd306c83ea43554e4f2c/src/json.Json -> @_:0xd9b268abd125fd306c83ea43554e4f2c/src/control.Ctx -> IO(0xd9b268abd125fd306c83ea43554e4f2c/src/queue.Action)) -> @+key:String -> @o:0xd9b268abd125fd306c83ea43554e4f2c/src/json.Json -> @+ctx:0xd9b268abd125fd306c83ea43554e4f2c/src/control.Ctx -> @+kind:String -> @+chan:Chan(Msg) -> @+to:U32 -> IO(Result<&1, &1, Msg, Unit>)
A reconcile, timed; a failure is logged; MDone answers on the channel.
template Ctl.spawn source · line 942 · raw
@-rec:(@_:0xd9b268abd125fd306c83ea43554e4f2c/src/json.Json -> @_:0xd9b268abd125fd306c83ea43554e4f2c/src/control.Ctx -> IO(0xd9b268abd125fd306c83ea43554e4f2c/src/queue.Action)) -> @jobs:List<&2, Job> -> @+chan:Chan(Msg) -> @+ctx:0xd9b268abd125fd306c83ea43554e4f2c/src/control.Ctx -> @+kind:String -> @+to:U32 -> IO(Unit)
Starts a reconcile per job, each with the caches and its key's failure count; each answers MDone on the channel.
template Ctl.run source · line 956 · raw
@-rec:(@_:0xd9b268abd125fd306c83ea43554e4f2c/src/json.Json -> @_:0xd9b268abd125fd306c83ea43554e4f2c/src/control.Ctx -> IO(0xd9b268abd125fd306c83ea43554e4f2c/src/queue.Action)) -> @outer:Nat -> @fuel:Nat -> @ev:CEv -> @+st:CState -> @+ctx:CCtx -> IO(Unit)
The controller loop: a message in, the state stepped, timers armed, reconciles started, the next message awaited; a stop request is answered once nothing runs, and ends the loop.
template Ctl.loop source · line 1043 · raw
@-rec:(@_:0xd9b268abd125fd306c83ea43554e4f2c/src/json.Json -> @_:0xd9b268abd125fd306c83ea43554e4f2c/src/control.Ctx -> IO(0xd9b268abd125fd306c83ea43554e4f2c/src/queue.Action)) -> @+cfg:0xd9b268abd125fd306c83ea43554e4f2c/src/config.Config -> @+spec:0xd9b268abd125fd306c83ea43554e4f2c/src/control.Spec -> @+chan:Chan(Msg) -> @+status:Chan(SMsg) -> @+idx:U32 -> IO(Unit)
template Manager.loops source · line 1150 · raw
@-rec:(@_:0xd9b268abd125fd306c83ea43554e4f2c/src/json.Json -> @_:0xd9b268abd125fd306c83ea43554e4f2c/src/control.Ctx -> IO(0xd9b268abd125fd306c83ea43554e4f2c/src/queue.Action)) -> @+cfg:0xd9b268abd125fd306c83ea43554e4f2c/src/config.Config -> @cs:List<&2, 0xd9b268abd125fd306c83ea43554e4f2c/src/control.Spec> -> @chs:List<&2, Chan(Msg)> -> @+status:Chan(SMsg) -> @+i:U32 -> IO(Unit)
template Manager.start source · line 1162 · raw
@-rec:(@_:0xd9b268abd125fd306c83ea43554e4f2c/src/json.Json -> @_:0xd9b268abd125fd306c83ea43554e4f2c/src/control.Ctx -> IO(0xd9b268abd125fd306c83ea43554e4f2c/src/queue.Action)) -> @+cfg:0xd9b268abd125fd306c83ea43554e4f2c/src/config.Config -> @+cs:List<&2, 0xd9b268abd125fd306c83ea43554e4f2c/src/control.Spec> -> @+chs:List<&2, Chan(Msg)> -> @+status:Chan(SMsg) -> @+started:Chan(Unit) -> IO(Unit)
Runs every controller on its inbox (Manager.inboxes), sharing their watches. rec(obj, ctx) reconciles obj; X.Ctx.idx(ctx) names the controller.