Announce a plan from a copy that shares nothing with the walk, which goes on writing its steps (issue 1260)
mesh/merge-gate head 14f405ece508 merged into trunk 5c807808e88a — pass: builds mesh-controller → novox; no bus step; every machine composes with the chang…
mesh/repo-check head 14f405ece508 merged into trunk 5c807808e88a — pass: its merge-check.sh passed
mesh/delivery delivered
mesh/merge-gate head 14f405ece508 merged into trunk 5c807808e88a — pass: builds mesh-controller → novox; no bus step; every machine composes with the chang…
mesh/repo-check head 14f405ece508 merged into trunk 5c807808e88a — pass: its merge-check.sh passed
mesh/delivery delivered
This commit is contained in:
@@ -1220,8 +1220,32 @@ func shelfOf(entries []inventory.Entry) map[string]catalogue.Manifest {
|
||||
// On the save that starts the walk and the one that ends it, the walk also says what it touches, its bound and,
|
||||
// at the end, its outcome (novox/hq ADR 0308 decision 1, walk_said.go), read from facts; nil facts say only what
|
||||
// the walk recorded.
|
||||
//
|
||||
// The plan the announcement is made from is a copy that shares nothing with the walk, taken before the goroutine
|
||||
// starts: the walk goes on writing its steps' maps and pointers while the announcement is marshalled and its
|
||||
// touches read (novox/hq issue 1260), and it says the plan as it was when this was called.
|
||||
func sayPlanMoved(ctx context.Context, bus link.Bus, facts walkFacts, p inventory.Plan) {
|
||||
go publishPlanMoved(ctx, bus, facts, p)
|
||||
kept, err := copyOfPlan(p)
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "%s: kept, and could not be said as plan-moved: %v\n", p.ID, err)
|
||||
return
|
||||
}
|
||||
go publishPlanMoved(ctx, bus, facts, kept)
|
||||
}
|
||||
|
||||
// copyOfPlan is the plan with nothing shared with the original: its JSON round trip, which is all of it but what
|
||||
// the plan never keeps (WalkSaid), carried over.
|
||||
func copyOfPlan(p inventory.Plan) (inventory.Plan, error) {
|
||||
raw, err := json.Marshal(p)
|
||||
if err != nil {
|
||||
return inventory.Plan{}, err
|
||||
}
|
||||
var kept inventory.Plan
|
||||
if err := json.Unmarshal(raw, &kept); err != nil {
|
||||
return inventory.Plan{}, err
|
||||
}
|
||||
kept.WalkSaid = p.WalkSaid
|
||||
return kept, nil
|
||||
}
|
||||
|
||||
func publishPlanMoved(ctx context.Context, bus link.Bus, facts walkFacts, p inventory.Plan) {
|
||||
|
||||
Reference in New Issue
Block a user