Builds: design 47 G A-313, A-314 Claude-Session: https://claude.ai/code/session_01NcbgfGKaxw984XyAPfLm4h
45 lines
1.6 KiB
Go
45 lines
1.6 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 answer in when it is over what
|
|
// step-ended carries inline (design 47 G A-254): the steps state's own objects store, `steps-objects`, which the holder's manifest
|
|
// `requires` asks for with its steps state (design 47 G A-313).
|
|
var OutputsStore = catalogue.StateObjectsName("steps")
|
|
|
|
// OutputObjects is the object store of OutputsStore as a holder uses it (mesh-sdk busstate.ObjectsOf(OutputsStore)).
|
|
type OutputObjects interface {
|
|
Put(name string, data []byte, description string) (buscalls.ObjectInfo, error)
|
|
Get(name string) (buscalls.ObjectData, error)
|
|
}
|
|
|
|
// KeepOutputIn is a holder's Puller.KeepOutput over its store of outputs.
|
|
func KeepOutputIn(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", OutputsStore)
|
|
}
|
|
_, err := o.Put(object, body, "a run's answer, named by its step-ended")
|
|
return err
|
|
}
|
|
}
|
|
|
|
// ReadOutputFrom is a holder's read of a kept answer for OutputTool over its store of outputs.
|
|
func ReadOutputFrom(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", OutputsStore)
|
|
}
|
|
got, err := o.Get(object)
|
|
if err != nil {
|
|
return nil, fmt.Errorf("the answer %s in the %s store: %w", object, OutputsStore, err)
|
|
}
|
|
return got.Data, nil
|
|
}
|
|
}
|