buildstep: BuildModuleOf goes, a build module is the holder of its build seat on the seat list
No caller is left (the checker, the watchman and the view find the holders; the builder's reader looks a step up by its seat). Builds: design 47 G A-82 Claude-Session: https://claude.ai/code/session_01NcbgfGKaxw984XyAPfLm4h
This commit is contained in:
@@ -1,41 +0,0 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"time"
|
||||
|
||||
mma "git.novox.be/novox/mesh-contracts/go/seats/meshmoduleassigner"
|
||||
"git.novox.be/novox/mesh-sdk/go/seatlist"
|
||||
)
|
||||
|
||||
// assignerHolder is the module holding the seat mesh-module-assigner now, asked of the seat list through mesh-sdk's seatlist.HolderOf
|
||||
// until it answers or ctx ends (design 47 G A-119, A-126): the builder names no assigner module, so a new holder is followed with no
|
||||
// change of code. 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, both made from the holder found at run time.
|
||||
type assignmentsNames struct{ Holder, Tool, Bucket string }
|
||||
|
||||
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
|
||||
}
|
||||
Reference in New Issue
Block a user