Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to integrate with tokio/rust async IO ecosystem? #338

Open
vimpunk opened this issue Jun 28, 2019 · 3 comments
Open

How to integrate with tokio/rust async IO ecosystem? #338

vimpunk opened this issue Jun 28, 2019 · 3 comments
Labels
Question Looking for answer

Comments

@vimpunk
Copy link
Contributor

vimpunk commented Jun 28, 2019

I'm wondering how to integrate grpc-rs with the futures/tokio ecosystem on stable rust. As far as I understand grpc-rs uses the IO reactor of grpc-core, so there isn't a way to drive futures to completion on the tokio reactor used for other things in rust. Is this correct? If so, how would you chain futures of grpc-rs and other async IO stuff using tokio?

Thanks in advance for the help.

@ice1000 ice1000 added the Question Looking for answer label Jun 28, 2019
@another-s347
Copy link

I'm using latest master branch of tokio with grpc-rs.
grpc client can drive its stream receiver and send it out through mpsc channel's sender, then the other side can be processed by tokio reactor.
Again, with a mpsc channel (futures 0.1 since grpc is not using the newly updated std::future) can pump data into grpc's sink. It works with futures 0.3's compat features too.

@porkbrain
Copy link

I use following setup:

futures = "0.3"
tokio = { version = "0.2", features = ["sync", "macros", "rt-threaded", "time", "fs"] }
grpcio = { version = "0.6", features = ["openssl"] }

I can confirm that mpsc channel sender works (although I suspect that's because sending a message is not actually a future), async mutex works, as well, but fs doesn't. tokio::fs::write produces following panic:

grpc-poll-0' panicked at 'not currently running on the Tokio runtime.

@BusyJay
Copy link
Member

BusyJay commented Aug 5, 2020

Unless tokio allow integration with other executors, I don't think this can work smoothly. You have to spawn the future carefully.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Question Looking for answer
Projects
None yet
Development

No branches or pull requests

5 participants