Documentation ¶
Index ¶
- Variables
- func AddChangeListener(listener ChangeListener)
- func CreateNamespaceConfig(namespace string)
- func GetApolloConfigCache() *sync.Map
- func GetChangeListeners() *list.List
- func GetDefaultNamespace() string
- func InitConfigCache()
- func RegisterListener(listener Listener, keys ...string) error
- func RemoveChangeListener(listener ChangeListener)
- func UnRegisterListener(listenerObj Listener, keys ...string) error
- func UpdateApolloConfig(apolloConfig *env.ApolloConfig, isBackupConfig bool)
- func UpdateApolloConfigCache(configurations map[string]interface{}, expireTime int, namespace string) map[string]*ConfigChange
- func UseEventDispatch()
- type ChangeEvent
- type ChangeListener
- type Config
- func (c *Config) GetBoolValue(key string, defaultValue bool) bool
- func (c *Config) GetCache() agcache.CacheInterface
- func (c *Config) GetContent() string
- func (c *Config) GetFloatValue(key string, defaultValue float64) float64
- func (c *Config) GetIntSliceValue(key string) []int
- func (c *Config) GetIntValue(key string, defaultValue int) int
- func (c *Config) GetIsInit() bool
- func (c *Config) GetSliceValue(key string) []interface{}
- func (c *Config) GetStringSliceValue(key string) []string
- func (c *Config) GetStringValue(key string, defaultValue string) string
- func (c *Config) GetValue(key string) string
- func (c *Config) GetWaitInit() *sync.WaitGroup
- type ConfigChange
- type ConfigChangeType
- type Dispatcher
- type Event
- type Listener
Constants ¶
This section is empty.
Variables ¶
var ( //ErrNilListener 为没有找到listener的错误 ErrNilListener = errors.New("nil listener") )
Functions ¶
func CreateNamespaceConfig ¶
func CreateNamespaceConfig(namespace string)
CreateNamespaceConfig 根据namespace初始化agollo内润配置
func GetApolloConfigCache ¶
GetApolloConfigCache 获取默认namespace的apollo配置
func RegisterListener ¶ added in v3.4.0
RegisterListener 为某些key注释Listener
func RemoveChangeListener ¶
func RemoveChangeListener(listener ChangeListener)
RemoveChangeListener 增加变更监控
func UnRegisterListener ¶ added in v3.4.0
UnRegisterListener 为某些key注释Listener
func UpdateApolloConfig ¶
func UpdateApolloConfig(apolloConfig *env.ApolloConfig, isBackupConfig bool)
UpdateApolloConfig 根据config server返回的内容更新内存 并判断是否需要写备份文件
func UpdateApolloConfigCache ¶
func UpdateApolloConfigCache(configurations map[string]interface{}, expireTime int, namespace string) map[string]*ConfigChange
UpdateApolloConfigCache 根据conf[ig server返回的内容更新内存
Types ¶
type ChangeEvent ¶
type ChangeEvent struct { Namespace string Changes map[string]*ConfigChange }
config change event
type ChangeListener ¶
type ChangeListener interface { //OnChange 增加变更监控 OnChange(event *ChangeEvent) //OnNewestChange 监控最新变更 OnNewestChange(configuration map[string]interface{}) }
ChangeListener 监听器
type Config ¶
type Config struct {
// contains filtered or unexported fields
}
Config apollo配置项
func (*Config) GetBoolValue ¶
GetBoolValue 获取配置值(bool),获取不到则取默认值
func (*Config) GetFloatValue ¶
GetFloatValue 获取配置值(float),获取不到则取默认值
func (*Config) GetIntSliceValue ¶ added in v3.4.0
GetIntSliceValue 获取配置值([]int)
func (*Config) GetIntValue ¶
GetIntValue 获取配置值(int),获取不到则取默认值
func (*Config) GetSliceValue ¶ added in v3.4.0
GetSliceValue 获取配置值([]interface)
func (*Config) GetStringSliceValue ¶ added in v3.4.0
GetStringSliceValue 获取配置值([]string)
func (*Config) GetStringValue ¶
GetStringValue 获取配置值(string),获取不到则取默认值
type ConfigChange ¶
type ConfigChange struct { OldValue interface{} NewValue interface{} ChangeType ConfigChangeType }
type ConfigChangeType ¶
type ConfigChangeType int
config change type
const ( ADDED ConfigChangeType = iota MODIFIED DELETED )
type Dispatcher ¶ added in v3.4.0
type Dispatcher struct {
// contains filtered or unexported fields
}
Dispatcher is the observer
func (*Dispatcher) OnChange ¶ added in v3.4.0
func (d *Dispatcher) OnChange(changeEvent *ChangeEvent)
OnChange 实现Apollo的ChangeEvent处理
func (*Dispatcher) OnNewestChange ¶ added in v3.4.3
func (d *Dispatcher) OnNewestChange(configuration map[string]interface{})
func (*Dispatcher) RegisterListener ¶ added in v3.4.0
func (d *Dispatcher) RegisterListener(listenerObject Listener, keys ...string) error
RegisterListener 是为某些key注释Listener的方法
func (*Dispatcher) UnRegisterListener ¶ added in v3.4.0
func (d *Dispatcher) UnRegisterListener(listenerObj Listener, keys ...string) error
UnRegisterListener 用于为某些key注释Listener
type Event ¶ added in v3.4.0
type Event struct { EventType ConfigChangeType Key string Value interface{} }
Event generated when any config changes