Hi all,
Greetings from me! I am a newbie of using gPRC, and my service is so simple:
service KeyDB {
rpc Init(InitRequest) returns (InitResponse) {}
}
enum ServerResponse {
SUCCESS = 0;
ALREADY_EXISTS = 1;
}
message InitRequest {
bytes pub_key = 1;
}
message InitResponse {
ServerResponse response = 1;
}
The client just sends pub_key, and servers responses SUCCESS or key ALREADY_EXISTS.
I find the ServerResponse code is very similar as grpc::StatusCode. So my Server::Init
function always returns OK, and uses response to carry error code.
grpc::Status Server::Init(grpc::ServerContext* context, request, response)
{
......
response.set_response(ALREADY_EXISTS);
......
return grpc::Status()
}
So is there any canonical way of processing when grpc::StatusCode are partly or all overlapped
with service's response? Or are there any better solutions?
Thanks very much in advance!
Best Regards
Nan Xiao