Documentation ¶
Overview ¶
Package config @Author hubo 2024/9/26 16:27:00
Package config @Author hubo 2024/9/26 14:14:00 service models model
Package config @Author hubo 2024/9/26 17:05:00
Package config @Author hubo 2024/9/27 17:07:00
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func LoadLocalConfig ¶
func LoadLocalConfig[S IServiceLocalConfig](configPath string) (*S, error)
LoadLocalConfig Load service models from yaml.
Types ¶
type AppConfig ¶
type AppConfig struct {
DbConfig DataBaseConfig `mapstructure:"database"`
}
AppConfig Consul KV 存储基础配置
func (AppConfig) GetBaseConfig ¶
GetBaseConfig 获取 KV 配置中的基础配置
type ConsulConfig ¶
type DataBaseConfig ¶
type DataBaseConfig struct { Driver string `mapstructure:"driver"` Host string `mapstructure:"host"` Port int `mapstructure:"port"` User string `mapstructure:"user"` Password string `mapstructure:"password"` DbName string `mapstructure:"dbname"` UseLogger bool `mapstructure:"useLogger"` LogLevel string `mapstructure:"logLevel"` GenConfig GenDBConfig `mapstructure:"gen"` MaxIdleConns int `mapstructure:"maxIdleConns"` MaxOpenConns int `mapstructure:"maxOpenConns"` ExtraKeys []string `mapstructure:"extraKeys"` // 由于 Viper 存在将 key 强制转为小写的问题(https://github.com/spf13/viper/issues/373), 需存储 ExtraParams 的 keys ExtraParams map[string]interface{} `mapstructure:"extraParams"` }
func (*DataBaseConfig) GetExParamsUrl ¶
func (c *DataBaseConfig) GetExParamsUrl() string
func (*DataBaseConfig) GetGormConfig ¶
func (c *DataBaseConfig) GetGormConfig() *gorm.Config
func (*DataBaseConfig) GetLogLevel ¶
func (c *DataBaseConfig) GetLogLevel() logger.LogLevel
type GenDBConfig ¶
type IAppConfig ¶
type IAppConfig interface {
GetBaseConfig() *AppConfig
}
IAppConfig Consul 上服务配置接口(空接口)
type IServiceLocalConfig ¶
type IServiceLocalConfig interface {
GetBaseConfig() *ServiceLocalConfig
}
IServiceLocalConfig 本地配置接口
type LoggerConfig ¶
type LoggerConfig struct { Level string `mapstructure:"level"` // 日志打印级别 Prefix string `mapstructure:"prefix"` // 日志前缀 Format string `mapstructure:"format"` // 输出 Directory string `mapstructure:"directory"` // 输出路径 EncodeLevel string `mapstructure:"encode-level"` // 编码级别 StacktraceKey string `mapstructure:"stacktrace-key"` // 栈名 ShowLine bool `mapstructure:"show-line"` // 显示行 LogInConsole bool `mapstructure:"log-in-console"` // 是否输出到控制台 RetentionDay int `mapstructure:"retention-day"` // 日志保留天数 }
func (*LoggerConfig) Encoder ¶
func (c *LoggerConfig) Encoder() zapcore.Encoder
func (*LoggerConfig) GetLevels ¶
func (c *LoggerConfig) GetLevels() []zapcore.Level
func (*LoggerConfig) LevelEncoder ¶
func (c *LoggerConfig) LevelEncoder() zapcore.LevelEncoder
LevelEncoder 根据 EncodeLevel 返回 zapcore.LevelEncoder
type ServiceLocalConfig ¶
type ServiceLocalConfig struct { Service struct { Id string `mapstructure:"-"` Name string `mapstructure:"name"` Host string `mapstructure:"host"` Port int `mapstructure:"port"` Check struct { Interval string `mapstructure:"interval"` Timeout string `mapstructure:"timeout"` } `mapstructure:"check"` } `mapstructure:"service"` Logger LoggerConfig `mapstructure:"logger"` Consul ConsulConfig `mapstructure:"consul"` }
ServiceLocalConfig 本地配置实体
func (ServiceLocalConfig) GetBaseConfig ¶
func (s ServiceLocalConfig) GetBaseConfig() *ServiceLocalConfig
Click to show internal directories.
Click to hide internal directories.