xds: use predefined XdsLbPolicies constants instead of string literals for consistency (#9408)

This commit is contained in:
sanjaypujare 2022-07-25 22:35:08 +05:30 committed by GitHub
parent 10979b2e2c
commit 1fe3ed9b53
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 4 deletions

View File

@ -47,7 +47,7 @@ public final class PriorityLoadBalancerProvider extends LoadBalancerProvider {
@Override @Override
public String getPolicyName() { public String getPolicyName() {
return "priority_experimental"; return XdsLbPolicies.PRIORITY_POLICY_NAME;
} }
@Override @Override

View File

@ -281,7 +281,7 @@ final class XdsNameResolver extends NameResolver {
Map<String, ?> rawServiceConfig = ImmutableMap.of( Map<String, ?> rawServiceConfig = ImmutableMap.of(
"loadBalancingConfig", "loadBalancingConfig",
ImmutableList.of(ImmutableMap.of( ImmutableList.of(ImmutableMap.of(
"cluster_manager_experimental", XdsLbPolicies.CLUSTER_MANAGER_POLICY_NAME,
ImmutableMap.of("childPolicy", childPolicy.buildOrThrow())))); ImmutableMap.of("childPolicy", childPolicy.buildOrThrow()))));
if (logger.isLoggable(XdsLogLevel.INFO)) { if (logger.isLoggable(XdsLogLevel.INFO)) {
@ -1014,13 +1014,15 @@ final class XdsNameResolver extends NameResolver {
private Map<String, ?> toLbPolicy() { private Map<String, ?> toLbPolicy() {
if (traditionalCluster != null) { if (traditionalCluster != null) {
return ImmutableMap.of("cds_experimental", ImmutableMap.of("cluster", traditionalCluster)); return ImmutableMap.of(
XdsLbPolicies.CDS_POLICY_NAME,
ImmutableMap.of("cluster", traditionalCluster));
} else { } else {
ImmutableMap<String, ?> rlsConfig = new ImmutableMap.Builder<String, Object>() ImmutableMap<String, ?> rlsConfig = new ImmutableMap.Builder<String, Object>()
.put("routeLookupConfig", rlsPluginConfig.config()) .put("routeLookupConfig", rlsPluginConfig.config())
.put( .put(
"childPolicy", "childPolicy",
ImmutableList.of(ImmutableMap.of("cds_experimental", ImmutableMap.of()))) ImmutableList.of(ImmutableMap.of(XdsLbPolicies.CDS_POLICY_NAME, ImmutableMap.of())))
.put("childPolicyConfigTargetFieldName", "cluster") .put("childPolicyConfigTargetFieldName", "cluster")
.buildOrThrow(); .buildOrThrow();
return ImmutableMap.of("rls_experimental", rlsConfig); return ImmutableMap.of("rls_experimental", rlsConfig);