surface

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const ConfigFile = "specrig.yaml"

ConfigFile holds what a record cannot learn from the code, at the service's root.

View Source
const Format = "surface/1"

Format is what this package writes under specrig: and the newest it reads.

Variables

View Source
var ErrForeign = errors.New("not a specrig record")

ErrForeign is a file at a record's path that does not say it is one.

View Source
var File = filepath.Join("tests", "surface.yaml")

File is where a service keeps its record, from the module root.

Functions

func Identify

func Identify(body []byte, format string) error

Identify checks that body says it is a record of format, as an OpenAPI document says so under openapi:.

func Receivers

func Receivers(set []Surface, from, kind, name string) (exact, wild []string)

func Senders

func Senders(set []Surface, to, kind, name string) []string

For HTTP, name is a route of service to, where Receivers takes a request.

Types

type Config

type Config struct {
	Clients  map[string]string `yaml:"clients"`
	Prefixes []string          `yaml:"prefixes"`
}

func LoadConfig

func LoadConfig(dir string) (Config, error)

func (Config) Validate

func (c Config) Validate() error

type Report

type Report struct {
	Unconsumed  []string `yaml:"unconsumed,omitempty"`
	Unpublished []string `yaml:"unpublished,omitempty"`
	Unserved    []string `yaml:"unserved,omitempty"`
	Uncalled    []string `yaml:"uncalled,omitempty"`
	Ambiguous   []string `yaml:"ambiguous,omitempty"`
	Hostless    []string `yaml:"hostless,omitempty"`
	Needless    []string `yaml:"needless,omitempty"`

	PatternOnly []string `yaml:"pattern_only,omitempty"`
	Loops       []string `yaml:"loops,omitempty"`
	Outside     []string `yaml:"outside,omitempty"`
}

func Verify

func Verify(set []Surface) (Report, error)

func (Report) Failed

func (r Report) Failed() bool

func (Report) String

func (r Report) String() string

type Surface

type Surface struct {
	Specrig   string              `yaml:"specrig"`
	Service   string              `yaml:"service"`
	Publishes []string            `yaml:"publishes,omitempty"`
	Consumes  []string            `yaml:"consumes,omitempty"`
	Serves    []string            `yaml:"serves,omitempty"`
	Calls     []string            `yaml:"calls,omitempty"`
	Clients   map[string][]string `yaml:"clients,omitempty"`
	// Calls between the module's own domains: a modular monolith's links.
	Domains []string `yaml:"domains,omitempty"`
	// From the service's specrig.yaml, not its code.
	Hosts map[string]string `yaml:"-"`
}

func Read

func Read(file string) (Surface, error)

func (Surface) Encode

func (s Surface) Encode() []byte

Jump to

Keyboard shortcuts

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