Files
mesh-delivery/modules/mesh-delivery-sdk/steprun/outputs.go
T
jschoubben 8813c4e9e9 BM4a (sdk): a build seat's holder keeps its outputs in its outputs objects
steprun.OutputsStore names the holder's `outputs` objects, which its manifest
requires with their cap and max-age, in place of the steps state's own
objects store.

Builds: design 47 H2 §791, §820; H-A-399 (1)
2026-11-22 01:00:22 +01:00

44 lines
1.5 KiB
Go

package steprun
import (
"fmt"
"git.novox.be/novox/mesh-sdk/go/buscalls"
)
// 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"
// 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
}
}