On Mon, Jun 26, 2017 at 4:10 PM, Ran Bi <[email protected]> wrote:

> I was under the impression that ServerCall.close also handle the
> cancellation because CANCELLED is declared in Status.Code.
> Why is cancelation handled specially from other status?
>

close() is for an application to tell gRPC to do something. In the case of
error, that won't necessarily happen and gRPC can't guarantee it will be
called, because gRPC isn't doing the calling.

If you do ServerCall.close(CANCELLED), if no other errors happen then
onCompleted() will be called, as specified in the API:

> If no errors or cancellations are known to have occurred, then a {@link
> Listener#onComplete} notification should be expected, independent of {@code
> status}.


So CANCELLED is not handled specially, since it is just a canonical status
code; client-side cancellation and similar imply certain behaviors, and
they will use CANCELLED, but that doesn't mean CANCELLED implies those
behaviors. Client-side cancellation and similar is handled specially
because the RPC is thrown away as quickly as possible and all messages
discarded. close(CANCELLED) is graceful in that it waits for any queued
messages to be sent before sending the close().

We have discussed before having server-side cancellation support, which
throws away the RPC as quickly as possible. It'd have its use cases, but we
were just going to wait until the strong need arose since we're doing other
things that can more dramatically help our users.

-- 
You received this message because you are subscribed to the Google Groups 
"grpc.io" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/grpc-io.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/grpc-io/CA%2B4M1oMyUs39ZNGcYRocXuiVR9uvXAejPiOfU_MV-HwqaB792A%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Attachment: smime.p7s
Description: S/MIME Cryptographic Signature

Reply via email to