Documentation
¶
Index ¶
- Variables
- func ConfigAddItem(others *map[string]ConfigObject, key string, item ConfigObject)
- func LoadConfig[T ConfigObject](prefix string, c T, file string, ext string, path []string) error
- func LoadConfigModule[T ConfigObject](moduleName string, c T, file string, ext string, path []string) error
- func LoadConfigModuleWithAdditional[T Configurable](moduleName string, c T, additional map[string]ConfigObject, file string, ...) error
- func LoadConfigWithAdditional[T Configurable](prefix string, c T, additional map[string]ConfigObject, file string, ...) error
- func LoadDefaultConfig[T ConfigObject](c T) error
- func LoadDefaultConfigModule[T ConfigObject](moduleName string, c T) error
- func LoadDefaultConfigModuleWithAdditional[T Configurable](moduleName string, c T, additional map[string]ConfigObject) error
- func LoadDefaultConfigWithAdditional[T Configurable](c T, additional map[string]ConfigObject) error
- func SetDefaultConfigName(name string, ext string)
- type AppConfig
- type AuthConfig
- type AuthSessionConfig
- type CORSConfig
- type Config
- func (c *Config) AddOtherItem(key string, item ConfigObject)
- func (c *Config) GetFiberConfig(errorHandler fiber.ErrorHandler) fiber.Config
- func (c *Config) GetOtherItem(key string) (ConfigObject, bool)
- func (c *Config) GetOthers() map[string]ConfigObject
- func (c *Config) SetDefaults() map[string]any
- func (c *Config) SetEnvBindings() map[string]string
- type ConfigHolder
- type ConfigObject
- type Configurable
- type ConsumerConfig
- type DatabaseConfig
- type FeaturesConfig
- type FlowControlConfig
- type GoogleCredential
- type KafkaConfig
- type LoggingConfig
- type MemoryConfig
- type ModuleConfig
- type ProducerConfig
- type PubSubConfig
- type RateLimitConfig
- type RedisConfig
- type RemoteLoggingConfig
- type ServerConfig
Constants ¶
This section is empty.
Variables ¶
View Source
var InstanceViper map[string]*ConfigHolder = make(map[string]*ConfigHolder)
Functions ¶
func ConfigAddItem ¶ added in v0.0.25
func ConfigAddItem(others *map[string]ConfigObject, key string, item ConfigObject)
func LoadConfig ¶
func LoadConfigModule ¶
func LoadConfigModuleWithAdditional ¶ added in v0.0.25
func LoadConfigModuleWithAdditional[T Configurable](moduleName string, c T, additional map[string]ConfigObject, file string, ext string, path []string) error
func LoadConfigWithAdditional ¶ added in v0.0.25
func LoadConfigWithAdditional[T Configurable](prefix string, c T, additional map[string]ConfigObject, file string, ext string, path []string) error
func LoadDefaultConfig ¶
func LoadDefaultConfig[T ConfigObject](c T) error
func LoadDefaultConfigModule ¶
func LoadDefaultConfigModule[T ConfigObject](moduleName string, c T) error
func LoadDefaultConfigModuleWithAdditional ¶ added in v0.0.25
func LoadDefaultConfigModuleWithAdditional[T Configurable](moduleName string, c T, additional map[string]ConfigObject) error
func LoadDefaultConfigWithAdditional ¶ added in v0.0.25
func LoadDefaultConfigWithAdditional[T Configurable](c T, additional map[string]ConfigObject) error
func SetDefaultConfigName ¶ added in v0.0.26
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"`
AdditionalHeaders []string `mapstructure:"additional_headers"`
Module ModuleConfig `mapstructure:"module"`
}
type AuthConfig ¶
type AuthConfig struct {
Directory string `mapstructure:"directory"` // e.g., "RBAC", "ABAC"
Control string `mapstructure:"control"` // e.g., "RBAC", "ABAC"
Store string `mapstructure:"store"` // e.g., "yaml", "db"
Type string `mapstructure:"type"` // e.g., "jwt", "apikey"
Session AuthSessionConfig `mapstructure:"session"`
SecretKey string `mapstructure:"secret_key"`
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 AuthSessionConfig ¶ added in v0.0.24
type AuthSessionConfig struct {
Backend string `mapstructure:"backend"` // e.g., "cache", "file", "db"
ExpiresIn time.Duration `mapstructure:"expires_in"` // In seconds
RefreshIn time.Duration `mapstructure:"refresh_in"` // In seconds
ContentType string `mapstructure:"content_type"` // e.g., "application/json", "application/x-www-form-urlencoded"
UsernameKey string `mapstructure:"username_key"`
PasswordKey string `mapstructure:"password_key"`
}
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"`
Memory MemoryConfig `mapstructure:"memory"`
Redis RedisConfig `mapstructure:"redis"`
Kafka KafkaConfig `mapstructure:"kafka"`
PubSub PubSubConfig `mapstructure:"pubsub"`
Auth AuthConfig `mapstructure:"auth"`
Others map[string]ConfigObject
}
func (*Config) AddOtherItem ¶ added in v0.0.25
func (c *Config) AddOtherItem(key string, item ConfigObject)
func (*Config) GetFiberConfig ¶
func (c *Config) GetFiberConfig(errorHandler fiber.ErrorHandler) fiber.Config
func (*Config) GetOtherItem ¶ added in v0.0.25
func (c *Config) GetOtherItem(key string) (ConfigObject, bool)
func (*Config) GetOthers ¶ added in v0.0.24
func (c *Config) GetOthers() map[string]ConfigObject
func (*Config) SetDefaults ¶
func (*Config) SetEnvBindings ¶
type ConfigObject ¶ added in v0.0.25
type Configurable ¶
type Configurable interface {
ConfigObject
AddOtherItem(key string, item ConfigObject)
GetOtherItem(key string) (ConfigObject, bool)
GetOthers() map[string]ConfigObject
}
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"
Uri string `mapstructure:"uri"`
Scheme string `mapstructure:"scheme"`
Host string `mapstructure:"host"`
Port int `mapstructure:"port"`
User string `mapstructure:"user"`
Password string `mapstructure:"password"`
Name string `mapstructure:"name"`
SchemaName string `mapstructure:"schema_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 GoogleCredential ¶ added in v0.0.8
type GoogleCredential struct {
Type string `mapstructure:"type" json:"type"`
ProjectID string `mapstructure:"project_id" json:"project_id"`
PrivateKeyID string `mapstructure:"private_key_id" json:"private_key_id"`
PrivateKey string `mapstructure:"private_key" json:"private_key"`
ClientEmail string `mapstructure:"client_email" json:"client_email"`
ClientID string `mapstructure:"client_id" json:"client_id"`
AuthURI string `mapstructure:"auth_uri" json:"auth_uri"`
TokenURI string `mapstructure:"token_uri" json:"token_uri"`
AuthProviderX509CertURL string `mapstructure:"auth_provider_x509_cert_url" json:"auth_provider_x509_cert_url"`
ClientX509CertURL string `mapstructure:"client_x509_cert_url" json:"client_x509_cert_url"`
UniverseDomain string `mapstructure:"universe_domain" json:"universe_domain"`
}
type KafkaConfig ¶
type LoggingConfig ¶
type LoggingConfig struct {
Level string `mapstructure:"level"`
Format string `mapstructure:"format"`
Output string `mapstructure:"output"`
Remote RemoteLoggingConfig `mapstructure:"remote"`
}
type MemoryConfig ¶ added in v0.0.8
type ModuleConfig ¶
type ProducerConfig ¶
type PubSubConfig ¶
type PubSubConfig struct {
ProjectID string `mapstructure:"project_id"`
Subscription string `mapstructure:"subscription"`
Topic string `mapstructure:"topic"`
NoCredentials bool `mapstructure:"no_credentials"`
CredentialsPath string `mapstructure:"credentials"`
Credentials *GoogleCredential `mapstructure:"credentials_data"`
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"`
}
type RemoteLoggingConfig ¶ added in v0.0.19
type RemoteLoggingConfig struct {
Driver string `mapstructure:"driver"`
Uri string `mapstructure:"uri"`
SampleRate int `mapstructure:"sample_rate"`
Structured bool `mapstructure:"structured"`
DefaultTags map[string]string `mapstructure:"default_tags"`
DefaultContexts map[string]map[string]any `mapstructure:"default_contexts"`
}
Click to show internal directories.
Click to hide internal directories.