Documentation
¶
Overview ¶
Package contracts holds rig's contracts: the named sources and actions a plugin provides to stand in for a kind of tool (metrics/1, scm/1, ...), with their arguments and frame fields, a conformance check, bridges that let a plugin serve rig's built-in screens, and standard views.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Bridge ¶
Bridge is component, served by plugin through the contract for kind, as the core interface that kind's screens and commands use. Every call carries the component's name, so one plugin can serve several components. The bridge has every optional interface of the kind, and core.As admits only those whose capability pr provides.
Types ¶
type ActionFunc ¶
type Caller ¶
type Caller interface {
Query(ctx context.Context, name string, args protocol.Args) (*protocol.Frame, error)
Run(ctx context.Context, name string, args protocol.Args, dryRun bool) (*protocol.RunResult, error)
Stream(ctx context.Context, name string, args protocol.Args) (<-chan protocol.StreamBatch, error)
}
Caller reaches a plugin's sources and actions by their namespaced names: the plugin host.
type Capability ¶
Capability is an optional group of sources and actions a plugin provides all of or none.
type Captured ¶
Captured is the command an attach would have run on a terminal, caught instead of run.
type Contract ¶
type Contract struct {
ID string `yaml:"contract"`
Kind string `yaml:"kind"`
Description string `yaml:"description"`
Sources map[string]Source `yaml:"sources"`
Actions map[string]Action `yaml:"actions"`
Caps map[string]Capability `yaml:"capabilities"`
// View is the standard view's YAML, for contracts no built-in screen shows.
View []byte `yaml:"-"`
}
Contract is one contract version. Args and fields map a name to a protocol type; an arg type ending in ! is required.
func ForKind ¶
ForKind is the contract that stands in for a component kind (runtime, metrics, ...), or nil.
func (*Contract) ArgsSchema ¶
ArgsSchema is the JSON Schema of a source's or action's arguments, as a plugin declares them.
func (*Contract) Check ¶
Check compares what a plugin says it provides with c: every source and action outside a capability is there, streams stream, and a capability is all there or not at all.
func (*Contract) CheckFrames ¶
func (c *Contract) CheckFrames(ctx context.Context, q Querier, plugin string, p *protocol.Provides) []Problem
CheckFrames queries every source p provides that needs no arguments and checks the frame's fields: each one the contract names is present with its type (a plugin may add more).
type Lookup ¶
type Lookup struct {
Component func(ctx context.Context, name string) (any, error)
Service func(name string) (*spec.Service, error)
}
Lookup finds what a call names: its component (args.component) and services.
type Problem ¶
type Problem struct {
Name, Text string
}
Problem is one way a plugin falls short of a contract.
type Querier ¶
type Querier interface {
Query(ctx context.Context, name string, args protocol.Args) (*protocol.Frame, error)
}
Querier is what a live check calls: the host, with names already namespaced by the plugin.
type Served ¶
type Served struct {
Contract *Contract
Sources map[string]SourceFunc
Streams map[string]StreamFunc
Actions map[string]ActionFunc
Effects map[string]string
}
Served is a component kind's side of its contract, the reverse of Bridge: what a plugin registers (names without the plugin prefix) to stand in for components it builds in-process.