Documentation ¶
Overview ¶
Package source manage all the config source and merge configs by precedence
Index ¶
- Constants
- Variables
- type ConfigSource
- type EventHandler
- type Manager
- func (m *Manager) AddDimensionInfo(labels map[string]string) (map[string]string, error)
- func (m *Manager) AddSource(source ConfigSource) error
- func (m *Manager) Cleanup() error
- func (m *Manager) Configs() map[string]interface{}
- func (m *Manager) ConfigsWithSourceNames() map[string]interface{}
- func (m *Manager) Delete(k string) error
- func (m *Manager) GetConfig(key string) interface{}
- func (m *Manager) IsKeyExist(key string) bool
- func (m *Manager) Marshal(w io.Writer) error
- func (m *Manager) OnEvent(event *event.Event)
- func (m *Manager) OnModuleEvent(event []*event.Event)
- func (m *Manager) Refresh(sourceName string) error
- func (m *Manager) RegisterListener(listenerObj event.Listener, keys ...string) error
- func (m *Manager) RegisterModuleListener(listenerObj event.ModuleListener, prefixes ...string) error
- func (m *Manager) Set(k string, v interface{}) error
- func (m *Manager) UnRegisterListener(listenerObj event.Listener, keys ...string) error
- func (m *Manager) UnRegisterModuleListener(listenerObj event.ModuleListener, prefixes ...string) error
- func (m *Manager) Unmarshal(obj interface{}) error
Constants ¶
const (
//DefaultPriority gives the default priority
DefaultPriority = -1
)
const
Variables ¶
var ( ErrKeyNotExist = errors.New("key does not exist") ErrIgnoreChange = errors.New("ignore key changed") ErrWriterInvalid = errors.New("writer is invalid") )
errors
Functions ¶
This section is empty.
Types ¶
type ConfigSource ¶
type ConfigSource interface { Set(key string, value interface{}) error Delete(key string) error GetConfigurations() (map[string]interface{}, error) GetConfigurationByKey(string) (interface{}, error) Watch(EventHandler) error GetPriority() int SetPriority(priority int) Cleanup() error GetSourceName() string AddDimensionInfo(labels map[string]string) error }
ConfigSource get key values from a system, like file system, key value store, memory etc
type EventHandler ¶
EventHandler handles config change event
type Manager ¶
type Manager struct { Sources map[string]ConfigSource ConfigurationMap sync.Map // contains filtered or unexported fields }
Manager manage all sources and config from them
func (*Manager) AddDimensionInfo ¶
AddDimensionInfo adds the dimensionInfo to the list of which configurations needs to be pulled
func (*Manager) AddSource ¶
func (m *Manager) AddSource(source ConfigSource) error
AddSource adds a source to configurationManager
func (*Manager) ConfigsWithSourceNames ¶ added in v1.5.0
ConfigsWithSourceNames returns all the key values along with its source name the returned map will be like:
map[string]interface{}{ key string: map[string]interface{"value": value, "source": sourceName} }
func (*Manager) IsKeyExist ¶
IsKeyExist check if key exist in cache
func (*Manager) Marshal ¶ added in v1.5.0
Marshal function is used to write all configuration by yaml
func (*Manager) OnModuleEvent ¶ added in v1.3.0
OnModuleEvent Triggers actions when events are generated
func (*Manager) RegisterListener ¶
RegisterListener Function to Register all listener for different key changes
func (*Manager) RegisterModuleListener ¶ added in v1.3.0
func (m *Manager) RegisterModuleListener(listenerObj event.ModuleListener, prefixes ...string) error
RegisterModuleListener Function to Register all moduleListener for different key(prefix) changes
func (*Manager) UnRegisterListener ¶
UnRegisterListener remove listener
func (*Manager) UnRegisterModuleListener ¶ added in v1.3.0
func (m *Manager) UnRegisterModuleListener(listenerObj event.ModuleListener, prefixes ...string) error
UnRegisterModuleListener remove moduleListener
func (*Manager) Unmarshal ¶
Unmarshal function is used in the case when user want his yaml file to be unmarshalled to structure pointer Unmarshal function accepts a pointer and in called function anyone can able to get the data in passed object Unmarshal only accepts a pointer values Unmarshal returns error if obj values are 0. nil and value type. Procedure:
- Unmarshal first checks the passed object type using reflection.
- Based on type Unmarshal function will check and set the values ex: If type is basic types like int, string, float then it will assigb directly values, If type is map, ptr and struct then it will again send for unmarshal until it find the basic type and set the values
Directories ¶
Path | Synopsis |
---|---|
Package cli created on 2017/6/22.
|
Package cli created on 2017/6/22. |
Package env created on 2017/6/22.
|
Package env created on 2017/6/22. |
Package filesource created on 2017/6/22.
|
Package filesource created on 2017/6/22. |