runtimeconfig

package
v0.511.0 Latest Latest
Warning

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

Go to latest
Published: Sep 7, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package runtimeconfig loads non-policy process settings for server and MCP operations. input: optional YAML runtime config path output: structured runtime Config for logging and metadata settings pos: infrastructure adapter for runtime configuration loading note: if this file changes, update this header and module README.md.

Package runtimeconfig loads non-policy process settings for server and MCP operations. input: optional YAML runtime config path output: structured runtime Config for logging and metadata settings pos: infrastructure adapter for runtime configuration loading note: if this file changes, update this header and module README.md.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrConnectionNotFound  = errors.New("connection not found")
	ErrPurposeNotAllowed   = errors.New("purpose not allowed for this connection")
	ErrPrincipalNotAllowed = errors.New("principal not allowed for this connection")
)

Functions

func ParseConnectTimeout

func ParseConnectTimeout(raw string) (time.Duration, bool, error)

ParseConnectTimeout parses a duration string for metadata connect timeout. Empty string and zero duration return (0, false, nil) indicating "use default". Positive durations return (duration, true, nil). Negative or invalid durations return an error.

Types

type APIKeyConfig added in v0.420.0

type APIKeyConfig struct {
	ID         string `yaml:"id"`
	SecretEnv  string `yaml:"secret_env"`
	SecretFile string `yaml:"secret_file"`
	// contains filtered or unexported fields
}

APIKeyConfig describes one API key identity.

type AuthConfig added in v0.420.0

type AuthConfig struct {
	Enabled bool           `yaml:"enabled"`
	Keys    []APIKeyConfig `yaml:"keys"`
}

AuthConfig controls API-key authentication.

type Config

type Config struct {
	Logging  LoggingConfig  `yaml:"logging"`
	Metadata MetadataConfig `yaml:"metadata"`
	HTTP     HTTPConfig     `yaml:"http"`
}

Config holds runtime (non-policy) process settings.

func Load

func Load(path string) (Config, error)

Load reads a runtime config YAML file. An empty path returns a zero Config. Unknown YAML fields are rejected. Read and parse errors include the path.

type ConnectionConfig added in v0.420.0

type ConnectionConfig struct {
	ID               string   `yaml:"id"`
	Dialect          string   `yaml:"dialect"` // "mysql", "tidb", "postgresql"
	Host             string   `yaml:"host"`
	Port             int      `yaml:"port"`
	Socket           string   `yaml:"socket"`
	Database         string   `yaml:"database"`
	Schema           string   `yaml:"schema"`
	User             string   `yaml:"user"`
	PasswordEnv      string   `yaml:"password_env"`
	PasswordFile     string   `yaml:"password_file"`
	ConnectTimeout   string   `yaml:"connect_timeout"`
	TLSMode          string   `yaml:"tls_mode"`    // "disabled" (default), "enabled"
	TLSCAFile        string   `yaml:"tls_ca_file"` // PEM file for private CA; only used when tls_mode=enabled
	Purposes         []string `yaml:"purposes"`    // "audit", "query_access"
	AllowedAPIKeyIDs []string `yaml:"allowed_api_key_ids"`
	// contains filtered or unexported fields
}

ConnectionConfig describes one named metadata connection in the runtime config.

func (ConnectionConfig) ResolvedCACert added in v0.420.0

func (c ConnectionConfig) ResolvedCACert() *x509.CertPool

ResolvedCACert returns the parsed CA certificate pool from tls_ca_file at startup. Returns nil when no CA file is configured or tls_mode is disabled. It never appears in serialized output.

func (ConnectionConfig) ResolvedPassword added in v0.420.0

func (c ConnectionConfig) ResolvedPassword() string

ResolvedPassword returns the password resolved from the configured secret source at startup. It never appears in serialized output.

type HTTPConfig added in v0.420.0

type HTTPConfig struct {
	Auth AuthConfig `yaml:"auth"`
}

HTTPConfig controls HTTP service settings.

type LoggingConfig

type LoggingConfig struct {
	Level  string       `yaml:"level"`
	Format string       `yaml:"format"`
	Output string       `yaml:"output"`
	File   string       `yaml:"file"`
	Rotate RotateConfig `yaml:"rotate"`
}

LoggingConfig controls structured logging behavior.

type MetadataConfig

type MetadataConfig struct {
	ConnectTimeout string             `yaml:"connect_timeout"`
	Connections    []ConnectionConfig `yaml:"connections"`
}

MetadataConfig controls metadata connection behavior.

type Registry added in v0.420.0

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

func ValidateAndBuildRegistry added in v0.420.0

func ValidateAndBuildRegistry(cfg Config) (*Registry, error)

func (*Registry) Authorize added in v0.420.0

func (r *Registry) Authorize(principalID, connectionID, purpose string) error

func (*Registry) IsAuthEnabled added in v0.420.0

func (r *Registry) IsAuthEnabled() bool

IsAuthEnabled reports whether API-key authentication is required.

func (*Registry) LookupConnection added in v0.420.0

func (r *Registry) LookupConnection(connectionID string) (ConnectionConfig, bool)

func (*Registry) ResolveAPIKey added in v0.420.0

func (r *Registry) ResolveAPIKey(rawKey string) (string, bool)

func (*Registry) String added in v0.420.0

func (r *Registry) String() string

type RotateConfig

type RotateConfig struct {
	Enabled    *bool `yaml:"enabled"`
	MaxSizeMB  *int  `yaml:"max_size_mb"`
	MaxBackups *int  `yaml:"max_backups"`
	MaxAgeDays *int  `yaml:"max_age_days"`
	Compress   *bool `yaml:"compress"`
}

RotateConfig controls log file rotation settings. Pointer fields distinguish "unset" from "explicit zero".

Jump to

Keyboard shortcuts

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