G findings4 mesh-enrolment: the enrolment's reader writes its findings through views.NewStdioHeldWriter
Builds: design 47 G §639, A-37, A-29 Claude-Session: https://claude.ai/code/session_01NcbgfGKaxw984XyAPfLm4h
This commit is contained in:
@@ -0,0 +1,16 @@
|
||||
package main
|
||||
|
||||
import "testing"
|
||||
|
||||
// The enrolment's findings are written through the held finding writer of a stdio module (design 47 G §639, A-37): it is made
|
||||
// over the state findings with the node the runtime sets, and refused without one.
|
||||
func TestFindingWriter(t *testing.T) {
|
||||
t.Setenv("MESH_NODE", "n1")
|
||||
if w, err := newFindingWriter(); err != nil || w == nil {
|
||||
t.Fatalf("writer = %v, %v; want one", w, err)
|
||||
}
|
||||
t.Setenv("MESH_NODE", "")
|
||||
if _, err := newFindingWriter(); err == nil {
|
||||
t.Error("a writer without a node was made: its events' subjects name none")
|
||||
}
|
||||
}
|
||||
@@ -13,6 +13,7 @@ import (
|
||||
"time"
|
||||
|
||||
"git.novox.be/novox/mesh-contracts/health-and-repair/go/clients/meshhandactsclient"
|
||||
mcseat "git.novox.be/novox/mesh-contracts/health-and-repair/go/seats/meshconditions"
|
||||
occ "git.novox.be/novox/mesh-contracts/operator-and-conversation/go/clients/operatorchannelclient"
|
||||
stdio "git.novox.be/novox/mesh-sdk/go"
|
||||
"git.novox.be/novox/mesh-sdk/go/views"
|
||||
@@ -120,10 +121,31 @@ const (
|
||||
AssignmentsTool = assignerModule + ".assigner_read_assignments"
|
||||
)
|
||||
|
||||
// heldWriter is the enrolment's finding writer.
|
||||
type heldWriter = views.HeldWriter[mcseat.Finding, mcseat.FindingCleared, mcseat.FindingsStated, mcseat.FindingsAskedEvent]
|
||||
|
||||
// newFindingWriter makes the enrolment's held finding writer over its state findings, its node from MESH_NODE (design 47 G §639, A-37).
|
||||
func newFindingWriter() (*heldWriter, error) {
|
||||
return views.NewStdioHeldWriter(views.WriterConfig[mcseat.Finding, mcseat.FindingCleared, mcseat.FindingsStated, mcseat.FindingsAskedEvent]{
|
||||
Module: Module, State: stdio.State(mcseat.StateFindings), Asked: mcseat.SubjectFindingsAsked, Logf: logf})
|
||||
}
|
||||
|
||||
// followed is the enrolment's pictures of the assigner's assignments, started at once: its first view asked through
|
||||
// AssignmentsTool, then the assigner's views family; past its bound the finding in the enrolment's own findings.
|
||||
func followed() *views.Reader {
|
||||
v := &views.Reader{Module: Module, Logf: func(f string, a ...any) { logf("["+Module+"] "+f, a...) }, Findings: views.OwnFindings{},
|
||||
// The enrolment's findings go through the held finding writer of a stdio module (design 47 G §639, A-37): the reader
|
||||
// writes its first-view finding through it, so the keeper's asks and statements hold it.
|
||||
var findings views.WireWriter
|
||||
w, err := newFindingWriter()
|
||||
if err != nil {
|
||||
logf("[%s] the finding writer cannot be made, so no finding is written: %v", Module, err)
|
||||
} else {
|
||||
if err := w.Start(context.Background()); err != nil {
|
||||
logf("[%s] the finding writer cannot start, its findings are kept in the state alone: %v", Module, err)
|
||||
}
|
||||
findings = w
|
||||
}
|
||||
v := &views.Reader{Module: Module, Logf: func(f string, a ...any) { logf("["+Module+"] "+f, a...) }, Findings: findings,
|
||||
Acts: meshhandactsclient.Recorder{Ask: stdio.Ask}}
|
||||
v.Follow(assignerModule, assignmentsState, AssignmentsTool)
|
||||
v.Start(context.Background())
|
||||
|
||||
Reference in New Issue
Block a user