-
Notifications
You must be signed in to change notification settings - Fork 3.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
xds: Parsing xDS Cluster Metadata #11741
xds: Parsing xDS Cluster Metadata #11741
Conversation
Note: I will add unit tests in the next commit after finalizing on main code. Please react on this comment (👍) if this looks good, and then I will proceed with unit tests. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems ready for tests
return INSTANCE; | ||
} | ||
|
||
ClusterMetadataValueParser findParser(String typeUrl) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should have a @Nullable
annotation as the underlying get(key)
method could return null
if the key (typeUrl
) is not found in the HashMap
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Nullable
is not required in grpc-java. It is inconsistent, and without a null checker, it is nothing more than documentation.
xds/src/main/java/io/grpc/xds/internal/ProtobufJsonConverter.java
Outdated
Show resolved
Hide resolved
.build(); | ||
|
||
Struct filterMetadata = Struct.newBuilder() | ||
.putFields("key1", Value.newBuilder().setStringValue("value1").build()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we craft other types of Values in the test cases to excersise all branches of the convertValue
method above (e.g. LIST_VALUE
, BOOL_VALUE
, etc.)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't feel like doing so right now, as we are concerned only about Audience here which will always be StringValue. We definitely need to add tests as and when the usage grows. Adding more tests on different value types right now will be purely based on assumption.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we are concerned only about Audience here which will always be StringValue ... Adding more tests on different value types right now will be purely based on assumption.
If we not using the other cases and only using STRING_VALUE
, then we should delete the other unused branches in convertValue
until they are needed. This would keep the code and tests focused.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Independent of the plan, I suspect we shouldn't do that sort of testing here. It can be part of a separate ProtobufJsonConverterTest.
Deleting the branches in ProtobufJsonConverter doesn't seem to benefit anyone.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We are not only concerned with Audience here. You are doing two things: 1) adding the metadata infrastructure and 2) supporting Audience. Properly handling the JSON is part of (1). We should add a ProtobufJsonConverterTest to fully-cover the converter. This should be very easy.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: the PR title should start with xds:
(module name) as it is all xDS related changes per convertValue per https://github.com/grpc/grpc-java/blob/master/CONTRIBUTING.md#guidelines-for-pull-requests
.build(); | ||
|
||
Struct filterMetadata = Struct.newBuilder() | ||
.putFields("key1", Value.newBuilder().setStringValue("value1").build()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we are concerned only about Audience here which will always be StringValue ... Adding more tests on different value types right now will be purely based on assumption.
If we not using the other cases and only using STRING_VALUE
, then we should delete the other unused branches in convertValue
until they are needed. This would keep the code and tests focused.
* <p>This class maintains a mapping of type URLs to {@link ClusterMetadataValueParser} instances, | ||
* allowing for the parsing of different metadata types. | ||
*/ | ||
final class ClusterMetadataRegistry { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This shouldn't have "Cluster" in its name. It is for all xds metadata.
Add Support for Audience Metadata Parsing in xDS Cluster Resource