mirror of https://github.com/go-redis/redis.git
cmdsInfo to actually use and return the first error
This commit is contained in:
parent
76f0041b12
commit
0557f66418
5
ring.go
5
ring.go
|
@ -508,7 +508,7 @@ func (c *Ring) ForEachShard(
|
||||||
|
|
||||||
func (c *Ring) cmdsInfo() (map[string]*CommandInfo, error) {
|
func (c *Ring) cmdsInfo() (map[string]*CommandInfo, error) {
|
||||||
shards := c.shards.List()
|
shards := c.shards.List()
|
||||||
firstErr := errRingShardsDown
|
var firstErr error
|
||||||
for _, shard := range shards {
|
for _, shard := range shards {
|
||||||
cmdsInfo, err := shard.Client.Command(context.TODO()).Result()
|
cmdsInfo, err := shard.Client.Command(context.TODO()).Result()
|
||||||
if err == nil {
|
if err == nil {
|
||||||
|
@ -518,6 +518,9 @@ func (c *Ring) cmdsInfo() (map[string]*CommandInfo, error) {
|
||||||
firstErr = err
|
firstErr = err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if firstErr == nil {
|
||||||
|
return nil, errRingShardsDown
|
||||||
|
}
|
||||||
return nil, firstErr
|
return nil, firstErr
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue