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

Stabilize config #95

Merged
merged 3 commits into from
Aug 19, 2021
Merged

Stabilize config #95

merged 3 commits into from
Aug 19, 2021

Conversation

Fishrock123
Copy link
Member

I've been using this in projects for a couple months now, and would like to land support in Surf directly, for which this should be stabilized.

This also adds the following things for stabilization:

  • wasm support for Config
    • Only supports timeout, unfortunately, and requires async-std...
  • Config::max_connections_per_host
    • The behavior of this is different depending on the backend in use, unfortunately.
  • H1Client::with_max_connections() has been deprecated.

Only supports `timeout`, unfortunately, and requires async-std...
I've been using this in projects for a couple months now, and would like to land support in Surf directly, for which this should be stabilized.

Refs: http-rs/surf#310
Refs: http-rs#86
Closes: http-rs#93
Follow-up for stabilising Config.
let mut res = req.send().await?;
let conn = req.send();
let mut res = if let Some(timeout) = config.timeout {
async_std::future::timeout(timeout, conn).await??

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @Fishrock123, just out of curiosity is this line ok? I think should be one ?.

Thanks!!

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, this does compile, it is roughly equivalent to the following:

let mut res = if let Some(timeout) = config.timeout {
    async_std::future::timeout(timeout, conn).await?
} else {
    conn.await
}?;

Basically... timeout has it's own error and then the connection await has it's error... this is like a cheap-seats Result::flatten() (which is still unstable).

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome 🙌, thanks for the explanation!!

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