A-340 process-bus-consumes: a process's bus reads the events it hears under consumes
catalogue.ProcessBus gains Consumes, so the strict reader takes a process's bus naming what its module consumes; the judge and the grants part read it. Builds: design 47 G A-340, A-339 Claude-Session: https://claude.ai/code/session_01NcbgfGKaxw984XyAPfLm4h
This commit is contained in:
@@ -19,6 +19,9 @@ type ProcessBus struct {
|
|||||||
// Emits are the events this process emits, named locally, as the module's own Emits names them
|
// 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.
|
// (EmitsAll): a process emits only what its module may emit as a whole.
|
||||||
Emits []string `json:"emits,omitempty"`
|
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 are the module's own work-queue streams (ADR 0436 §6) this process consumes.
|
||||||
Queues []string `json:"queues,omitempty"`
|
Queues []string `json:"queues,omitempty"`
|
||||||
// State is the module's own state, by local name, this process reads and writes.
|
// 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 := json.NewDecoder(bytes.NewReader(raw))
|
||||||
dec.DisallowUnknownFields()
|
dec.DisallowUnknownFields()
|
||||||
if err := dec.Decode(&p); err != nil {
|
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)
|
*b = ProcessBus(p)
|
||||||
return nil
|
return nil
|
||||||
|
|||||||
@@ -25,6 +25,12 @@ func TestProcessServesIsReadBesideTheBusAndRefusedInsideIt(t *testing.T) {
|
|||||||
if err := json.Unmarshal([]byte(`{"holds":["x"]}`), &ProcessBus{}); err == nil {
|
if err := json.Unmarshal([]byte(`{"holds":["x"]}`), &ProcessBus{}); err == nil {
|
||||||
t.Error("an unknown key was accepted")
|
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{
|
m := Manifest{Module: "nats", Resources: []map[string]any{
|
||||||
{"id": "keeper", "type": "process", "serves": []any{"seat:mesh-broker.snapshot-get", "seat:mesh-broker.list"},
|
{"id": "keeper", "type": "process", "serves": []any{"seat:mesh-broker.snapshot-get", "seat:mesh-broker.list"},
|
||||||
"bus": map[string]any{"keeps": true}},
|
"bus": map[string]any{"keeps": true}},
|
||||||
|
|||||||
Reference in New Issue
Block a user