Documentation
¶
Index ¶
- Variables
- func Apply(conf map[string]interface{}) error
- func Get(key string) interface{}
- func GetConfigType() string
- func LoadFromDataSource(ds DataSource, unmarshaller Unmarshaller) error
- func LoadFromReader(r io.Reader, unmarshaller Unmarshaller) error
- func ReadConfigKeyValue(file *os.File) (map[string]string, error)
- func Set(key string, val interface{})
- func SetConfigType(v string)
- func Unmarshal(rawVal interface{}) error
- func UnmarshalKey(key string, rawVal interface{}, opts ...GetOption) error
- func UnmarshallerKeyAndValue(p []byte, v interface{}) error
- type Configuration
- func (c *Configuration) Get(key string) interface{}
- func (c *Configuration) Load(content []byte, unmarshaller Unmarshaller) error
- func (c *Configuration) LoadFromDataSource(ds DataSource, unmarshaller Unmarshaller) error
- func (c *Configuration) LoadFromReader(reader io.Reader, unmarshaller Unmarshaller) error
- func (c *Configuration) Set(key string, val interface{}) error
- func (c *Configuration) Unmarshal(rawVal interface{}) error
- func (c *Configuration) UnmarshalKey(key string, rawVal interface{}, opts ...GetOption) error
- type DataSource
- type GetOption
- type GetOptions
- type Unmarshaller
Constants ¶
This section is empty.
Variables ¶
var ErrInvalidKey = errors.New("invalid key, maybe not exist in config")
ErrInvalidKey ...
Functions ¶
func Get ¶
func Get(key string) interface{}
Get returns an interface. For a specific value use one of the Get____ methods.
func LoadFromDataSource ¶
func LoadFromDataSource(ds DataSource, unmarshaller Unmarshaller) error
从数据原中读取配置 LoadFromDataSource load configuration from data source if data source supports dynamic config, a monitor goroutinue would be
func LoadFromReader ¶
func LoadFromReader(r io.Reader, unmarshaller Unmarshaller) error
Load loads configuration from provided provider with default defaultConfiguration.
func ReadConfigKeyValue ¶
读取key=value类型的配置文件(properties)
func UnmarshalKey ¶
放在默认的配置中 UnmarshalKey takes a single key and unmarshal it into a Struct with default defaultConfiguration.
Types ¶
type Configuration ¶
type Configuration struct {
// contains filtered or unexported fields
}
配置整个系统的应用
func (*Configuration) Get ¶
func (c *Configuration) Get(key string) interface{}
Get returns the value associated with the key
func (*Configuration) Load ¶
func (c *Configuration) Load(content []byte, unmarshaller Unmarshaller) error
Load ...
func (*Configuration) LoadFromDataSource ¶
func (c *Configuration) LoadFromDataSource(ds DataSource, unmarshaller Unmarshaller) error
LoadFromDataSource ...
func (*Configuration) LoadFromReader ¶
func (c *Configuration) LoadFromReader(reader io.Reader, unmarshaller Unmarshaller) error
Load loads configuration from provided data source.
func (*Configuration) Unmarshal ¶
func (c *Configuration) Unmarshal(rawVal interface{}) error
UnmarshalKey takes a single key and unmarshal it into a Struct.
func (*Configuration) UnmarshalKey ¶
func (c *Configuration) UnmarshalKey(key string, rawVal interface{}, opts ...GetOption) error
UnmarshalKey takes a single key and unmarshal it into a Struct.
type DataSource ¶
type DataSource interface { ReadConfig() ([]byte, error) IsConfigChanged() <-chan struct{} io.Closer }
DataSource ...配置数据的来源
type GetOption ¶
type GetOption func(o *GetOptions)
type GetOptions ¶
type GetOptions struct {
TagName string
}