Documentation ¶
Overview ¶
Package conf is a framework for reading configurations from variety of configuration Stores, such as ENV, files, and Apollo.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func WithDecodeHook ¶ added in v1.19.3
func WithDecodeHook(hook DecodeHook) option
WithDecodeHook sets a user-defined decoder
func WithStores ¶
WithStores sets Stores to ConfigParser
func WithTagName ¶
func WithTagName(tag string) option
WithTagName sets tag name used when unmarshalling data to the configuration struct. Default is mapstructure
Types ¶
type ConfigParser ¶
type ConfigParser[T any] struct { // contains filtered or unexported fields }
ConfigParser is a configuration data parser. It supports variety of configuration Stores, mainstream configuration formats, watching, and templates
- `T` is the struct for unmarshalling configuration data
func New ¶
func New[T any](opts ...option) *ConfigParser[T]
New creates a ConfigParser object
- T is the struct for unmarshalling configuration data
func (*ConfigParser[T]) Parse ¶
func (c *ConfigParser[T]) Parse() (*T, error)
Parse reads configuration data from all Stores, then unmarshal it to `T`.
func (*ConfigParser[T]) Watch ¶
func (c *ConfigParser[T]) Watch(cb func(cfg *T, changes []store.ConfigChange)) error
Watch watches configuration changes from all Stores, unmarshal the latest configuration data into `T`, then notify the caller via `cb`
Directories ¶
Path | Synopsis |
---|---|
Package store defines the Store interface, some common types and some common functions.
|
Package store defines the Store interface, some common types and some common functions. |
apollo
Package apollo implements Store for reading and watching configurations from Apollo.
|
Package apollo implements Store for reading and watching configurations from Apollo. |
env
Package env implements a Store for reading and watching configurations from ENV.
|
Package env implements a Store for reading and watching configurations from ENV. |
file
Package file implements a Store client for reading and watching configurations from local files.
|
Package file implements a Store client for reading and watching configurations from local files. |
Package tdata implements TemplateData from which data can be used to replace templates from other Stores.
|
Package tdata implements TemplateData from which data can be used to replace templates from other Stores. |