Documentation ¶
Index ¶
- Variables
- func GetDefaultNamespace() string
- type Cache
- func (c *Cache) AddChangeListener(listener ChangeListener)
- func (c *Cache) GetChangeListeners() *list.List
- func (c *Cache) GetConfig(namespace string) *Config
- func (c *Cache) RemoveChangeListener(listener ChangeListener)
- func (c *Cache) UpdateApolloConfig(apolloConfig *config.ApolloConfig, appConfigFunc func() config.AppConfig)
- func (c *Cache) UpdateApolloConfigCache(configurations map[string]interface{}, expireTime int, namespace string) map[string]*ConfigChange
- type ChangeEvent
- type ChangeListener
- type Config
- func (c *Config) GetBoolValue(key string, defaultValue bool) bool
- func (c *Config) GetBoolValueImmediately(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) GetFloatValueImmediately(key string, defaultValue float64) float64
- func (c *Config) GetIntSliceValue(key, separator string, defaultValue []int) []int
- func (c *Config) GetIntSliceValueImmediately(key string, defaultValue []int) []int
- func (c *Config) GetIntValue(key string, defaultValue int) int
- func (c *Config) GetIntValueImmediately(key string, defaultValue int) int
- func (c *Config) GetIsInit() bool
- func (c *Config) GetSliceValue(key string, defaultValue []interface{}) []interface{}
- func (c *Config) GetSliceValueImmediately(key string, defaultValue []interface{}) []interface{}
- func (c *Config) GetStringSliceValue(key, separator string, defaultValue []string) []string
- func (c *Config) GetStringSliceValueImmediately(key string, defaultValue []string) []string
- func (c *Config) GetStringValue(key string, defaultValue string) string
- func (c *Config) GetStringValueImmediately(key string, defaultValue string) string
- func (c *Config) GetValue(key string) string
- func (c *Config) GetValueImmediately(key string) string
- func (c *Config) GetWaitInit() *sync.WaitGroup
- type ConfigChange
- type ConfigChangeType
- type Dispatcher
- type Event
- type FullChangeEvent
- type Listener
Constants ¶
This section is empty.
Variables ¶
var ( //ErrNilListener 为没有找到listener的错误 ErrNilListener = errors.New("nil listener") )
Functions ¶
Types ¶
type Cache ¶
type Cache struct {
// contains filtered or unexported fields
}
Cache apollo 配置缓存
func CreateNamespaceConfig ¶
CreateNamespaceConfig 根据namespace初始化agollo内容配置
func (*Cache) AddChangeListener ¶
func (c *Cache) AddChangeListener(listener ChangeListener)
AddChangeListener 增加变更监控
func (*Cache) GetChangeListeners ¶
GetChangeListeners 获取配置修改监听器列表
func (*Cache) RemoveChangeListener ¶
func (c *Cache) RemoveChangeListener(listener ChangeListener)
RemoveChangeListener 删除变更监控
func (*Cache) UpdateApolloConfig ¶
func (c *Cache) UpdateApolloConfig(apolloConfig *config.ApolloConfig, appConfigFunc func() config.AppConfig)
UpdateApolloConfig 根据config server返回的内容更新内存 并判断是否需要写备份文件
func (*Cache) UpdateApolloConfigCache ¶
func (c *Cache) UpdateApolloConfigCache(configurations map[string]interface{}, expireTime int, namespace string) map[string]*ConfigChange
UpdateApolloConfigCache 根据conf[ig server返回的内容更新内存
type ChangeEvent ¶
type ChangeEvent struct { Changes map[string]*ConfigChange // contains filtered or unexported fields }
config change event
type ChangeListener ¶
type ChangeListener interface { //OnChange 增加变更监控 OnChange(event *ChangeEvent) //OnNewestChange 监控最新变更 OnNewestChange(event *FullChangeEvent) }
ChangeListener 监听器
type Config ¶
type Config struct {
// contains filtered or unexported fields
}
Config apollo配置项
func (*Config) GetBoolValue ¶
GetBoolValue 获取配置值(bool),获取不到则取默认值
func (*Config) GetBoolValueImmediately ¶ added in v4.2.0
GetBoolValueImmediately 获取配置值(bool),获取不到则取默认值,立即返回,初始化未完成直接返回错误
func (*Config) GetFloatValue ¶
GetFloatValue 获取配置值(float),获取不到则取默认值
func (*Config) GetFloatValueImmediately ¶ added in v4.2.0
GetFloatValueImmediately 获取配置值(float),获取不到则取默认值,立即返回,初始化未完成直接返回错误
func (*Config) GetIntSliceValue ¶
GetIntSliceValue 获取配置值([]int)
func (*Config) GetIntSliceValueImmediately ¶ added in v4.2.0
GetIntSliceValueImmediately 获取配置值([]int),立即返回,初始化未完成直接返回错误
func (*Config) GetIntValue ¶
GetIntValue 获取配置值(int),获取不到则取默认值
func (*Config) GetIntValueImmediately ¶ added in v4.2.0
GetIntValueImmediately 获取配置值(int),获取不到则取默认值,立即返回,初始化未完成直接返回错误
func (*Config) GetSliceValue ¶
GetSliceValue 获取配置值([]interface)
func (*Config) GetSliceValueImmediately ¶ added in v4.2.0
GetSliceValueImmediately 获取配置值([]interface),立即返回,初始化未完成直接返回错误
func (*Config) GetStringSliceValue ¶
GetStringSliceValue 获取配置值([]string)
func (*Config) GetStringSliceValueImmediately ¶ added in v4.2.0
GetStringSliceValueImmediately 获取配置值([]string),立即返回,初始化未完成直接返回错误
func (*Config) GetStringValue ¶
GetStringValue 获取配置值(string),获取不到则取默认值
func (*Config) GetStringValueImmediately ¶ added in v4.2.0
GetStringValueImmediately 获取配置值(string),立即返回,初始化未完成直接返回错误
func (*Config) GetValueImmediately ¶ added in v4.2.0
GetValueImmediately 获取配置值(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 ¶
type Dispatcher struct {
// contains filtered or unexported fields
}
Dispatcher is the observer
func (*Dispatcher) OnChange ¶
func (d *Dispatcher) OnChange(changeEvent *ChangeEvent)
OnChange 实现Apollo的ChangeEvent处理
func (*Dispatcher) OnNewestChange ¶
func (d *Dispatcher) OnNewestChange(event *FullChangeEvent)
func (*Dispatcher) RegisterListener ¶
func (d *Dispatcher) RegisterListener(listenerObject Listener, keys ...string) error
RegisterListener 是为某些key注释Listener的方法
func (*Dispatcher) UnRegisterListener ¶
func (d *Dispatcher) UnRegisterListener(listenerObj Listener, keys ...string) error
UnRegisterListener 用于为某些key注释Listener
type Event ¶
type Event struct { EventType ConfigChangeType Key string Value interface{} }
Event generated when any config changes
type FullChangeEvent ¶
type FullChangeEvent struct { Changes map[string]interface{} // contains filtered or unexported fields }
all config change event