Skip to content

Commit

Permalink
style: change if-else branch
Browse files Browse the repository at this point in the history
  • Loading branch information
proost committed Nov 1, 2023
1 parent f90bf48 commit 29c152a
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -233,18 +233,18 @@ func (c *clusterClient) _refresh() (err error) {

slots := [16384]conn{}
for master, g := range groups {
nodesCount := len(g.nodes)
for _, slot := range g.slots {
for i := slot[0]; i <= slot[1]; i++ {
var cc conn
if c.opt.ReplicaOnly && nodesCount > 1 {
addr := g.nodes[1+rand.Intn(nodesCount-1)]
cc = conns[addr]
} else {
cc = conns[master]
if c.opt.ReplicaOnly && len(g.nodes) > 1 {
nodesCount := len(g.nodes)
for _, slot := range g.slots {
for i := slot[0]; i <= slot[1]; i++ {
slots[i] = conns[g.nodes[1+rand.Intn(nodesCount-1)]]
}
}
} else {
for _, slot := range g.slots {
for i := slot[0]; i <= slot[1]; i++ {
slots[i] = conns[master]
}

slots[i] = cc
}
}
}
Expand Down

0 comments on commit 29c152a

Please sign in to comment.