fix nil node dereference when use RouteByLatency in cluster

This commit is contained in:
Pavlov Aleksey 2020-08-06 18:04:04 +03:00
parent 3fbf7df014
commit 8a5db20d32
1 changed files with 5 additions and 1 deletions

View File

@ -564,7 +564,11 @@ func (c *clusterState) slotClosestNode(slot int) (*clusterNode, error) {
node = n node = n
} }
} }
return node, nil if node != nil {
return node, nil
}
// If all nodes are failing - return random node
return c.nodes.Random()
} }
func (c *clusterState) slotRandomNode(slot int) (*clusterNode, error) { func (c *clusterState) slotRandomNode(slot int) (*clusterNode, error) {