options

package
v3.0.1 Latest Latest
Warning

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

Go to latest
Published: Mar 1, 2022 License: MPL-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type EnvValuesProvider

type EnvValuesProvider struct{}

func (*EnvValuesProvider) Dump

func (evp *EnvValuesProvider) Dump(w io.Writer) (err error)

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

func (mvp *MapValuesProvider) Dump(w io.Writer) (err error)

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

func (nvp *NullValuesProvider) Dump(w io.Writer) (err error)

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 New

New creates empty bag

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

func (p *ParameterBag) ReadDuration(name string, unit time.Duration, defaultVal uint) time.Duration

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

func (p *ParameterBag) ReadRequiredDuration(name string, unit time.Duration) (time.Duration, error)

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

func (*ParameterBag) ReadUint

func (p *ParameterBag) ReadUint(name string, defaultVal uint) uint

ReadUint same as Read but returns a uint

type ValuesProvider

type ValuesProvider interface {
	Read(name string) (val interface{}, found bool)
	Dump(w io.Writer) (err error)
	ToKeyValues() map[string]interface{}
}

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{}

Jump to

Keyboard shortcuts

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