From 656cad9ae5cf6ac93dc06669f308d29be7118481 Mon Sep 17 00:00:00 2001 From: Doug Fawley Date: Fri, 4 Jun 2021 12:00:13 -0700 Subject: [PATCH] xds: standardize xds client field name (xdsClient) (#4518) --- .../balancer/clusterimpl/clusterimpl.go | 18 +++++++++--------- xds/internal/balancer/lrs/balancer.go | 16 ++++++++-------- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/xds/internal/balancer/clusterimpl/clusterimpl.go b/xds/internal/balancer/clusterimpl/clusterimpl.go index 359ec850501..9f3acafbc92 100644 --- a/xds/internal/balancer/clusterimpl/clusterimpl.go +++ b/xds/internal/balancer/clusterimpl/clusterimpl.go @@ -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() @@ -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 @@ -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) } @@ -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 @@ -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") diff --git a/xds/internal/balancer/lrs/balancer.go b/xds/internal/balancer/lrs/balancer.go index 313b4b78a23..75a8cbb0dd7 100644 --- a/xds/internal/balancer/lrs/balancer.go +++ b/xds/internal/balancer/lrs/balancer.go @@ -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 @@ -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. @@ -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 } @@ -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 @@ -147,7 +147,7 @@ func (b *lrsBalancer) Close() { b.lb.Close() b.lb = nil } - b.client.close() + b.xdsClient.close() } type ccWrapper struct {