M6 networkmanager: the bundle gives the resolver the check's name

The bundle calls this node's node-resolver uplink-names with the check address's host
at its start, at a changed check-address, at its bus connection's return and when this
node's holder of node-resolver runs, reading the holder from the assignments; no holder
is recorded and no failure, a failed call stands failed in names.json until the next
moment.

Builds: design 08 sign-in-page §12, §13, §22
This commit is contained in:
jochen
2026-11-24 21:23:56 +01:00
parent f6646c7254
commit 786a23638b
6 changed files with 356 additions and 13 deletions
@@ -17,14 +17,25 @@ import (
type bundle struct {
folder Folder
pub *publisher
names *namer
mu sync.Mutex
missed bool
lastAt time.Time
}
// bundleRuns is what the bundle hears through: file events of the kernel, its consumer's heartbeat and its
// subscription.
type bundleRuns struct {
files func(dirs []string, stop <-chan struct{}) <-chan struct{}
fileMade func(dir, name string, stop <-chan struct{}) <-chan struct{}
onHeartbeat func(func(stdio.Heartbeat)) error
subscribe func(pattern string, handle func(stdio.Envelope) error) error
}
func newBundle(f Folder) *bundle {
return &bundle{folder: f, pub: &publisher{folder: f, publish: seatPublish}}
return &bundle{folder: f, pub: &publisher{folder: f, publish: seatPublish},
names: &namer{folder: f, ask: stdio.Ask, now: time.Now}}
}
// seatPublish says a kept event through the runtime, which awaits the stream's acknowledgement.
@@ -39,23 +50,43 @@ func startBundle() {
journal("the module's folder: %v", err)
return
}
b := newBundle(f)
b.start(fileEvents, stdio.OnHeartbeat)
newBundle(f).start(bundleRuns{files: fileEvents, fileMade: fileMade, onHeartbeat: stdio.OnHeartbeat,
subscribe: stdio.Subscribe})
}
// start publishes what is kept, then again at each file event on pending/ and at each return of the bus connection.
func (b *bundle) start(files func([]string, <-chan struct{}) <-chan struct{}, onHeartbeat func(func(stdio.Heartbeat)) error) {
// start publishes what is kept and gives the resolver the check's host name, then does each again at its moments: a
// file event on pending/ publishes, a changed check-address gives the names, node-resolver's holder running gives the
// names, and the bus connection's return does both (§13, §20).
func (b *bundle) start(runs bundleRuns) {
pending := filepath.Join(b.folder.Dir, pendingName)
if err := os.MkdirAll(pending, 0o700); err != nil {
journal("making %s failed: %v", pending, err)
}
kept := files([]string{pending}, nil)
kept := runs.files([]string{pending}, nil)
check := runs.fileMade(b.folder.Dir, checkName, nil)
b.pub.publishKept("the bundle's start")
if err := onHeartbeat(b.heartbeat); err != nil {
b.names.give("the bundle's start")
if err := runs.subscribe(runningPattern, b.names.running); err != nil {
journal("subscribing to %s failed: %v", runningPattern, err)
}
if err := runs.onHeartbeat(b.heartbeat); err != nil {
journal("hearing the bus connection's heartbeat failed: %v", err)
}
for range kept {
b.pub.publishKept("a kept event")
for kept != nil || check != nil {
select {
case _, ok := <-kept:
if !ok {
kept = nil
continue
}
b.pub.publishKept("a kept event")
case _, ok := <-check:
if !ok {
check = nil
continue
}
b.names.give("a changed check address")
}
}
}
@@ -84,4 +115,5 @@ func (b *bundle) heartbeat(hb stdio.Heartbeat) {
// reconnected is the work at the bus connection's return.
func (b *bundle) reconnected() {
b.pub.publishKept("the bus connection's return")
b.names.give("the bus connection's return")
}