@@ -42,7 +42,7 @@ type Balancer struct {
4242 discoveryRepeater repeater.Repeater
4343 localDCDetector func (ctx context.Context , endpoints []endpoint.Endpoint ) (string , error )
4444
45- connectionsState atomic.Pointer [connectionsState ]
45+ connectionsState atomic.Pointer [state ]
4646
4747 mu xsync.RWMutex
4848 onApplyDiscoveredEndpoints []func (ctx context.Context , endpoints []endpoint.Info )
@@ -152,7 +152,7 @@ func (b *Balancer) applyDiscoveredEndpoints(ctx context.Context, newest []endpoi
152152 }
153153
154154 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 )
156156
157157 endpointsInfo := make ([]endpoint.Info , len (newest ))
158158 for i , e := range newest {
@@ -319,7 +319,7 @@ func (b *Balancer) wrapCall(ctx context.Context, f func(ctx context.Context, cc
319319 return nil
320320}
321321
322- func (b * Balancer ) connections () * connectionsState {
322+ func (b * Balancer ) connections () * state {
323323 return b .connectionsState .Load ()
324324}
325325
@@ -351,7 +351,7 @@ func (b *Balancer) getConn(ctx context.Context) (c conn.Conn, err error) {
351351 }
352352 }()
353353
354- c , failedCount = state .GetConnection (ctx )
354+ c , failedCount = state .Next (ctx )
355355 if c == nil {
356356 return nil , xerrors .WithStackTrace (
357357 fmt .Errorf ("%w: cannot get connection from Balancer after %d attempts" , ErrNoEndpoints , failedCount ),
0 commit comments