Assuming I have no uncompleted async operation (like Read()), is it then valid to skip the Read()-Finish() sequence and immediately release the resources?
- Read(), ok =true - Read(), ok =true, exception while applying business logic - ClientContext::TryCancel() - Delete ClientAsyncReader and ClientContext Patrick On Tuesday, April 28, 2020 at 2:20:30 PM UTC+2, [email protected] wrote: > > Hi, > > > I am writing a C++ future/promised based interface around the grpc c++ > API. Some important details around termination of the streams are not clear > to me, even after reading through discussions here and many open/closed > issues in the GitHub repository. > > > Suppose a client calls a SERVER_STREAMING RPC using ClientAsyncReader, > ClientContext etc. > > > Finish() > > Can only be called after cq.Next() returns ok = false for a Read() > operation. So the normal sequence could look like: > > > > - Read(), ok =true > - Read(), ok =true > - Read(), ok =true > - Read(), ok = true > - Read(), ok = false // nothing more to read > - Finish(), ok = true // gets RPC status > - Delete ClientAsyncReader and ClientContext > > > Now suppose the client throws an exception while processing the response > returned by the second Read(). From what I understand I have to call > ClientContext::TryCancel() and then keep calling Read() until ok = false, > then call Finish(): > > > > - Read(), ok =true > - Read(), ok =true, exception while applying business logic > - ClientContext::TryCancel() > - Read(), ok =true // could happen from what I understand > - Read(), false = true > - Finish(), ok = true > - Delete ClientAsyncReader and ClientContext > > I have a strong feeling it's required to *always* call Finish() before > releasing resources, but I have not found any doc/issue/discussion, which > confirms it 100%. Is there any other alternative way to terminate the > stream in an orderly fashion? > > > Patrick > -- 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 view this discussion on the web visit https://groups.google.com/d/msgid/grpc-io/75203935-1898-4ee2-ad25-4b9663d9a848%40googlegroups.com.
