Documentation
¶
Overview ¶
Package topicschema holds MCP event definitions, in the MCP events/list format. A Catalog is built once at startup from the definitions, and is immutable afterwards, so it is safe for concurrent reads.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Argument ¶
type Argument struct {
Name string
// Types is a sorted, non-empty subset of string, number, integer, boolean.
Types []string
}
Argument describes one subscription argument: a top-level payload property matched by equality.
type Catalog ¶
type Catalog struct {
// contains filtered or unexported fields
}
Catalog is the immutable, compiled set of event definitions. It is safe for concurrent use: nothing in it changes after NewCatalog returns, and validating against a compiled schema doesn't modify it. Returned schemas and events share the catalog's memory and must not be modified.
func NewCatalog ¶
func NewCatalog(topics []string, defs Definitions) (*Catalog, error)
NewCatalog validates defs and compiles their schemas. When topics, the TOPICS list, is not empty, every event must be in it. The problems found are reported at once in a *ConfigError, up to 100 of them.
type ConfigError ¶
type ConfigError struct {
Problems []string
}
ConfigError aggregates every problem found in event definition configuration, so a startup failure reports all of them at once.
func (*ConfigError) Error ¶
func (e *ConfigError) Error() string
type Definition ¶
type Definition struct {
Name string `json:"name"`
Description string `json:"description,omitempty"`
// InputSchema is a JSON Schema 2020-12 object describing the
// subscription arguments. Empty means every scalar top-level payload
// property is an optional argument.
InputSchema json.RawMessage `json:"inputSchema,omitempty"`
// PayloadSchema is a JSON Schema 2020-12 document for the event data.
PayloadSchema json.RawMessage `json:"payloadSchema,omitempty"`
// Delivery lists the delivery modes; empty means unspecified.
Delivery []string `json:"delivery,omitempty"`
Meta json.RawMessage `json:"_meta,omitempty"`
}
Definition is one event's definition, as an entry of an events/list result.
type Definitions ¶
type Definitions []Definition
Definitions are the event definitions in configured order.
func ParseDefinitions ¶
func ParseDefinitions(data []byte) (Definitions, error)
ParseDefinitions parses event definitions in the MCP events/list format, a YAML or JSON object with an events list, from a file. Unknown fields and duplicate keys are errors. Schemas are kept as compact JSON in document order. Errors are a *ConfigError naming the event and the JSON pointer of each problem.
func ParseDefinitionsJSON ¶
func ParseDefinitionsJSON(data []byte) (Definitions, error)
ParseDefinitionsJSON parses event definitions from a JSON document, as ParseDefinitions does for YAML.
func ParseDefinitionsNode ¶
func ParseDefinitionsNode(n *yaml.Node) (Definitions, error)
ParseDefinitionsNode parses event definitions from a YAML node, as ParseDefinitions does. Scalars follow the YAML 1.2 core schema, so dates and other timestamps stay strings.
type Event ¶
type Event struct {
Name string
Description string
InputSchema json.RawMessage
// PayloadSchema is the payload schema as configured.
PayloadSchema json.RawMessage
// JSON is the full entry: name, description, delivery, inputSchema,
// payloadSchema and _meta.
JSON json.RawMessage
}
Event is one precomputed events/list entry.