config

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 18, 2026 License: MIT Imports: 10 Imported by: 1 module, 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

func SaveConfig

func SaveConfig(cfg *Config, filePath string) error

SaveConfig writes the provided Config struct to a YAML file.

Types

type CORSConfig

type CORSConfig struct {
	AllowedOrigins   []string `mapstructure:"allowed_origins" yaml:"allowed_origins"`
	AllowedMethods   []string `mapstructure:"allowed_methods" yaml:"allowed_methods"`
	AllowedHeaders   []string `mapstructure:"allowed_headers" yaml:"allowed_headers"`
	AllowCredentials bool     `mapstructure:"allow_credentials" yaml:"allow_credentials"`
	MaxAge           int      `mapstructure:"max_age" yaml:"max_age"`
}

type Config

type Config struct {
	LogLevel          string `mapstructure:"log_level"`
	Mode              string `mapstructure:"mode" yaml:"mode"` // Gin mode: development | production | test
	TelemetryEnabled  bool   `mapstructure:"telemetry_enabled"`
	JWTSecret         string `mapstructure:"jwt_secret"`
	DatabaseURL       string `mapstructure:"database_url"`
	ServerPort        string `mapstructure:"server_port"`
	MinPasswordLength int    `json:"min_password_length" yaml:"min_password_length"`

	// Redis settings
	Redis RedisConfig `mapstructure:"redis"`

	// CORS settings
	CORS CORSConfig `mapstructure:"cors"`

	// LLM settings
	LLM LLMConfig `mapstructure:"llm" yaml:"llm"`

	// Rate limiting for /auth/* (shared across replicas through Redis)
	RateLimit RateLimitConfig `mapstructure:"rate_limit" yaml:"rate_limit"`

	// TrustedProxies lists the proxies (IPs or CIDRs) whose X-Forwarded-For
	// header is trusted to find the client IP. Empty: use the TCP peer.
	TrustedProxies []string `mapstructure:"trusted_proxies" yaml:"trusted_proxies"`
}

Config holds all application settings.

func LoadConfig

func LoadConfig(configPath string) (Config, error)

LoadConfig loads the configuration from file and environment variables.

func LoadTestConfig

func LoadTestConfig() (Config, error)

LoadTestConfig loads a test configuration file.

func (Config) RedisClientOpt

func (c Config) RedisClientOpt() asynq.RedisClientOpt

RedisClientOpt returns the asynq connection options for the configured Redis, including password and database index.

func (Config) RedisOptions

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

RedisOptions returns go-redis options for the configured Redis.

type LLMConfig

type LLMConfig struct {
	Provider  string `mapstructure:"provider" yaml:"provider"`
	Model     string `mapstructure:"model" yaml:"model"`
	APIKey    string `mapstructure:"api_key" yaml:"api_key"`
	APISecret string `mapstructure:"api_secret" yaml:"api_secret"`
	BaseURL   string `mapstructure:"base_url" yaml:"base_url"` // optional API endpoint override
}

LLMConfig holds settings for Large Language Model providers.

type RateLimitConfig

type RateLimitConfig struct {
	Enabled bool `mapstructure:"enabled" yaml:"enabled"`
	// AuthPerMinute is the number of /auth/* requests allowed per client IP
	// per minute (0 disables it).
	AuthPerMinute int `mapstructure:"auth_per_minute" yaml:"auth_per_minute"`
	// LoginFailures is the number of failed logins allowed per username and
	// client IP within LoginWindow before further attempts get 429.
	LoginFailures int           `mapstructure:"login_failures" yaml:"login_failures"`
	LoginWindow   time.Duration `mapstructure:"login_window" yaml:"login_window"`
}

RateLimitConfig protects the authentication endpoints.

type RedisConfig

type RedisConfig struct {
	Address  string `mapstructure:"address" yaml:"address"`
	Password string `mapstructure:"password" yaml:"password"`
	DB       int    `mapstructure:"db" yaml:"db"`
}

RedisConfig holds settings for the Redis connection.

Jump to

Keyboard shortcuts

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