summaryrefslogtreecommitdiff
path: root/plugins/redis
diff options
context:
space:
mode:
authorValery Piashchynski <[email protected]>2021-09-13 15:40:57 +0300
committerGitHub <[email protected]>2021-09-13 15:40:57 +0300
commit5d2cd55ab522d4f1e65a833f91146444465a32ac (patch)
treea374c8e90383d5e868ffe6b44555a55029c54f79 /plugins/redis
parentfe72d84395970281fe330a2b9423f8c0e4c3b9c8 (diff)
parentb8a4b82f82e2cb9f9efc4a3601a97b4ff07fefc7 (diff)
[#793]: fix(plugins): incorrect parsing local and global drivers sections
[#793]: fix(plugins): incorrect parsing local and global drivers sections
Diffstat (limited to 'plugins/redis')
-rw-r--r--plugins/redis/jobs/config.go34
-rw-r--r--plugins/redis/jobs/consumer.go1
-rw-r--r--plugins/redis/jobs/item.go1
-rw-r--r--plugins/redis/kv/config.go4
-rw-r--r--plugins/redis/kv/kv.go7
-rw-r--r--plugins/redis/pubsub/pubsub.go6
6 files changed, 13 insertions, 40 deletions
diff --git a/plugins/redis/jobs/config.go b/plugins/redis/jobs/config.go
deleted file mode 100644
index 89d707af..00000000
--- a/plugins/redis/jobs/config.go
+++ /dev/null
@@ -1,34 +0,0 @@
-package jobs
-
-import "time"
-
-type Config struct {
- Addrs []string `mapstructure:"addrs"`
- DB int `mapstructure:"db"`
- Username string `mapstructure:"username"`
- Password string `mapstructure:"password"`
- MasterName string `mapstructure:"master_name"`
- SentinelPassword string `mapstructure:"sentinel_password"`
- RouteByLatency bool `mapstructure:"route_by_latency"`
- RouteRandomly bool `mapstructure:"route_randomly"`
- MaxRetries int `mapstructure:"max_retries"`
- DialTimeout time.Duration `mapstructure:"dial_timeout"`
- MinRetryBackoff time.Duration `mapstructure:"min_retry_backoff"`
- MaxRetryBackoff time.Duration `mapstructure:"max_retry_backoff"`
- PoolSize int `mapstructure:"pool_size"`
- MinIdleConns int `mapstructure:"min_idle_conns"`
- MaxConnAge time.Duration `mapstructure:"max_conn_age"`
- ReadTimeout time.Duration `mapstructure:"read_timeout"`
- WriteTimeout time.Duration `mapstructure:"write_timeout"`
- PoolTimeout time.Duration `mapstructure:"pool_timeout"`
- IdleTimeout time.Duration `mapstructure:"idle_timeout"`
- IdleCheckFreq time.Duration `mapstructure:"idle_check_freq"`
- ReadOnly bool `mapstructure:"read_only"`
-}
-
-// InitDefaults initializing fill config with default values
-func (s *Config) InitDefaults() {
- if s.Addrs == nil {
- s.Addrs = []string{"127.0.0.1:6379"} // default addr is pointing to local storage
- }
-}
diff --git a/plugins/redis/jobs/consumer.go b/plugins/redis/jobs/consumer.go
deleted file mode 100644
index 415ac457..00000000
--- a/plugins/redis/jobs/consumer.go
+++ /dev/null
@@ -1 +0,0 @@
-package jobs
diff --git a/plugins/redis/jobs/item.go b/plugins/redis/jobs/item.go
deleted file mode 100644
index 415ac457..00000000
--- a/plugins/redis/jobs/item.go
+++ /dev/null
@@ -1 +0,0 @@
-package jobs
diff --git a/plugins/redis/kv/config.go b/plugins/redis/kv/config.go
index 5b760952..5bd772a9 100644
--- a/plugins/redis/kv/config.go
+++ b/plugins/redis/kv/config.go
@@ -1,6 +1,8 @@
package kv
-import "time"
+import (
+ "time"
+)
type Config struct {
Addrs []string `mapstructure:"addrs"`
diff --git a/plugins/redis/kv/kv.go b/plugins/redis/kv/kv.go
index 3d062fbb..ae55d332 100644
--- a/plugins/redis/kv/kv.go
+++ b/plugins/redis/kv/kv.go
@@ -20,7 +20,7 @@ type Driver struct {
}
func NewRedisDriver(log logger.Logger, key string, cfgPlugin config.Configurer) (*Driver, error) {
- const op = errors.Op("new_boltdb_driver")
+ const op = errors.Op("new_redis_driver")
d := &Driver{
log: log,
@@ -32,8 +32,11 @@ func NewRedisDriver(log logger.Logger, key string, cfgPlugin config.Configurer)
return nil, errors.E(op, err)
}
+ if d.cfg == nil {
+ return nil, errors.E(op, errors.Errorf("config not found by provided key: %s", key))
+ }
+
d.cfg.InitDefaults()
- d.log = log
d.universalClient = redis.NewUniversalClient(&redis.UniversalOptions{
Addrs: d.cfg.Addrs,
diff --git a/plugins/redis/pubsub/pubsub.go b/plugins/redis/pubsub/pubsub.go
index c9ad3d58..3561ef18 100644
--- a/plugins/redis/pubsub/pubsub.go
+++ b/plugins/redis/pubsub/pubsub.go
@@ -13,7 +13,7 @@ import (
type PubSubDriver struct {
sync.RWMutex
- cfg *Config `mapstructure:"redis"`
+ cfg *Config
log logger.Logger
channel *redisChannel
@@ -34,6 +34,10 @@ func NewPubSubDriver(log logger.Logger, key string, cfgPlugin config.Configurer,
return nil, errors.E(op, err)
}
+ if ps.cfg == nil {
+ return nil, errors.E(op, errors.Errorf("config not found by provided key: %s", key))
+ }
+
ps.cfg.InitDefaults()
ps.universalClient = redis.NewUniversalClient(&redis.UniversalOptions{