config

package
v1.3.3 Latest Latest
Warning

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

Go to latest
Published: Oct 26, 2026 License: Apache-2.0 Imports: 5 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

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// Notices are startup warnings about settings: deprecated names, which keep
	// working through 1.x, and defaults that changed before 1.0.
	Notices []string

	DatabaseURL string
	// EncryptionKeys is the versioned AES-256-GCM keyring spec
	// ("1:<base64 32B>,2:..."); vendor keys are unreadable without it.
	EncryptionKeys     string
	GRPCAddr           string
	GRPCMaxRecvMsgSize int
	HTTPAddr           string
	// HTTPAPIEnabled mounts the OpenAI-compatible API on HTTPAddr; off leaves health only.
	HTTPAPIEnabled bool
	// HTTPAPITimeout bounds one HTTP API call, which waits on an upstream model.
	HTTPAPITimeout  time.Duration
	LogLevel        string
	ShutdownTimeout time.Duration
	DBMaxConns      int32
	DBMinConns      int32
	// DBTimeout bounds connecting and each per-request query (key checks), so
	// a hung database fails calls fast instead of exhausting the pool.
	DBTimeout time.Duration
	// AuthStaleIfError keeps recently verified keys working while Postgres is
	// unreachable; 0 refuses every call during an outage.
	AuthStaleIfError time.Duration

	// RoutingReload is how often replicas poll config_state for changes.
	RoutingReload time.Duration

	// AutoMigrate applies the embedded migrations at startup. On by default;
	// a half-migrated schema is a state the queries were not written for.
	AutoMigrate bool
	// MigrateTimeout bounds the whole run, including the wait for whichever
	// replica holds the advisory lock during a rolling deploy.
	MigrateTimeout time.Duration

	// AutoSeed populates initial models, rules, and dev keys when unconfigured.
	AutoSeed         bool
	SeedClientKey    string
	SeedClientName   string
	SeedOpenAIKey    string
	SeedGeminiKey    string
	SeedAnthropicKey string

	RedisAddr      string
	RedisPassword  string
	RedisDB        int
	RedisKeyPrefix string
	// RedisTimeout bounds each Redis read and write (dials get twice as long);
	// with redisguard failing fast after it trips, about what a hung Redis costs a request.
	RedisTimeout time.Duration

	// BootstrapAdminKey solves minting the first api key; unset after use.
	BootstrapAdminKey string

	UsageCollectorHost string
	// UsageCollectorTLS reaches the usage sink over TLS, as a managed
	// platform (Cloud Run) serves it; plaintext otherwise.
	UsageCollectorTLS bool
	// UsageCollectorToken is the collector's bearer token (write scope).
	UsageCollectorToken string
	UsageProjectID      string

	BatchMaxItems     int
	BatchPollInterval time.Duration
	ResultsRetention  time.Duration

	// Local Node Pool configuration
	NodeHeartbeatInterval time.Duration
	NodeHeartbeatTTL      time.Duration
	NodeRetentionTTL      time.Duration
	NodeAllowLocalhost    bool
	NodeUsageRetention    time.Duration // per-node request log for node owners; 0 = off

	BudgetGraceMargin float64

	// SpendLimitsFailMode is "open" (Redis down lets calls through unmetered)
	// or "closed" (calls under a spend limit are refused until it is back).
	SpendLimitsFailMode string
	// SpendDefaultOutputReserve is the output tokens priced into a spend
	// reservation when the call sets no max tokens.
	SpendDefaultOutputReserve int

	// Upstream vendor Circuit Breaker settings
	CircuitBreakerEnabled       bool
	CircuitBreakerFailThreshold int
	CircuitBreakerCooldown      time.Duration
	// UpstreamRequestTimeout bounds each attempt against an upstream vendor.
	// Stalls beyond this duration trip circuit breakers and advance fallback chains.
	UpstreamRequestTimeout time.Duration
	// VendorCooldownMax caps the pause taken from a vendor Retry-After; 0 disables pauses.
	VendorCooldownMax time.Duration

	MetricsAddr              string
	OTELServiceName          string
	OTELExporterOTLPEndpoint string

	CacheEnabled  bool
	CacheTTL      time.Duration
	CacheMaxBytes int

	// SemanticCache serves near-duplicate prompts from Redis by latent
	// similarity; it shares CACHE_TTL and CACHE_MAX_BYTES with the exact cache.
	SemanticCacheEnabled    bool
	SemanticCacheThreshold  float64
	SemanticCacheMaxEntries int

	GuardrailsEnabled               bool
	GuardrailsPIIAction             string
	GuardrailsPromptInjectionAction string
	// GuardrailsLatent* screen prompts against malicious centroids in
	// representation space; the categories file extends the built-in set.
	GuardrailsLatentEnabled        bool
	GuardrailsLatentThreshold      float64
	GuardrailsLatentAction         string
	GuardrailsLatentCategoriesFile string

	// LatentEncoderURL is an OpenAI-compatible /v1/embeddings endpoint (e.g. a
	// JEPA node); empty or unreachable falls back to the local hash encoder.
	LatentEncoderURL       string
	LatentEncoderModel     string
	LatentEncoderAPIKey    string
	LatentEncoderTimeout   time.Duration
	LatentLocalEncoderDims int
	LatentEncoderCacheSize int

	SentryDSN         string
	SentryEnvironment string
	SentryRelease     string
	SentryTracing     bool
	SentryDebug       bool
	SentryBreadcrumbs bool
}

Config holds the application configuration. Load never fails; main.go fatals on missing required values.

func Load

func Load() *Config

Load loads configuration from environment variables

func (*Config) LatentEncoderNeeded

func (c *Config) LatentEncoderNeeded() bool

LatentEncoderNeeded reports whether any feature consumes latent embeddings.

func (*Config) RedisConfigured

func (c *Config) RedisConfigured() bool

RedisConfigured reports whether throttling has a backing store; without it all requests are allowed (fail-open by design).

func (*Config) RedisOptions added in v0.13.1

func (c *Config) RedisOptions() *redis.Options

RedisOptions builds the client options. go-redis defaults (3s reads, 5s dials, 3 retries) let one blackholed Redis add seconds to every request.

func (*Config) SpendFailClosed

func (c *Config) SpendFailClosed() bool

SpendFailClosed reports whether spend limits refuse calls while their counters are unreachable.

func (*Config) UsageConfigured

func (c *Config) UsageConfigured() bool

UsageConfigured reports whether usage events are forwarded anywhere.

Jump to

Keyboard shortcuts

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