config

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Jan 9, 2023 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConfigPath

func ConfigPath() string

Types

type Config

type Config interface {
	Get(key string) interface{}
	GetBool(key string) bool
	GetInt(key string) int
	GetFloat(key string) float64
	GetString(key string) string
	GetTime(key string) time.Time
	GetDuration(key string) time.Duration
	GetViper() *viper.Viper
	Has(key string) bool
	Sub(key string) *Container
	AddObserver(o Observer)
	AddObserverFunc(f func(*Container, chan error))
	Dump() string
	Exist() bool
}

type Container

type Container struct {
	Id string

	Config Config
	// contains filtered or unexported fields
}

Container container for configuration

func NewFilesContainer

func NewFilesContainer(l log.Logger, configFiles ...string) *Container

NewFilesContainer Initialise configuration container to read files from the FS

func NewReaderContainer

func NewReaderContainer(l log.Logger, format string, configReaders ...io.Reader) *Container

NewReaderContainer Initialise configuration container to read config from ioReader

func (*Container) AddObserver

func (c *Container) AddObserver(o Observer)

AddObserver attach observer to trigger on config update

func (*Container) AddObserverFunc

func (c *Container) AddObserverFunc(f func(*Container, chan error))

AddObserverFunc attach function to trigger on config update

func (*Container) Dump

func (c *Container) Dump() string

Dump return config as json string

func (*Container) Exist

func (c *Container) Exist() bool

func (*Container) Get

func (c *Container) Get(key string) interface{}

Get interface value from config

func (*Container) GetBool

func (c *Container) GetBool(key string) bool

GetBool get Bool value from config

func (*Container) GetDuration

func (c *Container) GetDuration(key string) time.Duration

GetDuration get duration value from config

func (*Container) GetFloat

func (c *Container) GetFloat(key string) float64

GetFloat get Float value from config

func (*Container) GetInt

func (c *Container) GetInt(key string) int

GetInt get Bool value from config

func (*Container) GetString

func (c *Container) GetString(key string) string

GetString get string value from config

func (*Container) GetTime

func (c *Container) GetTime(key string) time.Time

GetTime get time value from config

func (*Container) GetViper

func (c *Container) GetViper() *viper.Viper

GetViper retrieves the underlying Viper configuration

func (*Container) Has

func (c *Container) Has(key string) bool

Has retrieves the underlying Viper configuration

func (*Container) Sub

func (c *Container) Sub(key string) *Container

Sub returns a subtree of the parent configuration

type Observer

type Observer struct {
	Run func(*Container, chan error)
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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