Make client lifetime and shutdown more explicit in client example #1568
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.
This is complimentary/in-addition to #1565. Originally I figured we might be able to resolve that one first, but then I found I needed to also reference this proposal.
Summary of examples/client.rs changes:
spawn
, which is more async™ thanrun
, and thus more educational for a real application.lazy(Fn)
and moving theClient
instance into a single request future. Thus this example is more amendable to multiple-requests on a shared Client for keep-alive, etc.Note (as in #1565)
tokio::runtime::Runtime
isn't currently re-exported inhyper::rt
. I could add it there instead, if desired (though I wonder about the sustainability of this re-export approach.)The client sections of the guide also uses this example, so with some positive indication, I could pursue a compatible guide change PR.