The mesh knows no pull request (design 47 G, G-1 §38-39), so mesh-config keeps no value held for one. The seat definition loses the state kept, its fixtures and generated Go and TypeScript (seatgen), and the generated client package, which held only the held values' key and decoder, goes with its artifact in module.json. Builds: ADR 0681 §1 (nothing mesh-config records is a held value), §6 (no check reads a held value, so the seat keeps none and its generated client goes). Claude-Session: https://claude.ai/code/session_01JG73KHUnBze48rdua8u2sy
200 lines
6.1 KiB
Go
200 lines
6.1 KiB
Go
// Code generated by seatgen from the seat definitions; DO NOT EDIT.
|
|
|
|
// Package meshconfig is the contract of the seat "mesh-config", defined whole (seats/mesh-config/seat.json): The mesh's config values: read and set one, and the renames still open. mesh-config's own events stay under its own subjects (ADR 0620 §2).
|
|
package meshconfig
|
|
|
|
import (
|
|
"bytes"
|
|
"encoding/json"
|
|
"errors"
|
|
"strings"
|
|
)
|
|
|
|
// Seat is the seat's name.
|
|
const Seat = "mesh-config"
|
|
|
|
const (
|
|
VerbConfig = "config"
|
|
VerbRenames = "renames"
|
|
)
|
|
|
|
// Verbs is every verb the seat serves, in its definition's order: a new copy each call.
|
|
func Verbs() []string {
|
|
return []string{VerbConfig, VerbRenames}
|
|
}
|
|
|
|
// The holder's own events, listed beside the seat and published under the holder's subjects (ADR 0620 §2).
|
|
const (
|
|
HolderEventConfigChanged = "config-changed"
|
|
HolderEventRenamed = "renamed"
|
|
HolderEventRetiring = "retiring"
|
|
HolderEventRetired = "retired"
|
|
)
|
|
|
|
// HolderSubjectConfigChanged is where the holder publishes config-changed.
|
|
func HolderSubjectConfigChanged(holder string) string {
|
|
return "mesh.mod." + holder + ".event.config-changed"
|
|
}
|
|
|
|
// HolderSubjectRenamed is where the holder publishes renamed, kept in config.events.
|
|
func HolderSubjectRenamed(holder string) string { return "mesh.stream." + holder + ".event.renamed" }
|
|
|
|
// HolderSubjectRetiring is where the holder publishes retiring, kept in config.events.
|
|
func HolderSubjectRetiring(holder string) string { return "mesh.stream." + holder + ".event.retiring" }
|
|
|
|
// HolderSubjectRetired is where the holder publishes retired, kept in config.events.
|
|
func HolderSubjectRetired(holder string) string { return "mesh.stream." + holder + ".event.retired" }
|
|
|
|
const (
|
|
StateResolved = "resolved"
|
|
)
|
|
|
|
// ResolvedByNodeModuleKeyKey is the key of one value of the state resolved under the form "<node>.<module>.<key>".
|
|
func ResolvedByNodeModuleKeyKey(node, module, key string) string {
|
|
return node + "." + module + "." + key
|
|
}
|
|
|
|
// ParseResolvedByNodeModuleKeyKey reads the parts of a key of the form "<node>.<module>.<key>", in the order of the form; the last result is false for a key of another form.
|
|
func ParseResolvedByNodeModuleKeyKey(key string) (string, string, string, bool) {
|
|
rest := key
|
|
v0, after0, found0 := strings.Cut(rest, ".")
|
|
if !found0 || v0 == "" {
|
|
return "", "", "", false
|
|
}
|
|
rest = after0
|
|
v2, after2, found2 := strings.Cut(rest, ".")
|
|
if !found2 || v2 == "" {
|
|
return "", "", "", false
|
|
}
|
|
rest = after2
|
|
if rest == "" {
|
|
return "", "", "", false
|
|
}
|
|
v4 := rest
|
|
rest = ""
|
|
if rest != "" {
|
|
return "", "", "", false
|
|
}
|
|
return v0, v2, v4, true
|
|
}
|
|
|
|
// DecodeResolvedByNodeModuleKeyValue reads one value of the state resolved under the form "<node>.<module>.<key>", refusing a field ResolvedByNodeModuleKeyValue does not know and any text after the value.
|
|
func DecodeResolvedByNodeModuleKeyValue(raw []byte) (ResolvedByNodeModuleKeyValue, error) {
|
|
var v ResolvedByNodeModuleKeyValue
|
|
dec := json.NewDecoder(bytes.NewReader(raw))
|
|
dec.DisallowUnknownFields()
|
|
if err := dec.Decode(&v); err != nil {
|
|
return v, err
|
|
}
|
|
if dec.More() {
|
|
return v, errors.New("text after the value")
|
|
}
|
|
return v, nil
|
|
}
|
|
|
|
// ConfigInput is what config takes.
|
|
type ConfigInput struct {
|
|
// list (when not given), set, clear or history
|
|
Action string `json:"action,omitempty"`
|
|
// who gave the value at the controller's terminal
|
|
By string `json:"by,omitempty"`
|
|
// the config key
|
|
Key string `json:"key,omitempty"`
|
|
// for history: at most this many, newest
|
|
Limit float64 `json:"limit,omitempty"`
|
|
// a module: its own value, with node
|
|
Module string `json:"module,omitempty"`
|
|
// a node
|
|
Node string `json:"node,omitempty"`
|
|
// for set: the value, of the key's type: a number, a string, a boolean, or for a trusted key an object or a list
|
|
Value any `json:"value,omitempty"`
|
|
// for set and clear: why
|
|
Why string `json:"why,omitempty"`
|
|
}
|
|
|
|
// ConfigAnswer is what config answers.
|
|
type ConfigAnswer = map[string]any
|
|
|
|
// RenamesInput is what renames takes.
|
|
type RenamesInput struct {
|
|
// one module (optional)
|
|
Module string `json:"module,omitempty"`
|
|
}
|
|
|
|
// RenamesAnswerRenamesItem is a type of the contract.
|
|
type RenamesAnswerRenamesItem struct {
|
|
// when it moved, RFC 3339
|
|
At string `json:"at,omitempty"`
|
|
// the old name
|
|
From string `json:"from"`
|
|
// the module
|
|
Module string `json:"module"`
|
|
// the nodes still holding the old name open
|
|
Open []string `json:"open,omitempty"`
|
|
// the new name
|
|
To string `json:"to"`
|
|
}
|
|
|
|
// RenamesAnswer is what renames answers.
|
|
type RenamesAnswer struct {
|
|
// every open rename
|
|
Renames []RenamesAnswerRenamesItem `json:"renames"`
|
|
}
|
|
|
|
// RenamedHolderEvent is the body of the holder's event renamed.
|
|
type RenamedHolderEvent struct {
|
|
// when, RFC 3339
|
|
At string `json:"at"`
|
|
// the old name
|
|
From string `json:"from"`
|
|
// the module
|
|
Module string `json:"module"`
|
|
// the new name
|
|
To string `json:"to"`
|
|
}
|
|
|
|
// RetiringHolderEvent is the body of the holder's event retiring.
|
|
type RetiringHolderEvent struct {
|
|
// the ask's id
|
|
Ask string `json:"ask,omitempty"`
|
|
// the value's or secret's name
|
|
Key string `json:"key"`
|
|
Kind string `json:"kind"`
|
|
// the module
|
|
Module string `json:"module"`
|
|
// since when, RFC 3339
|
|
Since string `json:"since"`
|
|
}
|
|
|
|
// The values of RetiringHolderEvent's kind.
|
|
const (
|
|
RetiringHolderEventKindValue = "value"
|
|
RetiringHolderEventKindSecret = "secret"
|
|
)
|
|
|
|
// RetiredHolderEvent is the body of the holder's event retired.
|
|
type RetiredHolderEvent struct {
|
|
// the ask's id
|
|
Ask string `json:"ask,omitempty"`
|
|
// the module
|
|
Module string `json:"module"`
|
|
// the name
|
|
Name string `json:"name"`
|
|
// the node
|
|
Node string `json:"node,omitempty"`
|
|
}
|
|
|
|
// ResolvedByNodeModuleKeyValue is one value of the state resolved under the key <node>.<module>.<key>.
|
|
type ResolvedByNodeModuleKeyValue struct {
|
|
Key string `json:"key"`
|
|
Module string `json:"module"`
|
|
Node string `json:"node"`
|
|
// the predefined key the value falls back to
|
|
Predefined string `json:"predefined,omitempty"`
|
|
// an unset value is the operator's own to set
|
|
Required bool `json:"required,omitempty"`
|
|
Source string `json:"source"`
|
|
Trusted bool `json:"trusted,omitempty"`
|
|
Value any `json:"value,omitempty"`
|
|
}
|