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

Use bytes to represent gRPC message body #833

Merged
merged 1 commit into from
Apr 10, 2020

Conversation

tiziano88
Copy link
Collaborator

This will also be useful for #819

@tiziano88 tiziano88 force-pushed the tzn_grpc_req_bytes branch 2 times, most recently from 87630b3 to 129d6d1 Compare April 9, 2020 12:29
@@ -223,7 +221,7 @@ void ModuleInvocation::BlockingSendResponse() {
auto callback = new std::function<void(bool)>(
std::bind(&ModuleInvocation::SendResponse, this, std::placeholders::_1));
stream_.Write(bb, options, callback);
} else if (!grpc_response.has_rsp_msg()) {
} else if (grpc_response.rsp_msg().empty()) {
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 causing tests to fail now, I am guessing because an empty bytes field is indistinguishable from a default message. @daviddrysdale do we need to keep this distinction between last message with and without payload?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I fixed it by assuming that only exactly one between rsp_msg and status is set. @ipetr0v is this compatible with the Rust implementation too? If so, should we make that a oneof, and / or explain in a comment in the proto message?

Copy link
Contributor

@daviddrysdale daviddrysdale left a comment

Choose a reason for hiding this comment

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

LGTM once Cloudbuild is happy.

@@ -29,12 +28,12 @@ import "third_party/google/rpc/status.proto";

message GrpcRequest {
string method_name = 1;
google.protobuf.Any req_msg = 2;
bytes req_msg = 2;
Copy link
Contributor

Choose a reason for hiding this comment

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

Need a comment to explain the expected contents of the field:

// Request message as a serialized protobuf; the message type is deduced from the request's method name.

bool last = 3;
}

message GrpcResponse {
google.protobuf.Any rsp_msg = 1;
bytes rsp_msg = 1;
Copy link
Contributor

Choose a reason for hiding this comment

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

Need a comment as above

@tiziano88 tiziano88 force-pushed the tzn_grpc_req_bytes branch from 129d6d1 to a49c05f Compare April 9, 2020 16:07
@tiziano88 tiziano88 force-pushed the tzn_grpc_req_bytes branch from a49c05f to 34df463 Compare April 9, 2020 20:51
@tiziano88 tiziano88 merged commit 64d3f90 into project-oak:master Apr 10, 2020
daviddrysdale added a commit that referenced this pull request May 26, 2020
Changes required by commit 68fbbe3 ("Use Rust Loader for running
examples (#993)"):
 - Add and use a config that doesn't include a translator node.
 - Add C++ code that is equivalent to oak::grpc::server::init().

Change required by commit 64d3f90 ("Use bytes to represent gRPC
message body (#833)"):
 - Re-work hand-coded response message for current GrpcResponse proto
   message definition.

For #1009
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants