Documentation
¶
Overview ¶
Package config provides structured configuration with validation for Tjo applications. It groups related configuration into logical sections and validates all values at startup.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AppConfig ¶
type AppConfig struct {
Name string
Debug bool
EncryptionKey string
Renderer string
Cache string // redis, badger, or empty
SMSProvider string // SMS provider name
}
AppConfig holds core application settings
type CORSConfig ¶
type CORSConfig struct {
AllowedOrigins []string // Empty means block all cross-origin requests
}
CORSConfig holds CORS settings
type Config ¶
type Config struct {
App AppConfig
Server ServerConfig
Database DatabaseConfig
Redis RedisConfig
Session SessionConfig
Cookie CookieConfig
Mail MailConfig
Storage StorageConfig
Logging LoggingConfig
Jobs JobsConfig
CORS CORSConfig
OTel OTelConfig
}
Config holds all application configuration grouped by domain. Use Load() to create a validated Config from environment variables.
type CookieConfig ¶
type CookieConfig struct {
Name string
Lifetime int // in minutes
Persist bool
Secure bool
Domain string
}
CookieConfig holds cookie settings
type DatabaseConfig ¶
type DatabaseConfig struct {
Type string
Host string
Port int
User string
Password string
Name string
SSLMode string
TablePrefix string
}
DatabaseConfig holds database connection settings
func (*DatabaseConfig) DSN ¶
func (c *DatabaseConfig) DSN(rootPath string) string
DSN returns the database connection string for the configured database type
func (*DatabaseConfig) IsEnabled ¶
func (c *DatabaseConfig) IsEnabled() bool
IsEnabled returns true if a database is configured
type JobsConfig ¶
JobsConfig holds background job settings
type LoggingConfig ¶
type LoggingConfig struct {
Level string // trace, debug, info, warn, error, fatal
Format string // json, text
}
LoggingConfig holds logging settings
type MailConfig ¶
type MailConfig struct {
// SMTP settings
SMTPHost string
SMTPPort int
SMTPUsername string
SMTPPassword string
SMTPEncryption string
// From settings
FromAddress string
FromName string
Domain string
// API-based mailer settings
API string
APIKey string
APIURL string
}
MailConfig holds email settings
type OTelConfig ¶
type OTelConfig struct {
Enabled bool // Enable OpenTelemetry tracing
ServiceName string // Service name for traces
ServiceVersion string // Service version
Environment string // Deployment environment (production, staging, etc.)
Exporter string // Exporter type: otlp, zipkin, none
Endpoint string // Collector endpoint (e.g., localhost:4317)
Insecure bool // Disable TLS for exporter connection
Sampler string // Sampling strategy: always, never, ratio, parent
SampleRatio float64 // Sample ratio (0.0-1.0) when using ratio sampler
EnableMetrics bool // Enable OpenTelemetry metrics
}
OTelConfig holds OpenTelemetry settings
func (*OTelConfig) IsEnabled ¶
func (c *OTelConfig) IsEnabled() bool
IsEnabled returns true if OpenTelemetry is configured and enabled
type RedisConfig ¶
RedisConfig holds Redis connection settings
type ServerConfig ¶
ServerConfig holds HTTP server settings
type SessionConfig ¶
type SessionConfig struct {
Type string // cookie, redis, database, badger
}
SessionConfig holds session management settings
type StorageConfig ¶
type StorageConfig struct {
// S3 settings
S3Key string
S3Secret string
S3Region string
S3Endpoint string
S3Bucket string
// MinIO settings
MinIOEndpoint string
MinIOAccessKey string
MinIOSecret string
MinIORegion string
MinIOBucket string
MinIOUseSSL bool
}
StorageConfig holds file storage settings
func (*StorageConfig) IsMinIOEnabled ¶
func (c *StorageConfig) IsMinIOEnabled() bool
IsMinIOEnabled returns true if MinIO storage is configured
func (*StorageConfig) IsS3Enabled ¶
func (c *StorageConfig) IsS3Enabled() bool
IsS3Enabled returns true if S3 storage is configured