cmdsInfo to actually use and return the first error

This commit is contained in:
Philip Manavopoulos 2020-05-07 15:14:16 +01:00 committed by Vladimir Mihailenco
parent 76f0041b12
commit 0557f66418
1 changed files with 4 additions and 1 deletions

View File

@ -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
} }