Skip to content

Commit

Permalink
xds: standardize xds client field name (xdsClient) (#4518)
Browse files Browse the repository at this point in the history
  • Loading branch information
dfawley committed Jun 4, 2021
1 parent 7f9eeea commit 656cad9
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 17 deletions.
18 changes: 9 additions & 9 deletions xds/internal/balancer/clusterimpl/clusterimpl.go
Expand Up @@ -75,7 +75,7 @@ func (bb) Build(cc balancer.ClientConn, bOpts balancer.BuildOptions) balancer.Ba
b.logger.Errorf("failed to create xds-client: %v", err)
return nil
}
b.xdsC = client
b.xdsClient = client
}
go b.run()

Expand Down Expand Up @@ -113,9 +113,9 @@ type clusterImplBalancer struct {
closed *grpcsync.Event
done *grpcsync.Event

bOpts balancer.BuildOptions
logger *grpclog.PrefixLogger
xdsC xdsClient
bOpts balancer.BuildOptions
logger *grpclog.PrefixLogger
xdsClient xdsClient

config *LBConfig
childLB balancer.Balancer
Expand Down Expand Up @@ -180,8 +180,8 @@ func (b *clusterImplBalancer) updateLoadStore(newConfig *LBConfig) error {
b.cancelLoadReport = nil
}
var loadStore *load.Store
if b.xdsC != nil {
loadStore, b.cancelLoadReport = b.xdsC.ReportLoad(b.lrsServerName)
if b.xdsClient != nil {
loadStore, b.cancelLoadReport = b.xdsClient.ReportLoad(b.lrsServerName)
}
b.loadWrapper.UpdateLoadStore(loadStore)
}
Expand Down Expand Up @@ -209,12 +209,12 @@ func (b *clusterImplBalancer) UpdateClientConnState(s balancer.ClientConnState)
return fmt.Errorf("balancer %q not registered", newConfig.ChildPolicy.Name)
}

if b.xdsC == nil {
if b.xdsClient == nil {
c := xdsclient.FromResolverState(s.ResolverState)
if c == nil {
return balancer.ErrBadResolverState
}
b.xdsC = c
b.xdsClient = c
}

// Update load reporting config. This needs to be done before updating the
Expand Down Expand Up @@ -329,7 +329,7 @@ func (b *clusterImplBalancer) Close() {
b.childLB = nil
}
if newXDSClient != nil {
b.xdsC.Close()
b.xdsClient.Close()
}
<-b.done.Done()
b.logger.Infof("Shutdown")
Expand Down
16 changes: 8 additions & 8 deletions xds/internal/balancer/lrs/balancer.go
Expand Up @@ -58,7 +58,7 @@ func (bb) Build(cc balancer.ClientConn, opts balancer.BuildOptions) balancer.Bal
b.logger.Errorf("failed to create xds-client: %v", err)
return nil
}
b.client = newXDSClientWrapper(client)
b.xdsClient = newXDSClientWrapper(client)
}

return b
Expand All @@ -76,8 +76,8 @@ type lrsBalancer struct {
cc balancer.ClientConn
buildOpts balancer.BuildOptions

logger *grpclog.PrefixLogger
client *xdsClientWrapper
logger *grpclog.PrefixLogger
xdsClient *xdsClientWrapper

config *LBConfig
lb balancer.Balancer // The sub balancer.
Expand All @@ -90,18 +90,18 @@ func (b *lrsBalancer) UpdateClientConnState(s balancer.ClientConnState) error {
return fmt.Errorf("unexpected balancer config with type: %T", s.BalancerConfig)
}

if b.client == nil {
if b.xdsClient == nil {
c := xdsclient.FromResolverState(s.ResolverState)
if c == nil {
return balancer.ErrBadResolverState
}
b.client = newXDSClientWrapper(c)
b.xdsClient = newXDSClientWrapper(c)
}

// Update load reporting config or xds client. This needs to be done before
// updating the child policy because we need the loadStore from the updated
// client to be passed to the ccWrapper.
if err := b.client.update(newConfig); err != nil {
if err := b.xdsClient.update(newConfig); err != nil {
return err
}

Expand All @@ -118,7 +118,7 @@ func (b *lrsBalancer) UpdateClientConnState(s balancer.ClientConnState) error {
if err != nil {
return fmt.Errorf("failed to marshal LocalityID: %#v", newConfig.Locality)
}
ccWrapper := newCCWrapper(b.cc, b.client.loadStore(), lidJSON)
ccWrapper := newCCWrapper(b.cc, b.xdsClient.loadStore(), lidJSON)
b.lb = bb.Build(ccWrapper, b.buildOpts)
}
b.config = newConfig
Expand Down Expand Up @@ -147,7 +147,7 @@ func (b *lrsBalancer) Close() {
b.lb.Close()
b.lb = nil
}
b.client.close()
b.xdsClient.close()
}

type ccWrapper struct {
Expand Down

0 comments on commit 656cad9

Please sign in to comment.