Increase timeout for redis
This commit is contained in:
parent
8d145bd5fe
commit
87a962504f
|
@ -9,6 +9,10 @@ import (
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
dialTimeout = 60 * time.Second
|
||||||
|
)
|
||||||
|
|
||||||
// RedisClient is the interface for redis client & redis cluster client
|
// RedisClient is the interface for redis client & redis cluster client
|
||||||
type RedisClient interface {
|
type RedisClient interface {
|
||||||
HMSet(ctx context.Context, key string, values ...interface{}) *redis.BoolCmd
|
HMSet(ctx context.Context, key string, values ...interface{}) *redis.BoolCmd
|
||||||
|
@ -41,8 +45,7 @@ func NewRedisProvider(redisURL string) (*provider, error) {
|
||||||
urls := []string{opt.Addr}
|
urls := []string{opt.Addr}
|
||||||
urlList := redisURLHostPortsList[1:]
|
urlList := redisURLHostPortsList[1:]
|
||||||
urls = append(urls, urlList...)
|
urls = append(urls, urlList...)
|
||||||
clusterOpt := &redis.ClusterOptions{Addrs: urls}
|
clusterOpt := &redis.ClusterOptions{Addrs: urls, DialTimeout: dialTimeout}
|
||||||
|
|
||||||
rdb := redis.NewClusterClient(clusterOpt)
|
rdb := redis.NewClusterClient(clusterOpt)
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
_, err = rdb.Ping(ctx).Result()
|
_, err = rdb.Ping(ctx).Result()
|
||||||
|
@ -62,7 +65,7 @@ func NewRedisProvider(redisURL string) (*provider, error) {
|
||||||
log.Debug("error parsing redis url: ", err)
|
log.Debug("error parsing redis url: ", err)
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
opt.DialTimeout = dialTimeout
|
||||||
rdb := redis.NewClient(opt)
|
rdb := redis.NewClient(opt)
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
_, err = rdb.Ping(ctx).Result()
|
_, err = rdb.Ping(ctx).Result()
|
||||||
|
|
Loading…
Reference in New Issue
Block a user