Documentation
¶
Overview ¶
Package proxy hosts the embedded L7/L4 proxy (tasks T-41..T-48). This file freezes the RouteSource contract between the route-table client and the proxy/DNS/VIP consumers.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ActivateFunc ¶
ActivateFunc asks the control plane to wake a scaled-to-zero env. It returns when the activation has been requested (not when the endpoint is ready).
type Activator ¶
type Activator struct {
// contains filtered or unexported fields
}
Activator holds a request for a scaled-to-zero env: it triggers activation, waits (bounded) for the env to gain a healthy endpoint via route updates, then signals the caller to retry — or sheds/expires the request (T-70).
func NewActivator ¶
func NewActivator(source RouteSource, activate ActivateFunc, clk clock.Clock) *Activator
NewActivator builds an activator over a route source and an activation hook.
func (*Activator) Hold ¶
func (a *Activator) Hold(w http.ResponseWriter, r *http.Request, envID string, ready func() bool) bool
Hold parks a request for an env until ready() reports the caller may proceed — a healthy endpoint appearing (scale-to-zero cold start) or a replica freeing capacity (serverless backpressure). It triggers activation (which nudges the scheduler to add replicas) and waits on route updates plus a short poll. Returns true when the caller should re-select an endpoint and proxy; false when the activator has already written a response (503 shed, 504 timeout, or oversized body).
type L4 ¶
type L4 struct {
// contains filtered or unexported fields
}
L4 is the raw TCP passthrough proxy (spec F5). It reconciles one listener per L4Route.public_port to the current RouteSnapshot, and for each accepted connection picks a healthy backend (P2C) and splices bytes both ways.
type L7 ¶
type L7 struct {
// DisableHTTPSRedirect serves plaintext requests directly instead of
// 308-redirecting them to HTTPS. Single-node/dev sets this: HTTPS runs on a
// non-standard port with a self-signed cert, so a bare https:// redirect
// would be broken (T-54).
DisableHTTPSRedirect bool
// contains filtered or unexported fields
}
L7 is the ingress HTTP reverse proxy: it matches a request to a route from the current RouteSnapshot, load-balances across the route's healthy endpoints (P2C), applies per-route middleware, and proxies. It serves both the :80 and :443 listeners (HTTPS redirect happens on the plaintext side).
func NewL7 ¶
func NewL7(source RouteSource, node string, clk clock.Clock) *L7
NewL7 builds an L7 proxy over a route source. node is this node's id (used to prefer node-local endpoints).
func (*L7) SetActivator ¶
SetActivator enables wake-on-request for scaled-to-zero envs (T-70).
type RouteClient ¶
type RouteClient struct {
// contains filtered or unexported fields
}
RouteClient keeps a WatchRoutes stream, persists each snapshot to disk, and implements proxy.RouteSource. It loads the last snapshot at startup so a node keeps serving traffic while the control plane is unreachable (spec §7).
func NewRouteClient ¶
func NewRouteClient(dialer RouteDialer, nodeID, path string, log *slog.Logger) *RouteClient
NewRouteClient constructs the client. path is where snapshots are cached.
func (*RouteClient) Current ¶
func (c *RouteClient) Current() *clusterv1.RouteSnapshot
Current returns the latest snapshot (never nil).
func (*RouteClient) Run ¶
func (c *RouteClient) Run(ctx context.Context)
Run keeps the WatchRoutes stream alive, applying each snapshot and reconnecting with backoff. It returns when ctx is canceled.
func (*RouteClient) Updates ¶
func (c *RouteClient) Updates(ctx context.Context) <-chan *clusterv1.RouteSnapshot
Updates returns a channel receiving each new snapshot until ctx is canceled.
type RouteDialer ¶
type RouteDialer interface {
WatchRoutes(ctx context.Context, haveVersion uint64) (RouteStream, error)
}
RouteDialer opens a WatchRoutes stream to a control node (over node mTLS). The daemon supplies the concrete transport; tests inject a fake.
type RouteSource ¶
type RouteSource interface {
// Current returns the latest snapshot (never nil; may be an empty
// snapshot with Version 0 before the first sync).
Current() *clusterv1.RouteSnapshot
// Updates returns a channel receiving each new snapshot. The channel is
// closed when ctx is canceled. Slow consumers may miss intermediate
// versions but always eventually receive the latest.
Updates(ctx context.Context) <-chan *clusterv1.RouteSnapshot
}
RouteSource provides the current route table and change notifications. Implementations: the RouteStream gRPC client with disk cache (T-42), a static source for tests, and a direct in-process source on control nodes.
type RouteStream ¶
type RouteStream interface {
Recv() (*clusterv1.RouteSnapshot, error)
}
RouteStream is the receive side of a WatchRoutes stream.
type StaticRouteSource ¶
type StaticRouteSource struct {
Snapshot *clusterv1.RouteSnapshot
}
StaticRouteSource serves a fixed snapshot (tests, and the bootstrap window before the first stream sync).
func (*StaticRouteSource) Current ¶
func (s *StaticRouteSource) Current() *clusterv1.RouteSnapshot
func (*StaticRouteSource) Updates ¶
func (s *StaticRouteSource) Updates(ctx context.Context) <-chan *clusterv1.RouteSnapshot