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

V1: Implement rest of gRPC server endpoints #638

Merged
merged 24 commits into from
Nov 8, 2023
Merged

Conversation

smaye81
Copy link
Member

@smaye81 smaye81 commented Nov 6, 2023

This implements the rest of the endpoints for the gRPC server (client streaming, server streaming, and bidi)

@smaye81 smaye81 requested a review from jhump November 6, 2023 19:38
smaye81 and others added 4 commits November 6, 2023 16:36
…expected response (#629)

This addresses the TODO about how comparing the actual response to
expected needed to be more sophisticated.

In particular:
1. It is acceptable for the actual headers/trailers to contain more than
what's in the test expectation. Not only is it common for some HTTP
client/server frameworks to add add'l headers (like "Date",
"User-Agent", etc.), but we also don't want to hard-code all of the
protocol-specific headers into the test case data (e.g. "Content-Type").
2. It is acceptable for a client or server to merge headers and trailers
for responses that have empty response streams and an error. These can
be conveyed via "trailers-only responses" in the gRPC protocol, in which
case it is not possible to separate headers and trailers. Furthermore,
such responses are actually "headers-only" on the wire, so we allow the
sets to be merged into either headers or trailers under these specific
conditions.
3. It is acceptable for the server to omit the Connect GET query params
in its response.
4. It is acceptable for the client to omit the raw Connect error
details.
5. `Any` messages need smarter treatment than just `proto.Equal` since
two semantically equivalent messages could be serialized differently,
which means the `value` byte slices in two messages may differ and cause
`proto.Equal` to consider them unequal.
This finally brings it all together. This also adds a single test case
to the embedded test suites (which gets expanded to 20 test cases with
default config, due to permutations with HTTP versions, protocols,
codecs, etc).
Base automatically changed from sayers/grpc_server to v2 November 7, 2023 15:06
Comment on lines 104 to 109
if err := grpcutil.AddHeaderMetadata(stream.Context(), responseDefinition.ResponseHeaders); err != nil {
return err
}
if err := grpcutil.AddTrailerMetadata(stream.Context(), responseDefinition.ResponseTrailers); err != nil {
return err
}
Copy link
Member

Choose a reason for hiding this comment

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

It is only necessary to set headers and trailers through the context for unary RPCs. For all stream RPCs, it is more clear to instead use the SetHeader and SetTrailer methods on stream.

Copy link
Member Author

Choose a reason for hiding this comment

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

Gotcha. Changed all the streaming endpoints do use the stream methods. Also, since unary was now the only one using AddHeader/TrailerMetadata, I removed it from the grpcutil package and just inlined right in the unary endpoint.

@smaye81 smaye81 changed the title Implement rest of gRPC server endpoints V2: Implement rest of gRPC server endpoints Nov 8, 2023
@smaye81 smaye81 merged commit 84f6ac7 into v2 Nov 8, 2023
@smaye81 smaye81 deleted the sayers/rest_of_grpc_server branch November 8, 2023 16:51
@jhump jhump changed the title V2: Implement rest of gRPC server endpoints V1: Implement rest of gRPC server endpoints Nov 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants