ingress

package
v0.4.2 Latest Latest
Warning

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

Go to latest
Published: Sep 24, 2026 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Overview

Package ingress mirrors inbound HTTP requests to reference and candidate services.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// Listen is the address for the ingress HTTP server.
	Listen string `default:"127.0.0.1:50050" help:"Address for the ingress HTTP server."`
	// Reference is the authoritative backend URL.
	Reference string `required:"" help:"Reference backend URL using http, https, or h2c."`
	// Candidate is the mirrored backend URL.
	Candidate string `required:"" help:"Candidate backend URL using a literal loopback IP and http, https, or h2c."`
	// CandidateTimeout limits the duration of a candidate request.
	CandidateTimeout time.Duration `default:"30s" help:"Maximum duration of a candidate request."`
	// CandidateMaxInFlight limits concurrent candidate requests.
	CandidateMaxInFlight int `default:"64" help:"Maximum concurrent candidate requests before quarantine."`
	// CandidateBufferBytes limits queued request data across all candidates.
	CandidateBufferBytes int `default:"1048576" help:"Maximum request bytes buffered across candidates before quarantine."`
	// MaxInFlightRequests limits concurrent ingress requests.
	MaxInFlightRequests int `default:"256" help:"Maximum concurrent ingress requests."`
	// MaxConnections limits concurrent client connections.
	MaxConnections int `default:"512" help:"Maximum concurrent client connections."`
	// ReadHeaderTimeout limits the duration spent reading request headers.
	ReadHeaderTimeout time.Duration `default:"10s" help:"Maximum duration for reading request headers."`
	// IdleTimeout limits how long an idle client connection remains open.
	IdleTimeout time.Duration `default:"1m" help:"Maximum idle client connection duration."`
	// MaxHeaderBytes limits the size of request headers.
	MaxHeaderBytes int `default:"65536" help:"Maximum request header size in bytes."`
	// ShutdownTimeout limits graceful server shutdown.
	ShutdownTimeout time.Duration `default:"10s" help:"Maximum graceful shutdown duration."`
}

Config contains the command-line configuration for an ingress proxy.

func NewConfig

func NewConfig() Config

NewConfig returns the default ingress configuration.

func (Config) Validate

func (c Config) Validate() error

Validate checks that the ingress resource limits are usable.

type Handler

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

Handler forwards requests to both backends and returns only the reference response.

func New

func New(config Config, transport http.RoundTripper, log *slog.Logger) (*Handler, error)

New constructs an ingress handler from its parsed configuration.

func (*Handler) Serve

func (h *Handler) Serve(ctx context.Context, listener net.Listener) error

Serve accepts ingress traffic until the context is cancelled or the server fails.

func (*Handler) ServeHTTP

func (h *Handler) ServeHTTP(writer http.ResponseWriter, request *http.Request)

ServeHTTP serves health checks or mirrors a request to both backends.

func (*Handler) Shutdown

func (h *Handler) Shutdown(ctx context.Context) error

Shutdown stops accepting candidate work and waits for active mirrors to finish.

type Transport

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

Transport forwards HTTP/1, encrypted HTTP/2, and unencrypted HTTP/2 requests.

func NewTransport

func NewTransport(config Config) *Transport

NewTransport constructs transports for HTTP/1, encrypted HTTP/2, and h2c.

func (*Transport) CloseIdleConnections

func (t *Transport) CloseIdleConnections()

CloseIdleConnections closes idle connections held by both underlying transports.

func (*Transport) RoundTrip

func (t *Transport) RoundTrip(request *http.Request) (*http.Response, error)

RoundTrip sends HTTP requests without deriving backend protocol from the client.

Jump to

Keyboard shortcuts

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