proxies

package
v0.55.2 Latest Latest
Warning

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

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

Documentation

Overview

Package proxies runs the SPECTRE proxies in front of a reference and a candidate service, and streams the mirror's state to the SPECTRE server. It never starts the services itself.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// Reflection loads and compares both backends' descriptors via gRPC reflection.
	Reflection bool `` /* 228-byte string literal not displayed */
	// Destinations maps each request host to its upstream URL for egress.
	Destinations map[string]string `` /* 178-byte string literal not displayed */
	// ScriptsDir holds the comparison scripts passed to both proxies.
	ScriptsDir string `type:"existingdir" placeholder:"DIR" help:"Directory of comparison scripts passed to both proxies."`
	// ScriptVariables are the values the comparison scripts read with variable.
	ScriptVariables map[string]string `` /* 171-byte string literal not displayed */
	// StateFile is the migration state that decides which routes ingress mirrors.
	StateFile string `` /* 214-byte string literal not displayed */
	// SchemaDir holds the TypeScript schema passed to both proxies.
	SchemaDir string `type:"existingdir" placeholder:"DIR" help:"Directory of TypeScript schema passed to both proxies."`
	// MatchWindow bounds how long a candidate call waits for a matching reference call.
	MatchWindow time.Duration `default:"5s" help:"Maximum time a candidate egress call waits for an equivalent reference call before a 502."`
	// CandidateStartupTimeout bounds how long the candidate has to accept a first connection.
	CandidateStartupTimeout time.Duration `` /* 142-byte string literal not displayed */
	// Descriptors supplies protobuf descriptors to both proxies.
	Descriptors descriptors.Config `embed:""`
	// Server reports the mirror's state to the SPECTRE server.
	Server reporter.Config `embed:""`
}

Config contains the command-line configuration of the proxies and reporting.

func NewConfig

func NewConfig() Config

NewConfig returns the default mirror configuration.

func (Config) Validate

func (c Config) Validate() error

Validate checks that the timeouts and reporting intervals are usable.

type Mirror

type Mirror struct {
	// contains filtered or unexported fields
}

Mirror runs the ingress and egress proxies and reports their state.

func New

func New(ctx context.Context, config Config, wiring Wiring, catalog *state.Catalog) (*Mirror, error)

New validates config and returns a mirror wired by wiring. The catalog checks the migration state, if config names one.

func NewProxy

func NewProxy(ctx context.Context, config ProxyConfig, catalog *state.Catalog) (*Mirror, error)

NewProxy validates config and returns a mirror of services that run elsewhere.

func (*Mirror) Run

func (m *Mirror) Run(ctx context.Context) error

Run starts the proxies, then serves until the context is cancelled or a proxy exits.

func (*Mirror) Start

func (m *Mirror) Start(ctx context.Context) error

Start opens every listener and serves the proxies in the background. Ingress is ready once the reference accepts, and mirrors once the candidate does.

func (*Mirror) Wait

func (m *Mirror) Wait(ctx context.Context) error

Wait blocks until the context is cancelled or a proxy exits, then stops and waits for the rest.

type ProxyConfig

type ProxyConfig struct {
	// Listen is the public ingress address that clients send traffic to.
	Listen string `default:"127.0.0.1:50050" help:"Public ingress address: host:port, or unix:<path|@abstract> for a unix socket."`
	// ReferenceURL is where ingress reaches the reference service.
	ReferenceURL string `name:"reference-url" required:"" help:"Reference service URL: http, https, h2c, or http+unix:<socket> / h2c+unix:<socket>."`
	// CandidateURL is where ingress reaches the candidate service.
	CandidateURL string `` /* 136-byte string literal not displayed */
	// ReferenceEgressListen receives the reference's dependency calls.
	ReferenceEgressListen string `default:"127.0.0.1:50060" help:"Address the reference sends its dependency calls to: host:port, or unix:<path|@abstract>."`
	// CandidateEgressListen receives the candidate's dependency calls.
	CandidateEgressListen string `` /* 155-byte string literal not displayed */
	// EgressHealthListen serves the egress proxy's own health endpoints.
	EgressHealthListen string `default:"127.0.0.1:50062" help:"Address of the egress proxy's own /livez and /readyz: host:port, or unix:<path|@abstract>."`
	// HealthListen serves the health of both proxies, for probes.
	HealthListen string `` /* 218-byte string literal not displayed */
	// Mirror configures the proxies and reporting.
	Mirror Config `embed:""`
}

ProxyConfig contains the command-line configuration of a mirror whose services run elsewhere, such as in other containers of the same pod.

func (ProxyConfig) Validate

func (c ProxyConfig) Validate() error

Validate checks that the mirror configuration is usable.

type Wiring

type Wiring struct {
	// Listen is the public ingress address.
	Listen string
	// Reference and Candidate are the service URLs ingress forwards to.
	Reference string
	Candidate string
	// ReferenceEgress and CandidateEgress receive each service's dependency calls.
	ReferenceEgress string
	CandidateEgress string
	// EgressHealth serves the egress proxy's own health endpoints.
	EgressHealth string
	// Health serves the health of both proxies.
	Health Option[string]
}

Wiring is where the proxies listen and where ingress reaches both services.

Jump to

Keyboard shortcuts

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