Name the watch a state change is for (novox/hq ADR 0201)

This commit is contained in:
jochen
2026-10-04 02:45:31 +02:00
parent dac8812968
commit 1adfcad88e
+6 -4
View File
@@ -231,12 +231,14 @@ func Start(module, entry string, env []string, mesh Bus, logf func(string, ...an
result = answered
}
case "mesh/state.watch":
// Each change is asked of this child, in order; the watch is answered once the
// current values have been handed over, so a bundle that awaits it has the whole
// of the state before it goes on (ADR 0201).
// Each change is asked of this child, in order, naming the watch it is for by
// the id the child asked it with — two watches of one state are two handlers;
// the watch is answered once the current values have been handed over, so a
// bundle that awaits it has the whole of the state before it goes on (ADR 0201).
var stop func()
watch := m.ID
stop, err = mesh.Watch(m.Params, func(change json.RawMessage) error {
_, err := c.ask(module, "mesh/state", map[string]any{"change": change}, EventTimeout)
_, err := c.ask(module, "mesh/state", map[string]any{"watch": watch, "change": change}, EventTimeout)
return err
})
if err == nil {