Files
mesh-delivery/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/reservedverb.go
T
jschoubben 71a35a6376 MV1: move contracts and sdk under modules/, importers follow
The delivery repository's contracts and SDK live under modules/ as
mesh-delivery-contracts and mesh-delivery-sdk, their Go module paths
renamed to match the folders (the TypeScript names already did), and
every importer in mesh-delivery, mesh-catalog, mesh-host, mesh-tools
and mesh-sdk follows in the same group: a design as it should be, one
path per module, checked by the group's check building every importer.

Builds: design 47 G §427, §88

Claude-Session: https://claude.ai/code/session_01NcbgfGKaxw984XyAPfLm4h
2026-11-12 05:09:56 +01:00

61 lines
2.5 KiB
Go

package main
import (
"context"
"encoding/json"
"fmt"
"strings"
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshbuilds"
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshcatalog"
"git.novox.be/novox/mesh-sdk/go/process"
"mesh-delivery-builder/internal/versions"
)
// The seat mesh-builds' verb reserved is answered by the builder's own process (design 47 G A-115, A-127; A-87: builder_build stays
// its tools bundle's): a module's reserved version with each artifact's digest once built, for a registry holder deciding whether to
// publish. Given a name it finds the module from the catalog half the process follows (carriers) and, for a version no reservation
// holds, asks the seat mesh-catalog's verb versions. The process's manifest declares the verb in `serves` beside its process.
// reservedReader is the state reserved read through its store, as the verb's answers read it.
func reservedReader(ctx context.Context, store versions.Store) versions.Reader {
return versions.Reader{
Keys: func() ([]string, error) { return store.KeysOf(ctx, versions.AllFilter) },
Get: func(key string) (json.RawMessage, bool, error) {
v, _, found, err := store.Get(ctx, key)
return v, found, err
}}
}
// reservedVerb is the handler of the verb reserved.
func reservedVerb(ctx context.Context, rr versions.Reader, carriers func(context.Context, string) ([]versions.Built, error), released versions.CatalogVersions) process.SeatHandler {
return func(_ string, body json.RawMessage) (any, error) {
var in meshbuilds.ReservedInput
if len(body) > 0 {
if err := json.Unmarshal(body, &in); err != nil {
return nil, fmt.Errorf("the arguments do not fit the verb reserved: %w", err)
}
}
if name := strings.TrimSpace(in.Name); name != "" {
return versions.AnswerReservedByName(ctx, rr, carriers, released, name, in.Version)
}
return versions.AnswerReservedVerb(rr, in.Module, in.Version)
}
}
// catalogReleased are a module's released versions, asked of the seat mesh-catalog's verb versions through call.
func catalogReleased(call toolCaller) versions.CatalogVersions {
return func(_ context.Context, module string) ([]meshcatalog.VersionEntry, error) {
raw, err := call("seat:"+meshcatalog.Seat+".versions", meshcatalog.VersionsInput{Module: module})
if err != nil {
return nil, err
}
var a meshcatalog.VersionsAnswer
if err := json.Unmarshal(raw, &a); err != nil {
return nil, fmt.Errorf("the seat mesh-catalog's versions answered what does not read: %w", err)
}
return a.Versions, nil
}
}