diff options
author | Valery Piashchynski <[email protected]> | 2021-01-21 13:25:36 +0300 |
---|---|---|
committer | Valery Piashchynski <[email protected]> | 2021-01-21 13:25:36 +0300 |
commit | 7da6c78449776e1f3c6716250bca0b712a0423a4 (patch) | |
tree | f3512de66aca2bba408485a0ea2fc936c0e4fb9b /plugins/kv/memory | |
parent | 0ff05b2732b4fd0783f959c94c54d7e39169f979 (diff) |
Uniform all configs
Add debug server
Check nil's for all plugin intialization
Diffstat (limited to 'plugins/kv/memory')
-rw-r--r-- | plugins/kv/memory/config.go | 7 | ||||
-rw-r--r-- | plugins/kv/memory/plugin.go | 8 | ||||
-rw-r--r-- | plugins/kv/memory/plugin_unit_test.go | 1 |
3 files changed, 8 insertions, 8 deletions
diff --git a/plugins/kv/memory/config.go b/plugins/kv/memory/config.go index 0816f734..e51d09c5 100644 --- a/plugins/kv/memory/config.go +++ b/plugins/kv/memory/config.go @@ -2,14 +2,13 @@ package memory // Config is default config for the in-memory driver type Config struct { - // Enabled or disabled (true or false) - Enabled bool // Interval for the check Interval int } // InitDefaults by default driver is turned off func (c *Config) InitDefaults() { - c.Enabled = false - c.Interval = 60 // seconds + if c.Interval == 0 { + c.Interval = 60 // seconds + } } diff --git a/plugins/kv/memory/plugin.go b/plugins/kv/memory/plugin.go index ddcf88a9..4201a1c0 100644 --- a/plugins/kv/memory/plugin.go +++ b/plugins/kv/memory/plugin.go @@ -25,13 +25,15 @@ type Plugin struct { func (s *Plugin) Init(cfg config.Configurer, log logger.Logger) error { const op = errors.Op("in_memory_plugin_init") - s.cfg = &Config{} - s.cfg.InitDefaults() - + if !cfg.Has(PluginName) { + return errors.E(op, errors.Disabled) + } err := cfg.UnmarshalKey(PluginName, &s.cfg) if err != nil { return errors.E(op, err) } + + s.cfg.InitDefaults() s.log = log s.stop = make(chan struct{}, 1) diff --git a/plugins/kv/memory/plugin_unit_test.go b/plugins/kv/memory/plugin_unit_test.go index 6daa0795..1965a696 100644 --- a/plugins/kv/memory/plugin_unit_test.go +++ b/plugins/kv/memory/plugin_unit_test.go @@ -17,7 +17,6 @@ func initStorage() kv.Storage { stop: make(chan struct{}), } p.cfg = &Config{ - Enabled: true, Interval: 1, } |