C++ async API

159 views
Skip to first unread message

chri...@lefty.io

unread,
Sep 23, 2016, 9:31:48 AM9/23/16
to grpc.io
Hello,

From reading the C++ example for async server, it seems that one has to write a CallData class for every
service and every method?

Are there any plans for the compiler to generate those CallData boilerplates?

Sree Kuchibhotla

unread,
Sep 23, 2016, 11:22:56 AM9/23/16
to chri...@lefty.io, grpc.io
Hi Christian,
I am assuming you are talking about the Greeter async server in the examples.  In this case the 'CallData' struct is not a gRPC structure. It is an application defined structure passed as a 'tag' to YourServiceName::AsyncServiceYourMethodName(...) and  ServerAsyncResponseWriter<T>::Finish(...) functions. 


// If the server receives a request for SayHello() function

// the next call to cq_->Next() will return the tag (in this case

// the CallData object passed)

service_->RequestSayHello(&ctx_, &request_, &responder_, cq_, cq_, this);


// Once the operation Finish() is actually complete, the tag

// (in this case, the CallData object again) is returned via the

// call to cq_->Next()

responder_.Finish(reply_, Status::OK, this);


We do not have plans to generate these CallData structures. 

Hope this helps
Sree

--
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 grpc-io+unsubscribe@googlegroups.com.
To post to this group, send email to grp...@googlegroups.com.
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/23678b27-c97f-4fc7-8239-aa9b67f1bc21%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Christian Rivasseau

unread,
Sep 23, 2016, 11:41:45 AM9/23/16
to Sree Kuchibhotla, grpc.io
So for a service that would have more than one method, I would create a new CallData() for each method
is that correct?




For more options, visit https://groups.google.com/d/optout.



--
Christian Rivasseau
Co-founder and CTO @ Lefty
+33 6 67 35 26 74

Sree Kuchibhotla

unread,
Sep 23, 2016, 12:04:32 PM9/23/16
to Christian Rivasseau, grpc.io
Yes. You would need a different 'tag' to pass to each's methods YourServiceName::AsyncService::RequestYourMethodName() call (so that when CompletionQueue::Next() returns a tag, you can know which method you just received a call for).  

So if a service as more than one method, creating one CallData per method sounds good.

Or more accurately, if you have multiple YourServiceName::AsyncService::RequestYourMethodName() calls in parallel, then you should make sure each of those calls have different tags so that when CompletionQueue::Next() returns a tag, you know which of your YourServiceName::AsyncService::RequestYourMethodName() 's tag it is.

Hope this helps,
Sree


On Fri, Sep 23, 2016 at 8:41 AM, Christian Rivasseau <chri...@lefty.io> wrote:
So for a service that would have more than one method, I would create a new CallData() for each method
is that correct?


On Fri, Sep 23, 2016 at 5:22 PM, 'Sree Kuchibhotla' via grpc.io <grp...@googlegroups.com> wrote:
Hi Christian,
I am assuming you are talking about the Greeter async server in the examples.  In this case the 'CallData' struct is not a gRPC structure. It is an application defined structure passed as a 'tag' to YourServiceName::AsyncService::RequestYourMethodName(...) and  ServerAsyncResponseWriter<T>::Finish(...) functions. 

Arpit Baldeva

unread,
Feb 13, 2017, 4:49:16 PM2/13/17
to grpc.io, chri...@lefty.io
Hi,

resurrecting this old thread. 

I am a bit puzzled that this boilerplate code is not auto-generated (or there is no option for it) and wondering what is the reason behind it? There can be different patterns to generate this boilerplate but at least one could be provided by default. Is async api usage not that common (it is certainly more usable for me as it allows a finer control of the threading model) or more precisely, is async api usage with many services with many rpcs not that common?  

Thanks.  
To unsubscribe from this group and stop receiving emails from it, send an email to grpc-io+u...@googlegroups.com.

To post to this group, send email to grp...@googlegroups.com.
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/23678b27-c97f-4fc7-8239-aa9b67f1bc21%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
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 grpc-io+u...@googlegroups.com.

To post to this group, send email to grp...@googlegroups.com.
Visit this group at https://groups.google.com/group/grpc-io.
Reply all
Reply to author
Forward
0 new messages