Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ConfigIn ¶
type ConfigIn interface {
// InitViperLocal 配置单个文件
// - filePath是文件路径 精确到文件名,如:config/dev.yaml
// - defaultConfig是默认配置项【viper.SetDefault("mysql.dsn", "root:root@tcp(localhost:3306)/webook")】
InitViperLocal(filePath string, defaultConfig ...DefaultConfig) error
// InitViperLocals 配置多个文件
// - 读取多个配置文件,fileName是文件名 精确文件名不带后缀,fileType是文件得类型eg: yaml、json....,filePath是文件路径 精确到文件夹名,
// - defaultConfig是默认配置项【viper.SetDefault("mysql.dsn", "root:root@tcp(localhost:3306)/webook")】
InitViperLocals(fileName, fileType, filePath string, defaultConfig ...DefaultConfig) error
// InitViperLocalWatch 配置单个本地文件并监听文件变化
// - filePath是文件路径 精确到文件名,如:config/dev.yaml
// - defaultConfig是默认配置项【viper.SetDefault("mysql.dsn", "root:root@tcp(localhost:3306)/webook")】
InitViperLocalWatch(filePath string, defaultConfig ...DefaultConfig) error
// InitViperLocalsWatchs 配置多个本地文件并监听文件变化
// - filePath是文件路径 精确到文件名,如:config/dev.yaml
// - defaultConfig是默认配置项【viper.SetDefault("mysql.dsn", "root:root@tcp(localhost:3306)/webook")】
InitViperLocalsWatchs(fileName, fileType, filePath string, defaultConfig ...DefaultConfig) error
// InitViperRemote 配置远程文件
// - provider 是远程配置的提供者,这里使用的是etcd3
// - endpoint 是远程配置的访问地址
// - path 是远程配置的存储路径
InitViperRemote(provider, endpoint, path string) error
// InitViperRemoteWatch 配置远程文件并监听文件变化
// - provider 是远程配置的提供者,这里使用的是etcd3
// - endpoint 是远程配置的访问地址
// - path 是远程配置的存储路径
// - interval 是远程配置的监听间隔频率【几秒监听一次...】
InitViperRemoteWatch(provider, endpoint, path string) error
// SetInterval 设置远程配置的监听间隔频率【几秒监听一次...】
// - t 是远程配置的监听间隔频率【几秒监听一次...】
SetInterval(t time.Duration)
/*
====================================================
此部分为读取读取配置文件接口
====================================================
*/
// Get 获取配置项【当整个项目读取Init一个配置文件,fileName文件名留空,但整个项目读取Init多个配置文件,需传入文件名eg: db.yaml】
// - - 注意=============注意=============注意=============
// - 新版本从【configx.Get】单独读取配置文件
// - 注意=============注意=============注意=============
Get(key string, fileName ...string) any
GetUnmarshalKey(key string, rawVal any, fileName ...string) error
}
ConfigIn 抽象配置服务接口
type DefaultConfig ¶
Click to show internal directories.
Click to hide internal directories.