Description
Grpc-java is a low-level api that is quite error prone to use without significant investment in code-generation and libraries encoding relevant concepts --e.g., (pagination, batching, etc.
The go use-case for grpc is much easier to get started with for applications largely due to channels and context propagation being part of the stub generation. Kotlin Coroutines can provide an even better experience out of the box, completely eliminating the need for Streaming libraries or a lot of the utilities provided by a library like gax --e.g., Batching and Paging would be much easier to codify on a per application bases.
At the moment we are prototyping with a glue layer that connects grpc-java concepts per request. The bidi stream use case in this context would code generate a method that creates a job that does:
- Glue a
Channel
to the inputStreamObserver
- Glue
LinkedListChannel
to the outStreamObserver
. - Bind Grpc context to Coroutine Context or create a dispatcher using
Context::fixedContextExecutor
. - Propogate Context cancelation to the Job.
This is quite heavy handed. Ideally we should have a fully kotlinx.coroutine based layer perhaps directly above Netty that sidesteps the need to use the grpc-java layer and it would be fully coroutine based from the ground up.