Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ConfigLoader ¶
type ConfigLoader[T Settings] struct { // contains filtered or unexported fields }
ConfigLoader handles loading and validation of all configurations
func NewConfigLoader ¶
func NewConfigLoader[T Settings]() *ConfigLoader[T]
NewConfigLoader creates a new configuration loader
func (*ConfigLoader[T]) GetCore ¶
func (l *ConfigLoader[T]) GetCore() *CoreConfig
GetCore returns the core configuration
func (*ConfigLoader[T]) GetProject ¶
func (l *ConfigLoader[T]) GetProject() T
GetProject returns the project settings
func (*ConfigLoader[T]) LoadFromFile ¶
func (l *ConfigLoader[T]) LoadFromFile(path string) error
LoadFromFile loads configuration from a YAML/JSON file
func (*ConfigLoader[T]) LoadModuleConfig ¶
func (l *ConfigLoader[T]) LoadModuleConfig(config Config) error
LoadModuleConfig retrieves configuration for a specific module
func (*ConfigLoader[T]) ValidateAll ¶
func (l *ConfigLoader[T]) ValidateAll() []ValidationError
ValidateAll performs validation on all configurations
type CoreConfig ¶
type CoreConfig struct {
Environment string `yaml:"environment" json:"environment" validate:"required,oneof=development staging production test"`
Debug bool `yaml:"debug" json:"debug"`
Database DatabaseConfig `yaml:"database" json:"database"`
Server ServerConfig `yaml:"server" json:"server" validate:"required"`
ProjectRoot string `yaml:"-" json:"-"`
}
CoreConfig represents the essential framework configuration
func (*CoreConfig) IsProduction ¶
func (c *CoreConfig) IsProduction() bool
func (*CoreConfig) Validate ¶
func (c *CoreConfig) Validate() error
type DatabaseConfig ¶
type DatabaseConfig struct {
Enabled bool `yaml:"enabled" json:"enabled"`
Driver string `yaml:"driver" json:"driver" validate:"omitempty,oneof=postgres sqlite cloudsqlpostgres"`
Host string `yaml:"host" json:"host"`
Port string `yaml:"port" json:"port"`
Name string `yaml:"name" json:"name"`
Username string `yaml:"username" json:"username"`
Password string `yaml:"password" json:"password"`
SSLMode string `yaml:"sslmode" json:"sslmode"`
}
DatabaseConfig holds database connection settings
type RawConfig ¶
type RawConfig[T Settings] struct { Core CoreConfig `yaml:"core" json:"core" validate:"required"` Modules map[string]any `yaml:"modules" json:"modules"` Project T `yaml:"project" json:"project" validate:"required"` }
RawConfig represents the structure of the configuration file
type ServerConfig ¶
type ServerConfig struct {
Host string `yaml:"host" json:"host" validate:"required"`
Port string `yaml:"port" json:"port" validate:"required"`
AllowedOrigins string `yaml:"allowedOrigins" json:"allowedOrigins"`
ReadTimeout time.Duration `yaml:"readTimeout" json:"readTimeout"`
WriteTimeout time.Duration `yaml:"writeTimeout" json:"writeTimeout"`
ShutdownTimeout time.Duration `yaml:"shutdownTimeout" json:"shutdownTimeout"`
}
ServerConfig holds HTTP server settings
type ValidationError ¶
ValidationError represents a configuration validation error