Documentation ¶
Index ¶
- Constants
- func AddChangeListener(listener ChangeListener)
- func Close()
- func Get(pattern string, def ...interface{}) value.Value
- func GetBoolKV(key string, defaultVal bool) bool
- func GetCacheVersion(defaultVal int) int
- func GetChangeListeners() *list.List
- func GetConsulConfig(key string) ([]byte, bool)
- func GetConsulConfigRemote(key string) ([]byte, error)
- func GetConsulKV(key string) (string, error)
- func GetDurationKV(key string, defaultVal time.Duration) time.Duration
- func GetIntKV(key string, defaultVal int) int
- func GetMapKV[T any](key string) (map[string]T, error)
- func GetStringKV(key string, defaultVal string) string
- func GetStringMapKV(key string) (map[string]string, error)
- func GetStringSliceKV(key string) ([]string, error)
- func GetStructKV[T any](key string) (*T, error)
- func Has(pattern string) bool
- func HasKey[T any](dict map[string]T, key string) bool
- func InitConsulConfig(ctx context.Context)
- func PutConsulConfig(key string, value []byte) error
- func PutConsulKV(key, value string) error
- func RemoveChangeListener(listener ChangeListener)
- func Set(pattern string, value interface{}) error
- func SetReader(reader Reader)
- type ApolloReader
- func (r *ApolloReader) AddChangeListener(listener storage.ChangeListener)
- func (r *ApolloReader) Close()
- func (r *ApolloReader) Get(pattern string, def ...interface{}) value.Value
- func (r *ApolloReader) Has(pattern string) bool
- func (r *ApolloReader) Range(f func(key, value interface{}) bool)
- func (r *ApolloReader) RemoveChangeListener(listener storage.ChangeListener)
- func (r *ApolloReader) Set(pattern string, value interface{}) error
- type ChangeListener
- type ConfigChange
- type ConfigChangeType
- type Configuration
- type CustomChangeListener
- type Decoder
- type Map
- func (cache *Map[T]) Add(id string, item T)
- func (cache *Map[T]) AddAll(itemMap map[string]T)
- func (cache *Map[T]) AddChangeListener(listener ChangeListener)
- func (cache *Map[T]) Clear(id string)
- func (cache *Map[T]) ClearAll()
- func (cache *Map[T]) Get(id string) (T, bool)
- func (cache *Map[T]) GetChangeListeners() *list.List
- func (cache *Map[T]) RemoveChangeListener(listener ChangeListener)
- func (cache *Map[T]) ResetAll(itemMap map[string]T)
- func (cache *Map[T]) ToMap() map[string]T
- type Option
- type Reader
- type RemoteReaderOption
- type Source
- type Watcher
Constants ¶
View Source
const (
Apollo = "apollo"
)
View Source
const (
RemoteReaderSetError = "cannot set key in remote reader"
)
Variables ¶
This section is empty.
Functions ¶
func AddChangeListener ¶ added in v0.0.31
func AddChangeListener(listener ChangeListener)
func GetCacheVersion ¶ added in v0.0.31
func GetChangeListeners ¶ added in v0.0.31
func GetConsulConfig ¶ added in v0.0.31
func GetConsulConfigRemote ¶ added in v0.0.31
default http timeout, take care
func GetConsulKV ¶ added in v0.0.31
func GetDurationKV ¶ added in v0.0.31
func GetStringKV ¶ added in v0.0.31
func GetStringSliceKV ¶ added in v0.0.31
func GetStructKV ¶ added in v0.0.31
func InitConsulConfig ¶ added in v0.0.31
func PutConsulConfig ¶ added in v0.0.31
func PutConsulKV ¶ added in v0.0.31
func RemoveChangeListener ¶ added in v0.0.31
func RemoveChangeListener(listener ChangeListener)
Types ¶
type ApolloReader ¶ added in v0.0.31
type ApolloReader struct {
// contains filtered or unexported fields
}
func NewApolloReader ¶ added in v0.0.31
func NewApolloReader(opts ...RemoteReaderOption) *ApolloReader
func (*ApolloReader) AddChangeListener ¶ added in v0.0.31
func (r *ApolloReader) AddChangeListener(listener storage.ChangeListener)
AddChangeListener 设置远端配置变更监听
func (*ApolloReader) Get ¶ added in v0.0.31
func (r *ApolloReader) Get(pattern string, def ...interface{}) value.Value
Get 获取配置值
func (*ApolloReader) Has ¶ added in v0.0.31
func (r *ApolloReader) Has(pattern string) bool
Has 是否存在配置
func (*ApolloReader) Range ¶ added in v0.0.31
func (r *ApolloReader) Range(f func(key, value interface{}) bool)
Range 遍历所有key
func (*ApolloReader) RemoveChangeListener ¶ added in v0.0.31
func (r *ApolloReader) RemoveChangeListener(listener storage.ChangeListener)
RemoveChangeListener 取消远端配置变更监听
func (*ApolloReader) Set ¶ added in v0.0.31
func (r *ApolloReader) Set(pattern string, value interface{}) error
Set 设置配置值
type ChangeListener ¶ added in v0.0.31
type ChangeListener interface { //OnChange 增加变更监控 OnChange(changes map[string]*ConfigChange) }
ChangeListener 监听器
type ConfigChange ¶ added in v0.0.31
type ConfigChange struct { OldValue []byte NewValue []byte ChangeType ConfigChangeType }
type ConfigChangeType ¶ added in v0.0.31
type ConfigChangeType int
config change type
const ( ADDED ConfigChangeType = iota MODIFIED DELETED )
type Configuration ¶
Configuration 配置项
type CustomChangeListener ¶ added in v0.0.31
type CustomChangeListener struct {
// contains filtered or unexported fields
}
func (*CustomChangeListener) OnChange ¶ added in v0.0.31
func (c *CustomChangeListener) OnChange(changeEvent *storage.ChangeEvent)
func (*CustomChangeListener) OnNewestChange ¶ added in v0.0.31
func (c *CustomChangeListener) OnNewestChange(event *storage.FullChangeEvent)
type Decoder ¶
type Decoder func(configuration *Configuration, value interface{}) error
type Map ¶ added in v0.0.31
type Map[T any] struct { // contains filtered or unexported fields }
func (*Map[T]) AddChangeListener ¶ added in v0.0.31
func (cache *Map[T]) AddChangeListener(listener ChangeListener)
AddChangeListener 增加变更监控
func (*Map[T]) GetChangeListeners ¶ added in v0.0.31
GetChangeListeners 获取配置修改监听器列表
func (*Map[T]) RemoveChangeListener ¶ added in v0.0.31
func (cache *Map[T]) RemoveChangeListener(listener ChangeListener)
RemoveChangeListener 删除变更监控
type Option ¶
type Option func(o *options)
func WithRemoteSources ¶ added in v0.0.31
WithRemoteSources 设置远程配置源
type Reader ¶
type Reader interface { // Has 是否存在配置 Has(pattern string) bool // Get 获取配置值 Get(pattern string, def ...interface{}) value.Value // Set 设置配置值 Set(pattern string, value interface{}) error // AddChangeListener 设置配置变更监听 AddChangeListener(listener interface{}) // RemoveChangeListener 设置配置变更监听 RemoveChangeListener(listener interface{}) // Close 关闭配置监听 Close() }
type RemoteReaderOption ¶ added in v0.0.31
type RemoteReaderOption func(o *remoteReaderOptions)
func WithNamespace ¶ added in v0.0.31
func WithNamespace(namespace string) RemoteReaderOption
WithNamespace 设置上下文
type Source ¶
type Watcher ¶
type Watcher interface { // Next 返回服务实例列表 Next() ([]*Configuration, error) // Stop 停止监听 Stop() error }
Click to show internal directories.
Click to hide internal directories.