Files
mesh-contracts/go/seats/meshconfig/contract.go
T
jschoubben f070c8defa H2 K: the node-engine's have carries the run a module was applied from
The engine kept the composition run each module was applied from in its
memory only, so a restarted engine applied an older run's want again. The
have value, the record of what the engine applied, gains run, and the
seat's form rises to 2. Packages generated again by mesh-delivery's seatgen
(feat/47-H2 1f5b0f81, whose fields digest is per type: the other four
packages' digest lines follow); seatgen -check clean.

Builds: design 47 H2 §813 (1); H-A-352 (2), H-A-384 (2), H-A-388 (1)
2026-11-22 00:15:31 +01:00

270 lines
9.5 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 (
"encoding/json"
"strings"
)
// Seat is the seat's name.
const Seat = "mesh-config"
// Form is the form of the seat's values, events and answers this contract was generated at (design 47 H2 §780):
// a reader of a value of another form says "form N, this reader knows M".
const Form = 1
// The forms and the digest of the fields this contract was generated from: the generator's compare fails a definition
// whose fields changed while its forms did not (design 47 H2 §780).
const (
generatedForms = "1"
generatedFieldsDigest = "ConfigAnswer=7538f2f5e68e RenamedHolderEvent=2f967997d9d0 RenamesAnswer=a8330ea7ee28 RenamesAnswerRenamesItem=7aa33a125ed8 ResolvedByNodeModuleKeyValue=6543f47665e3 RetiredHolderEvent=55e7aa07f9f5 RetiringHolderEvent=82baafab643b"
)
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>" as another part wrote it: a field ResolvedByNodeModuleKeyValue does not know is left unread, never refused; the form read is answered, 1 when absent (design 47 H2 §780).
func DecodeResolvedByNodeModuleKeyValue(raw []byte) (ResolvedByNodeModuleKeyValue, int, error) {
var v ResolvedByNodeModuleKeyValue
if err := json.Unmarshal(raw, &v); err != nil {
return v, 0, err
}
return v, formRead(raw), 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 {
// is the form of what this value carries, left out while it is 1 (design 47 H2 §780).
Form int64 `json:"form,omitempty"`
// 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"`
// is the form of what this value carries, left out while it is 1 (design 47 H2 §780).
Form int64 `json:"form,omitempty"`
// 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"`
// is the form of what this value carries, left out while it is 1 (design 47 H2 §780).
Form int64 `json:"form,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"`
// is the form of what this value carries, left out while it is 1 (design 47 H2 §780).
Form int64 `json:"form,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 {
// is the form of what this value carries, left out while it is 1 (design 47 H2 §780).
Form int64 `json:"form,omitempty"`
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"`
}
// DecodeConfigAnswer reads a ConfigAnswer as another part wrote it: a field this reader does not know is left unread, never refused; the form read is answered, 1 when absent (design 47 H2 §780).
func DecodeConfigAnswer(raw []byte) (ConfigAnswer, int, error) {
var v ConfigAnswer
if err := json.Unmarshal(raw, &v); err != nil {
return v, 0, err
}
return v, formRead(raw), nil
}
// DecodeRenamesAnswer reads a RenamesAnswer as another part wrote it: a field this reader does not know is left unread, never refused; the form read is answered, 1 when absent (design 47 H2 §780).
func DecodeRenamesAnswer(raw []byte) (RenamesAnswer, int, error) {
var v RenamesAnswer
if err := json.Unmarshal(raw, &v); err != nil {
return v, 0, err
}
return v, formRead(raw), nil
}
// DecodeRenamedHolderEvent reads a RenamedHolderEvent as another part wrote it: a field this reader does not know is left unread, never refused; the form read is answered, 1 when absent (design 47 H2 §780).
func DecodeRenamedHolderEvent(raw []byte) (RenamedHolderEvent, int, error) {
var v RenamedHolderEvent
if err := json.Unmarshal(raw, &v); err != nil {
return v, 0, err
}
return v, formRead(raw), nil
}
// DecodeRetiringHolderEvent reads a RetiringHolderEvent as another part wrote it: a field this reader does not know is left unread, never refused; the form read is answered, 1 when absent (design 47 H2 §780).
func DecodeRetiringHolderEvent(raw []byte) (RetiringHolderEvent, int, error) {
var v RetiringHolderEvent
if err := json.Unmarshal(raw, &v); err != nil {
return v, 0, err
}
return v, formRead(raw), nil
}
// DecodeRetiredHolderEvent reads a RetiredHolderEvent as another part wrote it: a field this reader does not know is left unread, never refused; the form read is answered, 1 when absent (design 47 H2 §780).
func DecodeRetiredHolderEvent(raw []byte) (RetiredHolderEvent, int, error) {
var v RetiredHolderEvent
if err := json.Unmarshal(raw, &v); err != nil {
return v, 0, err
}
return v, formRead(raw), nil
}
// formRead is the form a value says on the wire: 1 when it says none, or is no object.
func formRead(raw []byte) int {
var f struct {
Form int `json:"form"`
}
if json.Unmarshal(raw, &f) != nil || f.Form < 1 {
return 1
}
return f.Form
}