Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func SaveConfig ¶
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 ¶
LoadConfig loads the configuration from file and environment variables.
func LoadTestConfig ¶
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 ¶
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.