-
Notifications
You must be signed in to change notification settings - Fork 10
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
Conversation
…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).
internal/app/grpcserver/impl.go
Outdated
if err := grpcutil.AddHeaderMetadata(stream.Context(), responseDefinition.ResponseHeaders); err != nil { | ||
return err | ||
} | ||
if err := grpcutil.AddTrailerMetadata(stream.Context(), responseDefinition.ResponseTrailers); err != nil { | ||
return err | ||
} |
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.
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
.
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.
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.
This implements the rest of the endpoints for the gRPC server (client streaming, server streaming, and bidi)