Files
mesh-delivery/modules/mesh-delivery-sdk/steprun/outputs.go
T
jschoubben fad9f059ee BM4b (sdk): an end over the steps state's value is read through the verb answer
A step's end is an event, not a verb's answer, so an end over what the steps
state's value or step-ended carries has a reader of its own: keepOver keeps it
in the steps objects as answer.<ask>, the step key and step-ended carry
answer-object in place of output-object, and the build seats gain the read
verb answer (ask and call, marked chunks); output stays the run text's reader.
Step.Whole and StepEnded.ReadOutput read through answer.

Builds: design 47 H2 §791; H-A-412 (2) and its addendum
2026-11-22 01:08:58 +01:00

50 lines
2.0 KiB
Go

package steprun
import (
"fmt"
"git.novox.be/novox/mesh-sdk/go/buscalls"
"git.novox.be/novox/mesh-sdk/go/catalogue"
)
// OutputsStore is the local name of the object store a build seat's holder keeps a run's output in (design 47 H2 §791,
// §820): its `outputs` objects, which the holder's manifest `requires` with their cap and max-age, and which the seat's verb
// output reads (H-A-399 (1)).
const OutputsStore = "outputs"
// AnswersStore is the local name of the object store a build seat's holder keeps a step's end in when it is over what the
// steps state's value or step-ended carries (design 47 H2 H-A-412 addendum): the steps state's own objects store,
// `steps-objects`, which the holder's manifest `requires` with its steps state, and which the seat's verb answer reads.
var AnswersStore = catalogue.StateObjectsName("steps")
// OutputObjects is an object store as a holder uses it (mesh-sdk busstate.ObjectsOf(OutputsStore), or of AnswersStore).
type OutputObjects interface {
Put(name string, data []byte, description string) (buscalls.ObjectInfo, error)
Get(name string) (buscalls.ObjectData, error)
}
// KeepAnswerIn is a holder's Puller.KeepAnswer over its store of answers (AnswersStore).
func KeepAnswerIn(o OutputObjects) func(object string, body []byte) error {
return func(object string, body []byte) error {
if o == nil {
return fmt.Errorf("this module keeps no %s store", AnswersStore)
}
_, err := o.Put(object, body, "a step's end over what its key or step-ended carries, named by it")
return err
}
}
// ReadAnswerFrom is a holder's read of a kept end for AnswerTool over its store of answers (AnswersStore).
func ReadAnswerFrom(o OutputObjects) func(object string) ([]byte, error) {
return func(object string) ([]byte, error) {
if o == nil {
return nil, fmt.Errorf("this module keeps no %s store", AnswersStore)
}
got, err := o.Get(object)
if err != nil {
return nil, fmt.Errorf("the answer %s in the %s store: %w", object, AnswersStore, err)
}
return got.Data, nil
}
}