Skip to content

Commit 87a9625

Browse files
committed
Increase timeout for redis
1 parent 8d145bd commit 87a9625

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

server/memorystore/providers/redis/provider.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ import (
99
log "github.com/sirupsen/logrus"
1010
)
1111

12+
const (
13+
dialTimeout = 60 * time.Second
14+
)
15+
1216
// RedisClient is the interface for redis client & redis cluster client
1317
type RedisClient interface {
1418
HMSet(ctx context.Context, key string, values ...interface{}) *redis.BoolCmd
@@ -41,8 +45,7 @@ func NewRedisProvider(redisURL string) (*provider, error) {
4145
urls := []string{opt.Addr}
4246
urlList := redisURLHostPortsList[1:]
4347
urls = append(urls, urlList...)
44-
clusterOpt := &redis.ClusterOptions{Addrs: urls}
45-
48+
clusterOpt := &redis.ClusterOptions{Addrs: urls, DialTimeout: dialTimeout}
4649
rdb := redis.NewClusterClient(clusterOpt)
4750
ctx := context.Background()
4851
_, err = rdb.Ping(ctx).Result()
@@ -62,7 +65,7 @@ func NewRedisProvider(redisURL string) (*provider, error) {
6265
log.Debug("error parsing redis url: ", err)
6366
return nil, err
6467
}
65-
68+
opt.DialTimeout = dialTimeout
6669
rdb := redis.NewClient(opt)
6770
ctx := context.Background()
6871
_, err = rdb.Ping(ctx).Result()

0 commit comments

Comments
 (0)