storage

package
v4.0.9 Latest Latest
Warning

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

Go to latest
Published: Aug 18, 2021 License: Apache-2.0 Imports: 13 Imported by: 113

Documentation

Index

Constants

This section is empty.

Variables

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

Functions

func GetDefaultNamespace

func GetDefaultNamespace() string

GetDefaultNamespace 获取默认命名空间

Types

type Cache

type Cache struct {
	// contains filtered or unexported fields
}

Cache apollo 配置缓存

func CreateNamespaceConfig

func CreateNamespaceConfig(namespace string) *Cache

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

func (*Cache) AddChangeListener

func (c *Cache) AddChangeListener(listener ChangeListener)

AddChangeListener 增加变更监控

func (*Cache) GetChangeListeners

func (c *Cache) GetChangeListeners() *list.List

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

func (*Cache) GetConfig

func (c *Cache) GetConfig(namespace string) *Config

GetConfig 根据namespace获取apollo配置

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

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

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

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

GetSliceValue 获取配置值([]interface)

func (*Config) GetStringSliceValue

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

type Dispatcher struct {
	// contains filtered or unexported fields
}

Dispatcher is the observer

func UseEventDispatch

func UseEventDispatch() *Dispatcher

UseEventDispatch 用于开启事件分发功能

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

type Listener

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