Documentation
¶
Index ¶
- Variables
- func LoadConfig[T Configurable](prefix string, c T, file string, ext string, path []string) error
- func LoadConfigModule[T Configurable](moduleName string, c T, file string, ext string, path []string) error
- func LoadDefaultConfig[T Configurable](c T) error
- func LoadDefaultConfigModule[T Configurable](moduleName string, c T) error
- type AppConfig
- type AuthConfig
- type CORSConfig
- type Config
- type ConfigHolder
- type Configurable
- type ConsumerConfig
- type DatabaseConfig
- type FeaturesConfig
- type FlowControlConfig
- type KafkaConfig
- type LoggingConfig
- type ModuleConfig
- type ProducerConfig
- type PubSubConfig
- type RateLimitConfig
- type RedisConfig
- type ServerConfig
Constants ¶
This section is empty.
Variables ¶
View Source
var InstanceViper map[string]*ConfigHolder = make(map[string]*ConfigHolder)
Functions ¶
func LoadConfig ¶
func LoadConfigModule ¶
func LoadDefaultConfig ¶
func LoadDefaultConfig[T Configurable](c T) error
func LoadDefaultConfigModule ¶
func LoadDefaultConfigModule[T Configurable](moduleName string, c T) error
Types ¶
type AppConfig ¶
type AppConfig struct {
Name string `mapstructure:"name"`
Version string `mapstructure:"version"`
Environment string `mapstructure:"environment"`
Features FeaturesConfig `mapstructure:"features"`
Logging LoggingConfig `mapstructure:"logging"`
CORS CORSConfig `mapstructure:"cors"`
RateLimit RateLimitConfig `mapstructure:"rate_limit"`
SecurityHeaders bool `mapstructure:"security_headers"`
Module ModuleConfig `mapstructure:"module"`
}
type AuthConfig ¶
type AuthConfig struct {
Control string `mapstructure:"control"` // e.g., "RBAC", "ABAC"
Store string `mapstructure:"store"` // e.g., "yaml", "db"
Type string `mapstructure:"type"` // e.g., "jwt", "apikey"
SecretKey string `mapstructure:"secret_key"`
ExpiresIn time.Duration `mapstructure:"expires_in"` // In seconds
APIKeyHeader string `mapstructure:"api_key_header"` // Header name for API key (default: "X-API-Key")
APIKeyPrefix string `mapstructure:"api_key_prefix"` // Optional prefix for API key validation
}
type CORSConfig ¶
type CORSConfig struct {
AllowOrigins []string `mapstructure:"allow_origins"`
AllowMethods []string `mapstructure:"allow_methods"`
AllowHeaders []string `mapstructure:"allow_headers"`
ExposeHeaders []string `mapstructure:"expose_headers"`
AllowCredentials bool `mapstructure:"allow_credentials"`
MaxAge time.Duration `mapstructure:"max_age"`
}
type Config ¶
type Config struct {
App AppConfig `mapstructure:"app"`
Server ServerConfig `mapstructure:"server"`
Database DatabaseConfig `mapstructure:"database"`
Redis RedisConfig `mapstructure:"redis"`
Kafka KafkaConfig `mapstructure:"kafka"`
PubSub PubSubConfig `mapstructure:"pubsub"`
Auth AuthConfig `mapstructure:"auth"`
}
func (*Config) GetFiberConfig ¶
func (c *Config) GetFiberConfig(errorHandler fiber.ErrorHandler) fiber.Config
func (*Config) SetDefaults ¶
func (*Config) SetEnvBindings ¶
type Configurable ¶
type ConsumerConfig ¶
type ConsumerConfig struct {
MaxMessagesPerPull int `mapstructure:"maxmessages"`
SleepTimeBetweenPulls time.Duration `mapstructure:"sleeptime"`
AcknowledgeTimeout time.Duration `mapstructure:"acktimeout"`
RetryCount int `mapstructure:"retrycount"`
RetryDelay time.Duration `mapstructure:"retrydelay"`
FlowControl FlowControlConfig `mapstructure:"flowcontrol"`
}
type DatabaseConfig ¶
type DatabaseConfig struct {
Driver string `mapstructure:"driver"` // supported: "postgres", "mysql", "sqlite", "mongodb"
Host string `mapstructure:"host"`
Port int `mapstructure:"port"`
User string `mapstructure:"user"`
Password string `mapstructure:"password"`
Name string `mapstructure:"name"`
SSLMode string `mapstructure:"ssl_mode"`
Attributes map[string]string `mapstructure:"attributes"` // Additional connection parameters
MaxIdleConns int `mapstructure:"max_idle_conns"`
MaxOpenConns int `mapstructure:"max_open_conns"`
ConnMaxLifetime time.Duration `mapstructure:"conn_max_lifetime"`
SlaveHosts []DatabaseConfig `mapstructure:"slave_hosts"`
}
type FeaturesConfig ¶
type FlowControlConfig ¶
type KafkaConfig ¶
type LoggingConfig ¶
type ModuleConfig ¶
type ProducerConfig ¶
type PubSubConfig ¶
type PubSubConfig struct {
ProjectID string `mapstructure:"project_id"`
Subscription string `mapstructure:"subscription"`
Topic string `mapstructure:"topic"`
CredentialsPath string `mapstructure:"credentials"`
Consumer ConsumerConfig `mapstructure:"consumer"`
Producer ProducerConfig `mapstructure:"producer"`
}
type RateLimitConfig ¶
type RedisConfig ¶
type RedisConfig struct {
Host string `mapstructure:"host"`
Port int `mapstructure:"port"`
Password string `mapstructure:"password"`
DB int `mapstructure:"db"`
SlaveHosts []RedisConfig `mapstructure:"slave_hosts"`
}
Click to show internal directories.
Click to hide internal directories.