def Keeper.run
bend-kube-runtime@0.2.0.0 · src/runtime.bend:584
import bend-kube-runtime@0.2.0.0/src/runtime.bend as Runtime
import Base
584
585
586def Keeper.run(fuel: Nat, m: Maybe<&1, SMsg>, +last: Map<&2, Snap>, +inbox: Chan(SMsg)) -> IO(Unit):
587 match fuel m:
588 case 0n x:
589 IO.pure(Unit, Unit{})
590 case 1n+f None{}:
591 IO.pure(Unit, Unit{})
592 case 1n+f Some{SPut{i, s}}:
593 IO.bind(Maybe<&1, SMsg>, Unit, Chan.recv(SMsg, inbox),
594 x => Keeper.run(f, x, Map.set(&2, Snap, last, U32.show(i), s), inbox))
595 case 1n+f Some{SGet{r}}:
596 IO.bind(Result<&1, &1, List<&2, Snap>, Unit>, Unit,
597 Chan.send(List<&2, Snap>, r, Keeper.all(last)),
598 u => IO.bind(Maybe<&1, SMsg>, Unit, Chan.recv(SMsg, inbox), x => Keeper.run(f, x, last, inbox)))