Hello group,

I have been using grpc since 0.14, so far with a number of services that 
used C++ as client and server impls. Now I am in the process of 
transitioning those services from sync to async. I am quite familiar with 
async services, mostly using boost asio. 

With this in mind, I have looked at the example implementation here: 
https://github.com/grpc/grpc/blob/v1.15.1/examples/cpp/helloworld/greeter_async_server.cc

I have two questions that I would like to get some hints on.

1) This is my most important issue now. All examples I have seen only use 
one method for their service. I suppose this is a bit of a theoretical 
scenario as most real world use cases would have many. Mine have between 10 
and 30 methods per service. 

The way the example does its HandleRrpcs() method it always creates one 
CallData object of fixed type. How can I have more than one? I have tried 
to do a CRTP template base for such calls which then calls an overloaded 
work method but I don't know how I can translate this to the Next() call. 
Also, the way I understand it, each call to service->RequestMyMethod() with 
another method would override the last, right? Or am I supposed to 
call  service->RequestFoo() and service->RequestBar() back to back and let 
the system figure it out? So, is it possible at all to have multiple 
methods?

2) asio based servers have some kind of mechanism that allows for 
dispatching an async operation and hand in some callback when it's 
completed. For example an asio::io_context object. Looking at your example 
code I can see no equivalent. The example really seems to be synchronous. 
Suppose instead of saying response.set_answer("hello world") my call would 
really involve some blocking operations that I would like to async 'away'. 
Like, in a trivial example, I spawn a thread or something to do the work 
and then wait for a future or some kind of callback. How would that 
translate to grpc? 
Again, looking at the examples the only thing that would come to mind is 
having an actual asio io_context running next to the grpc AsyncService and 
post operations in there, referring to grpc mostly for when the call is 
done. Is that a reasonable approach or am I missing something here?

Thanks for any suggestions,

Stephan

-- 
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/5fab2267-860f-4903-9a13-203d096e531a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to