File tree Expand file tree Collapse file tree 3 files changed +10
-15
lines changed Expand file tree Collapse file tree 3 files changed +10
-15
lines changed Original file line number Diff line number Diff line change @@ -260,21 +260,16 @@ func (c *clusterClient) _refresh() (err error) {
260
260
if len (g .nodes ) > 1 {
261
261
n := len (g .nodes ) - 1
262
262
263
- if c .opt .EnableReplicaInfoAZ {
263
+ if c .opt .EnableReplicaAZInfo {
264
264
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 ++ {
270
267
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 ])
276
272
}
277
-
278
273
wg .Wait ()
279
274
}
280
275
}
Original file line number Diff line number Diff line change @@ -1478,7 +1478,7 @@ func TestClusterClientInit(t *testing.T) {
1478
1478
}
1479
1479
return - 1
1480
1480
},
1481
- EnableReplicaInfoAZ : true ,
1481
+ EnableReplicaAZInfo : true ,
1482
1482
},
1483
1483
func (dst string , opt * ClientOption ) conn {
1484
1484
switch {
Original file line number Diff line number Diff line change @@ -221,9 +221,9 @@ type ClientOption struct {
221
221
// NOTE: This function must be used with SendToReplicas function.
222
222
ReplicaSelector func (slot uint16 , replicas []ReplicaInfo ) int
223
223
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.
225
225
// If true, the client will set the `AZ` field in `ReplicaInfo`.
226
- EnableReplicaInfoAZ bool
226
+ EnableReplicaAZInfo bool
227
227
}
228
228
229
229
// SentinelOption contains MasterSet,
You can’t perform that action at this time.
0 commit comments