BG4, BN4, BI4: the three build modules' pullers say the seat's events
Builds: design 47 G §496, §602, §603 Claude-Session: https://claude.ai/code/session_01NcbgfGKaxw984XyAPfLm4h
This commit is contained in:
@@ -62,7 +62,11 @@ func (m *Module) Puller(steps []StepTool, source steprun.AskSource) *steprun.Pul
|
||||
if m.ReadPauses.Get != nil {
|
||||
load = func(key string) ([]byte, error) { return m.ReadPauses.Get(key) }
|
||||
}
|
||||
return &steprun.Puller{Source: source, Language: sdkstep.AskImage, Node: m.Node, Put: m.Steps, PausePut: m.Pauses, Load: load, ForgetPause: m.ForgetPause, WatchPauses: m.WatchPauses, PauseKeys: m.ReadPauses.Keys,
|
||||
var say func(string, any, string) error
|
||||
if m.SayEvent != nil {
|
||||
say = steprun.SayOn(sdkstep.AskImage, m.Node, m.SayEvent)
|
||||
}
|
||||
return &steprun.Puller{Source: source, Language: sdkstep.AskImage, Say: say, Node: m.Node, Put: m.Steps, PausePut: m.Pauses, Load: load, ForgetPause: m.ForgetPause, WatchPauses: m.WatchPauses, PauseKeys: m.ReadPauses.Keys,
|
||||
Capacity: capacity, SettingsFile: settings, WatchConfig: watch, CoresPerStep: cores, BuildHours: hours, Eligible: m.Eligible, Logf: m.Say,
|
||||
Run: func(ctx context.Context, a sdkstep.StepAsk) (any, error) {
|
||||
if err := m.Check(ctx); err != nil {
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
sdkstep "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-sdk/buildstep"
|
||||
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-sdk/steprun"
|
||||
)
|
||||
|
||||
// Design 47 G §496, §602 (BG4, BN4, BI4): the module's puller says the seat's events on this node's subjects.
|
||||
func TestPullerSaysTheSeatsEventsOnItsNodesSubject(t *testing.T) {
|
||||
var subjects []string
|
||||
m := &Module{Node: "ace", Capacity: func() int { return 0 },
|
||||
SayEvent: func(subject string, _ any, _ string) error { subjects = append(subjects, subject); return nil }}
|
||||
p := m.Puller(nil, steprun.NewFakeAsks())
|
||||
if p.Say == nil {
|
||||
t.Fatal("the puller says no event")
|
||||
}
|
||||
seat, _ := sdkstep.BuildSeat(sdkstep.AskImage)
|
||||
for _, event := range []string{"ask-taken", "step-progress", "step-ended"} {
|
||||
if err := p.Say(event, nil, "id"); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
for i, event := range []string{"ask-taken", "step-progress", "step-ended"} {
|
||||
if want := "mesh.seat." + seat + ".event." + event + ".ace"; subjects[i] != want {
|
||||
t.Errorf("%s said on %s, want %s", event, subjects[i], want)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -32,6 +32,7 @@ func logf(format string, a ...any) { fmt.Fprintf(os.Stderr, "[mesh-build-image]
|
||||
func main() {
|
||||
ctx := context.Background()
|
||||
m := &Module{
|
||||
SayEvent: stdio.SeatPublish,
|
||||
Node: strings.TrimSpace(os.Getenv("MESH_NODE")),
|
||||
RecordAct: handActRecorder,
|
||||
Steps: stdio.State(seat.StateSteps).Put,
|
||||
|
||||
@@ -20,6 +20,10 @@ const CheckRound = 10 * time.Minute
|
||||
|
||||
// Module is the image build module's one running state.
|
||||
type Module struct {
|
||||
// SayEvent publishes an event of the image build seat on a seat subject (stdio.SeatPublish; nil says none, a test's): the
|
||||
// puller's ask-taken, step-progress and step-ended (design 47 G §496, §602).
|
||||
SayEvent func(subject string, body any, id string) error
|
||||
|
||||
Node string
|
||||
// RecordAct writes an act in the hand-act log of the seat mesh-hand-acts (§463, §480): a drop writes it first.
|
||||
RecordAct func(what, why string) error
|
||||
|
||||
@@ -7,8 +7,8 @@ package main
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-sdk/steprun"
|
||||
seat "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/nodebuildimage"
|
||||
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-sdk/steprun"
|
||||
stdio "git.novox.be/novox/mesh-sdk/go"
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user