rust-s3 icon indicating copy to clipboard operation
rust-s3 copied to clipboard

Re-use the same HTTP client instance

Open glebpom opened this issue 3 years ago • 2 comments

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

glebpom avatar Dec 21 '20 22:12 glebpom

@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 :)

durch avatar Dec 23 '20 09:12 durch

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.

Ten0 avatar Jan 13 '21 21:01 Ten0

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 avatar Sep 25 '22 15:09 durch