-
-
Notifications
You must be signed in to change notification settings - Fork 7.3k
Integrating reqwest's async module as a rust module
#4175
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
Conversation
This commit contains modifications to the Rust codegen module in order to be able to generate futures-aware, threadsafe `reqwest` bindings from an openAPI template, in order to be able to take advantage of non-blocking API calls.
|
Hi @srenauld , This PR looks interesting. A technical point: since it is a new generator library, you should add a generation code for this library in the Personnaly, I was waiting Rust 1.39 to use |
|
Hey @bcourtine ! Thank you for the feedback. I deliberately left that name so we can have both; for instance, I commonly work with processor architectures where rust 1.39 is a no-go but futures are perfectly fine, and as such, would benefit from having the option to have either. That's why I laid it out the way I did. After all, I'm also pretty sure I am not the only one in this case. I will add a generation code and some tests to cover everything. I wasn't sure what I had to do next - now I know :-) |
I was not aware that openapi-generator could generate multipart MIME bindings. Implementing them was complicated further by `reqwest::async::multipart::Form` having an entirely different API than the `sync` version of it, leading to two decisions: 1. The file is read in its entirety. This is the same behavior as on the sync version; if time allows, I will convert this into a chunked stream 2. The entire mime detection logic is taken from the `sync` version and added as a private function in the module
|
Hey @bcourtine, I added a full client sample, which also revealed a feature I was not aware of - MIME file uploads. That's also done now. Throughout this time I've struggled with some teething CI problems, including:
Is there any chance you could have a quick look and tell me if there's something obvious that I am missing and/or re-run the CI to see if the travis error was just intermittent? Would be greatly appreciated :-) |
|
@ctaggart As explained in the initial PR comment, I'd personally be in favor of keeping both (as in, pre-1.39 futures-based, and post-1.39 Let me give you an example. In the past three years I've built, developed and released a few products running on a processor from ARM that you literally cannot use anything beyond the nightly from november 30th 2018 with. The reason being that a breaking change between 1.32 and 1.33 happened - I never properly dug down why, but I know it is related to atomic operation emulation (something which this specific processor needs). For that reason, even though the |
|
@srenauld I've added an option to support async operations in the Rust I wonder if you can pull the latest master to give it a try. |
|
Closing as there's no update. |
This commit contains modifications to the Rust codegen module in order to be able to generate futures-aware, threadsafe
reqwestbindings from an openAPI template, in order to be able to take advantage of non-blocking API calls.The changes are as follows:
reqwestFuturesCargo.toml(futuresis now a dependency forreqwestwhen using this librarySend, the reference-counting pointer is now anArcreqwestmodule itself, as the API from the sync and async client are virtually the sameDue to the upcoming changes regarding
async/await, I took the deliberate decision of calling the libraryreqwestFuturesrather thanreqwestAsync. When Rust 1.39 lands and those features become stable, a conversion tool from one to the other should be easy to build.Rust committee members are @frol @farcaller @bjgill @richardwhiuk - since this is my first PR here, I guess mentioning them should be good enough as a CC?