Skip to content
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

feat: (diregapic)add headers for rest client #871

Merged
merged 2 commits into from
May 19, 2021

Conversation

summer-ji-eng
Copy link
Collaborator

For REST transport, GAPICs will no longer send the grpc/{@grpc lib version} header value.
Instead, x-goog-api-client will include a new standard value rest/{VVV}. The version here we could reused gax version + "fallback", which is adopted by other headers like gax/{version|}-fallback and grpc-web/{version}+fallback.

The version value will be update in gax-nodejs PR.

@summer-ji-eng summer-ji-eng added the draft Do Not Review label May 13, 2021
@summer-ji-eng summer-ji-eng self-assigned this May 13, 2021
@summer-ji-eng summer-ji-eng requested a review from a team as a code owner May 13, 2021 06:32
@google-cla google-cla bot added the cla: yes This human has signed the Contributor License Agreement. label May 13, 2021
@@ -156,6 +156,8 @@ export class {{ service.name }}Client {
}
if (!opts.fallback) {
clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`);
} else {
clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't the value of this be something else, something that refers to the (language-specific) REST encoding version, instead of grpcVersion? Or does this single number encode both?

[In the latter case, let's at least make a note of that (ideally, changing the name to be more generic, but that might be a more far-reaching change that can handled separately, later, so a comment at least would be good)]

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is gax-nodejs existing implementation. I think it is worth to think to refactor the grpcClient and isolate fallback or rest from grpc.
But it is not block this task. I will revisit the evaluation. Thanks @vchudnov-g

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you generate a comment clarifying that even though the variable is called grpcVersion, it actually captures some non-gRPC info X (where X could be "gax version implementing HTTP" or whatever is an accurate description)

(Someone perusing the code would assume based on the name we're sending the wrong info in the REST case, so it helps to have a comment saying that this is intentional and the variable name is misleading. And then we can fix the name or reorganize the code later.)

@@ -156,6 +156,8 @@ export class {{ service.name }}Client {
}
if (!opts.fallback) {
clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`);
} else {
clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now that the value is in clientHeader, it will just automatically show up in the header emitted by the GAPIC (ie no further coding work needed to include the header)? Cool!

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct

@summer-ji-eng summer-ji-eng changed the title draft: add headers for rest client feat: add headers for rest client May 15, 2021
@summer-ji-eng summer-ji-eng removed the draft Do Not Review label May 15, 2021
Copy link

@vchudnov-g vchudnov-g left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. Just a suggestion to add a comment about the misleading grpcVersion fallback name in the REST case.

@@ -156,6 +156,8 @@ export class {{ service.name }}Client {
}
if (!opts.fallback) {
clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`);
} else {
clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you generate a comment clarifying that even though the variable is called grpcVersion, it actually captures some non-gRPC info X (where X could be "gax version implementing HTTP" or whatever is an accurate description)

(Someone perusing the code would assume based on the name we're sending the wrong info in the REST case, so it helps to have a comment saying that this is intentional and the variable name is misleading. And then we can fix the name or reorganize the code later.)

@summer-ji-eng summer-ji-eng merged commit 6ccc7fa into master May 19, 2021
@summer-ji-eng summer-ji-eng deleted the headers_fallback_metrics branch May 19, 2021 00:06
@summer-ji-eng summer-ji-eng changed the title feat: add headers for rest client feat: [diregapic]add headers for rest client Sep 9, 2021
@summer-ji-eng summer-ji-eng changed the title feat: [diregapic]add headers for rest client feat: (diregapic)add headers for rest client Sep 10, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla: yes This human has signed the Contributor License Agreement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants