Documentation
¶
Index ¶
- Constants
- func GetByTree(key string) ([]byte, error)
- func GetLocalConfigPath() string
- type Config
- func (c *Config) AddChangeCallback(callback func())
- func (c *Config) DisableHotReload() *Config
- func (c *Config) EnableHotReload() *Config
- func (c *Config) GetBoolWithDefault(key string, defaultValue bool) bool
- func (c *Config) GetIntWithDefault(key string, defaultValue int) int
- func (c *Config) GetStringWithDefault(key, defaultValue string) string
- func (c *Config) GetWithDefault(key string, defaultValue interface{}) interface{}
- func (c *Config) IsHotReloadEnabled() bool
- func (c *Config) ReloadConfig() error
- func (c *Config) RemoveAllCallbacks()
- func (c *Config) SetHotReloadInterval(intervalSeconds int) *Config
- func (c *Config) Validate() error
- func (c *Config) WatchConfig()
Constants ¶
View Source
const EnvConfigAddress = "CONFIG_ADDRESS"
View Source
const EnvConfigKEY = "CONFIG_KEY"
View Source
const EnvConfigPath = "CONFIG_PATH"
Variables ¶
This section is empty.
Functions ¶
func GetLocalConfigPath ¶
func GetLocalConfigPath() string
Get the local config file path from the command line
Types ¶
type Config ¶
Config 配置管理
func (*Config) AddChangeCallback ¶ added in v0.2.0
func (c *Config) AddChangeCallback(callback func())
AddChangeCallback 添加配置变更回调
func (*Config) DisableHotReload ¶ added in v0.2.0
DisableHotReload 禁用热重载
func (*Config) EnableHotReload ¶ added in v0.2.0
EnableHotReload 启用热重载(文件配置专用)
func (*Config) GetBoolWithDefault ¶ added in v0.2.0
GetBoolWithDefault 获取布尔配置值,如果不存在则返回默认值
func (*Config) GetIntWithDefault ¶ added in v0.2.0
GetIntWithDefault 获取整数配置值,如果不存在则返回默认值
func (*Config) GetStringWithDefault ¶ added in v0.2.0
GetStringWithDefault 获取字符串配置值,如果不存在则返回默认值
func (*Config) GetWithDefault ¶ added in v0.2.0
GetWithDefault 获取配置值,如果不存在则返回默认值
func (*Config) IsHotReloadEnabled ¶ added in v0.2.0
IsHotReloadEnabled 检查是否启用了热重载
func (*Config) ReloadConfig ¶ added in v0.2.0
ReloadConfig 手动重新加载配置
func (*Config) RemoveAllCallbacks ¶ added in v0.2.0
func (c *Config) RemoveAllCallbacks()
RemoveAllCallbacks 清除所有配置变更回调
func (*Config) SetHotReloadInterval ¶ added in v0.2.0
SetHotReloadInterval 设置热重载轮询间隔(仅对Consul配置有效) intervalSeconds: 轮询间隔秒数,-1或0表示禁用热重载,>0表示启用并设置间隔
func (*Config) WatchConfig ¶ added in v0.2.0
func (c *Config) WatchConfig()
WatchConfig 监听配置变更(只有启用热重载时才生效)
Click to show internal directories.
Click to hide internal directories.