Documentation
¶
Overview ¶
Package config loads and validates the relay's runtime configuration from environment variables (see the build plan's Step 2 and the deploy compose files). Every field has a default, so an empty environment produces a usable, if not internet-facing-appropriate, configuration — but Load fails loudly on a malformed value rather than silently falling back, so a bad deploy config is caught at startup, not at 3am under load.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
Addr string // e.g. ":8080"
MetricsAddr string // e.g. ":9091" — bind to loopback only in deploy
AllowedOrigins []string
MaxFrameBytes int
MaxPairs int
PingInterval time.Duration
PongTimeout time.Duration
HelloTimeout time.Duration
WriteTimeout time.Duration
// AgentGrace is how long a pair is kept alive, agentless, after its
// agent disconnects while a client is still attached — the window in
// which a restarting or reconnecting agent slots back into the same
// pair without the client noticing more than a pause. See the
// server's retireAgent.
AgentGrace time.Duration
ShutdownGrace time.Duration
PairRateBytesPerSec int64
IPConnPerMin int
TrustProxy bool
// OpenAI-compatible HTTP endpoint (spec §11). Serving the route costs
// nothing when no agent opts in — an agent must connect in mode:"http"
// with a token hash before any key resolves — but HTTPEnabled exists so
// a deploy can refuse the whole surface outright.
HTTPEnabled bool
// HTTPMaxInFlight caps concurrent requests per key. One consumer GPU
// thrashes badly past a handful of parallel generations, so shedding
// with 429 beats queueing without bound.
HTTPMaxInFlight int
// HTTPTombstoneTTL is how long a key stays resolvable after its agent
// disconnects, so the endpoint can answer 503 "offline" instead of 401
// "bad key". Past this, the entry is evicted and the key reads as
// unknown until the agent reconnects.
HTTPTombstoneTTL time.Duration
// HTTPFirstByteTimeout bounds the wait for the agent's RESP. Generous
// by default: a cold model load on a sleeping laptop is slow, and the
// failure mode of being too tight is a confusing 504 on a request that
// would have succeeded.
HTTPFirstByteTimeout time.Duration
// HTTPKeepaliveInterval is the gap after which an SSE response emits a
// comment line to keep intermediaries and client read timeouts from
// giving up during a long pause. Zero disables it.
HTTPKeepaliveInterval time.Duration
// HTTPStreamBuffer is the per-request response-frame buffer. Small on
// purpose — see hub.Stream on why buffering here would defeat
// backpressure rather than improve throughput.
HTTPStreamBuffer int
LogLevel string // "debug"|"info"|"warn"|"error"
LogFormat string // "json"|"text"
}
func Defaults ¶
func Defaults() Config
Defaults returns the configuration used when no environment variable overrides a field — the values named throughout spec/PROTOCOL.md and the build plan.