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

Async runtime support #9

Open
A248 opened this issue Aug 16, 2023 · 6 comments
Open

Async runtime support #9

A248 opened this issue Aug 16, 2023 · 6 comments
Labels
enhancement New feature or request

Comments

@A248
Copy link

A248 commented Aug 16, 2023

The client currently has calls to tokio::spawn for spawning async tasks. It should allow using async-std, smol, and possibly other runtimes instead of tokio.
https://github.com/GreptimeTeam/greptimedb-client-rust/blob/bc32362adf0df17a41a95bae4221d6d8f1775656/src/channel_manager.rs#L54-L56
https://github.com/GreptimeTeam/greptimedb-client-rust/blob/bc32362adf0df17a41a95bae4221d6d8f1775656/src/stream_insert.rs#L64-L67

@waynexia
Copy link
Member

Makes sense to me, this is an important feature 👍

@waynexia waynexia added the enhancement New feature or request label Aug 17, 2023
@sunng87
Copy link
Member

sunng87 commented Aug 18, 2023

@A248 are you using async-std or smol in your application?

@A248
Copy link
Author

A248 commented Aug 18, 2023

I use async-std myself.

@sunng87
Copy link
Member

sunng87 commented Aug 20, 2023

We are using tonic for grpc which is a tokio specific library. I'm afraid it's impossible to switch async runtime unless async-std ships a shim for tokio.

The rust async world is converging to tokio ecosystem tbh.

@A248
Copy link
Author

A248 commented Aug 20, 2023

Concretely speaking, tonic's gRPC relies on hyper for HTTP/2 -- from which comes the tokio dependence, from what I see. Fortunately, the hyper maintainers have since acknowledged the need for runtime independence, so hyper 1.0, which is currently in release candidate (RC) stage, has no dependency on tokio. Instead hyper defines its own async I/O traits since hyperium/hyper#3110, which notes:

All other integration with a runtime (Tokio) has been removed

Either Tonic will fully switch to Hyper 1.0 in the future, but if not, I believe downstream libraries can use Hyper 1.0 with Tonic already (see hyperium/tonic#1307).

More broadly, libraries depending on Tokio is the reason Tokio acquires its monopoly. Yet a lack of runtime independence reduces runtime competition and stifles the future of Rust's async ecosystem. Better implementations can always be made, and there are plenty of use-cases for alternative specialized runtimes. By not promoting runtime independence, libraries advance the vicious cycle of runtime vendor lock-in. Greptimedb's rust client is part of this process. It's a tragedy of the commons.

@sunng87
Copy link
Member

sunng87 commented Aug 21, 2023

Thank you for the information! We will revisit this issue when hyper 1.0 released with multi-runtime support.

Checked the issue you mentioned, I saw some attempts to create standard trait for async runtimes. That will be the key to resolve this situation. You cannot blame the community to converge on the single, most supported runtime if there is no standard trait to make switching runtime easier. The fragmentation of async runtimes, APIs will also weaken the quality of implementations, when the ecosystem at its early stage.

Anyway, we are 100% willing to support more runtimes if the underlying libraries provide a foundation for doing that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants