File tree Expand file tree Collapse file tree 1 file changed +10
-1
lines changed
balancer/weightedroundrobin Expand file tree Collapse file tree 1 file changed +10
-1
lines changed Original file line number Diff line number Diff line change @@ -154,7 +154,12 @@ func (b *wrrBalancer) updateAddresses(addrs []resolver.Address) {
154154 wsc = wsci .(* weightedSubConn )
155155 } else {
156156 // addr is a new address (not existing in b.subConns).
157- sc , err := b .cc .NewSubConn ([]resolver.Address {addr }, balancer.NewSubConnOptions {})
157+ var sc balancer.SubConn
158+ sc , err := b .cc .NewSubConn ([]resolver.Address {addr }, balancer.NewSubConnOptions {
159+ StateListener : func (state balancer.SubConnState ) {
160+ b .updateSubConnState (sc , state )
161+ },
162+ })
158163 if err != nil {
159164 b .logger .Warningf ("Failed to create new SubConn for address %v: %v" , addr , err )
160165 continue
@@ -205,6 +210,10 @@ func (b *wrrBalancer) ResolverError(err error) {
205210}
206211
207212func (b * wrrBalancer ) UpdateSubConnState (sc balancer.SubConn , state balancer.SubConnState ) {
213+ b .logger .Errorf ("UpdateSubConnState(%v, %+v) called unexpectedly" , sc , state )
214+ }
215+
216+ func (b * wrrBalancer ) updateSubConnState (sc balancer.SubConn , state balancer.SubConnState ) {
208217 wsc := b .scMap [sc ]
209218 if wsc == nil {
210219 b .logger .Errorf ("UpdateSubConnState called with an unknown SubConn: %p, %v" , sc , state )
You can’t perform that action at this time.
0 commit comments