proxy

package
v0.31.5 Latest Latest
Warning

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

Go to latest
Published: Oct 3, 2026 License: GPL-3.0 Imports: 23 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package proxy is the top-level request router. Hosts under the preview domain (<label>-<repo>.<domain>) serve deployed previews — static frontend files plus /api/* reverse-proxied to the supervised backend. Every other host (the apex domain, localhost, raw IPs) gets the dashboard.

Preview hosts must stay a single DNS label: a wildcard matches one label only, so this is what lets one *.<domain> record and one wildcard certificate cover every repo.

Routing state is cached in memory with a short TTL so the single-connection SQLite database isn't queried for every asset request.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Backends

type Backends interface {
	EnsureRunning(ctx context.Context, k supervise.Key, repoName string) (addr string, err error)
}

Backends is the slice of the supervisor the proxy needs. EnsureRunning returns the "host:port" the started process serves on — loopback for a process on this node (single-node / worker-local), or a worker's address when the control node routes to an elastic worker tier. The proxy is transport- agnostic: the same interface is satisfied by a local Manager adapter and by a remote worker-API client.

type ProcStatus added in v0.29.0

type ProcStatus interface {
	Status(k supervise.Key) string
}

ProcStatus is the slice of the runtime view the interim pages use to pick which side to narrate: a process-mode frontend spends its cold start inside its backend's init, and the page should say so.

type Router

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

Router routes by Host header. It wraps the dashboard handler and serves previews itself.

func New

func New(database *db.Store, files *store.Store, backends Backends, domain string, dashboard http.Handler) *Router

New returns a Router serving previews under domain and everything else from dashboard.

func (*Router) ServeHTTP

func (rt *Router) ServeHTTP(w http.ResponseWriter, r *http.Request)

func (*Router) SetOnyxAuth added in v0.21.0

func (rt *Router) SetOnyxAuth(label, cookieName string)

SetOnyxAuth turns on onyx single-sign-on for preview subdomains. label is the reserved upstream that runs the canonical onyx (the sole Google-OAuth host); it must also be registered via SetReservedUpstreams. cookieName is the onyx session cookie to watch for (empty → onyx's "fastapiusersauth" default). An empty label (the zero value) leaves previews un-gated by onyx, as before.

func (*Router) SetPreviewAuth added in v0.9.0

func (rt *Router) SetPreviewAuth(enabled bool, baseURL string, secure bool)

SetPreviewAuth turns on SSO gating of preview subdomains. baseURL is the dashboard origin (scheme://host) the grant handshake redirects through, and secure marks the preview cookie Secure. The zero value (never calling this) leaves previews open, so existing callers and tests are unaffected.

func (*Router) SetProcStatus added in v0.29.0

func (rt *Router) SetProcStatus(ps ProcStatus)

SetProcStatus wires the process-status source. Optional: without it a starting frontend is narrated as the frontend even while its backend is the side doing the work.

func (*Router) SetReservedUpstreams added in v0.20.0

func (rt *Router) SetReservedUpstreams(m map[string]string)

SetReservedUpstreams registers fixed <label> → "host:port" upstreams served under the preview domain. Labels are the single DNS label below the domain (e.g. "app" for app.<domain>); each is reverse-proxied wholesale to its upstream behind the SSO gate, shadowing any per-commit preview of the same label. A nil or empty map (the default) leaves routing unchanged.

func (*Router) SetRunLogs added in v0.18.0

func (rt *Router) SetRunLogs(logs RunLogs)

SetRunLogs wires the run-log source the interim "starting" pages stream from. Optional: without it the pages still poll for readiness.

type RunLogs added in v0.18.0

type RunLogs interface {
	RunLog(repoName, side, hash string, attempt int, offset int64) (supervise.RunLog, error)
}

RunLogs is the slice of the runtime view the interim pages need to stream startup output. Both the local *supervise.Manager and the fleet registry satisfy it; leaving it unset just serves the pages without logs.

Jump to

Keyboard shortcuts

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