Make the rust hyper client Send
so it can be used in rust threads more easily
#19375
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The hyper client cannot be used easily in threads as it isn't
Send
friendly. Something like this will fail to compile:Issue with more detailed steps to reproduce: #19208
This PR makes the hyper client and its internals
Send
. So the client can be used in threads.It ended up being a little larger of a PR in the pursuit of writing a test. It turns out the tests aren't actually being run when invoking verify on the petstore samples. This PR had to touch a few other thing to ensure
cargo test
would work. Let me know if I should break it up into multiple PRs.Should I update the pom.xml file to do a
cargo test
instead of acargo check
? I'm not sure if that was intentional.Commit summary
This might be a good order to review the changes:
7ee4bca - This is the commit that actually makes the code work in threads. I adds the
Send
constraint to a bunch generic parameters and traits and uses anArc
instead of anRc
bda9b6d - This commit adds a test to validate that it works and doesn't regress.
e53c04c - This commit regenerates the samples
The remaining commits were trying to get the tests to run in
samples/client/others/rust/
to run successfully. There were several issues to fix to get tests to run successfully.43ba4f0 46d3520 These set it up so the doc strings are compilable. The first one adds a property called
externCrateName
cribbing from the rust-server generator. The second one uses the externCrateName and fixes other issues with the example rustdoc examples.ddb330c The reqwest tests were not compiling and needed a small change.
efbf445 This changes the petstore swagger file and generates the petstore tests to use https. http://petstore.swagger.io/v2 is 301 redirecting to https://petstore.swagger.io/v2 and this is breaking POSTS.
When the client recieves a redirect it does not resend the POST data, instead it switches to GET. This is in line with how browsers behave when encountering a 301 redirect on a POST request, so I wouldn't consider it a bug in the client, but instead a bug in the test code.
Pinging the rust technical committee members: @frol @farcaller @richardwhiuk @paladinzh @jacob-pro
PR checklist
Commit all changed files.
This is important, as CI jobs will verify all generator outputs of your HEAD commit as it would merge with master.
These must match the expectations made by your contribution.
You may regenerate an individual generator by passing the relevant config(s) as an argument to the script, for example
./bin/generate-samples.sh bin/configs/java*
.IMPORTANT: Do NOT purge/delete any folders/files (e.g. tests) when regenerating the samples as manually written tests may be removed.
master
(upcoming 7.6.0 minor release - breaking changes with fallbacks),8.0.x
(breaking changes without fallbacks)