The console reads the assigner's state assignments and imports the contracts' new paths (issue 1966)
Claude-Session: https://claude.ai/code/session_01NcbgfFSnn24M3GcqttoU7i
This commit is contained in:
@@ -21,8 +21,8 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
assigner "git.novox.be/novox/mesh-contracts/placement/go/clients/meshmoduleassignerclient"
|
||||
seatplacement "git.novox.be/novox/mesh-contracts/placement/go/seats/meshmoduleassigner"
|
||||
assigner "git.novox.be/novox/mesh-contracts/go/clients/meshmoduleassignerclient"
|
||||
seatassigner "git.novox.be/novox/mesh-contracts/go/seats/meshmoduleassigner"
|
||||
meshcatalogclient "git.novox.be/novox/mesh-delivery/contracts/go/clients/meshcatalogclient"
|
||||
meshcatalog "git.novox.be/novox/mesh-delivery/contracts/go/seats/meshcatalog"
|
||||
"git.novox.be/novox/mesh-sdk/go/membership"
|
||||
@@ -158,18 +158,18 @@ func sdkMembership(t *testing.T, mem bus.Membership) membership.Membership {
|
||||
const (
|
||||
indexer = "mesh-delivery-indexer"
|
||||
assignerHolder = "mesh-delivery-assigner"
|
||||
// PlacementBucket and SeatHoldersBucket are the assigner's states placement and seat-holders.
|
||||
PlacementBucket = assignerHolder + "_placement"
|
||||
// AssignmentsBucket and SeatHoldersBucket are the assigner's states assignments and seat-holders.
|
||||
AssignmentsBucket = assignerHolder + "_assignments"
|
||||
SeatHoldersBucket = assignerHolder + "_seat-holders"
|
||||
ModulesBucket = indexer + "_modules"
|
||||
ManifestsBucket = indexer + "_manifests"
|
||||
)
|
||||
|
||||
// ConsoleReads are the states a console's runtime reads to say what the mesh holds (novox/hq ADR 0571 clauses 4, 5):
|
||||
// placement, the indexer's modules and manifests, and the seat holders.
|
||||
// assignments, the indexer's modules and manifests, and the seat holders.
|
||||
func ConsoleReads() []bus.StateIssued {
|
||||
return []bus.StateIssued{
|
||||
{Name: assignerHolder + ".placement", Bucket: PlacementBucket},
|
||||
{Name: assignerHolder + ".assignments", Bucket: AssignmentsBucket},
|
||||
{Name: indexer + ".modules", Bucket: ModulesBucket},
|
||||
{Name: indexer + ".manifests", Bucket: ManifestsBucket},
|
||||
{Name: assignerHolder + ".seat-holders", Bucket: SeatHoldersBucket},
|
||||
@@ -177,7 +177,7 @@ func ConsoleReads() []bus.StateIssued {
|
||||
}
|
||||
|
||||
// Placed writes what the mesh holds as its parts write it, with mesh-sdk's encoders: each module the indexer holds with
|
||||
// its manifest (tools, the tools it declares; none for a module without), and each node's placement of modules.
|
||||
// its manifest (tools, the tools it declares; none for a module without), and each node's assignment of modules.
|
||||
func (m *Mesh) Placed(t *testing.T, tools map[string][]string, on map[string][]string) {
|
||||
t.Helper()
|
||||
kv := func(bucket string) nats.KeyValue {
|
||||
@@ -188,7 +188,7 @@ func (m *Mesh) Placed(t *testing.T, tools map[string][]string, on map[string][]s
|
||||
}
|
||||
return b
|
||||
}
|
||||
modules, manifests, placement := kv(ModulesBucket), kv(ManifestsBucket), kv(PlacementBucket)
|
||||
modules, manifests, assigned := kv(ModulesBucket), kv(ManifestsBucket), kv(AssignmentsBucket)
|
||||
kv(SeatHoldersBucket)
|
||||
for module, declared := range tools {
|
||||
manifest, _ := json.Marshal(map[string]any{"module": module, "tools": declared})
|
||||
@@ -210,17 +210,17 @@ func (m *Mesh) Placed(t *testing.T, tools map[string][]string, on map[string][]s
|
||||
}
|
||||
}
|
||||
for node, placed := range on {
|
||||
p := seatplacement.Placement{V: assigner.Version, Node: node}
|
||||
p := seatassigner.Assignments{V: assigner.Version, Node: node}
|
||||
for _, module := range placed {
|
||||
p.Modules = append(p.Modules, seatplacement.PlacedModule{Module: module})
|
||||
p.Modules = append(p.Modules, seatassigner.PlacedModule{Module: module})
|
||||
}
|
||||
// As the seat writes it: its node key and a key per module (research 072 row 37).
|
||||
values, err := assigner.PlacementValues(p)
|
||||
values, err := assigner.AssignmentsValues(p)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
for key, raw := range values {
|
||||
if _, err := placement.Put(key, raw); err != nil {
|
||||
if _, err := assigned.Put(key, raw); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user