Documentation
¶
Overview ¶
Package core is Breadboard's engine API. Every capability is one method on Engine, taking a context and a request struct and returning a result struct and an error. The CLI, the web UI, and the MCP server are thin wrappers over these methods.
The core never prints, reads stdin, parses flags, or exits. Long operations report progress through an EventSink, streams are iterators, and failures a wrapper must react to are sentinel errors matched with errors.Is.
Index ¶
- Constants
- Variables
- type AddAppRequest
- type AddAppResult
- type AddServiceRequest
- type AddServiceResult
- type AppUse
- type ApplyStarterRequest
- type ApplyStarterResult
- type CAInfo
- type CAResult
- type CatalogEntry
- type CatalogResult
- type Certificate
- type ConfigGetRequest
- type ConfigResult
- type ConfigSetRequest
- type ConfigSetResult
- type ConsulCatalog
- type ConsulNode
- type ConsulService
- type CredsRequest
- type CredsResult
- type DownRequest
- type DownResult
- type Edge
- type Engine
- func (e *Engine) AddApp(ctx context.Context, req AddAppRequest) (*AddAppResult, error)
- func (e *Engine) AddService(_ context.Context, req AddServiceRequest) (*AddServiceResult, error)
- func (e *Engine) ApplyStarter(ctx context.Context, req ApplyStarterRequest) (*ApplyStarterResult, error)
- func (e *Engine) CA(ctx context.Context) (*CAResult, error)
- func (e *Engine) Catalog(_ context.Context) (*CatalogResult, error)
- func (e *Engine) ConfigGet(ctx context.Context, req ConfigGetRequest) (*ConfigResult, error)
- func (e *Engine) ConfigSet(ctx context.Context, req ConfigSetRequest) (*ConfigSetResult, error)
- func (e *Engine) ConsulCatalog(ctx context.Context, req ExploreRequest) (*ConsulCatalog, error)
- func (e *Engine) Creds(ctx context.Context, req CredsRequest) (*CredsResult, error)
- func (e *Engine) Down(ctx context.Context, req DownRequest) (*DownResult, error)
- func (e *Engine) EnvoyClusters(ctx context.Context, req ExploreRequest) (*EnvoyClusters, error)
- func (e *Engine) ExportCompose(ctx context.Context, req ExportComposeRequest) (*ExportComposeResult, error)
- func (e *Engine) HAProxyStats(ctx context.Context, req ExploreRequest) (*HAProxyStats, error)
- func (e *Engine) Init(ctx context.Context, req InitRequest) (*InitResult, error)
- func (e *Engine) KafkaTopics(ctx context.Context, req ExploreRequest) (*KafkaOverview, error)
- func (e *Engine) Learn(_ context.Context, req LearnRequest) (*LearnResult, error)
- func (e *Engine) Logs(ctx context.Context, req LogsRequest) (iter.Seq2[LogLine, error], error)
- func (e *Engine) Migrate(_ context.Context, req MigrateRequest) (*MigrateResult, error)
- func (e *Engine) NginxStatus(ctx context.Context, req ExploreRequest) (*NginxStatus, error)
- func (e *Engine) OpenSearchIndices(ctx context.Context, req ExploreRequest) (*OpenSearchOverview, error)
- func (e *Engine) OtelTelemetry(ctx context.Context, req ExploreRequest) (*OtelTelemetry, error)
- func (e *Engine) PgBouncerPools(ctx context.Context, req ExploreRequest) (*PgBouncerPools, error)
- func (e *Engine) PostgresTables(ctx context.Context, req ExploreRequest) (*PostgresTables, error)
- func (e *Engine) RedisKeys(ctx context.Context, req ExploreRequest) (*RedisKeys, error)
- func (e *Engine) RemoveService(_ context.Context, req RemoveServiceRequest) (*RemoveServiceResult, error)
- func (e *Engine) S3Buckets(ctx context.Context, req ExploreRequest) (*S3Buckets, error)
- func (e *Engine) ServiceDetails(ctx context.Context, req ServiceDetailsRequest) (*ServiceDetails, error)
- func (e *Engine) StartStatsSampler(ctx context.Context) (stop func())
- func (e *Engine) StarterDetails(ctx context.Context, req StarterDetailsRequest) (*StarterDetails, error)
- func (e *Engine) Starters(_ context.Context) (*StartersResult, error)
- func (e *Engine) Status(ctx context.Context, req StatusRequest) (*StatusResult, error)
- func (e *Engine) TraefikRoutes(ctx context.Context, req ExploreRequest) (*TraefikRoutes, error)
- func (e *Engine) Up(ctx context.Context, req UpRequest) (*UpResult, error)
- func (e *Engine) Version() VersionInfo
- type EnvGroup
- type EnvVar
- type EnvoyCluster
- type EnvoyClusters
- type EnvoyHost
- type EnvoyListener
- type Event
- type EventKind
- type EventSink
- type ExploreRequest
- type ExportComposeRequest
- type ExportComposeResult
- type HAProxyBackend
- type HAProxyFrontend
- type HAProxyServer
- type HAProxyStats
- type HostURL
- type InitRequest
- type InitResult
- type KafkaGroup
- type KafkaOverview
- type KafkaTopic
- type LearnRequest
- type LearnResult
- type Listener
- type LogLine
- type LogsRequest
- type MigrateRequest
- type MigrateResult
- type NginxBackend
- type NginxStatus
- type NginxUpstream
- type OpenSearchIndex
- type OpenSearchOverview
- type Options
- type OtelLog
- type OtelTelemetry
- type OtelTrace
- type PgBouncerPool
- type PgBouncerPools
- type PostgresTable
- type PostgresTables
- type ProxyUpstream
- type RedisKey
- type RedisKeys
- type RemoveServiceRequest
- type RemoveServiceResult
- type Runtime
- type S3Bucket
- type S3Buckets
- type Secret
- type ServiceCreds
- type ServiceDetails
- type ServiceDetailsRequest
- type ServiceStatus
- type Setting
- type SidecarInfo
- type SidecarPort
- type SidecarSetting
- type StarterApp
- type StarterDetails
- type StarterDetailsRequest
- type StarterFile
- type StarterInfo
- type StarterService
- type StartersResult
- type StatusRequest
- type StatusResult
- type TraefikRouter
- type TraefikRoutes
- type TraefikServer
- type TraefikService
- type UpRequest
- type UpResult
- type UpstreamInfo
- type ValidationError
- type VersionInfo
- type Violation
Constants ¶
const ( StateNotCreated = "not created" HealthHealthy = "healthy" HealthUnhealthy = "unhealthy" HealthStarting = "starting" )
Container states and health values reported in ServiceStatus.
const OtelMetricLimit = 200
OtelMetricLimit caps how many metric names the OTel explorer returns.
const RedisKeyLimit = 200
RedisKeyLimit caps how many keys the Redis explorer returns.
const S3ObjectLimit = 1000
S3ObjectLimit caps how many objects are counted per bucket.
Variables ¶
var ( ErrNotInitialized = errs.ErrNotInitialized ErrExists = errs.ErrExists ErrNotFound = errs.ErrNotFound ErrBusy = errs.ErrBusy ErrValidation = errs.ErrValidation ErrNewerFormat = errs.ErrNewerFormat ErrUnhealthy = errs.ErrUnhealthy )
Sentinel errors. Match them with errors.Is.
Functions ¶
This section is empty.
Types ¶
type AddAppRequest ¶
type AddAppRequest struct {
Dir string
Name string // the app's name: a DNS label, unused in experiment.yaml
// Uses lists the infra services the app connects to. Nil means every
// infra service in experiment.yaml; an empty, non-nil list means none.
Uses []string
// Path is the directory for the code, relative to the project. Empty
// means ./<Name>. It must not exist, or be empty.
Path string
}
AddAppRequest scaffolds the learner's own app.
type AddAppResult ¶
type AddAppResult struct {
Name string
Dir string // where the code lives, relative to the project
Command []string
Files []string // written, relative to the project
// Uses is each used service with the variables the app receives from
// it, exactly as bb up injects them. Secret values are never returned.
Uses []AppUse
}
AddAppResult reports what AddApp wrote.
type AddServiceRequest ¶
type AddServiceRequest struct {
Dir string
Type string
Name string // empty means the type id
Config map[string]string // optional type-specific config options
}
AddServiceRequest adds an infra service.
type AddServiceResult ¶
AddServiceResult names the service added.
type ApplyStarterRequest ¶
type ApplyStarterRequest struct {
Dir string
ID string
Target string // directory for the code, relative to the project; empty uses the starter's default
Events EventSink
}
ApplyStarterRequest applies a starter to the experiment.
type ApplyStarterResult ¶
type ApplyStarterResult struct {
Dir string // where the code lives, relative to the project
Written []string
Unchanged []string
Conflicts []string
AddedServices []string
AddedApps []string
ExistingApps []string // app names already present, left untouched
// ExistingServices are the starter's proxy services already present
// from an earlier apply to the same directory, left untouched.
ExistingServices []string
}
ApplyStarterResult reports what changed. Files that already exist with different content are never overwritten; they are listed as conflicts.
type CAInfo ¶
type CAInfo struct {
Name string
Domain string // the DNS domain the CA is constrained to
Subject string
NotBefore time.Time
NotAfter time.Time
Fingerprint string // SHA-256, hex
CertPath string
CertPEM []byte
Created bool
}
CAInfo describes one CA.
type CAResult ¶
type CAResult struct {
Name string
Domain string
Subject string
NotBefore time.Time
NotAfter time.Time
Fingerprint string // SHA-256, hex
CertPath string
CertPEM []byte
Created bool
// Host is the host CA, which signs only the host router's certificate
// for https://<target>.<experiment>.localhost names.
Host *CAInfo
}
CAResult describes the install CA. Its top-level fields are the lab CA, root, which signs every lab certificate; Host is the host CA.
type CatalogEntry ¶
type CatalogEntry struct {
Type string
Title string
Summary string
Image string
Ports []int
Memory string
CPUs string
Plaintext bool // whether an edge may turn TLS off
// Env names the variables an app that uses this type receives.
Env []string
}
CatalogEntry summarises an infra service type.
type CatalogResult ¶
type CatalogResult struct {
Entries []CatalogEntry
}
CatalogResult lists the catalog.
type Certificate ¶
type Certificate struct {
Issuer string
DNSNames []string
Identity string // SPIFFE URI
NotAfter time.Time
}
Certificate summarises a leaf certificate.
type ConfigGetRequest ¶
type ConfigGetRequest struct {
Key string // empty lists every setting
}
ConfigGetRequest reads settings.
type ConfigResult ¶
ConfigResult lists settings.
type ConfigSetRequest ¶
ConfigSetRequest changes a setting.
type ConfigSetResult ¶
ConfigSetResult reports the stored value. When an environment variable still overrides the file, OverriddenBy names it.
type ConsulCatalog ¶
type ConsulCatalog struct {
Services []ConsulService
Nodes []ConsulNode
}
ConsulCatalog is what the Consul server knows.
type ConsulNode ¶
ConsulNode is one agent in the cluster.
type ConsulService ¶
type ConsulService struct {
Name string
Tags []string
Instances int // instances with at least one check
Passing int
Warning int
Critical int
}
ConsulService is one registered service and the health of its instances.
type CredsRequest ¶
CredsRequest asks for generated credentials.
type CredsResult ¶
type CredsResult struct {
Services []ServiceCreds
}
CredsResult lists credentials.
type DownRequest ¶
DownRequest stops the experiment.
type DownResult ¶
DownResult reports what was stopped.
type Edge ¶
type Edge struct {
To string
Port int
TLS bool
Reason string
// Via is the Envoy sidecar (its name within the app) that carries the
// edge; empty for an edge from uses.
Via string
// ToApp marks an edge to an app; To is then the target app's name.
ToApp bool
// Mode is set on a proxy's upstream edges (Phase 5): on (re-encrypt,
// TLS), off (terminate; plaintext on a private segment) or passthrough.
Mode string
// Discovery is set on the edges of a proxy that discovers routes in a
// service registry: registry (to the registry) or route (to an app
// registered there for the proxy).
Discovery string
}
Edge is a connection from an app to a service, through an Envoy sidecar's outbound listener to another app or a service, or from a proxy to one of its upstreams.
type Engine ¶
type Engine struct {
// contains filtered or unexported fields
}
Engine is the Breadboard core.
func (*Engine) AddApp ¶
func (e *Engine) AddApp(ctx context.Context, req AddAppRequest) (*AddAppResult, error)
AddApp writes a minimal Go program into a new directory and adds it to experiment.yaml as an app with path, command and uses. The program names every variable its services give it, checks them at start, logs what it can reach, and shows how to connect to each service with its official client library. It never writes into a directory that has files.
func (*Engine) AddService ¶
func (e *Engine) AddService(_ context.Context, req AddServiceRequest) (*AddServiceResult, error)
AddService adds an infra service to experiment.yaml, keeping comments.
func (*Engine) ApplyStarter ¶
func (e *Engine) ApplyStarter(ctx context.Context, req ApplyStarterRequest) (*ApplyStarterResult, error)
ApplyStarter writes a starter's code into the project and adds its apps, its proxy services and any infra services it needs to experiment.yaml. Re-applying never overwrites user changes.
func (*Engine) CA ¶
CA returns the install CAs' details, creating either CA if needed. It never touches the host trust store.
func (*Engine) Catalog ¶
func (e *Engine) Catalog(_ context.Context) (*CatalogResult, error)
Catalog lists every infra service type.
func (*Engine) ConfigGet ¶
func (e *Engine) ConfigGet(ctx context.Context, req ConfigGetRequest) (*ConfigResult, error)
ConfigGet returns one setting or all of them.
func (*Engine) ConfigSet ¶
func (e *Engine) ConfigSet(ctx context.Context, req ConfigSetRequest) (*ConfigSetResult, error)
ConfigSet writes a setting to config.yaml.
func (*Engine) ConsulCatalog ¶
func (e *Engine) ConsulCatalog(ctx context.Context, req ExploreRequest) (*ConsulCatalog, error)
ConsulCatalog reads the catalog through the server's HTTPS API, from inside its container, verifying the certificate with the mounted CA.
func (*Engine) Creds ¶
func (e *Engine) Creds(ctx context.Context, req CredsRequest) (*CredsResult, error)
Creds returns generated credentials and connection strings, generating any that do not exist yet.
func (*Engine) Down ¶
func (e *Engine) Down(ctx context.Context, req DownRequest) (*DownResult, error)
Down stops and removes the experiment's containers and networks, and with Volumes its data.
func (*Engine) EnvoyClusters ¶
func (e *Engine) EnvoyClusters(ctx context.Context, req ExploreRequest) (*EnvoyClusters, error)
EnvoyClusters reads an Envoy's clusters, per-host health and counters, and listeners from its admin API on 127.0.0.1:15000. It takes an infra envoy service, or a sidecar as exploreSidecar finds one.
func (*Engine) ExportCompose ¶
func (e *Engine) ExportCompose(ctx context.Context, req ExportComposeRequest) (*ExportComposeResult, error)
ExportCompose writes a compose stack that runs with plain docker compose, without bb installed.
func (*Engine) HAProxyStats ¶
func (e *Engine) HAProxyStats(ctx context.Context, req ExploreRequest) (*HAProxyStats, error)
HAProxyStats reads an HAProxy service's stats page (per backend and server: status, last check, sessions, bytes) from 127.0.0.1:8404.
func (*Engine) Init ¶
func (e *Engine) Init(ctx context.Context, req InitRequest) (*InitResult, error)
Init creates experiment.yaml and .bb/ in Dir, and BB_HOME with the CA when missing. On a directory that already has experiment.yaml (a fresh clone, for example) it only restores .bb/.
func (*Engine) KafkaTopics ¶
func (e *Engine) KafkaTopics(ctx context.Context, req ExploreRequest) (*KafkaOverview, error)
KafkaTopics runs the broker's own CLI tools over TLS with the client configuration the health check uses. The three JVMs run in parallel.
func (*Engine) Learn ¶
func (e *Engine) Learn(_ context.Context, req LearnRequest) (*LearnResult, error)
Learn returns a catalog entry's learning notes.
func (*Engine) Logs ¶
Logs streams service output. The stream ends when the logs end or, with Follow, when ctx is cancelled.
func (*Engine) Migrate ¶
func (e *Engine) Migrate(_ context.Context, req MigrateRequest) (*MigrateResult, error)
Migrate rewrites experiment.yaml to the current spec version. It is the only operation that changes the file's version.
func (*Engine) NginxStatus ¶
func (e *Engine) NginxStatus(ctx context.Context, req ExploreRequest) (*NginxStatus, error)
NginxStatus reads an NGINX service's stub_status counters from 127.0.0.1:8404 and resolves its upstreams' instances.
func (*Engine) OpenSearchIndices ¶ added in v0.3.0
func (e *Engine) OpenSearchIndices(ctx context.Context, req ExploreRequest) (*OpenSearchOverview, error)
OpenSearchIndices reads cluster health, user indices, and aliases over HTTPS inside the OpenSearch container through docker exec (ADR-0012).
func (*Engine) OtelTelemetry ¶ added in v0.3.0
func (e *Engine) OtelTelemetry(ctx context.Context, req ExploreRequest) (*OtelTelemetry, error)
OtelTelemetry queries the enabled loopback backends (Tempo, Prometheus, Loki) inside the otel container through docker exec (ADR-0012).
func (*Engine) PgBouncerPools ¶
func (e *Engine) PgBouncerPools(ctx context.Context, req ExploreRequest) (*PgBouncerPools, error)
PgBouncerPools reads a PgBouncer's pools with psql inside it: an infra pgbouncer service, or a sidecar as exploreSidecar finds one.
func (*Engine) PostgresTables ¶
func (e *Engine) PostgresTables(ctx context.Context, req ExploreRequest) (*PostgresTables, error)
PostgresTables lists tables in the service's app database, connecting as the superuser over the container's local socket.
func (*Engine) RemoveService ¶
func (e *Engine) RemoveService(_ context.Context, req RemoveServiceRequest) (*RemoveServiceResult, error)
RemoveService removes an infra service or app from experiment.yaml. A service still listed in an app's uses is refused.
func (*Engine) ServiceDetails ¶
func (e *Engine) ServiceDetails(ctx context.Context, req ServiceDetailsRequest) (*ServiceDetails, error)
ServiceDetails returns how a service is set up.
func (*Engine) StartStatsSampler ¶
StartStatsSampler keeps the latest CPU and memory use of every running container, from one streaming docker stats, until ctx ends. While it runs, Status reads that sample instead of taking its own, which costs about two seconds (docker stats measures CPU across an interval). A long-lived front end that calls Status often (bb serve, every page and every live view) starts it once; one-shot callers (bb status, MCP) do not, and keep a fresh sample.
stop ends the sampler and returns only once its docker stats process has been killed and reaped, so a caller that defers it never exits leaving the process behind; it is safe to call more than once. Calling StartStatsSampler while a sampler runs starts nothing and returns a stop that does nothing.
func (*Engine) StarterDetails ¶
func (e *Engine) StarterDetails(ctx context.Context, req StarterDetailsRequest) (*StarterDetails, error)
StarterDetails renders a starter's files for an example experiment.
func (*Engine) Starters ¶
func (e *Engine) Starters(_ context.Context) (*StartersResult, error)
Starters lists every starter.
func (*Engine) Status ¶
func (e *Engine) Status(ctx context.Context, req StatusRequest) (*StatusResult, error)
Status reports every service's state, health, and resource use, plus warnings such as plaintext edges.
func (*Engine) TraefikRoutes ¶
func (e *Engine) TraefikRoutes(ctx context.Context, req ExploreRequest) (*TraefikRoutes, error)
TraefikRoutes reads a Traefik service's routers and services, with each server's status, from its API on the loopback entrypoint.
type EnvGroup ¶
type EnvGroup struct {
Service string
Title string
Plaintext bool
Reason string
// Sidecar marks the variables a sidecar adds (Service is the sidecar).
Sidecar bool
Vars []EnvVar
}
EnvGroup is a block of environment variables: Breadboard's own (Service empty) or one service's env contract.
type EnvoyCluster ¶
type EnvoyCluster struct {
Name string
// Role is what the cluster is for: outbound (to Target over TLS),
// inbound (to the app on loopback), egress (transparent passthrough
// to original destinations), or inbound passthrough (transparent); for
// an infra proxy, upstream.
Role string
Target string // the app or service it reaches, when known
// Mode is an infra proxy's upstream TLS mode: spec.TLSOn, spec.TLSOff
// or spec.TLSPassthrough.
Mode string
// Counters over the whole cluster.
Retries int64 // upstream_rq_retry
EjectionsActive int64 // hosts ejected by outlier detection right now
EjectionsEnforced int64 // ejections ever enforced
EjectionsOverflow int64 // ejections max_ejection_percent prevented
Hosts []EnvoyHost
}
EnvoyCluster is one upstream group and its hosts.
type EnvoyClusters ¶
type EnvoyClusters struct {
Sidecar string // the sidecar's service name, e.g. caller-envoy
App string // the app instance it serves
// Proxy is the infra Envoy service's name; Sidecar and App are empty
// then.
Proxy string
Listeners []EnvoyListener
Clusters []EnvoyCluster
}
EnvoyClusters is what an Envoy sidecar, or an infra Envoy proxy, knows about where it sends traffic.
type EnvoyHost ¶
type EnvoyHost struct {
Address string // ip:port
Hostname string // the DNS name Envoy resolved, if any
// Instance is the app instance or service at this address, from DNS
// inside the sidecar: which replica a request went to.
Instance string
Healthy bool
// Flags are why a host is not healthy: failed_outlier_check (ejected),
// failed_active_health_check, eds_unhealthy, ...
Flags []string
Ejected bool
Requests int64 // rq_total
Successes int64 // rq_success
Errors int64 // rq_error: 5xx and resets
Timeouts int64 // rq_timeout
ConnectFailures int64 // cx_connect_fail
ActiveConnections int64 // cx_active
ActiveRequests int64 // rq_active
}
EnvoyHost is one upstream address with its health and counters.
type EnvoyListener ¶
EnvoyListener is one address the sidecar accepts connections on.
type Event ¶
type Event struct {
Kind EventKind
Message string
Service string // set for health events
Health string // the new health, for health events
}
Event is one progress report.
type ExploreRequest ¶
ExploreRequest names the service to explore.
type ExportComposeRequest ¶
type ExportComposeRequest struct {
Dir string
// Out is the output directory; empty means <project>/export/compose.
// An existing non-empty directory is only replaced if bb wrote it.
Out string
// Secrets selects inline (default) or dotenv.
Secrets string
Events EventSink
}
ExportComposeRequest writes a standalone compose stack.
type ExportComposeResult ¶
ExportComposeResult reports what was written.
type HAProxyBackend ¶
type HAProxyBackend struct {
Name string
Upstream ProxyUpstream
Mode string // http or tcp
Status string // UP when a server is up, DOWN otherwise
Balance string // roundrobin, leastconn, ...
// Totals over the backend.
CurrentSessions int64
TotalSessions int64
BytesIn int64
BytesOut int64
Servers []HAProxyServer
}
HAProxyBackend is a pool of servers with the balancing algorithm and totals over its servers.
type HAProxyFrontend ¶
type HAProxyFrontend struct {
Name string
Mode string // http or tcp
Status string // OPEN, STOP
// Sessions: current, and total since HAProxy started.
CurrentSessions int64
TotalSessions int64
Requests int64 // HTTP requests (req_tot); zero in tcp mode
BytesIn int64
BytesOut int64
}
HAProxyFrontend is a listener HAProxy accepts connections on.
type HAProxyServer ¶
type HAProxyServer struct {
Name string // the slot, e.g. web1
// Address is ip:port, empty while the slot has no address;
// Instance is the replica or service at that address, from DNS inside
// the proxy. Slot numbers and replica numbers need not match.
Address string
Instance string
// Status is HAProxy's word: UP, DOWN, NOLB, MAINT, "MAINT
// (resolution)" for a slot DNS left empty, "UP 1/2" while rising, ...
Status string
Up bool
// The last health check: its code (L4OK, L6OK, L7OK, L4CON, L7STS,
// ...), its description, and how long it took.
CheckStatus string
CheckDesc string
CheckMillis int64
CheckFailures int64 // failed checks (chkfail)
Downs int64 // UP to DOWN transitions (chkdown)
LastChange int64 // seconds since the status last changed
Weight int64
// Traffic: sessions now and since start, how often the balancer
// picked it, and bytes. In http mode a session is a request.
CurrentSessions int64
TotalSessions int64
Selected int64 // lbtot
BytesIn int64
BytesOut int64
ConnectErrors int64 // econ
ResponseErrors int64 // eresp
HTTP5xx int64 // responses with a 5xx status
}
HAProxyServer is one server of a backend: with server-template, one slot that holds whichever address DNS returned for it.
type HAProxyStats ¶
type HAProxyStats struct {
Service string
Frontends []HAProxyFrontend
Backends []HAProxyBackend
}
HAProxyStats is HAProxy's stats page: every frontend, and every backend with its servers.
type HostURL ¶
type HostURL struct {
URL string
// Target is the app or service in experiment.yaml.
Target string
// Instance is the app instance's service name for a URL that reaches
// one replica alone (api-2); empty for the target's URL.
Instance string
}
HostURL is one URL that reaches a lab target from the host.
type InitRequest ¶
type InitRequest struct {
Dir string // project directory; created if missing
Name string // experiment name; empty derives it from the directory
}
InitRequest creates an experiment.
type InitResult ¶
type InitResult struct {
Dir string
Name string
SpecCreated bool // false when experiment.yaml already existed
StateCreated bool // .bb/ was created
HomeCreated bool
CACreated bool
CAPath string
}
InitResult reports what Init created.
type KafkaGroup ¶
type KafkaGroup struct {
Name string
Topics []string
Members int // distinct consumers holding partitions
Lag int64 // records written but not yet committed, over all partitions
}
KafkaGroup is one consumer group's progress.
type KafkaOverview ¶
type KafkaOverview struct {
Topics []KafkaTopic
Groups []KafkaGroup
}
KafkaOverview lists topics and consumer groups.
type KafkaTopic ¶
type KafkaTopic struct {
Name string
Partitions int
ReplicationFactor int
Messages int64
Internal bool // names starting with __, such as __consumer_offsets
}
KafkaTopic is one topic. Messages is the sum of its partitions' end offsets: every record ever written, before retention deleted any.
type LearnRequest ¶
type LearnRequest struct {
Type string
}
LearnRequest asks for an entry's learning notes.
type LearnResult ¶
LearnResult carries the notes as markdown.
type Listener ¶
type Listener struct {
Name string
Protocol string
Port int
PlaintextPort int // zero when the service has no plaintext listener
}
Listener is a port a service accepts connections on.
type LogsRequest ¶
type LogsRequest struct {
Dir string
Service string // empty means every service
Follow bool
Tail int // lines per service; zero means all
}
LogsRequest asks for service output.
type MigrateRequest ¶
type MigrateRequest struct {
Dir string
}
MigrateRequest upgrades experiment.yaml.
type MigrateResult ¶
MigrateResult reports the upgrade.
type NginxBackend ¶
NginxBackend is one instance of an upstream and the address its name resolves to inside the container; empty when it does not resolve (the instance is not running).
type NginxStatus ¶
type NginxStatus struct {
Service string
// Connections now: all of them, and those reading a request, writing a
// response, and idle keep-alive connections waiting for one.
Active int64
Reading int64
Writing int64
Waiting int64
// Totals since NGINX started: connections accepted and handled
// (fewer handled means a limit was hit), and requests.
Accepts int64
Handled int64
Requests int64
Upstreams []NginxUpstream
}
NginxStatus is what open-source NGINX reports about itself: the stub_status counters, which cover the whole server. Per-upstream and per-server counters are an NGINX Plus feature, so Backends lists what each upstream resolves to from inside the container instead, which is where NGINX sends traffic.
type NginxUpstream ¶
type NginxUpstream struct {
ProxyUpstream
Port int
Backends []NginxBackend
}
NginxUpstream is one upstream with the instances behind it.
type OpenSearchIndex ¶ added in v0.3.0
type OpenSearchIndex struct {
Name string
Health string
Status string
Primaries int
Replicas int
Docs int64
Deleted int64
Bytes int64
Aliases []string
}
OpenSearchIndex is one user index (system dot-indices omitted) with its health, shard counts, doc count, storage size, and aliases.
type OpenSearchOverview ¶ added in v0.3.0
type OpenSearchOverview struct {
Service string
ClusterName string
Status string
Version string
ActiveShards int
UnassignedShards int
Indices []OpenSearchIndex
}
OpenSearchOverview summarizes cluster health and user indices inside an OpenSearch service.
type Options ¶
type Options struct {
// Home is the install home; empty means $BB_HOME or the user config dir.
Home string
// Runtime drives Docker; nil means the docker CLI.
Runtime Runtime
// Now is the clock; nil means time.Now.
Now func() time.Time
// Version overrides the build version.
Version string
// SystemRoots returns public root certificates (PEM) for the trust
// bundle; nil reads the host's CA bundle.
SystemRoots func() []byte
// HealthTimeout bounds how long Up waits for every service to be healthy.
HealthTimeout time.Duration
// PollInterval is how often Up checks health.
PollInterval time.Duration
// StartupSettle is how long every service must stay healthy, without
// restarting, before Up reports success.
StartupSettle time.Duration
// PortFree reports whether a TCP port binds on 127.0.0.1 now, for the
// host router's port; nil tries to listen on it.
PortFree func(port int) bool
}
Options configures an Engine. Zero values pick production defaults.
type OtelTelemetry ¶ added in v0.3.0
type OtelTelemetry struct {
Signals []string // enabled signals: logs, metrics, traces
LogsEnabled bool
MetricsEnabled bool
TracesEnabled bool
TraceServices []string
Traces []OtelTrace
MetricServices []string
Metrics []string
MetricsMore bool
LogServices []string
Logs []OtelLog
}
OtelTelemetry summarizes live telemetry in an otel (LGTM) service, reading only the loopback backends whose signals are enabled.
type OtelTrace ¶ added in v0.3.0
type OtelTrace struct {
TraceID string
RootService string
RootName string
DurationMS int64
Spans int
}
OtelTrace is one recent trace from Tempo.
type PgBouncerPool ¶
type PgBouncerPool struct {
Database string
User string
PoolMode string
// Client connections from the app: linked to a server connection, or
// waiting for one.
ClientsActive int64
ClientsWaiting int64
// Server connections to Postgres: in use, idle and ready, idle but
// needing a reset, and logging in.
ServersActive int64
ServersIdle int64
ServersUsed int64
ServersLogin int64
// MaxWaitMicros is how long the oldest waiting client has waited.
MaxWaitMicros int64
// Totals since PgBouncer started.
Transactions int64
Queries int64
BytesReceived int64
BytesSent int64
AvgQueryMicros int64 // average query time over the last stats period
AvgWaitMicros int64 // average time clients waited for a server
}
PgBouncerPool is one database/user pool (SHOW POOLS) with its database's totals (SHOW STATS).
type PgBouncerPools ¶
type PgBouncerPools struct {
Sidecar string // the sidecar's service name, e.g. api-pgbouncer
App string // the app instance it serves
// Proxy is the infra pgbouncer service's name, shared by every app
// that uses it; Sidecar and App are empty then.
Proxy string
Service string // the Postgres service it pools
PoolMode string
PoolSize int
Port int // where apps reach it: on 127.0.0.1 for a sidecar
Pools []PgBouncerPool
}
PgBouncerPools is a PgBouncer sidecar's, or an infra PgBouncer's, pools and traffic.
type PostgresTable ¶
PostgresTable is one table with its exact row count and total size.
type PostgresTables ¶
type PostgresTables struct {
Database string
Tables []PostgresTable
}
PostgresTables lists the tables of the app database.
type ProxyUpstream ¶
type ProxyUpstream struct {
Route string // the route name: /<Route>/ with several HTTP upstreams
Target string // the app or service behind it
Mode string // spec.TLSOn (re-encrypt), spec.TLSOff (terminate) or spec.TLSPassthrough
}
ProxyUpstream identifies the upstream a proxy's backend balances, as experiment.yaml declares it. It is empty for a backend Breadboard did not generate (a user-owned file names its own).
type RedisKeys ¶
type RedisKeys struct {
Total int64 // DBSIZE
Keys []RedisKey
Truncated bool // more keys exist than were returned
}
RedisKeys is a sample of the keyspace.
type RemoveServiceRequest ¶
RemoveServiceRequest removes a service or app.
type RemoveServiceResult ¶
RemoveServiceResult reports what was removed.
type Runtime ¶
type Runtime interface {
Available(ctx context.Context) error
Up(ctx context.Context, p runtime.Project) error
Down(ctx context.Context, p runtime.Project, volumes bool) error
RemoveOwned(ctx context.Context, experimentID string, volumes bool) error
Containers(ctx context.Context, experiment string) ([]runtime.Container, error)
Stats(ctx context.Context, ids []string) (map[string]runtime.Usage, error)
// StatsStream yields usage rows for every running container until ctx
// ends (StartStatsSampler).
StatsStream(ctx context.Context) iter.Seq2[runtime.Sample, error]
Logs(ctx context.Context, p runtime.Project, services []string, follow bool, tail int) iter.Seq2[runtime.LogLine, error]
Subnets(ctx context.Context) ([]runtime.Network, error)
Owners(ctx context.Context, experiment string) ([]string, error)
Exec(ctx context.Context, experiment, service string, cmd []string) ([]byte, error)
Build(ctx context.Context, p runtime.Project, services []string) error
ImageUser(ctx context.Context, p runtime.Project, service string) (runtime.ImageUser, error)
PublishedPorts(ctx context.Context) ([]runtime.PublishedPort, error)
}
Runtime is how the core drives Docker. internal/runtime implements it with the docker CLI; tests use a fake.
type S3Bucket ¶
type S3Bucket struct {
Name string
Objects int
Bytes int64
Truncated bool // more than S3ObjectLimit objects; counts cover the first ones
}
S3Bucket is one bucket's object count and total size.
type S3Buckets ¶
type S3Buckets struct {
Buckets []S3Bucket
}
S3Buckets lists buckets with what they hold.
type ServiceCreds ¶
ServiceCreds is one infra service's credentials and the env an app gets when it uses the service.
type ServiceDetails ¶
type ServiceDetails struct {
Name string
Kind string // infra, app, or sidecar
Type string // catalog type for infra and sidecars
Title string // catalog title for infra and sidecars
Summary string // catalog summary for infra and sidecars
Image string
FQDN string
Address string
// Listeners are an infra service's ports.
Listeners []Listener
// UsedBy lists the services that connect to this one.
UsedBy []string
// Upstreams are a proxy's backends, in spec order, with the route
// that reaches each.
Upstreams []UpstreamInfo
// File and StaticFile are a proxy's user-owned configs from
// experiment.yaml, relative to it: file replaces the generated native
// config, static_file is merged into the generated static one.
File string
StaticFile string
// Env is, for infra, the variables every app that uses it receives (one
// group); for an app, its whole environment. Secret values are empty with
// Secret set: bb creds shows them.
Env []EnvGroup
// Certificate is the service's leaf (an app's, for its sidecar). Nil
// before the first bb up.
Certificate *Certificate
// Apps only.
Path string
Command []string
// App is the app in experiment.yaml; Instance the instance number (0
// with one replica). Replicas lists every instance's service name, and
// Sidecars describes the instance's sidecars (every instance of an app
// has the same ones).
App string
Instance int
Replicas []string
Sidecars []SidecarInfo
// Sidecars only.
Parent string
Registry string
Sidecar *SidecarInfo
// HostURLs reach the service from the host, as in ServiceStatus.
HostURLs []string
// HostRouter marks the lab's host router (bb-host).
HostRouter bool
}
ServiceDetails describes how a service is set up: what it is, how apps reach it, the environment involved, and its certificate. It is read-only: it takes no lock, generates nothing, and never returns a secret value.
type ServiceDetailsRequest ¶
ServiceDetailsRequest asks about one service.
type ServiceStatus ¶
type ServiceStatus struct {
Name string
Kind string // infra, app, or sidecar
Type string // catalog type for infra; empty for apps
Image string
Address string
State string // running, exited, ..., or "not created"
Health string // healthy, starting, unhealthy, or the state when not running
CPUPercent float64
CPULimit string
MemoryBytes uint64
MemoryLimit string // the configured limit, e.g. 512m
OOMKilled bool
StartedAt time.Time
Uses []Edge
// Apps only: the source directory and command from experiment.yaml.
Path string
Command []string
// App instances only: the app in experiment.yaml, the instance number
// (0 when the app runs one replica), how many replicas the app runs,
// and the instance's sidecars by service name. Each instance's row is
// followed by its sidecars' rows; the pod's namespace holder is never a
// row, but its state counts toward the instance's State and Health.
App string
Instance int
Replicas int
Sidecars []string
// Sidecars only: the app instance whose pod they share, the registry an
// agent joins, and what the sidecar is (ports, env, mode).
Parent string
Registry string
Sidecar *SidecarInfo
// HostURLs reach the service from the host (ADR-0017): an app
// instance's app URL, then its own URL when the app has replicas; an
// infra target's URL. Empty without host access or before the first
// bb up records the port.
HostURLs []string
// HostRouter marks the lab's host router (bb-host).
HostRouter bool
}
ServiceStatus is one service's live state.
type SidecarInfo ¶
type SidecarInfo struct {
Name string // within the app: envoy, or the declared name
Service string // the container's service name: api-envoy, api-2-envoy
Type string // sidecar catalog type: envoy, pgbouncer, fluent-bit, consul-agent
Title string
Summary string
Image string
// Ports are what the sidecar listens on in the pod's network namespace.
Ports []SidecarPort
// Env lists the variables the sidecar adds to the app's environment;
// Rewrites the app variables it points at itself (a pooler's
// DATABASE_URL), with their new values.
Env []EnvVar
Rewrites []EnvVar
// Settings are the declared knobs, defaults applied, for display.
Settings []SidecarSetting
// Envoy only: transparent capture and its egress policy (allow, deny).
Transparent bool
Egress string
// Targets are an Envoy sidecar's outbound targets (apps or services).
Targets []string
// Registry is the registry a consul-agent joins.
Registry string
}
SidecarInfo describes one sidecar as declared: what it is, the ports it binds inside its app's pod, and the environment it gives the app. Secret values are empty with Secret set.
type SidecarPort ¶
type SidecarPort struct {
Port int
// Loopback ports are bound on 127.0.0.1: only the app and its other
// sidecars reach them, in plaintext.
Loopback bool
Purpose string
}
SidecarPort is a port a sidecar binds inside the pod.
type SidecarSetting ¶
SidecarSetting is one declared knob of a sidecar.
type StarterApp ¶
type StarterApp struct {
Name string
Command []string
Uses []string // catalog types
Register *spec.Register
Replicas int
Sidecars []spec.Sidecar // infra references are catalog types
}
StarterApp is an app the starter adds to experiment.yaml.
type StarterDetails ¶
type StarterDetails struct {
StarterInfo
Dir string // default directory the code is written to
RequiresConfig map[string]map[string]string
RequiresHost []string
Apps []StarterApp
Services []StarterService
Files []StarterFile
}
StarterDetails is everything a starter would write and add, without writing anything: for the web UI's starter pages.
type StarterDetailsRequest ¶
type StarterDetailsRequest struct {
ID string
}
StarterDetailsRequest names a starter.
type StarterFile ¶
StarterFile is one rendered file, relative to the starter's directory.
type StarterInfo ¶
type StarterInfo struct {
ID string
Title string
Summary string
Language string
Requires []string
Apps []string
Services []string // proxy services the starter adds
}
StarterInfo summarises a starter.
type StarterService ¶
type StarterService struct {
Name string
Type string
// Upstreams name the starter's apps or catalog types (resolved to the
// experiment's service of that type when applied).
Upstreams []spec.Upstream
// File is the native config, relative to the starter's directory
// (one of Files); empty when the generated config is kept.
File string
// StaticFile is the static configuration merged into the proxy's
// generated one, relative to the starter's directory (one of Files);
// empty when there is none.
StaticFile string
// Config is the service's config as the starter writes it.
Config map[string]string
}
StarterService is a proxy service the starter adds to experiment.yaml.
type StartersResult ¶
type StartersResult struct {
Starters []StarterInfo
}
StartersResult lists starters.
type StatusRequest ¶
type StatusRequest struct {
Dir string
}
StatusRequest asks for the experiment's state.
type StatusResult ¶
type StatusResult struct {
Experiment string
Domain string
Services []ServiceStatus
Warnings []string
// HostURLs and HostPort as in UpResult.
HostURLs []HostURL
HostPort int
}
StatusResult is the experiment's state.
type TraefikRouter ¶
type TraefikRouter struct {
Name string // as Traefik names it, with its provider: web@file
Protocol string // http or tcp
EntryPoints []string
Rule string
Priority int64
Middlewares []string
Service string
// TLS is how the router treats TLS: "terminate" (it decrypts),
// "passthrough" (TCP, forwarded encrypted), or empty.
TLS string
Status string // enabled, disabled, warning
Errors []string
}
TraefikRouter matches requests (HTTP) or connections (TCP, by SNI) and sends them to a service.
type TraefikRoutes ¶
type TraefikRoutes struct {
Service string
Routers []TraefikRouter
Services []TraefikService
}
TraefikRoutes is Traefik's runtime routing configuration from its API: routers (which requests go where) and services (where they end up). Traefik's own routers and services (@internal: the API, the dashboard, ping) are left out.
type TraefikServer ¶
type TraefikServer struct {
Address string // a URL (HTTP) or host:port (TCP)
Instance string // the replica or service, from the server's name
Status string // UP or DOWN; empty when Traefik reports none
}
TraefikServer is one server of a service with the status Traefik's health check gives it. Traefik keeps no per-server request counter in its API; its access log has each request.
type TraefikService ¶
type TraefikService struct {
Name string
Upstream ProxyUpstream
Protocol string // http or tcp
Type string // loadbalancer, weighted, mirroring, failover
Strategy string // wrr, p2c, hrw, leasttime (HTTP)
Status string
UsedBy []string
// HealthCheck summarises the active check, empty without one.
HealthCheck string
Servers []TraefikServer
Errors []string
}
TraefikService is a load balancer over servers.
type UpRequest ¶
type UpRequest struct {
Dir string
Events EventSink
// Timeout overrides how long to wait for health.
Timeout time.Duration
}
UpRequest starts the experiment.
type UpResult ¶
type UpResult struct {
Experiment string
Services []ServiceStatus
Warnings []string
// HostURLs reach the lab's host targets from the host, in route order
// (each target, then its instances); HostPort is the 127.0.0.1 port
// they share. Empty and zero without a host target.
HostURLs []HostURL
HostPort int
}
UpResult is the experiment's state once every service is healthy.
type UpstreamInfo ¶
type UpstreamInfo struct {
Name string // the route name
Service string // the app or service behind it
App bool
// Instances is how many replicas of an app the proxy balances across.
Instances int
// Mode is spec.TLSOn (re-encrypt), spec.TLSOff (terminate, with
// Reason) or spec.TLSPassthrough.
Mode string
Reason string
Port int // the target port: TLS, or plaintext for terminate
// The route: the proxy port it arrives on, and for HTTP proxies the
// path prefix (stripped before forwarding; empty when the upstream
// gets every request), whether it also takes every other request
// (the first upstream), or for passthrough the SNI name.
ListenPort int
PathPrefix string
Default bool
SNI string
// Route says the same in words, e.g. "/api/ (prefix stripped) on :8443".
Route string
}
UpstreamInfo is one backend of a proxy and how traffic reaches it.
type ValidationError ¶
type ValidationError = spec.ValidationError
ValidationError lists every violation with its YAML path. It matches ErrValidation.
type VersionInfo ¶
VersionInfo describes the running build.