config

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Jun 15, 2026 License: AGPL-3.0 Imports: 5 Imported by: 0

Documentation

Overview

Package config centralizes all RELAY_* env var parsing for the relay binary. It is the single source of truth for the env contract; grep here to learn what env vars Relay reads.

Load() validates inputs at boot (master key shape, cluster-mode enum, etc.) so subsystem constructors can trust the fields they receive. Subsystems do NOT read env vars themselves — they accept values via their own typed configs.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// Cluster
	ClusterMode bool

	// Backends
	CatalogBackend  string
	StateBackend    string
	EventlogBackend string

	// Connections
	PGDSN        string
	RedisAddr    string
	CHDSN        string
	OTLPEndpoint string

	// Auth
	AdminToken string
	MasterKey  []byte // already parsed via crypto.ParseMasterKey; nil if unset

	// Behavior knobs
	CHRetentionDays int
	AutoSeedIfEmpty bool
	ConfigDir       string
	CatalogDir      string
	InstanceID      string
	EventlogDir     string
	MaxRequestBytes int64 // 0 = use httpmw.DefaultMaxRequestBytes

	HealthzDeadlineMS int
	ShutdownDeadlineS int

	// DevTrustEventTime makes the inference edge honor the X-WR-Event-Time
	// header as the usage Event timestamp (RELAY_DEV_TRUST_EVENT_TIME=1).
	// Dev/replay tooling only — never enable in production.
	DevTrustEventTime bool

	// ControlPort is the listener port for the control-plane HTTP server.
	// Empty disables the control listener entirely (data plane only).
	ControlPort string

	// ControlAllowOrigins is the CORS allowlist for the control API. Comma-
	// separated list of exact origin strings (no wildcards — credentialed
	// CORS forbids them). Empty disables CORS entirely.
	ControlAllowOrigins []string

	// UIDisable suppresses serving the embedded admin UI on the control
	// listener (RELAY_UI_DISABLE=1). Off by default; the UI is same-origin
	// and adds no surface beyond the control API it already fronts.
	UIDisable bool

	// Runtime is the public, unauthenticated runtime config the embedded admin
	// UI fetches at boot via GET /config.json. Public values only — it is
	// world-readable. All fields are optional; empty URL fields make the UI
	// fall back to its own origin (which is correct for controlApiUrl in the
	// single-binary case, but NOT for inferenceApiUrl when the data plane is a
	// separate origin — hence RELAY_INFERENCE_API_URL).
	Runtime RuntimeConfig
}

Config holds every RELAY_* setting parsed and validated at startup.

func Load

func Load() (*Config, error)

Load reads every RELAY_* environment variable, validates them, and returns a fully-populated *Config. Returns a descriptive error on the first validation failure.

type RuntimeConfig added in v0.2.0

type RuntimeConfig struct {
	ControlAPIURL   string // RELAY_CONTROL_API_URL   (empty ⇒ UI uses its origin)
	InferenceAPIURL string // RELAY_INFERENCE_API_URL (empty ⇒ UI prompts; no safe origin default)
	Mode            string // RELAY_MODE ("oss" | "cloud"); default "oss"
	SentryDSN       string // RELAY_UI_SENTRY_DSN        (public client-side DSN)
	TelemetryEnv    string // RELAY_UI_TELEMETRY_ENV
	DocsURL         string // RELAY_UI_DOCS_URL
	SupportURL      string // RELAY_UI_SUPPORT_URL
}

RuntimeConfig carries the deployment-specific values surfaced to the browser via GET /config.json. Mirrors the JSON the UI reads; see config_json.go.

Jump to

Keyboard shortcuts

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