Versions in this module Expand all Collapse all v2 v2.5.6 Mar 5, 2025 v2.5.5 Feb 25, 2025 Changes in this version + const CreateType + const DeleteType + const HighPriority + const LowPriority + const NormalPriority + const NotFormatPrefix + const ReadConfigTimeout + const RuntimeSource + const TombValue + const UpdateType + var ErrIgnoreChange = errors.New("ignore change") + var ErrKeyNotFound = errors.New("key not found") + var ErrNotInitial = errors.New("config is not initialized") + type ConfigManager interface + EvictCacheValueByFormat func(keys ...string) + type EnvSource struct + KeyFormatter func(string) string + func NewEnvSource(KeyFormatter func(string) string) EnvSource + func (es EnvSource) Close() + func (es EnvSource) GetConfigurationByKey(key string) (string, error) + func (es EnvSource) GetConfigurations() (map[string]string, error) + func (es EnvSource) GetPriority() int + func (es EnvSource) GetSourceName() string + func (es EnvSource) SetEventHandler(eh EventHandler) + func (es EnvSource) SetManager(m ConfigManager) + func (es EnvSource) UpdateOptions(opts Options) + type EtcdInfo struct + CaCertFile string + CertFile string + EnableAuth bool + Endpoints []string + KeyFile string + KeyPrefix string + MinVersion string + PassWord string + RefreshInterval time.Duration + UseEmbed bool + UseSSL bool + UserName string + type EtcdSource struct + func NewEtcdSource(etcdInfo *EtcdInfo) (*EtcdSource, error) + func (es *EtcdSource) Close() + func (es *EtcdSource) GetConfigurationByKey(key string) (string, error) + func (es *EtcdSource) GetConfigurations() (map[string]string, error) + func (es *EtcdSource) GetPriority() int + func (es *EtcdSource) GetSourceName() string + func (es *EtcdSource) SetEventHandler(eh EventHandler) + func (es *EtcdSource) SetManager(m ConfigManager) + func (es *EtcdSource) UpdateOptions(opts Options) + type Event struct + EventSource string + EventType string + HasUpdated bool + Key string + Value string + func PopulateEvents(source string, currentConfig, updatedConfig map[string]string) ([]*Event, error) + type EventDispatcher struct + func NewEventDispatcher() *EventDispatcher + func (ed *EventDispatcher) Clean() + func (ed *EventDispatcher) Dispatch(event *Event) + func (ed *EventDispatcher) Get(key string) []EventHandler + func (ed *EventDispatcher) Register(key string, handler EventHandler) + func (ed *EventDispatcher) RegisterForKeyPrefix(keyPrefix string, handler EventHandler) + func (ed *EventDispatcher) Unregister(key string, handler EventHandler) + type EventHandler interface + GetIdentifier func() string + OnEvent func(event *Event) + func NewHandler(ident string, onEvent func(*Event)) EventHandler + type FileInfo struct + Files []string + RefreshInterval time.Duration + type FileSource struct + func NewFileSource(fileInfo *FileInfo) *FileSource + func (fs *FileSource) Close() + func (fs *FileSource) GetConfigurationByKey(key string) (string, error) + func (fs *FileSource) GetConfigurations() (map[string]string, error) + func (fs *FileSource) GetPriority() int + func (fs *FileSource) GetSourceName() string + func (fs *FileSource) SetEventHandler(eh EventHandler) + func (fs *FileSource) SetManager(m ConfigManager) + func (fs *FileSource) UpdateOptions(opts Options) + type Filter func(key string) (string, bool) + func RemovePrefix(prefix string) Filter + func WithOneOfPrefixs(prefixs ...string) Filter + func WithPrefix(prefix string) Filter + func WithSubstr(substring string) Filter + type Manager struct + Dispatcher *EventDispatcher + func Init(opts ...Option) (*Manager, error) + func NewManager() *Manager + func (m *Manager) AddSource(source Source) error + func (m *Manager) CASCachedValue(key string, origin string, value interface{}) bool + func (m *Manager) Close() + func (m *Manager) DeleteConfig(key string) + func (m *Manager) EvictCacheValueByFormat(keys ...string) + func (m *Manager) EvictCachedValue(key string) + func (m *Manager) FileConfigs() map[string]string + func (m *Manager) ForbidUpdate(key string) + func (m *Manager) GetBy(filters ...Filter) map[string]string + func (m *Manager) GetCachedValue(key string) (interface{}, bool) + func (m *Manager) GetConfig(key string) (string, string, error) + func (m *Manager) GetConfigs() map[string]string + func (m *Manager) GetConfigsView() map[string]string + func (m *Manager) GetIdentifier() string + func (m *Manager) OnEvent(event *Event) + func (m *Manager) ResetConfig(key string) + func (m *Manager) SetConfig(key, value string) + func (m *Manager) SetMapConfig(key, value string) + func (m *Manager) UpdateSourceOptions(opts ...Option) + type Option func(options *Options) + func WithEnvSource(keyFormatter func(string) string) Option + func WithEtcdSource(ri *EtcdInfo) Option + func WithFilesSource(fi *FileInfo) Option + type Options struct + EnvKeyFormatter func(string) string + EtcdInfo *EtcdInfo + FileInfo *FileInfo + type Source interface + Close func() + GetConfigurationByKey func(string) (string, error) + GetConfigurations func() (map[string]string, error) + GetPriority func() int + GetSourceName func() string + SetEventHandler func(eh EventHandler) + SetManager func(m ConfigManager) + UpdateOptions func(opt Options)