options

package
v1.3.11 Latest Latest
Warning

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

Go to latest
Published: Feb 3, 2021 License: MPL-2.0 Imports: 11 Imported by: 2

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 added in v1.3.11

func (mvp EnvValuesProvider) Dump(w io2.Writer) (err error)

func (EnvValuesProvider) Read

func (mvp EnvValuesProvider) Read(name string) (val interface{}, found bool)

type JsonFileValuesProvider

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

func NewJsonValuesProvider

func NewJsonValuesProvider(jsond io2.Reader) (jfvp JsonFileValuesProvider, err error)

func (JsonFileValuesProvider) Dump added in v1.3.11

func (mvp JsonFileValuesProvider) Dump(w io2.Writer) (err error)

func (JsonFileValuesProvider) Read

func (mvp JsonFileValuesProvider) Read(name string) (val interface{}, found bool)

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 added in v1.3.11

func (mvp MapValuesProvider) Dump(w io2.Writer) (err error)

func (MapValuesProvider) Read

func (mvp MapValuesProvider) Read(name string) (val interface{}, found bool)

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) 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 io2.Writer) (err error)
}

type ValuesProviderComposite

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

func NewValuesProviderComposite

func NewValuesProviderComposite(vps ...ValuesProvider) ValuesProviderComposite

func (ValuesProviderComposite) Read

func (mvp ValuesProviderComposite) Read(name string) (val interface{}, found bool)

Jump to

Keyboard shortcuts

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