mirror of https://github.com/grpc/grpc-java.git
rls: fix wrong grpcKeybuilder field name (#8999)
The `grpcKeybuilders` [field](9fb243ce29/grpc/lookup/v1/rls_config.proto (L176)) should not be `grpcKeyBuilders` in json format. The mistake in Java was introduced since the [beginning](0fd4975d4c (diff-585b634c79155b4ac9417f7805e1b9d5f6d5c11a940c88e27fdf53c209e619cfR104)).
This commit is contained in:
parent
d196e588a2
commit
c772eb0f4e
|
|
@ -109,12 +109,12 @@ final class RlsProtoConverters {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected RouteLookupConfig doForward(Map<String, ?> json) {
|
protected RouteLookupConfig doForward(Map<String, ?> json) {
|
||||||
ImmutableList<GrpcKeyBuilder> grpcKeyBuilders =
|
ImmutableList<GrpcKeyBuilder> grpcKeybuilders =
|
||||||
GrpcKeyBuilderConverter.covertAll(
|
GrpcKeyBuilderConverter.covertAll(
|
||||||
checkNotNull(JsonUtil.getListOfObjects(json, "grpcKeyBuilders"), "grpcKeyBuilders"));
|
checkNotNull(JsonUtil.getListOfObjects(json, "grpcKeybuilders"), "grpcKeybuilders"));
|
||||||
checkArgument(!grpcKeyBuilders.isEmpty(), "must have at least one GrpcKeyBuilder");
|
checkArgument(!grpcKeybuilders.isEmpty(), "must have at least one GrpcKeyBuilder");
|
||||||
Set<Name> names = new HashSet<>();
|
Set<Name> names = new HashSet<>();
|
||||||
for (GrpcKeyBuilder keyBuilder : grpcKeyBuilders) {
|
for (GrpcKeyBuilder keyBuilder : grpcKeybuilders) {
|
||||||
for (Name name : keyBuilder.names()) {
|
for (Name name : keyBuilder.names()) {
|
||||||
checkArgument(names.add(name), "duplicate names in grpc_keybuilders: " + name);
|
checkArgument(names.add(name), "duplicate names in grpc_keybuilders: " + name);
|
||||||
}
|
}
|
||||||
|
|
@ -147,7 +147,7 @@ final class RlsProtoConverters {
|
||||||
cacheSize = Math.min(cacheSize, MAX_CACHE_SIZE);
|
cacheSize = Math.min(cacheSize, MAX_CACHE_SIZE);
|
||||||
String defaultTarget = Strings.emptyToNull(JsonUtil.getString(json, "defaultTarget"));
|
String defaultTarget = Strings.emptyToNull(JsonUtil.getString(json, "defaultTarget"));
|
||||||
return RouteLookupConfig.builder()
|
return RouteLookupConfig.builder()
|
||||||
.grpcKeyBuilders(grpcKeyBuilders)
|
.grpcKeybuilders(grpcKeybuilders)
|
||||||
.lookupService(lookupService)
|
.lookupService(lookupService)
|
||||||
.lookupServiceTimeoutInNanos(timeout)
|
.lookupServiceTimeoutInNanos(timeout)
|
||||||
.maxAgeInNanos(maxAge)
|
.maxAgeInNanos(maxAge)
|
||||||
|
|
|
||||||
|
|
@ -75,7 +75,7 @@ final class RlsProtoData {
|
||||||
* keyed by name. If no GrpcKeyBuilder matches, an empty key_map will be sent to the lookup
|
* keyed by name. If no GrpcKeyBuilder matches, an empty key_map will be sent to the lookup
|
||||||
* service; it should likely reply with a global default route and raise an alert.
|
* service; it should likely reply with a global default route and raise an alert.
|
||||||
*/
|
*/
|
||||||
abstract ImmutableList<GrpcKeyBuilder> grpcKeyBuilders();
|
abstract ImmutableList<GrpcKeyBuilder> grpcKeybuilders();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the name of the lookup service as a gRPC URI. Typically, this will be a subdomain of
|
* Returns the name of the lookup service as a gRPC URI. Typically, this will be a subdomain of
|
||||||
|
|
@ -119,7 +119,7 @@ final class RlsProtoData {
|
||||||
@AutoValue.Builder
|
@AutoValue.Builder
|
||||||
abstract static class Builder {
|
abstract static class Builder {
|
||||||
|
|
||||||
abstract Builder grpcKeyBuilders(ImmutableList<GrpcKeyBuilder> grpcKeyBuilders);
|
abstract Builder grpcKeybuilders(ImmutableList<GrpcKeyBuilder> grpcKeybuilders);
|
||||||
|
|
||||||
abstract Builder lookupService(String lookupService);
|
abstract Builder lookupService(String lookupService);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -50,7 +50,7 @@ final class RlsRequestFactory {
|
||||||
private static Map<String, GrpcKeyBuilder> createKeyBuilderTable(
|
private static Map<String, GrpcKeyBuilder> createKeyBuilderTable(
|
||||||
RouteLookupConfig config) {
|
RouteLookupConfig config) {
|
||||||
Map<String, GrpcKeyBuilder> table = new HashMap<>();
|
Map<String, GrpcKeyBuilder> table = new HashMap<>();
|
||||||
for (GrpcKeyBuilder grpcKeyBuilder : config.grpcKeyBuilders()) {
|
for (GrpcKeyBuilder grpcKeyBuilder : config.grpcKeybuilders()) {
|
||||||
for (Name name : grpcKeyBuilder.names()) {
|
for (Name name : grpcKeyBuilder.names()) {
|
||||||
boolean hasMethod = name.method() == null || name.method().isEmpty();
|
boolean hasMethod = name.method() == null || name.method().isEmpty();
|
||||||
String method = hasMethod ? "*" : name.method();
|
String method = hasMethod ? "*" : name.method();
|
||||||
|
|
|
||||||
|
|
@ -428,7 +428,7 @@ public class CachingRlsLbClientTest {
|
||||||
|
|
||||||
private static RouteLookupConfig getRouteLookupConfig() {
|
private static RouteLookupConfig getRouteLookupConfig() {
|
||||||
return RouteLookupConfig.builder()
|
return RouteLookupConfig.builder()
|
||||||
.grpcKeyBuilders(ImmutableList.of(
|
.grpcKeybuilders(ImmutableList.of(
|
||||||
GrpcKeyBuilder.create(
|
GrpcKeyBuilder.create(
|
||||||
ImmutableList.of(Name.create("service1", "create")),
|
ImmutableList.of(Name.create("service1", "create")),
|
||||||
ImmutableList.of(
|
ImmutableList.of(
|
||||||
|
|
|
||||||
|
|
@ -392,7 +392,7 @@ public class RlsLoadBalancerTest {
|
||||||
|
|
||||||
private String getRlsConfigJsonStr() {
|
private String getRlsConfigJsonStr() {
|
||||||
return "{\n"
|
return "{\n"
|
||||||
+ " \"grpcKeyBuilders\": [\n"
|
+ " \"grpcKeybuilders\": [\n"
|
||||||
+ " {\n"
|
+ " {\n"
|
||||||
+ " \"names\": [\n"
|
+ " \"names\": [\n"
|
||||||
+ " {\n"
|
+ " {\n"
|
||||||
|
|
|
||||||
|
|
@ -101,7 +101,7 @@ public class RlsProtoConvertersTest {
|
||||||
@Test
|
@Test
|
||||||
public void convert_jsonRlsConfig() throws IOException {
|
public void convert_jsonRlsConfig() throws IOException {
|
||||||
String jsonStr = "{\n"
|
String jsonStr = "{\n"
|
||||||
+ " \"grpcKeyBuilders\": [\n"
|
+ " \"grpcKeybuilders\": [\n"
|
||||||
+ " {\n"
|
+ " {\n"
|
||||||
+ " \"names\": [\n"
|
+ " \"names\": [\n"
|
||||||
+ " {\n"
|
+ " {\n"
|
||||||
|
|
@ -177,7 +177,7 @@ public class RlsProtoConvertersTest {
|
||||||
|
|
||||||
RouteLookupConfig expectedConfig =
|
RouteLookupConfig expectedConfig =
|
||||||
RouteLookupConfig.builder()
|
RouteLookupConfig.builder()
|
||||||
.grpcKeyBuilders(ImmutableList.of(
|
.grpcKeybuilders(ImmutableList.of(
|
||||||
GrpcKeyBuilder.create(
|
GrpcKeyBuilder.create(
|
||||||
ImmutableList.of(Name.create("service1", "create")),
|
ImmutableList.of(Name.create("service1", "create")),
|
||||||
ImmutableList.of(
|
ImmutableList.of(
|
||||||
|
|
@ -216,7 +216,7 @@ public class RlsProtoConvertersTest {
|
||||||
@Test
|
@Test
|
||||||
public void convert_jsonRlsConfig_emptyKeyBuilders() throws IOException {
|
public void convert_jsonRlsConfig_emptyKeyBuilders() throws IOException {
|
||||||
String jsonStr = "{\n"
|
String jsonStr = "{\n"
|
||||||
+ " \"grpcKeyBuilders\": [],\n"
|
+ " \"grpcKeybuilders\": [],\n"
|
||||||
+ " \"lookupService\": \"service1\",\n"
|
+ " \"lookupService\": \"service1\",\n"
|
||||||
+ " \"lookupServiceTimeout\": \"2s\",\n"
|
+ " \"lookupServiceTimeout\": \"2s\",\n"
|
||||||
+ " \"maxAge\": \"300s\",\n"
|
+ " \"maxAge\": \"300s\",\n"
|
||||||
|
|
@ -240,7 +240,7 @@ public class RlsProtoConvertersTest {
|
||||||
@Test
|
@Test
|
||||||
public void convert_jsonRlsConfig_namesNotUnique() throws IOException {
|
public void convert_jsonRlsConfig_namesNotUnique() throws IOException {
|
||||||
String jsonStr = "{\n"
|
String jsonStr = "{\n"
|
||||||
+ " \"grpcKeyBuilders\": [\n"
|
+ " \"grpcKeybuilders\": [\n"
|
||||||
+ " {\n"
|
+ " {\n"
|
||||||
+ " \"names\": [\n"
|
+ " \"names\": [\n"
|
||||||
+ " {\n"
|
+ " {\n"
|
||||||
|
|
@ -329,7 +329,7 @@ public class RlsProtoConvertersTest {
|
||||||
@Test
|
@Test
|
||||||
public void convert_jsonRlsConfig_defaultValues() throws IOException {
|
public void convert_jsonRlsConfig_defaultValues() throws IOException {
|
||||||
String jsonStr = "{\n"
|
String jsonStr = "{\n"
|
||||||
+ " \"grpcKeyBuilders\": [\n"
|
+ " \"grpcKeybuilders\": [\n"
|
||||||
+ " {\n"
|
+ " {\n"
|
||||||
+ " \"names\": [\n"
|
+ " \"names\": [\n"
|
||||||
+ " {\n"
|
+ " {\n"
|
||||||
|
|
@ -345,7 +345,7 @@ public class RlsProtoConvertersTest {
|
||||||
|
|
||||||
RouteLookupConfig expectedConfig =
|
RouteLookupConfig expectedConfig =
|
||||||
RouteLookupConfig.builder()
|
RouteLookupConfig.builder()
|
||||||
.grpcKeyBuilders(ImmutableList.of(
|
.grpcKeybuilders(ImmutableList.of(
|
||||||
GrpcKeyBuilder.create(
|
GrpcKeyBuilder.create(
|
||||||
ImmutableList.of(Name.create("service1", null)),
|
ImmutableList.of(Name.create("service1", null)),
|
||||||
ImmutableList.<NameMatcher>of(),
|
ImmutableList.<NameMatcher>of(),
|
||||||
|
|
@ -369,7 +369,7 @@ public class RlsProtoConvertersTest {
|
||||||
@Test
|
@Test
|
||||||
public void convert_jsonRlsConfig_staleAgeCappedByMaxAge() throws IOException {
|
public void convert_jsonRlsConfig_staleAgeCappedByMaxAge() throws IOException {
|
||||||
String jsonStr = "{\n"
|
String jsonStr = "{\n"
|
||||||
+ " \"grpcKeyBuilders\": [\n"
|
+ " \"grpcKeybuilders\": [\n"
|
||||||
+ " {\n"
|
+ " {\n"
|
||||||
+ " \"names\": [\n"
|
+ " \"names\": [\n"
|
||||||
+ " {\n"
|
+ " {\n"
|
||||||
|
|
@ -402,7 +402,7 @@ public class RlsProtoConvertersTest {
|
||||||
|
|
||||||
RouteLookupConfig expectedConfig =
|
RouteLookupConfig expectedConfig =
|
||||||
RouteLookupConfig.builder()
|
RouteLookupConfig.builder()
|
||||||
.grpcKeyBuilders(ImmutableList.of(
|
.grpcKeybuilders(ImmutableList.of(
|
||||||
GrpcKeyBuilder.create(
|
GrpcKeyBuilder.create(
|
||||||
ImmutableList.of(Name.create("service1", "create")),
|
ImmutableList.of(Name.create("service1", "create")),
|
||||||
ImmutableList.of(
|
ImmutableList.of(
|
||||||
|
|
@ -428,7 +428,7 @@ public class RlsProtoConvertersTest {
|
||||||
@Test
|
@Test
|
||||||
public void convert_jsonRlsConfig_staleAgeGivenWithoutMaxAge() throws IOException {
|
public void convert_jsonRlsConfig_staleAgeGivenWithoutMaxAge() throws IOException {
|
||||||
String jsonStr = "{\n"
|
String jsonStr = "{\n"
|
||||||
+ " \"grpcKeyBuilders\": [\n"
|
+ " \"grpcKeybuilders\": [\n"
|
||||||
+ " {\n"
|
+ " {\n"
|
||||||
+ " \"names\": [\n"
|
+ " \"names\": [\n"
|
||||||
+ " {\n"
|
+ " {\n"
|
||||||
|
|
@ -472,7 +472,7 @@ public class RlsProtoConvertersTest {
|
||||||
@Test
|
@Test
|
||||||
public void convert_jsonRlsConfig_keyBuilderWithoutName() throws IOException {
|
public void convert_jsonRlsConfig_keyBuilderWithoutName() throws IOException {
|
||||||
String jsonStr = "{\n"
|
String jsonStr = "{\n"
|
||||||
+ " \"grpcKeyBuilders\": [\n"
|
+ " \"grpcKeybuilders\": [\n"
|
||||||
+ " {\n"
|
+ " {\n"
|
||||||
+ " \"headers\": [\n"
|
+ " \"headers\": [\n"
|
||||||
+ " {\n"
|
+ " {\n"
|
||||||
|
|
@ -510,7 +510,7 @@ public class RlsProtoConvertersTest {
|
||||||
@Test
|
@Test
|
||||||
public void convert_jsonRlsConfig_nameWithoutService() throws IOException {
|
public void convert_jsonRlsConfig_nameWithoutService() throws IOException {
|
||||||
String jsonStr = "{\n"
|
String jsonStr = "{\n"
|
||||||
+ " \"grpcKeyBuilders\": [\n"
|
+ " \"grpcKeybuilders\": [\n"
|
||||||
+ " {\n"
|
+ " {\n"
|
||||||
+ " \"names\": [\n"
|
+ " \"names\": [\n"
|
||||||
+ " {\n"
|
+ " {\n"
|
||||||
|
|
@ -553,7 +553,7 @@ public class RlsProtoConvertersTest {
|
||||||
@Test
|
@Test
|
||||||
public void convert_jsonRlsConfig_keysNotUnique() throws IOException {
|
public void convert_jsonRlsConfig_keysNotUnique() throws IOException {
|
||||||
String jsonStr = "{\n"
|
String jsonStr = "{\n"
|
||||||
+ " \"grpcKeyBuilders\": [\n"
|
+ " \"grpcKeybuilders\": [\n"
|
||||||
+ " {\n"
|
+ " {\n"
|
||||||
+ " \"names\": [\n"
|
+ " \"names\": [\n"
|
||||||
+ " {\n"
|
+ " {\n"
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,7 @@ public class RlsRequestFactoryTest {
|
||||||
|
|
||||||
private static final RouteLookupConfig RLS_CONFIG =
|
private static final RouteLookupConfig RLS_CONFIG =
|
||||||
RouteLookupConfig.builder()
|
RouteLookupConfig.builder()
|
||||||
.grpcKeyBuilders(ImmutableList.of(
|
.grpcKeybuilders(ImmutableList.of(
|
||||||
GrpcKeyBuilder.create(
|
GrpcKeyBuilder.create(
|
||||||
ImmutableList.of(Name.create("com.google.service1", "Create")),
|
ImmutableList.of(Name.create("com.google.service1", "Create")),
|
||||||
ImmutableList.of(
|
ImmutableList.of(
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue