Documentation
¶
Index ¶
- Constants
- func IsDatabaseConfigured(cfg *DatabaseConfig) bool
- func Validate(cfg *Config) error
- type AppConfig
- type Config
- func (c *Config) All() map[string]interface{}
- func (c *Config) Custom() map[string]interface{}
- func (c *Config) Exists(key string) bool
- func (c *Config) GetBool(key string, defaultVal ...bool) bool
- func (c *Config) GetFloat64(key string, defaultVal ...float64) float64
- func (c *Config) GetInt(key string, defaultVal ...int) int
- func (c *Config) GetInt64(key string, defaultVal ...int64) int64
- func (c *Config) GetRequiredBool(key string) (bool, error)
- func (c *Config) GetRequiredFloat64(key string) (float64, error)
- func (c *Config) GetRequiredInt(key string) (int, error)
- func (c *Config) GetRequiredInt64(key string) (int64, error)
- func (c *Config) GetRequiredString(key string) (string, error)
- func (c *Config) GetString(key string, defaultVal ...string) string
- func (c *Config) Unmarshal(key string, out interface{}) error
- type DatabaseConfig
- type LogConfig
- type MessagingConfig
- type ServerConfig
Constants ¶
const ( PostgreSQL = "postgresql" Oracle = "oracle" )
Database type constants
const ( EnvDevelopment = "development" EnvStaging = "staging" EnvProduction = "production" )
Environment constants
Variables ¶
This section is empty.
Functions ¶
func IsDatabaseConfigured ¶ added in v0.4.1
func IsDatabaseConfigured(cfg *DatabaseConfig) bool
IsDatabaseConfigured determines if database is intentionally configured. This mirrors the logic used in app.isDatabaseEnabled() for consistency.
Types ¶
type Config ¶
type Config struct {
App AppConfig `koanf:"app"`
Server ServerConfig `koanf:"server"`
Database DatabaseConfig `koanf:"database"`
Log LogConfig `koanf:"log"`
Messaging MessagingConfig `koanf:"messaging"`
// contains filtered or unexported fields
}
func Load ¶
Load loads configuration from multiple sources with priority: 1. Environment variables (highest priority) 2. YAML configuration files 3. Default values (lowest priority)
func (*Config) GetBool ¶ added in v0.4.0
GetBool retrieves a bool value from the configuration or the provided default.
func (*Config) GetFloat64 ¶ added in v0.4.0
GetFloat64 retrieves a float64 value from the configuration or the provided default.
func (*Config) GetInt ¶ added in v0.4.0
GetInt retrieves an int value from the configuration or the provided default.
func (*Config) GetInt64 ¶ added in v0.4.0
GetInt64 retrieves an int64 value from the configuration or the provided default.
func (*Config) GetRequiredBool ¶ added in v0.4.0
GetRequiredBool retrieves a required bool value from the configuration.
func (*Config) GetRequiredFloat64 ¶ added in v0.4.0
GetRequiredFloat64 retrieves a required float64 value from the configuration.
func (*Config) GetRequiredInt ¶ added in v0.4.0
GetRequiredInt retrieves a required int value from the configuration.
func (*Config) GetRequiredInt64 ¶ added in v0.4.0
GetRequiredInt64 retrieves a required int64 value from the configuration.
func (*Config) GetRequiredString ¶ added in v0.4.0
GetRequiredString retrieves a required string value from the configuration.
type DatabaseConfig ¶
type DatabaseConfig struct {
Type string `koanf:"type"` // "postgresql" or "oracle"
Host string `koanf:"host"`
Port int `koanf:"port"`
Database string `koanf:"database"`
Username string `koanf:"username"`
Password string `koanf:"password"`
SSLMode string `koanf:"ssl_mode"`
MaxConns int32 `koanf:"max_conns"`
MaxIdleConns int32 `koanf:"max_idle_conns"`
ConnMaxLifetime time.Duration `koanf:"conn_max_lifetime"`
ConnMaxIdleTime time.Duration `koanf:"conn_max_idle_time"`
// Oracle-specific settings
ServiceName string `koanf:"service_name"` // Oracle service name
SID string `koanf:"sid"` // Oracle SID
// Connection string override (if needed)
ConnectionString string `koanf:"connection_string"`
}