CAT-RD9: nfs-server asks the assigner's seat-holders once and follows its events, no reads

This commit is contained in:
2026-11-04 12:07:07 +01:00
parent aff9d6ae6a
commit 9e726d4c41
3 changed files with 31 additions and 27 deletions
+14 -20
View File
@@ -23,6 +23,8 @@ import (
stdio "git.novox.be/novox/mesh-sdk/go"
"git.novox.be/novox/mesh-sdk/go/delivery"
"git.novox.be/novox/mesh-sdk/go/health"
"git.novox.be/novox/mesh-delivery/sdk/views"
)
// ExportsState is the state the exports are kept in on the bus; MountsState the `mounts` modules' state,
@@ -47,8 +49,10 @@ func main() {
return
}
m := Here()
seats.Follow(delivery.AssignerModule, delivery.SeatHoldersState, SeatHoldersTool)
seats.Start(context.Background())
go ShareExports(m)
if err := stdio.Serve("", Tools(m)); err != nil {
if err := stdio.Serve("", append(Tools(m), seats.Tools("nfs_server")...)); err != nil {
fmt.Fprintln(os.Stderr, err)
os.Exit(1)
}
@@ -117,25 +121,15 @@ func readingsOf(node string) ([]health.Reading, error) {
return out, nil
}
// seatHolderKeys reads the placement seat's state of who holds which seat, every key.
func seatHolderKeys() (map[string][]byte, error) {
state := stdio.State(delivery.SeatHoldersRead)
names, err := state.Keys()
if err != nil {
return nil, err
}
keys := map[string][]byte{}
for _, k := range names {
e, err := state.Get(k)
if err != nil {
return nil, err
}
if e != nil {
keys[k] = e.Value
}
}
return keys, nil
}
// SeatHoldersTool is the assigner's read tool of who holds which seat, which the manifest invokes (ADR 0615).
const SeatHoldersTool = delivery.AssignerModule + ".assigner_read_seat_holders"
// seats is the picture of the placement seat's state of who holds which seat: asked of the assigner once and followed by
// its events, never read from its state (ADR 0615).
var seats = &views.Reader{Module: "nfs-server", Logf: func(f string, a ...any) { fmt.Fprintf(os.Stderr, "nfs-server: "+f+"\n", a...) }}
// seatHolderKeys is the placement seat's state of who holds which seat, every key.
func seatHolderKeys() (map[string][]byte, error) { return seats.Values(delivery.SeatHoldersRead) }
// TakeWants reads every node's `mounts` state from the bus and writes what is asked of this machine to
// the wants file, for the root process. When the bus does not answer, the last wants stay.
@@ -2,7 +2,6 @@ package main
import (
"encoding/json"
"git.novox.be/novox/mesh-sdk/go/delivery"
"git.novox.be/novox/mesh-sdk/go/health"
"os"
"regexp"
@@ -132,16 +131,22 @@ func TestTheDefinitionNamesNoFolderNoMachineAndGivesTheSharesNoDefault(t *testin
func TestTheManifestCarriesGrantsTheRosterTheWantsAndTheRemovalOrder(t *testing.T) {
m, raw := readManifest(t)
var full struct {
Reads []string `json:"reads"`
Facts map[string]map[string]string `json:"facts"`
Config map[string]map[string]any `json:"config"`
Reads []string `json:"reads"`
Invokes []string `json:"invokes"`
Consumes []string `json:"consumes"`
Facts map[string]map[string]string `json:"facts"`
Config map[string]map[string]any `json:"config"`
}
if err := json.Unmarshal([]byte(raw), &full); err != nil {
t.Fatal(err)
}
if len(full.Reads) != 3 || full.Reads[0] != health.ReadingsRead || full.Reads[1] != delivery.SeatHoldersRead || full.Reads[2] != MountsState {
// The assigner's seat-holders is asked once and followed by its events (ADR 0615), no longer read.
if len(full.Reads) != 2 || full.Reads[0] != health.ReadingsRead || full.Reads[1] != MountsState {
t.Errorf("reads: %v", full.Reads)
}
if len(full.Invokes) != 1 || full.Invokes[0] != SeatHoldersTool || len(full.Consumes) != 1 || full.Consumes[0] != "mesh-delivery-assigner.views.seat-holders" {
t.Errorf("invokes %v, consumes %v", full.Invokes, full.Consumes)
}
roster := full.Facts["machines"]
if roster["path"] != RosterFile || !strings.Contains(roster["template"], "{{range .Machines}}{{.Name}} {{.Address}}") {
t.Errorf("the roster fact: %v", roster)
+7 -2
View File
@@ -49,7 +49,6 @@
],
"reads": [
"disk-load.readings",
"mesh-delivery-assigner.seat-holders",
"mounts.shares"
],
"config": {
@@ -188,5 +187,11 @@
"from": "files"
}
]
}
},
"invokes": [
"mesh-delivery-assigner.assigner_read_seat_holders"
],
"consumes": [
"mesh-delivery-assigner.views.seat-holders"
]
}