config

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: May 31, 2026 License: GPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AuditConfig added in v0.4.0

type AuditConfig struct {
	Path string `json:"path"` // file path for JSONL audit log; empty = disabled
}

AuditConfig holds audit logging settings.

type CacheConfig

type CacheConfig struct {
	Driver string `json:"driver"`
	URL    string `json:"url"`
}

CacheConfig holds cache connection settings (driver provided by cache module). The URL field may contain credentials (e.g., redis://user:pass@host:6379). LogValue redacts the URL when logged via slog to prevent credential exposure.

func (CacheConfig) LogValue added in v0.4.0

func (c CacheConfig) LogValue() slog.Value

LogValue implements slog.LogValuer to redact credentials from the URL when this config is logged.

type ChangedFields added in v0.4.0

type ChangedFields struct {
	LogLevel      bool
	LogFormat     bool
	AuditPath     bool
	StrictCall    bool
	StrictPublish bool
	SeedNodes     bool
	JoinToken     bool
	// Unsafe indicates changes that require a restart (addresses, certs, etc.).
	Unsafe       bool
	UnsafeFields []string
}

ChangedFields describes which config fields changed during a reload. The caller can use this to apply only the changed subset to subsystems.

type Config

type Config struct {
	Server   ServerConfig   `json:"server"`
	GRPC     GRPCConfig     `json:"grpc"`
	Log      LogConfig      `json:"log"`
	Database DatabaseConfig `json:"database"`
	Cache    CacheConfig    `json:"cache"`
	Audit    AuditConfig    `json:"audit"`
	Storage  StorageConfig  `json:"storage"`
	Modules  map[string]any `json:"modules"` // per-module arbitrary config
}

Config is the top-level configuration for MuxCore.

func Default

func Default() *Config

Default returns a Config populated with sensible defaults.

func Load

func Load(path string) (*Config, error)

Load reads configuration from a JSON file, overlays environment variable overrides, and validates the result. If path is empty, only defaults and env vars are used.

func (*Config) RedactedJSON added in v0.4.0

func (c *Config) RedactedJSON() (json.RawMessage, error)

RedactedJSON returns the config as JSON with secrets removed. Credential URLs (database, cache) are redacted, and TLS key paths are replaced with "<set>" to avoid leaking filesystem layout.

type DatabaseConfig

type DatabaseConfig struct {
	Driver string `json:"driver"`
	URL    string `json:"url"`
}

DatabaseConfig holds database connection settings (driver provided by database module). The URL field may contain credentials (e.g., postgres://user:pass@host/db). LogValue redacts the URL when logged via slog to prevent credential exposure.

func (DatabaseConfig) LogValue added in v0.4.0

func (d DatabaseConfig) LogValue() slog.Value

LogValue implements slog.LogValuer to redact credentials from the URL when this config is logged. Returns the URL with the userinfo portion replaced with "***".

type GRPCConfig added in v0.3.0

type GRPCConfig struct {
	Addr        string   `json:"addr"`         // listen address, e.g. ":9090"
	CertFile    string   `json:"cert_file"`    // path to TLS certificate file
	KeyFile     string   `json:"key_file"`     // path to TLS key file
	MTLSEnabled bool     `json:"mtls_enabled"` // require mutual TLS
	CACertFile  string   `json:"ca_cert_file"` // path to CA cert for mTLS client verification
	SeedNodes   []string `json:"seed_nodes"`   // comma-separated host:port of existing cluster nodes to join
	JoinToken   string   `json:"join_token"`   // pre-shared token required to join the cluster
	// MaxMessageSizeMB is the maximum gRPC message size in megabytes.
	// Applies to both send and receive. Default 32MB. Increase for large storage objects.
	MaxMessageSizeMB int `json:"max_message_size_mb"`
}

GRPCConfig holds gRPC server settings.

type LogConfig

type LogConfig struct {
	Level  string `json:"level"`  // debug, info, warn, error
	Format string `json:"format"` // text, json
}

LogConfig controls structured logging output.

type ReloadResult added in v0.4.0

type ReloadResult struct {
	Config  *Config
	Changes *ChangedFields
}

ReloadResult is the outcome of a config reload.

func Reload added in v0.4.0

func Reload(previous *Config, path string) (*ReloadResult, error)

Reload re-reads the config file and returns the new config along with a description of which fields changed. Safe changes (log level, audit path, etc.) can be applied live. Unsafe changes (server address, TLS certs, ports) require a restart.

Returns the existing config unchanged if the file cannot be read or parsed.

type ServerConfig

type ServerConfig struct {
	Addr         string `json:"addr"`          // listen address, e.g. ":8080"
	ReadTimeout  int    `json:"read_timeout"`  // seconds
	WriteTimeout int    `json:"write_timeout"` // seconds
	CertFile     string `json:"cert_file"`     // path to TLS certificate PEM
	KeyFile      string `json:"key_file"`      // path to TLS private key PEM
}

ServerConfig holds HTTP server settings.

type StorageConfig added in v0.4.0

type StorageConfig struct {
	// ReadTimeoutSeconds caps Get, Exists, Stat, List, Stream operations. Default: 30.
	ReadTimeoutSeconds int `json:"read_timeout_seconds"`
	// WriteTimeoutSeconds caps Put operations (larger files need more time). Default: 300.
	WriteTimeoutSeconds int `json:"write_timeout_seconds"`
	// DeleteTimeoutSeconds caps Delete and Move operations. Default: 30.
	DeleteTimeoutSeconds int `json:"delete_timeout_seconds"`
}

StorageConfig controls per-operation timeouts for the storage orchestrator. Timeouts wrap provider calls so a hung provider cannot block callers indefinitely.

Jump to

Keyboard shortcuts

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