config

package
v0.21.1 Latest Latest
Warning

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

Go to latest
Published: Jul 29, 2026 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package config loads configuration from environment variables.

Index

Constants

View Source
const (
	ConfigSyncAuthModeShared = "shared"
	ConfigSyncAuthModeSigned = "signed"
	// ConfigSyncAuthModeComposite accepts both a signed per-tenant JWT (external
	// data planes → scoped snapshot) and the shared bearer token (in-cluster data
	// plane → global snapshot) on a single control plane.
	ConfigSyncAuthModeComposite = "composite"
)

Variables

This section is empty.

Functions

func DBLessDataPlaneEnabled added in v0.3.4

func DBLessDataPlaneEnabled() bool

Types

type CORSConfig

type CORSConfig struct {
	AllowOrigins     []string
	AllowMethods     []string
	AllowHeaders     []string
	ExposeHeaders    []string
	AllowCredentials bool
	MaxAge           string
}

CORSConfig drives the CORSMiddleware applied by both admin and proxy. Lists are comma-separated in env. Use "*" in AllowOrigins to allow any.

type CacheConfig

type CacheConfig struct {
	LocalTTL time.Duration
}

CacheConfig drives the in-process TTL cache used by app-layer finders. RUN-291 (B.1) will add a parallel Redis-backed layer; the finder contract will not change.

type CatalogConfig

type CatalogConfig struct {
	ModelsDevBaseURL string
}

type Config

type Config struct {
	AppEnv             string
	Server             ServerConfig
	Database           DatabaseConfig
	Redis              RedisConfig
	Cache              CacheConfig
	SemanticCache      SemanticCacheConfig
	SessionStore       SessionStoreConfig
	Kafka              KafkaConfig
	Telemetry          TelemetryConfig
	Metrics            MetricsConfig
	Playground         PlaygroundConfig
	Upstream           UpstreamConfig
	Provider           ProviderConfig
	Catalog            CatalogConfig
	CORS               CORSConfig
	Logger             LoggerConfig
	TrustGuard         TrustGuardConfig
	FirewallComplexity FirewallComplexityConfig
	OpenAIModeration   OpenAIModerationConfig
	ConfigSync         ConfigSyncConfig
	RateLimit          RateLimitConfig
}

func LoadConfig

func LoadConfig() (*Config, error)

func (*Config) IsDeployed added in v0.3.4

func (c *Config) IsDeployed() bool

IsDeployed reports whether APP_ENV marks a non-local deployment (staging or production), so plane wiring can enforce deployed-only requirements such as the control-plane config-sync gRPC server TLS certificate.

func (*Config) Validate

func (c *Config) Validate() error

type ConfigSyncConfig added in v0.3.4

type ConfigSyncConfig struct {
	DataPlaneEnabled bool
	Token            string // #nosec G117 -- config struct field, not a hardcoded credential
	// TokenPrevious is the prior bearer accepted alongside Token so a token can be
	// rotated without a window where in-flight data planes fail to authenticate.
	TokenPrevious string // #nosec G117 -- config struct field, not a hardcoded credential
	AuthMode      string
	// JWTSecret is the HS256 shared secret used to verify config-sync credentials
	// minted by DataCore. JWTSecretPrevious is the prior secret accepted alongside
	// it so the secret can be rotated without a window where data planes fail to
	// authenticate.
	JWTSecret         string // #nosec G117 -- config struct field, not a hardcoded credential
	JWTSecretPrevious string // #nosec G117 -- config struct field, not a hardcoded credential
	JWTIssuer         string
	JWTAudience       string
	LKGPath           string
	LKGKey            string // #nosec G117 -- config struct field, not a hardcoded credential
	PollInterval      time.Duration
	RecompileDebounce time.Duration
	// RecompileBackstop periodically recompiles even without a write signal so the
	// control plane recovers from a failed boot compile and picks up out-of-band
	// mutations.
	RecompileBackstop time.Duration
	InstanceID        string
	// GRPCEndpoint is the control-plane host:port the data plane dials for the
	// config-sync gRPC transport (ENG-959).
	GRPCEndpoint string
	// GRPCListenAddr is the control-plane listen address for the config-sync gRPC
	// server.
	GRPCListenAddr string
	TLSCAPath      string
	TLSServerName  string
	// TLSInsecure disables transport security on the data-plane dial. It is a
	// dev-only escape hatch and is rejected in deployed environments.
	TLSInsecure          bool
	GRPCTLSCertPath      string
	GRPCTLSKeyPath       string // #nosec G117 -- config struct field, not a hardcoded credential
	GRPCKeepaliveTime    time.Duration
	GRPCKeepaliveTimeout time.Duration
	GRPCMinBackoff       time.Duration
	GRPCMaxBackoff       time.Duration
	OutboxRetention      time.Duration
	OutboxMaxRows        int64
}

func (ConfigSyncConfig) Validate added in v0.3.4

func (cs ConfigSyncConfig) Validate() error

type DatabaseConfig

type DatabaseConfig struct {
	Login             string
	Host              string
	Port              int
	User              string
	Password          string // #nosec G117 -- config struct field, not a hardcoded credential
	Name              string
	SSLMode           string
	SSLRootCert       string
	MinConns          int32
	MaxConns          int32
	MaxConnLifetime   time.Duration
	MaxConnIdleTime   time.Duration
	HealthCheckPeriod time.Duration
	ConnectTimeout    time.Duration
}

type FirewallComplexityConfig added in v0.20.0

type FirewallComplexityConfig struct {
	BaseURL string
	Token   string // #nosec G117 -- config struct field, not a hardcoded credential
	Timeout time.Duration
}

FirewallComplexityConfig configures the Firewall Complexity API used by the smart-routing load balancer. Token is a static bearer sent in the "token" header; an empty BaseURL or Token disables smart routing at runtime.

type KafkaConfig

type KafkaConfig struct {
	Brokers []string
}

type LoggerConfig

type LoggerConfig struct {
	Level       slog.Level
	Format      string
	FileEnabled bool
}

type MCPDefaultIdPConfig added in v0.21.0

type MCPDefaultIdPConfig struct {
	// Issuer is the authorization server's issuer URL (e.g.
	// https://app.neuraltrust.ai/api/mcp/oauth). Empty disables the default.
	Issuer string
	// AuthorizeURL/TokenURL/JWKSURL default to {Issuer}/authorize, /token and
	// /jwks respectively when left empty.
	AuthorizeURL string
	TokenURL     string
	JWKSURL      string
	ClientID     string
	ClientSecret string // #nosec G117 -- config struct field, not a hardcoded credential
	Audiences    []string
	Scopes       []string
}

MCPDefaultIdPConfig configures the built-in NeuralTrust identity provider that MCP consumers fall back to when they have no oauth2 auth of their own. The gateway brokers the interactive login to this provider (the NeuralTrust platform acting as an OAuth2 authorization server) and mints its own MCP session token bound to the platform user, so operators do not have to stand up and register an identity provider just to run a PoC.

type MetricsConfig

type MetricsConfig struct {
	Enabled       bool
	QueueSize     int
	WorkerCount   int
	FlushInterval time.Duration
}

type OTLPConfig

type OTLPConfig struct {
	Endpoint    string
	Headers     map[string]string
	Protocol    string
	Timeout     time.Duration
	Insecure    bool
	Compression string
}

OTLPConfig holds process-level OTLP exporter defaults read from the standard OTEL_EXPORTER_OTLP_* environment variables. Per-gateway telemetry settings override any field present in the gateway configuration.

type OpenAIModerationConfig added in v0.2.4

type OpenAIModerationConfig struct {
	BaseURL string
	Timeout time.Duration
}

type PlaygroundConfig

type PlaygroundConfig struct {
	TraceStoreEnabled bool
	TraceStoreTTL     time.Duration
}

PlaygroundConfig drives the default Redis-backed trace store that lets the dashboard playground fetch the metrics Event for a request it just made. Only requests carrying the playground token are stored, with a short TTL.

type ProviderConfig

type ProviderConfig struct {
	RequestTimeout time.Duration
	MaxRetries     int
}

type RateLimitConfig added in v0.8.0

type RateLimitConfig struct {
	Enabled bool
}

RateLimitConfig gates the per-gateway plan rate limiter.

type RedisConfig

type RedisConfig struct {
	Login             string
	Host              string
	Port              int
	Password          string
	DB                int
	TLSEnabled        bool
	TLSInsecureVerify bool
	Username          string
	CacheName         string
	AWSServerless     bool
}

type SemanticCacheConfig added in v0.3.4

type SemanticCacheConfig struct {
	VectorStore string
}

SemanticCacheConfig selects the vector store backing the semantic cache plugin. VectorStore defaults to "redis".

type ServerConfig

type ServerConfig struct {
	AdminPort    int
	ProxyPort    int
	MCPPort      int
	ReadTimeout  time.Duration
	WriteTimeout time.Duration
	IdleTimeout  time.Duration
	// SecretKey signs and verifies admin-plane JWTs and encrypts vault material.
	// Empty disables admin auth token acceptance until resolved. In prod, when
	// empty at boot, the DI layer auto-provisions a shared value in Redis
	// (see crypto.ResolveSharedSecretKey) so replicas converge.
	SecretKey         string
	GatewayBaseDomain string
	MCPBaseDomain     string
	STSIssuer         string
	STSSigningKey     string
	TrustXFCCFrom     []string
	// MCPDefaultIdP is the built-in NeuralTrust identity provider used as the
	// fallback OAuth2 login for MCP consumers that have no identity provider of
	// their own. Empty Issuer disables it (behaviour unchanged).
	MCPDefaultIdP MCPDefaultIdPConfig
}

type SessionStoreConfig

type SessionStoreConfig struct {
	Enabled bool
	TTL     time.Duration
}

type TelemetryConfig

type TelemetryConfig struct {
	Enabled             bool
	KafkaTopic          string
	ExportersFile       string
	EnableRequestTraces bool
	EnablePluginTraces  bool
	// OpsMetricsEnabled turns on AgentGateway operational OTel metrics
	// (http.server.request.duration / agentgateway.request.outcome_total).
	// Independent of Enabled (product-event pipeline). Default false.
	OpsMetricsEnabled bool
	OTLP              OTLPConfig
}

type TrustGuardConfig added in v0.2.4

type TrustGuardConfig struct {
	BaseURL      string
	Timeout      time.Duration
	ClientID     string
	ClientSecret string
}

type UpstreamConfig

type UpstreamConfig struct {
	Timeout          time.Duration
	ErrorPassthrough bool
}

Jump to

Keyboard shortcuts

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