diff options
author | Valery Piashchynski <[email protected]> | 2021-01-13 11:11:36 +0300 |
---|---|---|
committer | Valery Piashchynski <[email protected]> | 2021-01-13 11:11:36 +0300 |
commit | c3cf1d988b980e9408862d380f7ae33dae501e05 (patch) | |
tree | 79430ed15f75e23242e921a1471633e33279c395 /plugins/config | |
parent | 44b0ad21e0d70e413a62814fb408faa033b0d478 (diff) |
Update styly of the .rr.yaml
Add comments
Add support for the automatically set RR_RPC, RR_HTTP env variables for
the worker process.
Diffstat (limited to 'plugins/config')
-rw-r--r-- | plugins/config/interface.go | 6 | ||||
-rwxr-xr-x | plugins/config/plugin.go | 9 |
2 files changed, 14 insertions, 1 deletions
diff --git a/plugins/config/interface.go b/plugins/config/interface.go index 2a7c67ce..23279f53 100644 --- a/plugins/config/interface.go +++ b/plugins/config/interface.go @@ -1,7 +1,7 @@ package config type Configurer interface { - // UnmarshalKey reads configuration section into configuration object. + // // UnmarshalKey takes a single key and unmarshals it into a Struct. // // func (h *HttpService) Init(cp config.Configurer) error { // h.config := &HttpConfig{} @@ -11,6 +11,10 @@ type Configurer interface { // } UnmarshalKey(name string, out interface{}) error + // Unmarshal unmarshals the config into a Struct. Make sure that the tags + // on the fields of the structure are properly set. + Unmarshal(out interface{}) error + // Get used to get config section Get(name string) interface{} diff --git a/plugins/config/plugin.go b/plugins/config/plugin.go index 1a170448..9cecf9f9 100755 --- a/plugins/config/plugin.go +++ b/plugins/config/plugin.go @@ -64,6 +64,15 @@ func (v *Viper) UnmarshalKey(name string, out interface{}) error { return nil } +func (v *Viper) Unmarshal(out interface{}) error { + const op = errors.Op("config unmarshal") + err := v.viper.Unmarshal(&out) + if err != nil { + return errors.E(op, err) + } + return nil +} + // Get raw config in a form of config section. func (v *Viper) Get(name string) interface{} { return v.viper.Get(name) |