rust-s3
rust-s3 copied to clipboard
Re-use the same HTTP client instance
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 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 :)
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.
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