-
Notifications
You must be signed in to change notification settings - Fork 20
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
Support async requests #51
Comments
Could you provide some more detail as to why (and how) you think the |
I imagine because |
To comment on the implementation, a |
I'm not 100% sure what have to be done at the
|
Yes it looks like it is basically what @lnicola wrote. The However, as this only is a problem for async traits I for now oped-in into Non-threadsafe futures ... Can't wait until async traits are stable After resolving this for now, I followed @lnicola suggestion and structured it like the src
|___blocking // Code with blocking api requests
|___geoadmin.rs
|___opencage.rs
|___openstreetmap.rs
|___async_impl // Code with async api requests
|___geoadmin.rs
|___opencage.rs
|___openstreetmap.rs
|___lib.rs
|___geoadmin.rs // shared structs and functions e.g. params, ...
|___opencage.rs // shared
|___openstreetmap.rs //shared
So we have two features The // lib.rs
#[cfg(feature = "blocking")]
pub use crate::blocking::openstreetmap::Openstreetmap; The async tests are already passing as well. So we are on a good track. I moved a lot of code around and have some failing doc-tests atm. So I have to tackle this as next. Furthermore the async api need some examples and documentation as well. One last drawback in my opinion is that we have some duplicated code now in the So the next steps are:
Do you have any suggestions or thoughts on that and how to continue? 😄 |
Does that still work across an What if you
File a PR? 😄 |
I come across this issue this was my take on this problem:
This is my fork that builds with async reqwest: https://github.com/fakeshadow/geocoding |
Thanks a lot, @fakeshadow ! I will look into this and give it another try! |
@fakeshadow thanks for the effort. To have a little bit of an easier time working into this, is it possible to update the test to the changes? |
We've forked this and published this as a new crate: https://github.com/jun-sheaf/geocoding-async If you'd like, we can send a PR, but the PR will be as is. |
I recently found this crate and absolutely love it. Thanks for the amazing project and keep up the good work! 👍
During usage I wonder why the provided functions aren't
async
as the data must be fetched from somewhere. After looking into the code base I found that we currently use blocking requests.At first it seems like an easy implementation for me, since we just have to migrate the usage of the blocking
reqwest
client to a non blocking and transform some traits and functions toasync
. What maybe could be implemented with a optional feature flag. However, after trying to prototype this on my own fork (https://github.com/jontze/geocoding/tree/feat/async-fetching) I came to the conclusion that it is not that easy 😆 . Since it looks like that there have to be done some refactor of at least thePoint
struct in the geo-types crate to support rust futures.Furthermore, a feature flag is definitely not the cleanest solution to implement this since it will lead to some code duplication, I guess. On the other side transforming the whole crate to async will be a major breaking change for the user...
However, before continuing on that, are there any plans for the future to support async data fetching instead of blocking?
The text was updated successfully, but these errors were encountered: