Files
mesh-contracts/go/seats/meshbroker/contract.go
T
jschoubben ed12ffb387 mesh-broker's Binding is the wire form and Held carries it, so list, show and orphans answer the binding
The seat's Binding takes the fields the events carry and the membership holds
(local, storage, template, stream, subject, bucket, object-store, history,
state, indexes, snapshot, types): one form in the events, in list, show and
orphans. Held gains binding, present on an entry the bus holds. Definition,
fixture and generated Go and TypeScript contract.

Builds: design 25 bindings-first-view §2, §7 (hq d0760629, PR 543)

Claude-Session: https://claude.ai/code/session_01JG73KEq4zoDfM9WtYpcQgZ
2026-11-11 10:14:55 +01:00

385 lines
12 KiB
Go

// Code generated by seatgen from the seat definitions; DO NOT EDIT.
// Package meshbroker is the contract of the seat "mesh-broker", defined whole (seats/mesh-broker/seat.json): The mesh's bus, and the bus state modules ask of it in requires (design 25 § 12). create, apply, recreate and drop are granted to the bus module's own credential alone.
package meshbroker
// Seat is the seat's name.
const Seat = "mesh-broker"
const (
VerbList = "list"
VerbShow = "show"
VerbCheck = "check"
VerbOrphans = "orphans"
VerbCreate = "create"
VerbApply = "apply"
VerbRecreate = "recreate"
VerbDrop = "drop"
)
const (
EventCreated = "created"
EventRefused = "refused"
EventDrifted = "drifted"
EventDriftCleared = "drift-cleared"
EventFull = "full"
EventFullCleared = "full-cleared"
EventOrphaned = "orphaned"
EventRecreated = "recreated"
EventDropped = "dropped"
)
// Verbs is every verb the seat serves, in its definition's order: a new copy each call.
func Verbs() []string {
return []string{VerbList, VerbShow, VerbCheck, VerbOrphans, VerbCreate, VerbApply, VerbRecreate, VerbDrop}
}
// Events is every event published on the seat's subject: a new copy each call.
func Events() []string {
return []string{EventCreated, EventRefused, EventDrifted, EventDriftCleared, EventFull, EventFullCleared, EventOrphaned, EventRecreated, EventDropped}
}
// Family is where the seat's events are kept: the shared events stream, filtered to the seat's subjects.
const (
Family = "mesh-broker.events"
FamilyMaxAgeDays = 7
)
// SubjectCreated is where created is published.
const SubjectCreated = "mesh.seat.mesh-broker.event.created"
// SubjectRefused is where refused is published.
const SubjectRefused = "mesh.seat.mesh-broker.event.refused"
// SubjectDrifted is where drifted is published.
const SubjectDrifted = "mesh.seat.mesh-broker.event.drifted"
// SubjectDriftCleared is where drift-cleared is published.
const SubjectDriftCleared = "mesh.seat.mesh-broker.event.drift-cleared"
// SubjectFull is where full is published.
const SubjectFull = "mesh.seat.mesh-broker.event.full"
// SubjectFullCleared is where full-cleared is published.
const SubjectFullCleared = "mesh.seat.mesh-broker.event.full-cleared"
// SubjectOrphaned is where orphaned is published.
const SubjectOrphaned = "mesh.seat.mesh-broker.event.orphaned"
// SubjectRecreated is where recreated is published.
const SubjectRecreated = "mesh.seat.mesh-broker.event.recreated"
// SubjectDropped is where dropped is published.
const SubjectDropped = "mesh.seat.mesh-broker.event.dropped"
// Binding is the binding a module receives in its membership for one entry (ADR 0595 §1, §7): the names on the bus of the entry's objects, one form in the events, in list, show and orphans, and in the membership.
type Binding struct {
// a key-value bucket's name
Bucket string `json:"bucket,omitempty"`
// a ledger's history stream
History string `json:"history,omitempty"`
// a ledger's index buckets, by index name
Indexes map[string]string `json:"indexes,omitempty"`
// the entry's local name in the module's manifest
Local string `json:"local"`
// an object store's name
ObjectStore string `json:"object-store,omitempty"`
// the subject of a ledger's instances' snapshots
Snapshot string `json:"snapshot,omitempty"`
// a ledger's state bucket
State string `json:"state,omitempty"`
// how the bus keeps it: the entry's storage type
Storage string `json:"storage"`
// a stream's name on the bus
Stream string `json:"stream,omitempty"`
// the subject a stream's messages are on; also a ledger's history's
Subject string `json:"subject,omitempty"`
// its template
Template string `json:"template,omitempty"`
// a ledger's types, as its manifest declares them
Types []map[string]any `json:"types,omitempty"`
}
// Entry is one piece of bus state as a manifest asks it.
type Entry struct {
// its own configuration, where no template fits
Configuration map[string]any `json:"configuration,omitempty"`
// its local name in the module's manifest
LocalName string `json:"local-name"`
// the module asking it
Module string `json:"module"`
// the template's options the module set, within their bounds
Options map[string]any `json:"options,omitempty"`
// how the bus keeps it
StorageType string `json:"storage-type"`
// its template; empty for a configuration of its own
Template string `json:"template,omitempty"`
}
// The values of Entry's storage-type.
const (
EntryStorageTypeStream = "stream"
EntryStorageTypeKeyValue = "key-value"
EntryStorageTypeObjectStore = "object-store"
EntryStorageTypeLedger = "ledger"
)
// The values of Entry's template.
const (
EntryTemplateState = "state"
EntryTemplateEvents = "events"
EntryTemplateWorkQueue = "work-queue"
EntryTemplateLog = "log"
EntryTemplateObjects = "objects"
EntryTemplateLedger = "ledger"
EntryTemplate = ""
)
// Fill is a type of the contract.
type Fill struct {
// bytes held
Bytes int64 `json:"bytes"`
// its cap in bytes
Cap int64 `json:"cap"`
// messages, keys or objects held
Count int64 `json:"count"`
}
// Held is one entry as the bus holds it.
type Held struct {
// the binding a module receives for the entry, as created and recreated carry it; present on an entry whose objects the bus holds, absent on one it does not (design 25 bindings-first-view §2)
Binding *Binding `json:"binding,omitempty"`
// its name on the bus, <module>_<local name>
BusName string `json:"bus-name"`
// its own configuration, where no template fits
Configuration map[string]any `json:"configuration,omitempty"`
Fill *Fill `json:"fill,omitempty"`
// its local name in the module's manifest
LocalName string `json:"local-name"`
// the module asking it
Module string `json:"module"`
// the template's options the module set, within their bounds
Options map[string]any `json:"options,omitempty"`
// the settings the bus holds
Settings map[string]any `json:"settings,omitempty"`
// the entry's state: held as asked, refused, waiting to be made, drifted from what is asked, full, or orphaned (no manifest asks it)
State string `json:"state,omitempty"`
// how the bus keeps it
StorageType string `json:"storage-type"`
// its template; empty for a configuration of its own
Template string `json:"template,omitempty"`
// why it is in its state, in plain words; empty when held as asked
Why string `json:"why,omitempty"`
}
// The values of Held's state.
const (
HeldStateHeld = "held"
HeldStateRefused = "refused"
HeldStateWaiting = "waiting"
HeldStateDrifted = "drifted"
HeldStateFull = "full"
HeldStateOrphaned = "orphaned"
)
// The values of Held's storage-type.
const (
HeldStorageTypeStream = "stream"
HeldStorageTypeKeyValue = "key-value"
HeldStorageTypeObjectStore = "object-store"
HeldStorageTypeLedger = "ledger"
)
// The values of Held's template.
const (
HeldTemplateState = "state"
HeldTemplateEvents = "events"
HeldTemplateWorkQueue = "work-queue"
HeldTemplateLog = "log"
HeldTemplateObjects = "objects"
HeldTemplateLedger = "ledger"
HeldTemplate = ""
)
// Named is a type of the contract.
type Named struct {
// the entry's local name
LocalName string `json:"local-name"`
// the module
Module string `json:"module"`
}
// Said is the body of every event of the seat.
type Said struct {
// the settings asked
Asked map[string]any `json:"asked,omitempty"`
Binding *Binding `json:"binding,omitempty"`
// its name on the bus
BusName string `json:"bus-name"`
// its own configuration, where no template fits
Configuration map[string]any `json:"configuration,omitempty"`
Fill *Fill `json:"fill,omitempty"`
// the settings held
Held map[string]any `json:"held,omitempty"`
// its local name in the module's manifest
LocalName string `json:"local-name"`
// the module asking it
Module string `json:"module"`
// the template's options the module set, within their bounds
Options map[string]any `json:"options,omitempty"`
// the indexer's revision of the verdict the bus module acted on (ADR 0622 §2), so a reader orders what it hears
Revision int64 `json:"revision,omitempty"`
// the stream snapshot taken before a recreate or drop
Snapshot string `json:"snapshot,omitempty"`
// how the bus keeps it
StorageType string `json:"storage-type,omitempty"`
// its template; empty for a configuration of its own
Template string `json:"template,omitempty"`
// why: a refusal's cause, a drift's difference, a drop's or recreate's reason
Why string `json:"why,omitempty"`
}
// The values of Said's storage-type.
const (
SaidStorageTypeStream = "stream"
SaidStorageTypeKeyValue = "key-value"
SaidStorageTypeObjectStore = "object-store"
SaidStorageTypeLedger = "ledger"
)
// The values of Said's template.
const (
SaidTemplateState = "state"
SaidTemplateEvents = "events"
SaidTemplateWorkQueue = "work-queue"
SaidTemplateLog = "log"
SaidTemplateObjects = "objects"
SaidTemplateLedger = "ledger"
SaidTemplate = ""
)
// Warranted is a type of the contract.
type Warranted struct {
// the entry's local name
LocalName string `json:"local-name"`
// the module
Module string `json:"module"`
// the operator's warrant, as the operator channel decided it (ADR 0259 §6)
Warrant string `json:"warrant"`
// why, kept in the record
Why string `json:"why"`
}
// ListInput is what list takes.
type ListInput struct {
// one module (optional)
Module string `json:"module,omitempty"`
}
// ListAnswer is what list answers.
type ListAnswer struct {
// every entry
Entries []Held `json:"entries"`
}
// ShowInput is what show takes.
type ShowInput = Named
// ShowAnswer is what show answers.
type ShowAnswer = Held
// CheckInput is what check takes.
type CheckInput struct {
// one module (optional)
Module string `json:"module,omitempty"`
}
// CheckAnswerDifferencesItem is a type of the contract.
type CheckAnswerDifferencesItem struct {
// asked
Asked map[string]any `json:"asked,omitempty"`
// the difference only grows: apply may act on it
Grows bool `json:"grows,omitempty"`
// held
Held map[string]any `json:"held,omitempty"`
// the entry
LocalName string `json:"local-name"`
// the module
Module string `json:"module"`
}
// CheckAnswer is what check answers.
type CheckAnswer struct {
// every difference
Differences []CheckAnswerDifferencesItem `json:"differences"`
}
// OrphansInput is what orphans takes.
type OrphansInput struct {
}
// OrphansAnswer is what orphans answers.
type OrphansAnswer struct {
// every orphan
Entries []Held `json:"entries"`
}
// CreateInput is what create takes.
type CreateInput = Entry
// CreateAnswer is what create answers.
type CreateAnswer = Held
// ApplyInput is what apply takes.
type ApplyInput = Named
// ApplyAnswer is what apply answers.
type ApplyAnswer = Held
// RecreateInput is what recreate takes.
type RecreateInput = Warranted
// RecreateAnswer is what recreate answers.
type RecreateAnswer = Held
// DropInput is what drop takes.
type DropInput = Warranted
// DropAnswer is what drop answers.
type DropAnswer struct {
// it is gone
Dropped bool `json:"dropped"`
// the snapshot taken first
Snapshot string `json:"snapshot,omitempty"`
}
// CreatedEvent is the body of the event created.
type CreatedEvent = Said
// RefusedEvent is the body of the event refused.
type RefusedEvent = Said
// DriftedEvent is the body of the event drifted.
type DriftedEvent = Said
// DriftClearedEvent is the body of the event drift-cleared.
type DriftClearedEvent = Said
// FullEvent is the body of the event full.
type FullEvent = Said
// FullClearedEvent is the body of the event full-cleared.
type FullClearedEvent = Said
// OrphanedEvent is the body of the event orphaned.
type OrphanedEvent = Said
// RecreatedEvent is the body of the event recreated.
type RecreatedEvent = Said
// DroppedEvent is the body of the event dropped.
type DroppedEvent = Said
// BusStateForm is the form of the provision bus-state.
type BusStateForm = Binding