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:
@@ -134,16 +134,8 @@ func resolving(c *Config) {
|
||||
// every change of what a module declares where (issue 1953); the builds themselves are read, not watched.
|
||||
for _, read := range []string{PlacementRead, WantsRead, ModulesRead, PredefinedRead, IndexerPredefinedRead,
|
||||
CandidatesRead, MirrorDeclaredRead, TakeoverState} {
|
||||
go func(read string) {
|
||||
for wait := 2 * time.Second; ; wait = min(wait*2, time.Minute) {
|
||||
time.Sleep(wait)
|
||||
if err := stdio.State(read).Watch("", poke); err != nil {
|
||||
logf("[mesh-config] %s is not watched yet (%v); asking again in %s", read, err, wait)
|
||||
continue
|
||||
}
|
||||
return
|
||||
}
|
||||
}(read)
|
||||
// Asked again until the runtime takes it, each give-up said (mesh-sdk's Follow).
|
||||
go stdio.State(read).Follow("", poke)
|
||||
}
|
||||
tick := time.NewTicker(5 * time.Minute)
|
||||
defer tick.Stop()
|
||||
|
||||
Reference in New Issue
Block a user