Files
mesh-delivery/modules/mesh-delivery-builder/buildrun/assignerholder.go
T
jschoubben 6d9a7b8aae Checker follows the assignments of the holder of the seat mesh-module-assigner found at run time; FollowAssignments, AssignerModule and AssignmentsBucket go
buildrun gains AssignerHolder, AssignmentsOf and SleepFor (moved from the builder's program, which uses them), so
the builder and the checker follow the holder's first-view tool, views family and state alike; the checker's
manifest consumes the seat's views assignments and reads its assignments state, its composition reads the
picture once followed. The assigner's callers list for the first view gains the checker.

Builds: design 47 G A-82, A-119, A-126, A-131
Claude-Session: https://claude.ai/code/session_01NcbgfGKaxw984XyAPfLm4h
2026-11-12 01:38:34 +01:00

46 lines
1.9 KiB
Go

package buildrun
import (
"context"
"time"
mma "git.novox.be/novox/mesh-contracts/go/seats/meshmoduleassigner"
"git.novox.be/novox/mesh-sdk/go/seatlist"
)
// **No part names the assigner** (design 47 G A-119, A-126, A-131): the module holding the seat mesh-module-assigner is asked of
// the seat that places modules through mesh-sdk's seatlist.HolderOf, and the names of the view of its state assignments are made
// from it, so a new holder is followed with no change of code. The builder and the checker follow the assignments so.
// AssignerHolder is the module holding the seat mesh-module-assigner now, asked until it answers or ctx ends. wait is the pause
// between two asks that failed; sleep says false when ctx ended during it.
func AssignerHolder(ctx context.Context, call seatlist.HolderCaller, wait time.Duration, sleep func(context.Context, time.Duration) bool, logf func(string, ...any)) (string, bool) {
for {
holder, err := seatlist.HolderOf(call, mma.Seat)
if err == nil {
return holder, true
}
logf("who holds the seat %s is not known yet, so no node is counted by the assignments: %v", mma.Seat, err)
if !sleep(ctx, wait) {
return "", false
}
}
}
// AssignmentsNames are the names made from the holder: the view's first-view tool `<holder>.assignments` and the bucket
// `<holder>_assignments` of the state.
type AssignmentsNames struct{ Holder, Tool, Bucket string }
// AssignmentsOf is the names of the holder's state assignments.
func AssignmentsOf(holder string) AssignmentsNames {
return AssignmentsNames{Holder: holder, Tool: holder + "." + mma.StateAssignments, Bucket: holder + "_" + mma.StateAssignments}
}
// SleepFor waits d, a context's bound, and says whether ctx is still alive.
func SleepFor(ctx context.Context, d time.Duration) bool {
w, cancel := context.WithTimeout(ctx, d)
defer cancel()
<-w.Done()
return ctx.Err() == nil
}