package runtime import ( "git.novox.be/novox/mesh-sdk/go/approval" ) // gateHolding is the runner's gate as far as the runtime reaches it: it records the calls it is run for and answers // `approvals` from them. type gateHolding struct{ calls []approval.Call } func (g *gateHolding) Unserved(string, string, []string) []string { return nil } func (g *gateHolding) Run(c approval.Call, run func() (any, error)) (any, error) { g.calls = append(g.calls, c) return run() } func (g *gateHolding) Approvals(caller string) (approval.Approvals, error) { out := approval.Approvals{Calls: []approval.ListedCall{}, Acts: []approval.ListedAct{}, Claims: []string{}} for i, c := range g.calls { l := approval.ListedCall{Call: string(rune('a' + i)), Caller: c.Caller, Verb: c.Seat + "." + c.Name, State: "waiting"} if caller == c.Caller { l.Arguments = c.Args } out.Calls = append(out.Calls, l) } return out, nil }