grpc-rust
grpc-rust copied to clipboard
Integrate with tokio runtime?
I'm currently writing an application which exposes a gRPC service. This application, however, performs other async tasks, not only running the server. I would like to use tokio runtime to run everything in a single event loop, but apparently grpc-rust is not integrated with tokio runtime; it uses cpupool or tokio-core instead. Even though it allows specifying an external event loop for the server, it requires Remote
from tokio-core
, which is not compatible with tokio::reactor::Handle
.
Is integration with tokio runtime planned? As far as I understand, it is the intended way to write async applications now.
@stepancheg Can I assume you're not working on this right now? I don't mind jumping in to help here. I suppose we need to update https://github.com/stepancheg/rust-http2 first.
FYI currently I'm doing a big rewrite of rust-http2 API, to make API more similar to h2/grpc-rs.
The task is here: https://github.com/stepancheg/rust-http2/issues/34
(It is mostly done, but cleanup is necessary).
New server API is for instance:
- provide direct access to
Remote
in a callback (notHandle
, but should make no difference) - based on
Sink
not onStream
(sometimes easier to implement, and sometimes cheaper) - still keeps an API to provide response data as
Stream
After that, I'm planning to change grpc-rust to have similar API: https://github.com/stepancheg/grpc-rust/issues/137 (making it again more similar to h2/grps-rs; should be easy because the grpc runtime is a thin wrapper around http2 runtime)
While API changes, I'd appreciate feedback about API/design/code review/etc.
Patches are also appreciated of course.
tokio-core
to tokio
isn't a large change. It can just feel large. I've changed over a number of libs already. I'll see what I can do with a PR to rust-http2
to remove tokio-core
.
We should definitely do this.