summaryrefslogtreecommitdiff
path: root/plugins/redis
diff options
context:
space:
mode:
authorValery Piashchynski <[email protected]>2021-01-21 13:25:36 +0300
committerValery Piashchynski <[email protected]>2021-01-21 13:25:36 +0300
commit7da6c78449776e1f3c6716250bca0b712a0423a4 (patch)
treef3512de66aca2bba408485a0ea2fc936c0e4fb9b /plugins/redis
parent0ff05b2732b4fd0783f959c94c54d7e39169f979 (diff)
Uniform all configs
Add debug server Check nil's for all plugin intialization
Diffstat (limited to 'plugins/redis')
-rw-r--r--plugins/redis/config.go4
-rw-r--r--plugins/redis/plugin.go7
2 files changed, 8 insertions, 3 deletions
diff --git a/plugins/redis/config.go b/plugins/redis/config.go
index 58766293..41348236 100644
--- a/plugins/redis/config.go
+++ b/plugins/redis/config.go
@@ -28,5 +28,7 @@ type Config struct {
// InitDefaults initializing fill config with default values
func (s *Config) InitDefaults() {
- s.Addrs = []string{"localhost:6379"} // default addr is pointing to local storage
+ if s.Addrs == nil {
+ s.Addrs = []string{"localhost:6379"} // default addr is pointing to local storage
+ }
}
diff --git a/plugins/redis/plugin.go b/plugins/redis/plugin.go
index 06158b43..204abd17 100644
--- a/plugins/redis/plugin.go
+++ b/plugins/redis/plugin.go
@@ -24,14 +24,17 @@ func (s *Plugin) GetClient() redis.UniversalClient {
func (s *Plugin) Init(cfg config.Configurer, log logger.Logger) error {
const op = errors.Op("redis_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, errors.Disabled, err)
}
+ s.cfg.InitDefaults()
s.log = log
s.universalClient = redis.NewUniversalClient(&redis.UniversalOptions{