It seems to me that the built in cancellation support of gRPC is quite aggressive in the following sense: If I invoke cancellation on client side, the communication channel is closed immediately. The server gets informed and can do cleanup work, but there seems to be no chance to inform the client after cleanup has been finished.
What am I supposed to do if I want the following "soft cancellation" behavior?
- Client requests cancellation
- Server receives cancellation request and starts cleanup
- Server finishes cleanup and closes the communication channel
- Client gets informed that cancellation procedure has been finished
This behavior could be achieved using a request stream and the oneof keyword:
service ServiceName{
rpc Communicate (stream Request) returns (Response);
}
message Request {
oneof request_oneof {
ActualRequest actual = 1;
CancellationRequest cancellation = 2;
}
}
This should not be too hard to implement, but it also looks quite cumbersome. What do you think is the intended way?