@@ -353,27 +353,27 @@ func (s) TestNonGRPCLBBalancerGetsNoGRPCLBAddress(t *testing.T) {
353353 }
354354}
355355
356- const aiBalancerName = "addrInfo- attribute-balancer"
356+ const attrBalancerName = "attribute-balancer"
357357
358- // aiBalancerBuilder builds a balancer and passes the attribute key and value
358+ // attrBalancerBuilder builds a balancer and passes the attribute key and value
359359// with which it was configured at creation time by the test.
360- type aiBalancerBuilder struct {
360+ type attrBalancerBuilder struct {
361361 attrKey string
362362 attrVal string
363363}
364364
365- func (bb * aiBalancerBuilder ) Build (cc balancer.ClientConn , opts balancer.BuildOptions ) balancer.Balancer {
366- return & aiBalancer {cc : cc , attrKey : bb .attrKey , attrVal : bb .attrVal }
365+ func (bb * attrBalancerBuilder ) Build (cc balancer.ClientConn , opts balancer.BuildOptions ) balancer.Balancer {
366+ return & attrBalancer {cc : cc , attrKey : bb .attrKey , attrVal : bb .attrVal }
367367}
368368
369- func (bb * aiBalancerBuilder ) Name () string {
370- return aiBalancerName
369+ func (bb * attrBalancerBuilder ) Name () string {
370+ return attrBalancerName
371371}
372372
373- // aiBalancer receives an attribute key and value which it adds to the address
374- // that it calls NewSubConn on. This key/value pair reaches the credential
375- // handshaker and the test verifies the same.
376- type aiBalancer struct {
373+ // attrBalancer receives an attribute key and value which it adds to the
374+ // address that it calls NewSubConn on. This key/value pair reaches the
375+ // credential handshaker and the test verifies the same.
376+ type attrBalancer struct {
377377 balancer.Balancer
378378 cc balancer.ClientConn
379379 attrKey string
@@ -382,7 +382,7 @@ type aiBalancer struct {
382382
383383// UpdateClientConnState adds an attribute with the configured key/value to the
384384// addresses received and invokes NewSubConn.
385- func (b * aiBalancer ) UpdateClientConnState (ccs balancer.ClientConnState ) error {
385+ func (b * attrBalancer ) UpdateClientConnState (ccs balancer.ClientConnState ) error {
386386 addrs := ccs .ResolverState .Addresses
387387 if len (addrs ) == 0 {
388388 return nil
@@ -399,12 +399,12 @@ func (b *aiBalancer) UpdateClientConnState(ccs balancer.ClientConnState) error {
399399 return nil
400400}
401401
402- func (b * aiBalancer ) UpdateSubConnState (sc balancer.SubConn , state balancer.SubConnState ) {
402+ func (b * attrBalancer ) UpdateSubConnState (sc balancer.SubConn , state balancer.SubConnState ) {
403403 b .cc .UpdateState (balancer.State {ConnectivityState : state .ConnectivityState , Picker : & aiPicker {result : balancer.PickResult {SubConn : sc }, err : state .ConnectionError }})
404404}
405405
406- func (b * aiBalancer ) ResolverError (error ) {}
407- func (b * aiBalancer ) Close () {}
406+ func (b * attrBalancer ) ResolverError (error ) {}
407+ func (b * attrBalancer ) Close () {}
408408
409409type aiPicker struct {
410410 result balancer.PickResult
@@ -415,22 +415,23 @@ func (aip *aiPicker) Pick(_ balancer.PickInfo) (balancer.PickResult, error) {
415415 return aip .result , aip .err
416416}
417417
418- // addrInfoTransportCreds is a transport credential implementation which stores
419- // the Attributes struct passed in the context locally for the test to inspect.
420- type addrInfoTransportCreds struct {
418+ // attrTransportCreds is a transport credential implementation which stores
419+ // Attributes from the ClientHandshakeInfo struct passed in the context locally
420+ // for the test to inspect.
421+ type attrTransportCreds struct {
421422 credentials.TransportCredentials
422423 attr * attributes.Attributes
423424}
424425
425- func (ac * addrInfoTransportCreds ) ClientHandshake (ctx context.Context , addr string , rawConn net.Conn ) (net.Conn , credentials.AuthInfo , error ) {
426- ai := credentials .AddressInfoFromContext (ctx )
426+ func (ac * attrTransportCreds ) ClientHandshake (ctx context.Context , addr string , rawConn net.Conn ) (net.Conn , credentials.AuthInfo , error ) {
427+ ai := credentials .ClientHandshakeInfoFromContext (ctx )
427428 ac .attr = ai .Attr
428429 return rawConn , nil , nil
429430}
430- func (ac * addrInfoTransportCreds ) Info () credentials.ProtocolInfo {
431+ func (ac * attrTransportCreds ) Info () credentials.ProtocolInfo {
431432 return credentials.ProtocolInfo {}
432433}
433- func (ac * addrInfoTransportCreds ) Clone () credentials.TransportCredentials {
434+ func (ac * attrTransportCreds ) Clone () credentials.TransportCredentials {
434435 return nil
435436}
436437
@@ -444,9 +445,9 @@ func (s) TestAddressAttributesInNewSubConn(t *testing.T) {
444445 testAttrVal = "bar"
445446 )
446447
447- balancer .Register (& aiBalancerBuilder {attrKey : testAttrKey , attrVal : testAttrVal })
448- defer internal .BalancerUnregister (aiBalancerName )
449- t .Logf ("Registered balancer %s..." , aiBalancerName )
448+ balancer .Register (& attrBalancerBuilder {attrKey : testAttrKey , attrVal : testAttrVal })
449+ defer internal .BalancerUnregister (attrBalancerName )
450+ t .Logf ("Registered balancer %s..." , attrBalancerName )
450451
451452 r , cleanup := manual .GenerateAndRegisterManualResolver ()
452453 defer cleanup ()
@@ -463,10 +464,10 @@ func (s) TestAddressAttributesInNewSubConn(t *testing.T) {
463464 defer s .Stop ()
464465 t .Logf ("Started gRPC server at %s..." , lis .Addr ().String ())
465466
466- creds := & addrInfoTransportCreds {}
467+ creds := & attrTransportCreds {}
467468 dopts := []grpc.DialOption {
468469 grpc .WithTransportCredentials (creds ),
469- grpc .WithDefaultServiceConfig (fmt .Sprintf (`{ "loadBalancingConfig": [{"%v": {}}] }` , aiBalancerName )),
470+ grpc .WithDefaultServiceConfig (fmt .Sprintf (`{ "loadBalancingConfig": [{"%v": {}}] }` , attrBalancerName )),
470471 }
471472 cc , err := grpc .Dial (r .Scheme ()+ ":///test.server" , dopts ... )
472473 if err != nil {
0 commit comments