storage

package
v3.4.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 21, 2020 License: Apache-2.0 Imports: 13 Imported by: 16

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	//ErrNilListener 为没有找到listener的错误
	ErrNilListener = errors.New("nil listener")
)

Functions

func AddChangeListener

func AddChangeListener(listener ChangeListener)

AddChangeListener 增加变更监控

func CreateNamespaceConfig

func CreateNamespaceConfig(namespace string)

CreateNamespaceConfig 根据namespace初始化agollo内润配置

func GetApolloConfigCache

func GetApolloConfigCache() *sync.Map

GetApolloConfigCache 获取默认namespace的apollo配置

func GetChangeListeners

func GetChangeListeners() *list.List

GetChangeListeners 获取配置修改监听器列表

func GetDefaultNamespace

func GetDefaultNamespace() string

GetDefaultNamespace 获取默认命名空间

func InitConfigCache

func InitConfigCache()

InitConfigCache 获取程序配置初始化agollo内润配置

func RegisterListener added in v3.4.0

func RegisterListener(listener Listener, keys ...string) error

RegisterListener 为某些key注释Listener

func RemoveChangeListener

func RemoveChangeListener(listener ChangeListener)

RemoveChangeListener 增加变更监控

func UnRegisterListener added in v3.4.0

func UnRegisterListener(listenerObj Listener, keys ...string) error

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返回的内容更新内存

func UseEventDispatch added in v3.4.0

func UseEventDispatch()

UseEventDispatch 用于开启事件分发功能

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 GetConfig

func GetConfig(namespace string) *Config

GetConfig 根据namespace获取apollo配置

func (*Config) GetBoolValue

func (c *Config) GetBoolValue(key string, defaultValue bool) bool

GetBoolValue 获取配置值(bool),获取不到则取默认值

func (*Config) GetCache

func (c *Config) GetCache() agcache.CacheInterface

GetCache 获取cache

func (*Config) GetContent

func (c *Config) GetContent() string

GetContent 获取配置文件内容

func (*Config) GetFloatValue

func (c *Config) GetFloatValue(key string, defaultValue float64) float64

GetFloatValue 获取配置值(float),获取不到则取默认值

func (*Config) GetIntSliceValue added in v3.4.0

func (c *Config) GetIntSliceValue(key string) []int

GetIntSliceValue 获取配置值([]int)

func (*Config) GetIntValue

func (c *Config) GetIntValue(key string, defaultValue int) int

GetIntValue 获取配置值(int),获取不到则取默认值

func (*Config) GetIsInit

func (c *Config) GetIsInit() bool

GetIsInit 获取标志

func (*Config) GetSliceValue added in v3.4.0

func (c *Config) GetSliceValue(key string) []interface{}

GetSliceValue 获取配置值([]interface)

func (*Config) GetStringSliceValue added in v3.4.0

func (c *Config) GetStringSliceValue(key string) []string

GetStringSliceValue 获取配置值([]string)

func (*Config) GetStringValue

func (c *Config) GetStringValue(key string, defaultValue string) string

GetStringValue 获取配置值(string),获取不到则取默认值

func (*Config) GetValue

func (c *Config) GetValue(key string) string

GetValue 获取配置值(string)

func (*Config) GetWaitInit

func (c *Config) GetWaitInit() *sync.WaitGroup

GetWaitInit 获取标志

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

type Listener added in v3.4.0

type Listener interface {
	Event(event *Event)
}

Listener All Listener should implement this Interface

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL