How to import and indicate empty request or reply messages:
import "google/protobuf/empty.proto";
service SomeService {
rpc SomeOperation (google.protobuf.Empty) returns (google.protobuf.Empty) {}
}
How to import and indicate empty request or reply messages:
import "google/protobuf/empty.proto";
service SomeService {
rpc SomeOperation (google.protobuf.Empty) returns (google.protobuf.Empty) {}
}
If an rpc returns Empty, is there still a message sent over the wire?
I think yes: the response contains at least the status code from the RPC executon on the server. The HTTP payload should have an empty body though.
Assuming we're talking about gRPC, there's still data sent over the wire.
The response body has a five-byte prefix, which should be all zeros: the first byte indicates whether the message is compressed, and the next four bytes are a 32-bit unsigned integer. Empty protobuf messages serialize to zero bytes, and google.protobuf.Empty
is always empty, so there's no data following the initial 5 bytes.
You'll also end up sending at least one trailer with the status code (grpc-status: 0
). Depending on your implementation, you may also send the grpc-message
and grpc-status-details-bin
trailers.
If an rpc returns Empty, is there still a message sent over the wire?