Documentation
¶
Overview ¶
Package model resolves a validated spec against the catalog into the resolved model: every default applied, edges derived from uses, listeners chosen, and private segments computed for plaintext edges. Every output is generated from this model.
Index ¶
- Constants
- func HostName(label, experiment string) string
- func SegmentFQDN(service, domain string) string
- type Edge
- type Kind
- type Model
- func (m *Model) EdgesFrom(name string) []Edge
- func (m *Model) HostRouter() (*Service, bool)
- func (m *Model) Instances(app string) []*Service
- func (m *Model) PlaintextEdges() []Edge
- func (m *Model) Segment(target string) (Segment, bool)
- func (m *Model) SegmentsOf(name string) []Segment
- func (m *Model) Service(name string) (*Service, bool)
- type Segment
- type Service
Constants ¶
const ( DefaultAppMemory = "256m" DefaultAppCPUs = "0.5" // Used when an app opts into an HTTP health check with `health`. DefaultAppHealthPath = "/healthz" DefaultAppHealthPort = spec.DefaultHealthPort )
Defaults for app services.
const ( DiscoveryRegistry = "registry" DiscoveryRoute = "route" )
Discovery values.
Variables ¶
This section is empty.
Functions ¶
func HostName ¶
HostName is a host name for a target or instance label: <label>.<experiment>.localhost.
func SegmentFQDN ¶
SegmentFQDN is a service's alias on its private segment.
Types ¶
type Edge ¶
type Edge struct {
From string
To string
Listener string
Port int
TLS bool
Reason string // why the edge is plaintext
// Via is the name (within the app) of the Envoy sidecar whose outbound
// listener carries the edge; empty for an edge from uses.
Via string
// ToApp marks an edge whose target is an app (all its replicas).
ToApp bool
// Mode is set on a proxy's upstream edges: spec.TLSOn (re-encrypt),
// spec.TLSOff (terminate) or spec.TLSPassthrough. From is the proxy.
Mode string
// Discovery is set on the edges of a proxy that discovers routes in a
// service registry (D-225): DiscoveryRegistry to the registry, and
// DiscoveryRoute to each app registered there for the proxy.
Discovery string
}
Edge is a directed connection from an app (by its name in experiment.yaml) to an infra listener, through an Envoy sidecar to another app or an infra service, or from a proxy to one of its upstreams, to the registry it discovers routes in, or to an app it finds there.
type Kind ¶
type Kind string
Kind separates catalog infrastructure from user code.
const ( // Infra is a service from the infrastructure catalog. Infra Kind = "infra" // App is the user's own program. App Kind = "app" // Sidecar runs in an app instance's network namespace and uses its // certificate: a type from the sidecar catalog, or the agent that // registers the app with a service registry (consul-agent). Sidecar Kind = "sidecar" )
type Model ¶
type Model struct {
Name string
Domain string
Project string // compose project name: bb-<name>
Services []*Service
Edges []Edge
Segments []Segment
}
Model is a fully resolved experiment.
func (*Model) HostRouter ¶
HostRouter returns the lab's host router, if it has one.
func (*Model) PlaintextEdges ¶
PlaintextEdges lists edges that deliberately skip TLS.
func (*Model) SegmentsOf ¶
SegmentsOf lists the segments a service belongs to, as target or client.
type Segment ¶
type Segment struct {
Name string // compose network name, e.g. plain-postgres
Target string // an infra service, or an app (every replica joins)
Clients []string
Reasons []string
// Port is the plaintext port an app target listens on (it receives
// BB_PLAIN_LISTEN_ADDR); zero for an infra target, whose catalog
// entry binds its own plaintext listener.
Port int
}
Segment is a private network shared by a plaintext listener and its clients.
type Service ¶
type Service struct {
Name string
Kind Kind
FQDN string
Identity string
Resources catalog.Resources
// Image is the container image: the exact pin for infra and sidecars;
// empty for apps, which are built from their directory.
Image string
// Aliases are the DNS names on the default network and on the
// service's certificate (infra and apps): the FQDN, plus the app's
// shared name for a replica.
Aliases []string
// Infra only.
Entry *catalog.Entry
Config map[string]string
// Upstreams are a proxy's resolved backends, in spec order.
Upstreams []catalog.Upstream
// File is a proxy's user-owned config, relative to experiment.yaml.
File string
// StaticFile is a proxy's user-owned static configuration, relative
// to experiment.yaml, merged into its generated one.
StaticFile string
// HostRouter marks the engine-owned host router (spec.HostRouterName),
// an infra service of type traefik; HostTargets are what it serves,
// in route order (ADR-0017).
HostRouter bool
HostTargets []catalog.HostTarget
// App only.
App *spec.App
// Health is the app's HTTP health check, or nil for the default check
// that the container's main process is running. Apps need no health code.
Health *spec.Health
// AppName is the app in experiment.yaml this instance belongs to; it
// equals Name for an app with one replica.
AppName string
// Instance is 1…N for a replica, 0 for an app with one replica.
Instance int
SharedFQDN string
// Pod is the service name of the instance's namespace holder, or empty
// when the app keeps its own namespace (no sidecars).
Pod string
// Netinit is the service name of the pod's init container, which
// installs its traffic rules (transparent mode, the plaintext guard of
// a terminate target), or empty.
Netinit string
// Transparent is set when an Envoy sidecar captures the instance's
// traffic.
Transparent bool
// PlainGuard is set when the instance is the target of a terminating
// proxy: it runs as a pod, and its netinit confines the plaintext port
// to the instance's segment address.
PlainGuard bool
// Sidecars are the instance's sidecar service names, in spec order
// (the registration agent last).
Sidecars []string
// Sidecar only. For consul-agent, Entry is the registry's catalog entry.
Parent string // the app instance whose namespace it shares
SidecarType *sidecar.Type // its sidecar catalog type
Sidecar *spec.Sidecar // the declared entry, defaults applied; nil for consul-agent
Targets []sidecar.Target // Envoy outbound targets
Registry string // consul-agent: the registry service it joins
Register *spec.Register // consul-agent: what it registers, defaults applied
}
Service is an infra or app service with everything defaulted.