Adding gRPC end point to an existing server

78 views
Skip to first unread message

ctmah...@gmail.com

unread,
Sep 20, 2019, 9:03:22 PM9/20/19
to grpc.io
Hello,

We have an existing multithreaded c++ server that works by passing messages between threads to avoid synchronization. Now if I add an async gRPC server, how would I pass a gRPC context to the appropriate thread and complete the call after getting a response?

It is similar to someone asking how to integrate gRPC async loop with other event loops, but I have not seen any solution. For example, libevent has ‘runInEventThread’ method to pass a function to the event thread to execute.

Penn (Dapeng) Zhang

unread,
Oct 2, 2019, 1:19:09 PM10/2/19
to grpc.io
Is your existing server a gRPC server, or is just a TCP or HTTP server and you want add another gRPC server and share the port?

Ctmahapa95

unread,
Oct 2, 2019, 6:31:50 PM10/2/19
to Penn (Dapeng) Zhang, grpc.io
It is just a TCP server and will add gRPC service on a different port.
Reading the async example, it appears that I can pass a CallData object to another thread using a queue (different from cq) and respond from that thread and finally get completion event back in the gRPC thread and I can delete the CallData object at that time. It should work as ‘cq’ is safe to call from multiple threads.

Thank you.


--
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 view this discussion on the web visit https://groups.google.com/d/msgid/grpc-io/1334949c-a7a4-40ce-a670-0c11d53cf496%40googlegroups.com.

Yash Tibrewal

unread,
Oct 3, 2019, 6:42:39 PM10/3/19
to grpc.io
Yes, that would work.


On Wednesday, October 2, 2019 at 3:31:50 PM UTC-7, Ctmahapa95 wrote:
It is just a TCP server and will add gRPC service on a different port.
Reading the async example, it appears that I can pass a CallData object to another thread using a queue (different from cq) and respond from that thread and finally get completion event back in the gRPC thread and I can delete the CallData object at that time. It should work as ‘cq’ is safe to call from multiple threads.

Thank you.
On Oct 2, 2019 at 1:19 PM, <'Penn (Dapeng) Zhang' via grpc.io> wrote:

Is your existing server a gRPC server, or is just a TCP or HTTP server and you want add another gRPC server and share the port?

On Friday, September 20, 2019 at 6:03:22 PM UTC-7, ctmah...@gmail.com wrote:
Hello,

We have an existing multithreaded c++ server that works by passing messages between threads to avoid synchronization. Now if I add an async gRPC server, how would I pass a gRPC context to the appropriate thread and complete the call after getting a response?

It is similar to someone asking how to integrate gRPC async loop with other event loops, but I have not seen any solution. For example, libevent has ‘runInEventThread’ method to pass a function to the event thread to execute.

--
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 grp...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages