Skip to content

Commit 3927502

Browse files
committed
feat: rename EnableReplicaInfoAZ to EnableReplicaAZInfo
Signed-off-by: Rueian <[email protected]>
1 parent f14b451 commit 3927502

File tree

3 files changed

+10
-15
lines changed

3 files changed

+10
-15
lines changed

cluster.go

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -260,21 +260,16 @@ func (c *clusterClient) _refresh() (err error) {
260260
if len(g.nodes) > 1 {
261261
n := len(g.nodes) - 1
262262

263-
if c.opt.EnableReplicaInfoAZ {
263+
if c.opt.EnableReplicaAZInfo {
264264
var wg sync.WaitGroup
265-
for i := 0; i < n; i += 4 { // batch AZ() for every 4 connections
266-
for j := i; j < i+4 && j < n; j++ {
267-
replica := g.nodes[j+1]
268-
rConn := conns[replica.Addr].conn
269-
265+
for i := 1; i <= n; i += 4 { // batch AZ() for every 4 connections
266+
for j := i; j <= i+4 && j <= n; j++ {
270267
wg.Add(1)
271-
go func(j int, rConn conn) {
272-
defer wg.Done()
273-
274-
g.nodes[j+1].AZ = rConn.AZ()
275-
}(j, rConn)
268+
go func(wg *sync.WaitGroup, conn conn, info *ReplicaInfo) {
269+
info.AZ = conn.AZ()
270+
wg.Done()
271+
}(&wg, conns[g.nodes[j].Addr].conn, &g.nodes[j])
276272
}
277-
278273
wg.Wait()
279274
}
280275
}

cluster_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1478,7 +1478,7 @@ func TestClusterClientInit(t *testing.T) {
14781478
}
14791479
return -1
14801480
},
1481-
EnableReplicaInfoAZ: true,
1481+
EnableReplicaAZInfo: true,
14821482
},
14831483
func(dst string, opt *ClientOption) conn {
14841484
switch {

rueidis.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -221,9 +221,9 @@ type ClientOption struct {
221221
// NOTE: This function must be used with SendToReplicas function.
222222
ReplicaSelector func(slot uint16, replicas []ReplicaInfo) int
223223

224-
// EnableReplicaInfoAZ enables the client to load the replica node's availability zone.
224+
// EnableReplicaAZInfo enables the client to load the replica node's availability zone.
225225
// If true, the client will set the `AZ` field in `ReplicaInfo`.
226-
EnableReplicaInfoAZ bool
226+
EnableReplicaAZInfo bool
227227
}
228228

229229
// SentinelOption contains MasterSet,

0 commit comments

Comments
 (0)