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

http-client's future #98

Open
Fishrock123 opened this issue Aug 30, 2021 · 12 comments
Open

http-client's future #98

Fishrock123 opened this issue Aug 30, 2021 · 12 comments

Comments

@Fishrock123
Copy link
Member

For Surf 3.0 I am almost certainly going to merge http-client back into it. The feature flag mess currently is hellish and maintaining it is a bad experience. Most of this would be solved by not having surf set downstream feature flags.

If you use http-client for a client other than surf you either need to step up and help me maintain this or lose it. Thanks.

@Fishrock123 Fishrock123 pinned this issue Aug 30, 2021
@yoshuawuyts
Copy link
Member

yoshuawuyts commented Aug 31, 2021

Yeah that makes a lot of sense. Do you have a sketch of what that API would look like? I'm still interested in eventually implementing a win32-native HTTP client backend. Getting a sense of what that would look like under this model would be nice.

@Fishrock123
Copy link
Member Author

I don’t think anything would change other than the removal of the intermediate crate.

@bugproof
Copy link

bugproof commented Oct 1, 2021

Does that mean surf will replace http-client? I'm kind of confused right now.

@Fishrock123
Copy link
Member Author

Yes

@bugproof
Copy link

bugproof commented Oct 6, 2021

Oh but Surf only supports async-std. I think that defeats the purpose of http-client crate.

@Fishrock123
Copy link
Member Author

You can still run surf with the hyper backend...?

@bugproof
Copy link

bugproof commented Oct 6, 2021

Dependency doesn't seem to be optional https://github.com/http-rs/surf/blob/main/Cargo.toml#L67 or maybe I misunderstood something. I'm not that experienced in Rust 😄

@Fishrock123
Copy link
Member Author

Do you actually use http-client for something that is not Surf and if so, what is it?

@bugproof
Copy link

bugproof commented Oct 7, 2021

I planned to use it as an abstraction for API client libraries to avoid coupling them to specific async runtime and HTTP client.

@Fishrock123
Copy link
Member Author

Then you will need to help me maintain http-client. As I said, the feature flag situation with Surf is quite poor right now, and development is just overcomplicated by having this be a separate library.

surf with an http-client-only feature would probably be better or something

@bugproof
Copy link

bugproof commented Oct 8, 2021

How would this be solved if http-client was merged into Surf? You would need to create a separate surf crates for each HTTP backend no? surf-hyper, surf-curl to solve feature flag situation. Unfortunately feature flags in Cargo aren't solved in very elegant way. I try to avoid using them whenever I can. If you could remove a direct dependency on async-std in Surf then I guess it would be a fine alternative to http-client traits.

The problem with Rust right now is that the async ecosystem is pretty much an opinionated mess and many api client libraries just choose 1 http client for the job, mostly reqwest which uses tokio under the hood.

It doesn't give a lot of freedom with async runtime choice and feature flags is mostly just additional boilerplate code that's hard to maintain. What users of these libraries can do is either move to the supported runtime, write their own library or fork the existing library and replace the runtime or add support to another runtime via feature flags.

@sagudev
Copy link

sagudev commented Oct 18, 2021

Upcoming Rust 2021 edition will also solve some of feature flags hell. If I am not mistaken resolver 2 can be explicitly used from older versions of rust.

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

No branches or pull requests

4 participants