diff --git a/go/catalogue/process_bus.go b/go/catalogue/process_bus.go index f563eaf5..8df5cee4 100644 --- a/go/catalogue/process_bus.go +++ b/go/catalogue/process_bus.go @@ -19,6 +19,9 @@ type ProcessBus struct { // Emits are the events this process emits, named locally, as the module's own Emits names them // (EmitsAll): a process emits only what its module may emit as a whole. Emits []string `json:"emits,omitempty"` + // Consumes are the events this process hears, each as its module's `consumes` names it: only an event its module + // consumes (design 47 G A-340, after design 42 zfs-owns-zfs V5 and G1). + Consumes []string `json:"consumes,omitempty"` // Queues are the module's own work-queue streams (ADR 0436 ยง6) this process consumes. Queues []string `json:"queues,omitempty"` // State is the module's own state, by local name, this process reads and writes. @@ -99,7 +102,7 @@ func (b *ProcessBus) UnmarshalJSON(raw []byte) error { dec := json.NewDecoder(bytes.NewReader(raw)) dec.DisallowUnknownFields() if err := dec.Decode(&p); err != nil { - return fmt.Errorf("a process's bus is {emits, queues, state, asks, invokes, removes, keeps}; `serves` is a field of the process beside its bus (design 47 G A-127): %w", typedUnknown(err)) + return fmt.Errorf("a process's bus is {emits, consumes, queues, state, asks, invokes, removes, keeps}; `serves` is a field of the process beside its bus (design 47 G A-127): %w", typedUnknown(err)) } *b = ProcessBus(p) return nil diff --git a/go/catalogue/process_bus_test.go b/go/catalogue/process_bus_test.go index 1f778c94..1402f3c5 100644 --- a/go/catalogue/process_bus_test.go +++ b/go/catalogue/process_bus_test.go @@ -25,6 +25,12 @@ func TestProcessServesIsReadBesideTheBusAndRefusedInsideIt(t *testing.T) { if err := json.Unmarshal([]byte(`{"holds":["x"]}`), &ProcessBus{}); err == nil { t.Error("an unknown key was accepted") } + // Design 47 G A-340: a process's bus names the events it hears under `consumes`. + var heard ProcessBus + if err := json.Unmarshal([]byte(`{"consumes":["mesh-conditions.findings-asked"]}`), &heard); err != nil || + !strSliceEqual(heard.Consumes, []string{"mesh-conditions.findings-asked"}) { + t.Errorf("a bus's consumes read as %v (%v)", heard.Consumes, err) + } m := Manifest{Module: "nats", Resources: []map[string]any{ {"id": "keeper", "type": "process", "serves": []any{"seat:mesh-broker.snapshot-get", "seat:mesh-broker.list"}, "bus": map[string]any{"keeps": true}},