-
Notifications
You must be signed in to change notification settings - Fork 8
Enable client-side timeouts and replace retry logic with reqwest's
#39
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Enable client-side timeouts and replace retry logic with reqwest's
#39
Conversation
|
👋 Thanks for assigning @tankyleo as a reviewer! |
src/client.rs
Outdated
| .timeout(DEFAULT_TIMEOUT) | ||
| .connect_timeout(DEFAULT_TIMEOUT) | ||
| .read_timeout(DEFAULT_TIMEOUT) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you seems like we could just do with the single global timeout here, no need for connect and read ?
But we can leave it as is and potentially tweak the inner timeouts later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, no strong opinion here.
For reference original PR is #20. On first impression, I'd be in favor of the drop myself. |
Do the added timeouts apply to a single operation? If it is never exceeded, wouldn't we still want What is meant by client-side default delay? |
Yes, they apply for a single read, but also for connecting / detecting dropped connections AFAIU.
Yes, it could be useful, but of course its somewhat redundant if we set a client-side
Ah, sorry, that was a typo I only corrected in the PR title: should have said default timeout, not delay. |
Do you mean
Isn't this already the case when configured as I mentioned above? Number of attempts takes priority over total delay given the way Maybe I'm confused about what is lesser in that example. |
Yes, if each client call is also limited by a timeout, then we'd have either
Say you configure Or, maybe even a bit more confusing would be if the user configured a |
|
🔔 1st Reminder Hey @jkczyz! This PR has been waiting for your review. |
Isn't that expected? "done after 50s" is really "done after 5 attempts".
Yeah, though isn't that a good argument to use select? Or does the current design not allow that given policy timeout is built into the type rather than the calling site being aware of it? |
True, seems like we should? And given that we already use tokio with the time feature, it should be straightforward. I think I'll add a commit to this PR. |
Argh, after looking into it for a bit I have to eat my words: it's actually not trivial, as currently And more generally, with a generic error type, we don't know what error we'd return in case the the timeout happens before the |
Would it help defining an enum parameterized by the error |
|
🔔 2nd Reminder Hey @jkczyz! This PR has been waiting for your review. |
|
🔔 3rd Reminder Hey @jkczyz! This PR has been waiting for your review. |
|
🔔 4th Reminder Hey @jkczyz! This PR has been waiting for your review. |
|
🔔 5th Reminder Hey @jkczyz! This PR has been waiting for your review. |
|
🔔 6th Reminder Hey @jkczyz! This PR has been waiting for your review. |
|
🔔 7th Reminder Hey @jkczyz! This PR has been waiting for your review. |
|
🔔 8th Reminder Hey @jkczyz! This PR has been waiting for your review. |
|
🔔 9th Reminder Hey @jkczyz! This PR has been waiting for your review. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Waiting on @tnull (no rush!). Just want to silence the review bot.
5e83c2b to
5670866
Compare
reqwest's
5670866 to
4e360cf
Compare
|
Excuse the delay here. After yet another |
9c94320 to
9c3148f
Compare
f926914 to
8b8910d
Compare
|
Now also tacked-on a commit that corrected the expected HTTP status codes in our mocked test service. Relatedly, I discovered that the Rust vss-server didn't use the correct codes either (a regression from the Java version), fixed in lightningdevkit/vss-server#65 |
.. and finally it turns out that we can drop our |
6bc7bce to
b258cec
Compare
While the `RetryPolicy` has a `MaxTotalDelayRetryPolicy`, the retry `loop` would only check this configured delay once the operation future actually returns a value. However, without client-side timeouts, we're not super sure the operation is actually guaranteed to return anything (even an error, IIUC). So here, we enable some coarse client-side default timeouts to ensure the polled futures eventualy return either the response *or* an error we can handle via our retry logic.
.. as some types are part of our API.
We here make use of `reqwest`'s `retry` functionlity that was introduced with its recent v0.12.23 release. As we can't fully replace the old 'application-level' behavior just yet, we configure it to only apply for error that arent INTERNAL_SERVER_ERROR, which is the status VSS uses to send error responses. We set some default values here, but note that these can always can be overridden by the user when using the `from_client` constructor.
We drop our (~broken) `RetryPolicy`, and replace it with the new-ish retry policy that is shipping in `reqwest` since 0.12.23.
b258cec to
e6d8e57
Compare
|
Rebased to resolve minor conflicts. |
Previously, we'd allow to either re-use a `reqwest::Client` or supply a header provider. Here we add a new constructor that allows us to do both at the same time.
Based on #38.
We enable
reqwestclient-level timeouts:~~Additionally, we here rip out our ~broken retry logic and replace it by utilizing
reqwest's retry logic that shipped in the recent v0.12.23 release.~~