https://kotlinlang.org logo
#grpc
Title
# grpc
f

Francis Reynders

03/25/2023, 10:38 AM
Hello all. I'm implementing a grpc service which needs a request/response rpc call from server to client. I did some research and understand there is no support for this communication pattern. A common way to shoehorn this pattern in the current infrastructure would be to add a correlation id to the request payload (server->client stream) and for the client to respond with an rpc call to the server, repeating that correlation id. My questions: 1) is there a better way? Should I maybe consider a different protocol? 2) Is there any library support for this? I could not find any so far. 3) I consider implementing this myself. I'm thinking about a bidirectionnal grpc pattern where the server->client stream would be a
ChannelFlow
. A request/response request from the server -> client could then be initiated by an async coroutine launch that sends the payload with correlation id to the channel and listens with timeout for a respone on a
SharedChannel
flow (client->server stream), listening for the first response with that correlation id. Would that work? Thank you
m

Minsoo Cheong

03/27/2023, 1:09 AM
your solution seems to use two rpc methods: 1. server-side streaming rpc for server -> client invocation 2. client-side streaming rpc for the response Although it would work, maybe you could just use a single bidirectional streaming rpc
13 Views