rpcschema

package
v0.11.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 18, 2026 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Overview

Package rpcschema is the schema snapshot of the functions an app serves to other apps: the input and output type of each function, and the number each field of those types has on the wire. An app's own snapshot is .aicoded/rpc.json; an app that calls it holds a copy in .aicoded/services/<app>.json.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Break

type Break struct {
	Method, Path, Reason string
}

Break is one change in a schema that breaks calls made with an older snapshot of it. Path is the field, such as GetInvoiceIn.Lines[].Amount; it is empty for a removed function.

func Compatible

func Compatible(held, current Schema) []Break

Compatible returns the changes in current that break calls made with the snapshot held: a removed function, and any field reachable from a function's input or output that was removed, renamed, renumbered or given another type. Added functions and fields break nothing. Type names may change. The breaks are sorted by function, then path.

type Field

type Field struct {
	Number int    `json:"number"`
	Type   string `json:"type"`
}

Field is one field of a type. Type is bool, int32, int64, uint32, uint64, float32, float64, string, bytes, time or the name of a type of the schema; "[]" and one of those for a slice; or "*" and one of those except bytes for an optional value.

type Method

type Method struct {
	In  string `json:"in"`
	Out string `json:"out"`
}

Method is one function: the names of its input and output types.

type Schema

type Schema struct {
	App     string            `json:"app"`
	Methods map[string]Method `json:"methods"`
	Types   map[string]Type   `json:"types"`
}

Schema is the snapshot of one app's functions.

func Load

func Load(path string) (Schema, error)

Load reads and parses the snapshot at path.

func Number

func Number(prev *Schema, fresh Schema) Schema

Number returns fresh with its field numbers set; fresh's own numbers are ignored. A field keeps the number prev gives it under the same type and field name. A new field gets one more than the highest number its type has ever used. The number of a field prev has and fresh does not is retired for good. Types no function reaches are left out. prev may be nil.

func Parse

func Parse(path string, data []byte) (Schema, error)

Parse reads the snapshot data, read from path. It refuses anything aicoded does not write with E-RPC-005 at path:line: invalid JSON, an unknown or repeated key, a missing or invalid name, a bad type, a reference to a type the snapshot does not have, and a field number that is not valid, is used twice in a type or is also retired.

func (Schema) Marshal

func (s Schema) Marshal() []byte

Marshal returns s as aicoded writes it: keys sorted, indented by two spaces, with a trailing newline.

type Type

type Type struct {
	Fields  map[string]Field `json:"fields"`
	Retired []int            `json:"retired,omitempty"`
}

Type is a struct type: its fields by name, and the numbers of its removed fields, which are never used again.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL