config

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Sep 3, 2025 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AllSettings added in v0.3.0

func AllSettings() map[string]interface{}

AllSettings returns all configuration settings as a map. Useful for debugging and configuration inspection.

func BindEnv added in v0.3.0

func BindEnv(key string, envVar string) error

BindEnv explicitly binds an environment variable to a config key. This is useful for non-standard environment variable names.

func GetBool added in v0.3.0

func GetBool(key string) bool

GetBool retrieves a boolean value from configuration by key.

func GetDuration added in v0.3.0

func GetDuration(key string) time.Duration

GetDuration retrieves a duration value from configuration by key.

func GetInt added in v0.3.0

func GetInt(key string) int

GetInt retrieves an integer value from configuration by key.

func GetString added in v0.3.0

func GetString(key string) string

GetString retrieves a string value from configuration by key. This enables dynamic access to config values without unmarshaling.

func IsSet added in v0.3.0

func IsSet(key string) bool

IsSet checks if a configuration key is set.

func WatchConfig added in v0.3.0

func WatchConfig(onChange func(*Config)) error

WatchConfig enables automatic configuration reloading on changes. The callback function will be called whenever the config file changes.

Types

type CalibrationConfig

type CalibrationConfig struct {
	Enabled              bool          `mapstructure:"enabled"`
	Schedule             string        `mapstructure:"schedule"`
	BatchSize            int           `mapstructure:"batch_size"`
	MinFeedbackThreshold int           `mapstructure:"min_feedback_threshold"`
	DecayRate            float64       `mapstructure:"decay_rate"`
	RecencyDecayDays     int           `mapstructure:"recency_decay_days"`
	MaxFrequencyBoost    float64       `mapstructure:"max_frequency_boost"`
	CalibrationTimeout   time.Duration `mapstructure:"calibration_timeout"`
}

CalibrationConfig holds confidence calibration settings.

type Config

type Config struct {
	Redis       RedisConfig       `mapstructure:"redis"`
	MCP         MCPConfig         `mapstructure:"mcp"`
	Logging     LoggingConfig     `mapstructure:"logging"`
	Calibration CalibrationConfig `mapstructure:"calibration"`
}

Config holds all application configuration for the simplified server.

func Load

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

Load reads configuration from a YAML file and applies environment overrides using Viper.

func LoadFromEnv

func LoadFromEnv() *Config

LoadFromEnv creates a config purely from environment variables using Viper.

func LoadWithFormat added in v0.3.0

func LoadWithFormat(path string, format string) (*Config, error)

LoadWithFormat loads configuration from a file with automatic format detection. Viper supports YAML, JSON, TOML, HCL, and more formats automatically.

func (*Config) Validate

func (c *Config) Validate() error

Validate checks if the configuration is valid.

type LoggingConfig

type LoggingConfig struct {
	Level  string `mapstructure:"level"`
	Format string `mapstructure:"format"`
}

LoggingConfig holds logging settings.

type MCPConfig

type MCPConfig struct {
	Name    string `mapstructure:"name"`
	Version string `mapstructure:"version"`
}

MCPConfig holds MCP server information.

type RedisConfig

type RedisConfig struct {
	Addr     string `mapstructure:"addr"`
	Password string `mapstructure:"password"`
	DB       int    `mapstructure:"db"`
}

RedisConfig holds Redis connection configuration.

Jump to

Keyboard shortcuts

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