@@ -42,7 +42,7 @@ type Balancer struct {
42
42
discoveryRepeater repeater.Repeater
43
43
localDCDetector func (ctx context.Context , endpoints []endpoint.Endpoint ) (string , error )
44
44
45
- connectionsState atomic.Pointer [connectionsState ]
45
+ connectionsState atomic.Pointer [state ]
46
46
47
47
mu xsync.RWMutex
48
48
onApplyDiscoveredEndpoints []func (ctx context.Context , endpoints []endpoint.Info )
@@ -152,7 +152,7 @@ func (b *Balancer) applyDiscoveredEndpoints(ctx context.Context, newest []endpoi
152
152
}
153
153
154
154
info := balancerConfig.Info {SelfLocation : localDC }
155
- state := newConnectionsState (connections , b .config .Filter , info , b .config .AllowFallback )
155
+ state := newState (connections , b .config .Filter , info , b .config .AllowFallback )
156
156
157
157
endpointsInfo := make ([]endpoint.Info , len (newest ))
158
158
for i , e := range newest {
@@ -319,7 +319,7 @@ func (b *Balancer) wrapCall(ctx context.Context, f func(ctx context.Context, cc
319
319
return nil
320
320
}
321
321
322
- func (b * Balancer ) connections () * connectionsState {
322
+ func (b * Balancer ) connections () * state {
323
323
return b .connectionsState .Load ()
324
324
}
325
325
@@ -351,7 +351,7 @@ func (b *Balancer) getConn(ctx context.Context) (c conn.Conn, err error) {
351
351
}
352
352
}()
353
353
354
- c , failedCount = state .GetConnection (ctx )
354
+ c , failedCount = state .Next (ctx )
355
355
if c == nil {
356
356
return nil , xerrors .WithStackTrace (
357
357
fmt .Errorf ("%w: cannot get connection from Balancer after %d attempts" , ErrNoEndpoints , failedCount ),
0 commit comments