Documentation ¶
Index ¶
- type EnvValuesProvider
- type JSONFileValuesProvider
- type MapValuesProvider
- type NullValuesProvider
- type ParameterBag
- func (p *ParameterBag) CheckRequiredValues(keys []string) error
- func (p *ParameterBag) MergeParameterBag(m *ParameterBag)
- func (p *ParameterBag) Read(name string, defaultVal interface{}) (interface{}, bool)
- func (p *ParameterBag) ReadBool(name string, defaultVal bool) bool
- func (p *ParameterBag) ReadDuration(name string, unit time.Duration, defaultVal uint) time.Duration
- func (p *ParameterBag) ReadInt(name string, defaultVal int) int
- func (p *ParameterBag) ReadInt64(name string, defaultVal int64) int64
- func (p *ParameterBag) ReadRequired(name string) (interface{}, error)
- func (p *ParameterBag) ReadRequiredBool(name string) (bool, error)
- func (p *ParameterBag) ReadRequiredDuration(name string, unit time.Duration) (time.Duration, error)
- func (p *ParameterBag) ReadRequiredInt(name string) (int, error)
- func (p *ParameterBag) ReadRequiredInt64(name string) (int64, error)
- func (p *ParameterBag) ReadRequiredString(name string) (string, error)
- func (p *ParameterBag) ReadRequiredStrings(name string) ([]string, error)
- func (p *ParameterBag) ReadRequiredUint(name string) (uint, error)
- func (p *ParameterBag) ReadString(name, defaultVal string) string
- func (p *ParameterBag) ReadStrings(name string, defaultVal ...string) []string
- func (p *ParameterBag) ReadUint(name string, defaultVal uint) uint
- type ValuesProvider
- type ValuesProviderComposite
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type EnvValuesProvider ¶
type EnvValuesProvider struct{}
func (*EnvValuesProvider) Read ¶
func (evp *EnvValuesProvider) Read(name string) (val interface{}, found bool)
func (*EnvValuesProvider) ToKeyValues ¶
func (evp *EnvValuesProvider) ToKeyValues() map[string]interface{}
type JSONFileValuesProvider ¶
type JSONFileValuesProvider struct {
// contains filtered or unexported fields
}
func NewJSONValuesProvider ¶
func NewJSONValuesProvider(jsond io.Reader) (jfvp *JSONFileValuesProvider, err error)
func (*JSONFileValuesProvider) Dump ¶
func (jfvp *JSONFileValuesProvider) Dump(w io.Writer) (err error)
func (*JSONFileValuesProvider) Read ¶
func (jfvp *JSONFileValuesProvider) Read(name string) (val interface{}, found bool)
func (*JSONFileValuesProvider) ToKeyValues ¶
func (jfvp *JSONFileValuesProvider) ToKeyValues() map[string]interface{}
type MapValuesProvider ¶
type MapValuesProvider struct {
// contains filtered or unexported fields
}
func NewMapValuesProvider ¶
func NewMapValuesProvider(params map[string]interface{}) *MapValuesProvider
func (*MapValuesProvider) Copy ¶
func (mvp *MapValuesProvider) Copy(newParams map[string]interface{}) *MapValuesProvider
Copy takes internal items, merges them with newParams and returns the result
func (*MapValuesProvider) Read ¶
func (mvp *MapValuesProvider) Read(name string) (val interface{}, found bool)
func (*MapValuesProvider) ToKeyValues ¶
func (mvp *MapValuesProvider) ToKeyValues() map[string]interface{}
type NullValuesProvider ¶
type NullValuesProvider struct{}
func (*NullValuesProvider) Read ¶
func (nvp *NullValuesProvider) Read(name string) (val interface{}, found bool)
func (*NullValuesProvider) ToKeyValues ¶
func (nvp *NullValuesProvider) ToKeyValues() map[string]interface{}
type ParameterBag ¶
type ParameterBag struct {
BaseValuesProvider ValuesProvider
}
ParameterBag construction for holding configuration options
func (*ParameterBag) CheckRequiredValues ¶
func (p *ParameterBag) CheckRequiredValues(keys []string) error
CheckRequiredValues checks if all required values are not empty
func (*ParameterBag) MergeParameterBag ¶
func (p *ParameterBag) MergeParameterBag(m *ParameterBag)
func (*ParameterBag) Read ¶
func (p *ParameterBag) Read(name string, defaultVal interface{}) (interface{}, bool)
Read reads interface value, if not found, will read from envs, if not found there will return defaultVal
func (*ParameterBag) ReadBool ¶
func (p *ParameterBag) ReadBool(name string, defaultVal bool) bool
ReadBool same as Read but returns a bool or defaultVal
func (*ParameterBag) ReadDuration ¶
ReadDuration reads int value and converts it to duration identified by the unit, if not set, will return defaultVal
func (*ParameterBag) ReadInt ¶
func (p *ParameterBag) ReadInt(name string, defaultVal int) int
ReadInt same as Read but returns a int
func (*ParameterBag) ReadInt64 ¶
func (p *ParameterBag) ReadInt64(name string, defaultVal int64) int64
ReadInt same as Read but returns a int
func (*ParameterBag) ReadRequired ¶
func (p *ParameterBag) ReadRequired(name string) (interface{}, error)
ReadRequired reads interface value, if not found, will return error
func (*ParameterBag) ReadRequiredBool ¶
func (p *ParameterBag) ReadRequiredBool(name string) (bool, error)
ReadRequiredBool same as ReadRequired but returns bool or error
func (*ParameterBag) ReadRequiredDuration ¶
ReadRequiredDuration reads int value and converts it to duration identified by the unit, if not set, will return error
func (*ParameterBag) ReadRequiredInt ¶
func (p *ParameterBag) ReadRequiredInt(name string) (int, error)
ReadRequiredInt same as Read but returns a int and fails if value is missing
func (*ParameterBag) ReadRequiredInt64 ¶
func (p *ParameterBag) ReadRequiredInt64(name string) (int64, error)
ReadRequiredInt same as Read but returns a int64 and fails if value is missing
func (*ParameterBag) ReadRequiredString ¶
func (p *ParameterBag) ReadRequiredString(name string) (string, error)
ReadRequiredString same as ReadRequired but returns string or error
func (*ParameterBag) ReadRequiredStrings ¶
func (p *ParameterBag) ReadRequiredStrings(name string) ([]string, error)
ReadRequiredStrings same as Read but returns []string
func (*ParameterBag) ReadRequiredUint ¶
func (p *ParameterBag) ReadRequiredUint(name string) (uint, error)
ReadRequiredUint same as ReadRequired but returns uint or error
func (*ParameterBag) ReadString ¶
func (p *ParameterBag) ReadString(name, defaultVal string) string
ReadString same as Read but returns a string
func (*ParameterBag) ReadStrings ¶
func (p *ParameterBag) ReadStrings(name string, defaultVal ...string) []string
ReadStrings same as Read but returns []string
type ValuesProvider ¶
type ValuesProviderComposite ¶
type ValuesProviderComposite struct {
// contains filtered or unexported fields
}
func NewValuesProviderComposite ¶
func NewValuesProviderComposite(vps ...ValuesProvider) *ValuesProviderComposite
func (*ValuesProviderComposite) Dump ¶
func (vpc *ValuesProviderComposite) Dump(w io.Writer) (err error)
func (*ValuesProviderComposite) Read ¶
func (vpc *ValuesProviderComposite) Read(name string) (val interface{}, found bool)
func (*ValuesProviderComposite) ToKeyValues ¶
func (vpc *ValuesProviderComposite) ToKeyValues() map[string]interface{}