Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type ConfReader ¶
type ConfReader struct { Verbose bool // contains filtered or unexported fields }
ConfReader reads configuration from config file, environment variables or command line flags. Flags have precedence over env vars and env vars have precedence over config file.
For example:
type NestedConf struct { Foo string } type Config struct{ Nested NestedConf }
in that case flag --nested.foo will be mapped automatically This flag could be also set by NESTED_FOO env var or by creating config file .ukama.yaml: nested:
foo: bar
func NewConfReader ¶
func NewConfReader(configName string) *ConfReader
NewConfReader creates new instance of ConfReader configName is a name of config file name without extension and evn vars prefix
func (*ConfReader) Read ¶
func (c *ConfReader) Read(configStruct interface{}) error
Read reads config from config file, env vars or flags.
func (*ConfReader) Watch ¶
func (c *ConfReader) Watch() *sync.RWMutex
Watch watches for config changes and reloads config. This method should be called after Read() to make sure that ConfReader konws which struct to reload. Returns a mutex that can be used to synchronize access to the config. If you care about thread safety, call RLock() on the mutex while accessing the config and the RUnlock(). This will ensure that the config is not reloaded while you are accessing it.
func (*ConfReader) WithPrefix ¶
func (c *ConfReader) WithPrefix(prefix string) *ConfReader
WithPrefix sets the prefix for environment variables. It adds '_' to the end of the prefix. For example, if prefix is "MYAPP", then environment variable for field "Name" will be "MYAPP_NAME".
func (*ConfReader) WithSearchDirs ¶
func (c *ConfReader) WithSearchDirs(s ...string) *ConfReader