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

Re-use the same HTTP client instance #152

Closed
glebpom opened this issue Dec 21, 2020 · 3 comments
Closed

Re-use the same HTTP client instance #152

glebpom opened this issue Dec 21, 2020 · 3 comments
Assignees

Comments

@glebpom
Copy link
Contributor

glebpom commented Dec 21, 2020

Is your feature request related to a problem? Please describe.
Re-creating reqwest/surf instance is not effective, since the connection pool cannot be re-used.

Describe the solution you'd like
Request implementation may be refactored, so that Client instance is stored in the particular implementation struct, and move command and `path to trait functions arguments

@durch
Copy link
Owner

durch commented Dec 23, 2020

@glebpom thanks for the call out, a few versions ago I switched this back to spawning a dedicated client due to issues with tests. I'm in general pro this approach, its just a hassle to rework the tests, I'll have some more free time in the next few weeks so I might revisit this. I'm always open to PRs :)

@Ten0
Copy link
Contributor

Ten0 commented Jan 13, 2021

It looks like this could even use a single reqwest::Client in a lazy_static, given that all requests are made to the same endpoints. This may allow e.g. reusing SSL sessions across several objects, so there's a good chance this would be the best approach.
Also, this may solve your issue with tests.

@durch
Copy link
Owner

durch commented Sep 25, 2022

Same as #234, while we could add it to lazy_static its a bit too magical for my taste, it would be ideal to allow ppl to bring their own client, something I'm thinking through

@durch durch closed this as completed Sep 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants