Runtime.Drv.run: def of bend-kube-runtime@0.2.0.0 Import: import bend-kube-runtime@0.2.0.0/src/runtime.bend as Runtime Lines 241-289 of bend-kube-runtime@0.2.0.0/src/runtime.bend: https://jend.leeeet.dev/read.txt?path=bend-kube-runtime@0.2.0.0/src/runtime.bend&start_line=241&end_line=289 import Base import bend-kube-runtime@0.2.0.0/src/json.bend as J import bend-kube-runtime@0.2.0.0/src/http.bend as H import bend-kube-runtime@0.2.0.0/src/core.bend as C import bend-kube-runtime@0.2.0.0/src/net.bend as N import bend-kube-runtime@0.2.0.0/src/client.bend as Cl import bend-kube-runtime@0.2.0.0/src/watcher.bend as W # 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 Drv.run(fuel: Nat, ev: DEv, +st: W.WState, +resp: H.Resp, +carry: List<&2, U32>, +ctx: WCtx) -> IO(Unit): match fuel ev: case 0n e: IO.pure(Unit, Unit{}) case 1n+f DStart{}: match st: case W.WState{W.WList{+c}, +fl, +first}: IO.bind(Unit, Unit, Drv.note_list(first, WCtx.path(ctx)), u => IO.bind(Result<&2, &2, Cl.KErr, J.Json>, Unit, Cl.Client.json(WCtx.cfg(ctx), WCtx.list_req(ctx, c)), r => Drv.run(f, DListed{r}, W.WState{W.WList{c}, fl, first}, resp, carry, ctx))) case W.WState{W.WWatch{+rv}, +fl, +first}: IO.bind(Result<&1, &1, U32 & String, N.Tls>, Unit, Cl.Conn.open(WCtx.cfg(ctx), WCtx.watch_req(ctx, rv), False{}), r => Drv.run(f, DOpened{r}, W.WState{W.WWatch{rv}, fl, first}, resp, carry, ctx)) case 1n+f DListed{Done{+j}}: Drv.run(f, DStepped{W.Watcher.step(st, W.IPage{C.Page.of(j)}), None{}, False{}}, st, resp, carry, ctx) case 1n+f DListed{Fail{+e}}: Drv.run(f, DStepped{W.Watcher.step(st, W.IListErr{Cl.KErr.code(e)}), None{}, False{}}, st, resp, carry, ctx) case 1n+f DOpened{Done{N.Tls{s}}}: IO.bind(Socket & Result<&1, &1, U32 & String, List<&2, U32>>, Unit, N.Tls.recv(s, 65536, 350000), p => Drv.run(f, DEv.recv(p), st, H.Http.resp.init(), Nil{}, ctx)) case 1n+f DOpened{Fail{e}}: Drv.run(f, DStepped{W.Watcher.step(st, W.IWatchErr{0}), None{}, False{}}, st, resp, carry, ctx) case 1n+f DRecv{s, Done{+bs}}: Drv.run(f, DDig{s, Drv.digest(st, H.Http.feed(bs, resp), carry, List.is_empty(&2, U32, bs))}, st, resp, carry, ctx) case 1n+f DDig{s, Dig{step, r2, c2, more}}: Drv.run(f, DStepped{step, Some{s}, more}, st, r2, c2, ctx) case 1n+f DRecv{s, Fail{e}}: Drv.run(f, DStepped{W.Watcher.step(st, W.IWatchErr{0}), Some{s}, False{}}, st, resp, carry, ctx) case 1n+f DStepped{W.Step{st2, outs, wait}, s, more}: IO.bind(Unit, Unit, Drv.send_all(WCtx.subs(ctx), outs), u => Drv.run(f, DNext{s, wait, more}, st2, resp, carry, ctx)) case 1n+f DNext{Some{s}, False{}, True{}}: IO.bind(Socket & Result<&1, &1, U32 & String, List<&2, U32>>, Unit, N.Tls.recv(s, 65536, 350000), p => Drv.run(f, DEv.recv(p), st, resp, carry, ctx)) case 1n+f DNext{s, wait, more}: IO.bind(Unit, Unit, Drv.close(s), u => IO.bind(Unit, Unit, Drv.pause(wait, WState.fails(st), WCtx.path(ctx)), u2 => Drv.run(f, DStart{}, st, H.Http.resp.init(), Nil{}, ctx))) Uses (45): https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Bool https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=IO https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=IO.bind https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=IO.pure https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=List https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=List.is_empty https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Maybe https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Nat https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Pair https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Result https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Socket https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=String https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=U32 https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Unit https://jend.leeeet.dev/definition.txt?path=bend-kube-runtime@0.2.0.0/src/client.bend&name=Client.json https://jend.leeeet.dev/definition.txt?path=bend-kube-runtime@0.2.0.0/src/client.bend&name=Conn.open https://jend.leeeet.dev/definition.txt?path=bend-kube-runtime@0.2.0.0/src/client.bend&name=KErr https://jend.leeeet.dev/definition.txt?path=bend-kube-runtime@0.2.0.0/src/client.bend&name=KErr.code https://jend.leeeet.dev/definition.txt?path=bend-kube-runtime@0.2.0.0/src/core.bend&name=Page.of https://jend.leeeet.dev/definition.txt?path=bend-kube-runtime@0.2.0.0/src/http.bend&name=Http.feed https://jend.leeeet.dev/definition.txt?path=bend-kube-runtime@0.2.0.0/src/http.bend&name=Http.resp.init https://jend.leeeet.dev/definition.txt?path=bend-kube-runtime@0.2.0.0/src/http.bend&name=Resp https://jend.leeeet.dev/definition.txt?path=bend-kube-runtime@0.2.0.0/src/json.bend&name=Json https://jend.leeeet.dev/definition.txt?path=bend-kube-runtime@0.2.0.0/src/net.bend&name=Tls https://jend.leeeet.dev/definition.txt?path=bend-kube-runtime@0.2.0.0/src/net.bend&name=Tls.recv https://jend.leeeet.dev/definition.txt?path=bend-kube-runtime@0.2.0.0/src/runtime.bend&name=DEv https://jend.leeeet.dev/definition.txt?path=bend-kube-runtime@0.2.0.0/src/runtime.bend&name=DEv.recv https://jend.leeeet.dev/definition.txt?path=bend-kube-runtime@0.2.0.0/src/runtime.bend&name=Dig https://jend.leeeet.dev/definition.txt?path=bend-kube-runtime@0.2.0.0/src/runtime.bend&name=Drv.close https://jend.leeeet.dev/definition.txt?path=bend-kube-runtime@0.2.0.0/src/runtime.bend&name=Drv.digest https://jend.leeeet.dev/definition.txt?path=bend-kube-runtime@0.2.0.0/src/runtime.bend&name=Drv.note_list https://jend.leeeet.dev/definition.txt?path=bend-kube-runtime@0.2.0.0/src/runtime.bend&name=Drv.pause https://jend.leeeet.dev/definition.txt?path=bend-kube-runtime@0.2.0.0/src/runtime.bend&name=Drv.send_all https://jend.leeeet.dev/definition.txt?path=bend-kube-runtime@0.2.0.0/src/runtime.bend&name=WCtx https://jend.leeeet.dev/definition.txt?path=bend-kube-runtime@0.2.0.0/src/runtime.bend&name=WCtx.cfg https://jend.leeeet.dev/definition.txt?path=bend-kube-runtime@0.2.0.0/src/runtime.bend&name=WCtx.list_req https://jend.leeeet.dev/definition.txt?path=bend-kube-runtime@0.2.0.0/src/runtime.bend&name=WCtx.path https://jend.leeeet.dev/definition.txt?path=bend-kube-runtime@0.2.0.0/src/runtime.bend&name=WCtx.subs https://jend.leeeet.dev/definition.txt?path=bend-kube-runtime@0.2.0.0/src/runtime.bend&name=WCtx.watch_req https://jend.leeeet.dev/definition.txt?path=bend-kube-runtime@0.2.0.0/src/runtime.bend&name=WState.fails https://jend.leeeet.dev/definition.txt?path=bend-kube-runtime@0.2.0.0/src/watcher.bend&name=Input https://jend.leeeet.dev/definition.txt?path=bend-kube-runtime@0.2.0.0/src/watcher.bend&name=Phase https://jend.leeeet.dev/definition.txt?path=bend-kube-runtime@0.2.0.0/src/watcher.bend&name=Step https://jend.leeeet.dev/definition.txt?path=bend-kube-runtime@0.2.0.0/src/watcher.bend&name=WState https://jend.leeeet.dev/definition.txt?path=bend-kube-runtime@0.2.0.0/src/watcher.bend&name=Watcher.step