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

implement optional async support #150

Open
wants to merge 27 commits into
base: master
Choose a base branch
from
Open

Conversation

wfraser
Copy link
Member

@wfraser wfraser commented Apr 22, 2024

The new features controlling this are async_routes which enables compiling the async functions, and and default_async_client which enables a default HTTP client based on reqwest.

For most current use cases this should be a seamless transition, as I've made great pains to ensure that types are in the same locations unless you use the new features.

However if users have implemented a custom HTTP client, they will need to rework it a lot, as the HTTP client traits have been completely rewritten and are very different. That said, the new trait moves more things to the helper code, so implementing a custom client should be easier now.

This change violates our MSRV policy by quite a lot (requiring rust 1.75.0 which is only ~4 months old instead of the desired 12) so I'm proposing to land this as a beta release for now.

Checklist

General Contributing

  • I have read the Code of Conduct and signed the CLA.
  • I have added an entry to the RELEASE_NOTES.md file, or believe it's not necessary for this change.

Validation

A copy of the demo example has been made (called demo-async) which uses the default async client, which acts as a decent integration test.

This creates async HTTP client traits which mirror the existing sync
ones.

It also reimplements sync in terms of async, since we can use
now_or_never as an escape hatch to get back to sync land, but the
reverse is not possible.

One ugly wart is that there's no good escape hatch to convert the
sync-reader-in-async-wrapper response body back to a sync reader other
than an unsafe pointer cast.

No async routes generated yet; that's coming next.
this helps users who have no-default-features but also default_client; they want all the routes in the old places
Then this can be used by the oauth2 code to provide better responses when tokens are bogus
We're using HTTP2 where it's just a repeat of the code number anyway, so it adds no value.
not just 2.0.0; the signature of ureq::Response::into_reader() was changed in 2.5.0
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.

None yet

1 participant