assigner: the watchman's machine-away and machine-back have one hearer, the world's, so a durable on their streams no longer splits them
The composition step's own hub handler for machine-away and machine-back shared the durable of hearDelivery on the kept streams, so each event went to one of the two and a machine away was often not known away to the delivery judge. The step now asks the world. Builds: design 47 G §389, §64
This commit is contained in:
@@ -43,36 +43,6 @@ const (
|
||||
seatDefinitionsKey = "seat:" + meshcatalog.Seat + "." + meshcatalog.VerbSeatDefinitions
|
||||
)
|
||||
|
||||
// awayNodes are the machines the watchman said away (machine-away of the seat mesh-watchdogs, §389) and not back since.
|
||||
type awayNodes struct {
|
||||
mu sync.Mutex
|
||||
away map[string]bool
|
||||
}
|
||||
|
||||
// set keeps machine away (true) or back (false).
|
||||
func (a *awayNodes) set(machine string, away bool) {
|
||||
a.mu.Lock()
|
||||
defer a.mu.Unlock()
|
||||
if a.away == nil {
|
||||
a.away = map[string]bool{}
|
||||
}
|
||||
if away {
|
||||
a.away[machine] = true
|
||||
} else {
|
||||
delete(a.away, machine)
|
||||
}
|
||||
}
|
||||
|
||||
// is says machine is away.
|
||||
func (a *awayNodes) is(machine string) bool {
|
||||
if a == nil {
|
||||
return false
|
||||
}
|
||||
a.mu.Lock()
|
||||
defer a.mu.Unlock()
|
||||
return a.away[machine]
|
||||
}
|
||||
|
||||
// compositionRun runs a composition step.
|
||||
type compositionRun struct {
|
||||
// runs are the composition runs of the state composition-runs (compositionruns.go).
|
||||
@@ -85,7 +55,9 @@ type compositionRun struct {
|
||||
trunk func() (mcc.Half, bool)
|
||||
// running is the last `running` heard of a module on a node (world.runningOf), never the node-engine's bucket.
|
||||
running func(node, module string) (ne.Running, bool)
|
||||
away *awayNodes
|
||||
// away says the watchman holds machine away (machine-away, not back since): the one presence the assigner keeps (world.awayNow),
|
||||
// so a durable on the watchman's streams has one hearer.
|
||||
away func(machine string) bool
|
||||
// put puts a run ask on the build seat's check queue under the assigner's name.
|
||||
put func(ctx context.Context, a buildstep.StepAsk) error
|
||||
// reads shares the catalog reads among steps (compositionreads.go); sleep waits between two tries of a read (nil: a timer).
|
||||
@@ -122,7 +94,7 @@ func (r *compositionRun) run(ctx context.Context, id string, step meshwants.Step
|
||||
var ends []machineEnd
|
||||
var keys []string
|
||||
for _, node := range nodes {
|
||||
if r.away.is(node) {
|
||||
if r.away != nil && r.away(node) {
|
||||
ends = append(ends, machineEnd{warnings: []string{node + " is away (the watchman's machine-away), so it is not composed"}})
|
||||
continue
|
||||
}
|
||||
@@ -633,26 +605,6 @@ func (r *compositionRun) programs(ctx context.Context, half mcc.Half) (func(node
|
||||
}, nil
|
||||
}
|
||||
|
||||
// heardPresence keeps a machine-away (away true) or machine-back of the seat mesh-watchdogs (§389, §436): the machine it names.
|
||||
func heardPresence(a *awayNodes, away bool, m jetstream.Msg, logf func(string, ...any)) {
|
||||
var e struct {
|
||||
Machine string `json:"machine"`
|
||||
}
|
||||
if err := json.Unmarshal(m.Data(), &e); err != nil || e.Machine == "" {
|
||||
logf("%s holds no machine, left: %v", m.Subject(), err)
|
||||
} else {
|
||||
a.set(e.Machine, away)
|
||||
if away {
|
||||
logf("%s is away (machine-away): a composition step does not compose it until its machine-back", e.Machine)
|
||||
} else {
|
||||
logf("%s is back (machine-back): a composition step composes it again", e.Machine)
|
||||
}
|
||||
}
|
||||
if err := m.Ack(); err != nil {
|
||||
logf("acknowledging %s: %v", m.Subject(), err)
|
||||
}
|
||||
}
|
||||
|
||||
// trunkOf is the trunk's catalog half the assigner's views hold, trunk naming the first watched branch, or false while none is
|
||||
// held.
|
||||
func trunkOf(iv *catalogViews, trunk func() string) func() (mcc.Half, bool) {
|
||||
|
||||
@@ -102,8 +102,7 @@ func newRunStand(t *testing.T, revisionEngine, trunkEngine, seatDigest string) *
|
||||
return json.RawMessage(`{"candidate":"main.7","node":"` + node + `","verdict":"composed","input":{"node":"` + node + `"},"modules":[],"own":{},"took":1,"v":1}`), nil
|
||||
}
|
||||
running := map[string]string{"ace": "src2:e1", "g14": "src2:e2"}
|
||||
away := &awayNodes{}
|
||||
away.set("shanks", true)
|
||||
away := func(machine string) bool { return machine == "shanks" }
|
||||
keeper := testKeeper(&objectsMem{objs: map[string][]byte{}}, time.Now)
|
||||
s.runs = newCompositionRuns(newRunsMem(), defaultRunSettings, time.Now, t.Logf)
|
||||
s.r = &compositionRun{runs: s.runs,
|
||||
|
||||
@@ -123,6 +123,7 @@ func hearDelivery(ctx context.Context, js jetstream.JetStream, w *world, wake fu
|
||||
m, at, err := presenceOf(data)
|
||||
if err == nil {
|
||||
w.heardPresence(m, true, at)
|
||||
logf("%s is away (machine-away): a composition step does not compose it until its machine-back", m)
|
||||
}
|
||||
return err
|
||||
}},
|
||||
@@ -130,6 +131,7 @@ func hearDelivery(ctx context.Context, js jetstream.JetStream, w *world, wake fu
|
||||
m, at, err := presenceOf(data)
|
||||
if err == nil {
|
||||
w.heardPresence(m, false, at)
|
||||
logf("%s is back (machine-back): a composition step composes it again", m)
|
||||
}
|
||||
return err
|
||||
}},
|
||||
|
||||
@@ -32,7 +32,6 @@ import (
|
||||
|
||||
mma "git.novox.be/novox/mesh-contracts/go/seats/meshmoduleassigner"
|
||||
mcseat "git.novox.be/novox/mesh-contracts/health-and-repair/go/seats/meshconditions"
|
||||
"git.novox.be/novox/mesh-contracts/health-and-repair/go/seats/meshwatchdogs"
|
||||
occ "git.novox.be/novox/mesh-contracts/operator-and-conversation/go/clients/operatorchannelclient"
|
||||
oc "git.novox.be/novox/mesh-contracts/operator-and-conversation/go/seats/operatorchannel"
|
||||
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/clients/meshcatalogclient"
|
||||
@@ -527,9 +526,7 @@ func follow(ctx context.Context, js jetstream.JetStream, nc process.Subscriber,
|
||||
gate.Follow(seatlist.ProcessBus(bus.Call, hub), wake, logger.Printf)
|
||||
}
|
||||
// The build seat's step-ended of an ask deletes the input kept for it (design 47 G §354) and ends the composition run that waits
|
||||
// for it (A-240); the watchman's machine-away and machine-back say which machines a composition step does not compose (§64,
|
||||
// §389). Registered before the hub starts.
|
||||
away := &awayNodes{}
|
||||
// for it (A-240). The machines a composition step does not compose are the watchman's machine-away, heard once, in the world (§64, §389).
|
||||
// The composition runs (design 47 G §718, §719), watched in their own state; a build seat's step-ended of a run's ask ends
|
||||
// the run in its key.
|
||||
var runs *compositionRuns
|
||||
@@ -560,11 +557,6 @@ func follow(ctx context.Context, js jetstream.JetStream, nc process.Subscriber,
|
||||
return err
|
||||
}
|
||||
}
|
||||
for subject, isAway := range map[string]bool{meshwatchdogs.SubjectMachineAwayAll: true, meshwatchdogs.SubjectMachineBackAll: false} {
|
||||
if err := hub.Handle(subject, func(m jetstream.Msg) { heardPresence(away, isAway, m, logger.Printf) }); err != nil {
|
||||
logger.Printf("%s is not heard, so a composition step asks a machine that sleeps: %v", subject, err)
|
||||
}
|
||||
}
|
||||
// The indexer's manifests, modules and module graph, through its first views and views family, never its buckets
|
||||
// (DLV-F2r, ADR 0631): the first pass waits for the three answers, as it waits for every watch to hand what stands.
|
||||
if iv != nil {
|
||||
@@ -712,7 +704,7 @@ func follow(ctx context.Context, js jetstream.JetStream, nc process.Subscriber,
|
||||
// The composition step (design 47 G §22, §354): the seat mesh-wants' accepted kind step, run by one run ask per machine.
|
||||
if bus != nil && js != nil && inputs != nil && p.publishWants != nil && runs != nil {
|
||||
run := &compositionRun{runs: runs, inputs: &compositionInputs{machines: w.machinesOf, callFile: bus.CallFile}, keeper: inputs, reads: &compositionReads{}, call: bus.CallKept,
|
||||
trunk: trunkOf(iv, w.trunkName), running: w.runningOf, away: away, put: runAskPublisher(js), ask: bus.CallFile, now: time.Now, logf: logger.Printf}
|
||||
trunk: trunkOf(iv, w.trunkName), running: w.runningOf, away: func(machine string) bool { return w.awayNow()[machine] }, put: runAskPublisher(js), ask: bus.CallFile, now: time.Now, logf: logger.Printf}
|
||||
steps := &compositionSteps{node: thisNode, say: p.publishWants, run: run.run, resume: run.resume, ended: runs.stepEnded, now: time.Now, logf: logger.Printf,
|
||||
asker: stepAskerOf(seatlist.Definition(gate.Reader, meshwants.Seat))}
|
||||
move := steps.move(ctx) // the readers a rerun carried (§727, A-470d)
|
||||
|
||||
Reference in New Issue
Block a user