Documentation ¶
Index ¶
- func AddBackend(scheme string, backend Backend)
- func GetConfig() interface{}
- func GetPrefixKeys(key string, target interface{}) (ret []string)
- func Init(opts ...Option) error
- func SetFieldListener(field string, onchange OnChange)
- func Unmarshal(key string, kvs []*KV, target interface{}) (err error)
- type Backend
- type Config
- type KV
- type OnChange
- type OnLoaded
- type Option
- type Options
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetPrefixKeys ¶ added in v1.2.0
GetPrefixKeys get the prefix keys by target
func SetFieldListener ¶
AddFieldListener bind some trigger when config is changed if field is "", it add listen whole config
Types ¶
type Backend ¶
Backend defines a configuration backend, implement this interface to support additional backends, such as etcd, consul, file ...
type Config ¶
type Config struct {
// contains filtered or unexported fields
}
Config the struct of config instance
func StandardConfig ¶
func StandardConfig() *Config
StandardConfig return instance of default config
func (*Config) AddBackend ¶
AddBackend add backend
func (*Config) GetConfig ¶
func (c *Config) GetConfig() interface{}
GetConfig set default config for a instance
func (*Config) SetFieldListener ¶
SetFieldListener bind some trigger when config is changed
type OnChange ¶
type OnChange func(pre, current interface{})
OnChange Trigger On config change function
type Option ¶
type Option func(*Options)
Option is just Option functions
func URL ¶
URL is the registry addresses to use exp: etcd://127.0.0.1:6379,127.0.0.1:7379/xl/config/key exp: file://conf/service.yaml
func WithDefault ¶
func WithDefault(defaultConfig interface{}) Option
WithDefault set default config of the instance
type Options ¶
type Options struct { URL string Timeout time.Duration //ReloadDelay refresh the config after some time, it used for etcd, consul for the backend may not notify the config ReloadDelay time.Duration //Watch is watch is true, the etcd will keep connection for mq notify Watch bool //DefaultConfig default config DefaultConfig interface{} //OnLoaded ! do not set this Manually, this is internal usage OnLoaded OnLoaded // Other options for implementations of the interface // can be stored in a context Context context.Context // contains filtered or unexported fields }
Options the Options of config