Non experimental way to allow a client to gracefully cancel streaming service in Java

55 views
Skip to first unread message

san...@wepay.com

unread,
Oct 3, 2018, 10:39:10 PM10/3/18
to grpc.io

Since all StreamObserver (CallStreamObserver, ServerCallStreamObserver) classes are marked as experimental https://github.com/grpc/grpc-java/issues/1788 , What is a stable way to allow a client to gracefully cancel streaming service by signaling the server to stop sending messages?

Also, if I decide to use these experimental classes to achieve this functionality, can I assume that I will be fine unless I upgrade grpc-java version?


I have tried to seach for the answer on Stackoverflow and this group but could not get a concrete answer. Ideally this should be documented as part of gRPC official documentation.


Thanks,

Sankate

Carl Mastrangelo

unread,
Oct 4, 2018, 4:24:13 PM10/4/18
to grpc.io
(speaking on my own behalf, rather than the team):  You can assume this part of the API will never change.   The usage of that API is widespread enough that it would be infeasible to change it now, even if we reserved the right to.  

If you are keen on using a Non experimental API, you can use the ClientCall and Server call directly, which do have stable APIs.  If worse came to worse, you could copy paste our io.grpc.stub package and not worry about API breakages (we infrequently update that package anyways).   StreamObserver and friends are thin wrappers on top of ClientCall and Server call.   You can make your own "Observers" and pass them into the helper functions in io.grpc.stub.ClientCalls and ServerCalls, which do have stable APIs.

I have personally done all of these things, and would still feel comfortable using the unstable API in CallStreamObserver.

san...@wepay.com

unread,
Oct 13, 2018, 5:06:20 PM10/13/18
to grpc.io
Here is another answer from Stackoverflow https://stackoverflow.com/a/52786692/6693234
Reply all
Reply to author
Forward
0 new messages