1
0
mirror of https://github.com/redis/go-redis.git synced 2025-06-14 01:21:30 +03:00

Fix not applying updated ClusterClient context after calling WithContext method (#1480)

pass context to command info cache init call
This commit is contained in:
GreenHedgehog
2020-09-14 15:30:50 +03:00
committed by GitHub
parent f354306eec
commit 1a65d677b3
3 changed files with 10 additions and 10 deletions

View File

@ -1554,7 +1554,7 @@ func (c *ClusterClient) retryBackoff(attempt int) time.Duration {
return internal.RetryBackoff(attempt, c.opt.MinRetryBackoff, c.opt.MaxRetryBackoff)
}
func (c *ClusterClient) cmdsInfo() (map[string]*CommandInfo, error) {
func (c *ClusterClient) cmdsInfo(ctx context.Context) (map[string]*CommandInfo, error) {
// Try 3 random nodes.
const nodeLimit = 3
@ -1581,7 +1581,7 @@ func (c *ClusterClient) cmdsInfo() (map[string]*CommandInfo, error) {
continue
}
info, err := node.Client.Command(c.ctx).Result()
info, err := node.Client.Command(ctx).Result()
if err == nil {
return info, nil
}
@ -1597,7 +1597,7 @@ func (c *ClusterClient) cmdsInfo() (map[string]*CommandInfo, error) {
}
func (c *ClusterClient) cmdInfo(name string) *CommandInfo {
cmdsInfo, err := c.cmdsInfoCache.Get()
cmdsInfo, err := c.cmdsInfoCache.Get(c.ctx)
if err != nil {
return nil
}