setting

package
v0.0.11 Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2020 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DefaultSetting

type DefaultSetting struct {
	Value *Value
	Env   map[string]string
	// contains filtered or unexported fields
}
var Default *DefaultSetting = NewSetting()

func NewSetting

func NewSetting(opts ...Opt) *DefaultSetting

func (*DefaultSetting) ExecTemplate

func (ctx *DefaultSetting) ExecTemplate(r io.Reader) (io.Reader, error)

func (*DefaultSetting) Get

func (ctx *DefaultSetting) Get(key string) (string, bool)

Env.ENVNAME Value.A.B.C

func (*DefaultSetting) GetValue

func (ctx *DefaultSetting) GetValue(key string, result interface{}) error

Value.A.B.C 依赖于ValueReader的序列化和反序列化方式

func (*DefaultSetting) LoadValue

func (ctx *DefaultSetting) LoadValue(r io.Reader) error

func (*DefaultSetting) RefreshEnv

func (ctx *DefaultSetting) RefreshEnv()

func (*DefaultSetting) SetValueReader

func (ctx *DefaultSetting) SetValueReader(r ValueReader)

type JsonValue

type JsonValue struct{}

func (*JsonValue) Deserialize

func (v *JsonValue) Deserialize(value string, result interface{}) error

func (*JsonValue) Read

func (v *JsonValue) Read(r io.Reader) (*Value, error)

func (*JsonValue) Serialize

func (v *JsonValue) Serialize(o interface{}) (string, error)

type Opt

type Opt func(ctx *DefaultSetting) error

func SetValue

func SetValue(r io.Reader) Opt

func SetValueReader

func SetValueReader(r ValueReader) Opt

type Setting

type Setting interface {
	//配置ValueReader
	SetValueReader(r ValueReader)
	//刷新环境变量
	RefreshEnv()
	//读取setting value
	LoadValue(r io.Reader) error
	// Env.ENVNAME
	// Value.A.B.C
	Get(key string) (string, bool)
	// Value.A.B.C
	// 依赖于ValueReader的序列化和反序列化方式
	GetValue(key string, result interface{}) error
}

type Value

type Value = map[string]interface{}

type ValueReader

type ValueReader interface {
	Read(r io.Reader) (*Value, error)
	Serialize(o interface{}) (string, error)
	Deserialize(v string, result interface{}) error
}

Jump to

Keyboard shortcuts

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