Documentation ¶
Overview ¶
Package source manage all the config source and merge configs by precedence
Index ¶
- Constants
- func ToRvalueType(confValue interface{}, convertType reflect.Type) (returnValue reflect.Value, err error)
- type ConfigSource
- type EventHandler
- type Manager
- func (m *Manager) AddDimensionInfo(labels map[string]string) (map[string]string, error)
- func (m *Manager) AddSource(source ConfigSource, priority int) error
- func (m *Manager) Cleanup() error
- func (m *Manager) Configs() 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) OnEvent(event *event.Event)
- func (m *Manager) Refresh(sourceName string) error
- func (m *Manager) RegisterListener(listenerObj event.Listener, keys ...string) error
- func (m *Manager) Set(k string, v interface{}) error
- func (m *Manager) UnRegisterListener(listenerObj event.Listener, keys ...string) error
- func (m *Manager) Unmarshal(obj interface{}) error
Constants ¶
const (
//DefaultPriority gives the default priority
DefaultPriority = -1
)
Variables ¶
This section is empty.
Functions ¶
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 map[string]string // 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, priority int) error
AddSource adds a source to configurationManager
func (*Manager) IsKeyExist ¶
IsKeyExist check if key exist in cache
func (*Manager) RegisterListener ¶
RegisterListener Function to Register all listener for different key changes
func (*Manager) UnRegisterListener ¶
UnRegisterListener remove listener
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. |
Package remote created on 2017/6/22.
|
Package remote created on 2017/6/22. |