summaryrefslogtreecommitdiff
path: root/workhorse/internal/redis/redis.go
diff options
context:
space:
mode:
Diffstat (limited to 'workhorse/internal/redis/redis.go')
-rw-r--r--workhorse/internal/redis/redis.go19
1 files changed, 9 insertions, 10 deletions
diff --git a/workhorse/internal/redis/redis.go b/workhorse/internal/redis/redis.go
index 588fba6e242..03118cfcef6 100644
--- a/workhorse/internal/redis/redis.go
+++ b/workhorse/internal/redis/redis.go
@@ -1,7 +1,6 @@
package redis
import (
- "errors"
"fmt"
"net"
"net/url"
@@ -164,7 +163,15 @@ func sentinelDialer(dopts []redis.DialOption) redisDialerFunc {
return nil, err
}
dopts = append(dopts, redis.DialNetDial(keepAliveDialer))
- return redisDial("tcp", address, dopts...)
+ conn, err := redisDial("tcp", address, dopts...)
+ if err != nil {
+ return nil, err
+ }
+ if !sentinel.TestRole(conn, "master") {
+ conn.Close()
+ return nil, fmt.Errorf("%s is not redis master", address)
+ }
+ return conn, nil
}
}
@@ -247,14 +254,6 @@ func Configure(cfg *config.RedisConfig, dialFunc func(*config.RedisConfig, bool)
Dial: poolDialFunc,
Wait: true,
}
- if sntnl != nil {
- pool.TestOnBorrow = func(c redis.Conn, t time.Time) error {
- if !sentinel.TestRole(c, "master") {
- return errors.New("role check failed")
- }
- return nil
- }
- }
}
// Get a connection for the Redis-pool