If I have a simple unary gRPC function. Say the protobuf file looks like
message Request {
string very_long_string = 1;
}
service MyService {
rpc MyRPC(Request) returns (Response) {};
}
On the server when I use the generated implementation for this, the function header will look something like
grpc::Status MyRPC(grpc::ServerContext* context, const Request* request,
Response* response) override
In general I like that the request is const. However I would like a way to move the string ('very_long_string' above) OUT of the request instead of making a copy of it. I seem to be able to do it if I const_cast the request then use the protobuf release function on the very_long_string value. However is there a better way to do this? Also if there is NOT a better way to do this does gRPC require that the request is not modified in any way? Will removing const cause any problems?