What is the proper way to handle 2 different rpcs in the server example?
rbresalier opened this issue · 1 comments
In hello-world-server-cpp20.cpp you show an example with just 1 rpc type, the HelloRequest.
What if I have multiple rpcs that I want to handle in my server? Lets say I want to add a "GoodbyeRequest"?
Would the proper way to do this be to spawn another co-routine, a 2nd call to co_spawn() that looks very similar to the one with HelloRequest, but I would have it be a GoodbyeRequest instead? Basically replace all "hello" with "goodbye" (case insensistive)?
Correct, you can spawn another coroutine for the GoodbyeRequests and handle them in a while(true)
loop. Even better than the while-loop is the helper function repeatedly_request which can be seen in use in one of the examples: here.
I am still unsure about the API design of that function which is why I marked it as experimental
for now. It works correctly and we use it in production here at 3YOURMIND but its API might change a bit in a future release.