update reconnect to std::future#531
Merged
hawkw merged 8 commits intomaster-tokio-0.2from May 27, 2020
Merged
Conversation
turns out these _worked_ but i never actually put them back. whoopsie! this is necessary for the only integration test that really exercises reconnects, which relies on these metrics to determine if a connection exists. Signed-off-by: Eliza Weisman <[email protected]>
Signed-off-by: Eliza Weisman <[email protected]>
Signed-off-by: Eliza Weisman <[email protected]>
Signed-off-by: Eliza Weisman <[email protected]>
Signed-off-by: Eliza Weisman <[email protected]>
This is a fun one: the test `retry_reconnect_errors` relied on `Client::request_async` *eagerly* causing the test client to connect to the proxy when called, rather than when the returned future is polled. Switching `request_async` to an `async fn` broke this property — the *entire* body of the function, even the synchronous parts, was run only when the `async fn` future is polled. This means that the connection was not opened when the test expected it to be, and the subsequent assertion that it was open always failed. This commit changes this back into a synchronous function returning `impl Future`. This is identical at the callsite (it still returns something that you can `.await`), but calling the function now once again eagerly tells the test client background thread to open a connection. This fixes the test. Signed-off-by: Eliza Weisman <[email protected]>
Signed-off-by: Eliza Weisman <[email protected]>
Signed-off-by: Eliza Weisman <[email protected]>
olix0r
approved these changes
May 27, 2020
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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 branch updates the
reconnectmiddleware tostd::future.Updating reconnect was pretty straightforward and mechanical, so it
should be easy to review.
Most of the complexity was actually in getting the test
retry_reconnect_errorswhich exercises this functionality to pass: thetest uses transport metrics to determine when the proxy has actually
accepted a connection from the test client, so that it can advance to
the next state; it was necessary to re-enable transport metrics for this
to work (see PR #530).
Additionally, there was a subtle change in the test-support client's
behavior that needed to be resolved as well: the test relied on
Client::request_asynceagerly causing the test client to connect tothe proxy when called, rather than when the returned future is polled.
Switching
request_asyncto anasync fnbroke this property — theentire body of the function, even the synchronous parts, was run only
when the
async fnfuture is polled. This means that the connection wasnot opened when the test expected it to be, and the subsequent assertion
that it was open always failed.
Therefore, I changed
request_asyncback into a synchronous functionreturning
impl Future. This is identical at the callsite (it stillreturns something that you can
.await), but calling the function nowonce again eagerly tells the test client background thread to open a
connection. This fixes the test.
Depends on #530.