Documentation
¶
Index ¶
- Constants
- Variables
- func InitConfig(ctx context.Context, localConfigPath string, bootConfig *BootstrapConfig)
- func RegisterConfigChangeHandler(dataId, group string, handler ChangeHandler)
- type BootOption
- type BootstrapConfig
- type ChangeHandler
- type CustomConfig
- type GlobalConfig
- type LoggerConfig
- type MySqlConfig
- type NaCosConfig
- type Option
- type RedisConfig
- type WebGroup
- type WebPath
- type WebServerConfig
Constants ¶
View Source
const ( DefaultGroup = "DEFAULT_GROUP" LoggerDataId = "logger" MySqlDataId = "mysql" RedisDataId = "redis" OssDataOddId = "oss" PowerJobDataId = "powerjob" GrpcDataId = "grpc" PrometheusDataId = "prometheus" WebDataId = "web" )
Variables ¶
View Source
var NaCosClient config_client.IConfigClient
Functions ¶
func InitConfig ¶
func InitConfig(ctx context.Context, localConfigPath string, bootConfig *BootstrapConfig)
初始化配置
func RegisterConfigChangeHandler ¶
func RegisterConfigChangeHandler(dataId, group string, handler ChangeHandler)
RegisterConfigChangeHandler 注册配置变更监听
Types ¶
type BootOption ¶
type BootOption func(*BootstrapConfig)
func WithCustomerConfigs ¶
func WithCustomerConfigs(name string, configs interface{}) BootOption
func WithWebApi ¶
func WithWebApi(api []WebGroup) BootOption
func WithWebMiddlewares ¶
func WithWebMiddlewares(hf []gin.HandlerFunc) BootOption
func WithWebValidators ¶
func WithWebValidators(validators map[string]validator.Func) BootOption
type BootstrapConfig ¶
type CustomConfig ¶
type CustomConfig struct {
Name string
ConfigStruct *interface{}
}
type GlobalConfig ¶
type GlobalConfig struct {
NaCos *NaCosConfig `yaml:"nacos"`
WebServer *WebServerConfig `yaml:"web-server"`
Logger *LoggerConfig `yaml:"logger"`
MySQL *MySqlConfig `yaml:"mysql"`
Redis *RedisConfig `yaml:"redis"`
}
var GlobalConf *GlobalConfig
type LoggerConfig ¶
type LoggerConfig struct {
Level string `yaml:"level"` // 日志级别
Filename string `yaml:"filename"` // 日志文件名
MaxSize int `yaml:"max-size"` // 日志文件最大大小
MaxAge int `yaml:"max-age"` // 日志文件最大保存时间
MaxBackups int `yaml:"max-backups"` // 日志文件最大保存个数
Compress bool `yaml:"compress"` // 日志文件是否压缩
}
LoggerConfig 日志配置结构体
type MySqlConfig ¶
type MySqlConfig struct {
Host string `yaml:"host"`
Port int `yaml:"port"`
UserName string `yaml:"user-name"`
Password string `yaml:"password"`
DbName string `yaml:"db-name"`
MaxIdle int `yaml:"max-idle"` //最大空闲连接
MaxConn int `yaml:"max-conn"` //最大连接数
MaxLife int `yaml:"max-life"` //连接生命周期,单位为分钟
MaxIdleTime int `yaml:"max-idle-time"` //连接空闲时间,单位为分钟
}
MySqlConfig mysql配置
type NaCosConfig ¶
type NaCosConfig struct {
ServerAddr string `yaml:"server-addr"` // NaCos服务器地址
UserName string `yaml:"user-name"` // NaCos用户名
Password string `yaml:"password"` // NaCos <PASSWORD>
Namespace string `yaml:"namespace"` // NaCos命名空间
}
NaCosConfig 专门用于NaCos的配置信息
type Option ¶
type Option func(*GlobalConfig)
func WithLoggerConfig ¶
func WithLoggerConfig(logger *LoggerConfig) Option
func WithMySqlConfig ¶
func WithMySqlConfig(mysql *MySqlConfig) Option
func WithNaCosConfig ¶
func WithNaCosConfig(nc *NaCosConfig) Option
func WithRedisConfig ¶
func WithRedisConfig(redis *RedisConfig) Option
type RedisConfig ¶
type RedisConfig struct {
ServerAddress string `yaml:"server-address"` // Redis服务器地址
Password string `yaml:"password"` // Redis密码
DB int `yaml:"db"` // Redis数据库
PoolSize int `yaml:"pool-size"` // Redis连接池大小
MinIdleCones int `yaml:"min-idle-cones"` // Redis最小空闲连接数
}
RedisConfig Redis配置结构体
type WebServerConfig ¶
Click to show internal directories.
Click to hide internal directories.