Keep the seat mesh-placement's state as one key per module and node, so a node watches its own keys and a change writes only the modules it moves (issue 774, research 072 row 37)
The node key <node>.node is a write's commit: it names each placed module with its value's digest, the module keys carry the value they replace until it lands, so a reader never composes half a write. Every reader goes through PlacementKeys/PlacementsOf, which read the legacy placement.<node> too while the change is delivered.
This commit is contained in:
@@ -819,10 +819,11 @@ func statesOf(t *testing.T, ctx context.Context, b *bus) mapStates {
|
||||
out[state][key] = raw
|
||||
}
|
||||
placements, _ := b.Placements(ctx)
|
||||
for node, p := range placements {
|
||||
k, _ := delivery.PlacementKey(node)
|
||||
raw, err := delivery.EncodePlacement(p)
|
||||
put(PlacementRead, k, raw, err)
|
||||
for _, p := range placements {
|
||||
values, err := delivery.PlacementValues(p)
|
||||
for k, raw := range values {
|
||||
put(PlacementRead, k, raw, err)
|
||||
}
|
||||
}
|
||||
records, _ := b.Records(ctx)
|
||||
for node, r := range records {
|
||||
|
||||
@@ -68,15 +68,11 @@ func (r statesReader) each(read string, visit func(key string, value []byte)) er
|
||||
}
|
||||
|
||||
func (r statesReader) Placements(context.Context) (map[string]delivery.Placement, error) {
|
||||
out := map[string]delivery.Placement{}
|
||||
keys := delivery.NewPlacementKeys()
|
||||
err := r.each(PlacementRead, func(k string, v []byte) {
|
||||
if node, err := delivery.ParsePlacementKey(k); err == nil {
|
||||
if p, err := delivery.DecodePlacement(v); err == nil && p.Node == node {
|
||||
out[node] = p
|
||||
}
|
||||
}
|
||||
_, _ = keys.Put(k, v, 0, false) // a key that does not read places nothing, as before
|
||||
})
|
||||
return out, err
|
||||
return keys.All(), err
|
||||
}
|
||||
|
||||
func (r statesReader) Records(context.Context) (map[string]delivery.NodeRecord, error) {
|
||||
|
||||
Reference in New Issue
Block a user