Follow the runtime's watches through mesh-sdk's KeptState.Follow, not four loops of their own (issue 774)
mesh-provisioner, mesh-config, mesh-issues and mesh-healers each wrote a watch-again loop (`watched`). mesh-sdk 61b67d61 adds KeptState.Follow, which asks again with backoff and says each give-up, and its watches now answer a change at once and run the handler beside the runtime (the provisioner's "names no watch of this bundle"). The four modules use it; their loops are gone. Built and tested against the mesh-sdk group head through a go.work that is not committed: their mesh-sdk pins move to that head with the group.
This commit is contained in:
@@ -132,14 +132,8 @@ func main() {
|
||||
// reads the bucket, and a write carries the issue it changes first, so no write reaches the log before its
|
||||
// issue's carry.
|
||||
func start(t *Tracker) {
|
||||
for wait := 2 * time.Second; ; wait = min(wait*2, time.Minute) {
|
||||
time.Sleep(wait)
|
||||
if err := stdio.State(IssuesState).Watch("", t.Watched); err != nil {
|
||||
logf("[mesh-issues] the bucket is not watched yet (%v); asking again in %s", err, wait)
|
||||
continue
|
||||
}
|
||||
break
|
||||
}
|
||||
// Asked again until the runtime takes it, each give-up said (mesh-sdk's Follow).
|
||||
stdio.State(IssuesState).Follow("", t.Watched)
|
||||
for wait := 2 * time.Second; ; wait = min(wait*2, time.Minute) {
|
||||
s, err := t.Start()
|
||||
if err == nil {
|
||||
|
||||
Reference in New Issue
Block a user