Skip to content

Commit 582ef45

Browse files
authored
cluster_resolver: move balancer config types into cluster_resolver package and unexport (#4607)
1 parent c513103 commit 582ef45

15 files changed

+371
-450
lines changed

xds/internal/balancer/cdsbalancer/cdsbalancer.go

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ import (
3535
"google.golang.org/grpc/resolver"
3636
"google.golang.org/grpc/serviceconfig"
3737
"google.golang.org/grpc/xds/internal/balancer/clusterresolver"
38-
"google.golang.org/grpc/xds/internal/balancer/clusterresolver/balancerconfig"
3938
"google.golang.org/grpc/xds/internal/xdsclient"
4039
)
4140

@@ -304,12 +303,12 @@ func (b *cdsBalancer) handleWatchUpdate(update clusterHandlerUpdate) {
304303
b.logger.Infof("Created child policy %p of type %s", b.childLB, clusterresolver.Name)
305304
}
306305

307-
dms := make([]balancerconfig.DiscoveryMechanism, len(update.updates))
306+
dms := make([]clusterresolver.DiscoveryMechanism, len(update.updates))
308307
for i, cu := range update.updates {
309308
switch cu.ClusterType {
310309
case xdsclient.ClusterTypeEDS:
311-
dms[i] = balancerconfig.DiscoveryMechanism{
312-
Type: balancerconfig.DiscoveryMechanismTypeEDS,
310+
dms[i] = clusterresolver.DiscoveryMechanism{
311+
Type: clusterresolver.DiscoveryMechanismTypeEDS,
313312
Cluster: cu.ClusterName,
314313
EDSServiceName: cu.EDSServiceName,
315314
MaxConcurrentRequests: cu.MaxRequests,
@@ -322,8 +321,8 @@ func (b *cdsBalancer) handleWatchUpdate(update clusterHandlerUpdate) {
322321

323322
}
324323
case xdsclient.ClusterTypeLogicalDNS:
325-
dms[i] = balancerconfig.DiscoveryMechanism{
326-
Type: balancerconfig.DiscoveryMechanismTypeLogicalDNS,
324+
dms[i] = clusterresolver.DiscoveryMechanism{
325+
Type: clusterresolver.DiscoveryMechanismTypeLogicalDNS,
327326
DNSHostname: cu.DNSHostName,
328327
}
329328
default:

xds/internal/balancer/cdsbalancer/cdsbalancer_test.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ import (
3636
"google.golang.org/grpc/resolver"
3737
"google.golang.org/grpc/serviceconfig"
3838
"google.golang.org/grpc/xds/internal/balancer/clusterresolver"
39-
"google.golang.org/grpc/xds/internal/balancer/clusterresolver/balancerconfig"
4039
xdstestutils "google.golang.org/grpc/xds/internal/testutils"
4140
"google.golang.org/grpc/xds/internal/testutils/fakeclient"
4241
"google.golang.org/grpc/xds/internal/xdsclient"
@@ -198,8 +197,8 @@ func cdsCCS(cluster string, xdsC xdsclient.XDSClient) balancer.ClientConnState {
198197
// edsCCS is a helper function to construct a good update passed from the
199198
// cdsBalancer to the edsBalancer.
200199
func edsCCS(service string, countMax *uint32, enableLRS bool) balancer.ClientConnState {
201-
discoveryMechanism := balancerconfig.DiscoveryMechanism{
202-
Type: balancerconfig.DiscoveryMechanismTypeEDS,
200+
discoveryMechanism := clusterresolver.DiscoveryMechanism{
201+
Type: clusterresolver.DiscoveryMechanismTypeEDS,
203202
Cluster: service,
204203
MaxConcurrentRequests: countMax,
205204
}
@@ -208,7 +207,7 @@ func edsCCS(service string, countMax *uint32, enableLRS bool) balancer.ClientCon
208207

209208
}
210209
lbCfg := &clusterresolver.LBConfig{
211-
DiscoveryMechanisms: []balancerconfig.DiscoveryMechanism{discoveryMechanism},
210+
DiscoveryMechanisms: []clusterresolver.DiscoveryMechanism{discoveryMechanism},
212211
}
213212

214213
return balancer.ClientConnState{

xds/internal/balancer/clusterresolver/balancerconfig/type.go

Lines changed: 0 additions & 140 deletions
This file was deleted.

xds/internal/balancer/clusterresolver/balancerconfig/type_test.go

Lines changed: 0 additions & 88 deletions
This file was deleted.

xds/internal/balancer/clusterresolver/clusterresolver.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ import (
3434
"google.golang.org/grpc/internal/pretty"
3535
"google.golang.org/grpc/resolver"
3636
"google.golang.org/grpc/serviceconfig"
37-
"google.golang.org/grpc/xds/internal/balancer/clusterresolver/balancerconfig"
3837
"google.golang.org/grpc/xds/internal/balancer/priority"
3938
"google.golang.org/grpc/xds/internal/xdsclient"
4039
)
@@ -138,7 +137,7 @@ type clusterResolverBalancer struct {
138137
attrsWithClient *attributes.Attributes // Attributes with xdsClient attached to be passed to the child policies.
139138

140139
child balancer.Balancer
141-
priorities []balancerconfig.PriorityConfig
140+
priorities []priorityConfig
142141
watchUpdateReceived bool
143142
}
144143

@@ -210,7 +209,7 @@ func (b *clusterResolverBalancer) updateChildConfig() error {
210209
b.child = newChildBalancer(b.priorityBuilder, b.cc, b.bOpts)
211210
}
212211

213-
childCfgBytes, addrs, err := balancerconfig.BuildPriorityConfigJSON(b.priorities, b.config.EndpointPickingPolicy)
212+
childCfgBytes, addrs, err := buildPriorityConfigJSON(b.priorities, b.config.EndpointPickingPolicy)
214213
if err != nil {
215214
return fmt.Errorf("failed to build priority balancer config: %v", err)
216215
}

xds/internal/balancer/clusterresolver/clusterresolver_test.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ import (
3333
"google.golang.org/grpc/internal/testutils"
3434
"google.golang.org/grpc/resolver"
3535
"google.golang.org/grpc/xds/internal"
36-
"google.golang.org/grpc/xds/internal/balancer/clusterresolver/balancerconfig"
3736
"google.golang.org/grpc/xds/internal/testutils/fakeclient"
3837
"google.golang.org/grpc/xds/internal/xdsclient"
3938

@@ -492,9 +491,9 @@ func (s) TestClientWatchEDS(t *testing.T) {
492491

493492
func newLBConfigWithOneEDS(edsServiceName string) *LBConfig {
494493
return &LBConfig{
495-
DiscoveryMechanisms: []balancerconfig.DiscoveryMechanism{{
494+
DiscoveryMechanisms: []DiscoveryMechanism{{
496495
Cluster: testClusterName,
497-
Type: balancerconfig.DiscoveryMechanismTypeEDS,
496+
Type: DiscoveryMechanismTypeEDS,
498497
EDSServiceName: edsServiceName,
499498
}},
500499
}

0 commit comments

Comments
 (0)