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

Add async-std support #108

Merged
merged 9 commits into from
Dec 26, 2020
Merged

Add async-std support #108

merged 9 commits into from
Dec 26, 2020

Conversation

TheButlah
Copy link
Contributor

@TheButlah TheButlah commented Dec 25, 2020

Review #109 first - this is based on that.

To avoid contributing to the fragmentation of the async ecosystem, I think its really important to support both tokio and async-std. Additionally, async-std is the only runtime that has wasm support currently, and it is a personal goal of mine to get this project capable of running in the browser and communicating over web sockets (see #64).

You can control which version via feature flags, as this seemed to be the canonical approach in other projects that can use either runtime (like async-tungstenite) for example. I've left the default runtime to be tokio, as it seems to be the more popular and fully featured option.

In terms of the complexity of maintaining two versions, the two libraries present an extremely similar api. In most places, the wrappers I wrote are a drop in replacement for whatever we were using before, and you can see that with just wrappers for spawning tasks. everything else is just in how transports are implemented, and even there the code doesn't diverge much. I had to add some beginner-unfriendly cfg statements in the example code, but that is a small price to pay for being able to build all tests and examples in either version, rather than just the source code. Also, both tokio and async-std are 1.0 now, so we shouldn't need to worry to much about changing APIs.

I also now test both tokio and async std in the CI. This should ensure that our code operates on both versions.

@TheButlah TheButlah marked this pull request as ready for review December 26, 2020 10:03
@Alexei-Kornienko
Copy link
Collaborator

Mostly LGTM. Could you please add some description in README explaining how to properly build/run examples with different runtimes? IMHO examples become a little bit more complicated cause now they support both runtimes.

@TheButlah
Copy link
Contributor Author

@Alexei-Kornienko OK, I've updated the readmes. Hows that?

@Alexei-Kornienko
Copy link
Collaborator

@TheButlah looks great. Thanks for working on this.

@Alexei-Kornienko Alexei-Kornienko merged commit 776fd07 into zeromq:master Dec 26, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants