Add throttling support using retry-after headers #1517
Merged
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.
Fixes: #1516
Updated
azure_core
retry policy to implement throttling by looking for and using the values returned by a server viaretry-after
,retry-after-ms
orx-ms-retry-after-ms
headers when the server returns 429 (TooManyRequests
) or 503 (ServerUnavailable
).Details:
retry-after
headers inlro.rs
(long-running operations).retry_policies
module, as I felt this was probably a more appropriate home for it.<xxx>-ms
headers before theretry-after
header.RetryPolicy
traitwait(...)
method to have an additionalretry_after
parameter, to enable passing in of retry-after duration extracted from the headers (if any):retry-after
header value when the server response is 429 or 503. Then when calculating the sleep time for any retry policy in thewait(...)
method it takes the maximum of the retry-after value (if any) and the calculated policy value.