conf

package
v1.0.1-0...-e52dcc8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 31, 2020 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidKey = errors.New("invalid key, maybe not exist in config")

ErrInvalidKey ...

Functions

func Apply

func Apply(conf map[string]interface{}) error

Apply ...

func Get

func Get(key string) interface{}

Get returns an interface. For a specific value use one of the Get____ methods.

func GetConfigType

func GetConfigType() string

获取配置文件类型

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

func ReadConfigKeyValue(file *os.File) (map[string]string, error)

读取key=value类型的配置文件(properties)

func Set

func Set(key string, val interface{})

Set set config value for key

func SetConfigType

func SetConfigType(v string)

设置配置文件类型

func Unmarshal

func Unmarshal(rawVal interface{}) error

解析配置

func UnmarshalKey

func UnmarshalKey(key string, rawVal interface{}, opts ...GetOption) error

放在默认的配置中 UnmarshalKey takes a single key and unmarshal it into a Struct with default defaultConfiguration.

func UnmarshallerKeyAndValue

func UnmarshallerKeyAndValue(p []byte, v interface{}) error

反序列化

Types

type Configuration

type Configuration struct {
	// contains filtered or unexported fields
}

配置整个系统的应用

func New

func New() *Configuration

New constructs a new Configuration with provider.

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) Set

func (c *Configuration) Set(key string, val interface{}) error

Set ...

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
}

type Unmarshaller

type Unmarshaller = func([]byte, interface{}) error

Unmarshaller ...

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL