Draft
Conversation
Member
|
Thank you for opening this PR. Before diving into the code details I would love to get @guoye-zhang and @fabianfett opinion on the general topic of retries. Is this something that we think a client should have request options for or users should build around a client with a more general purpose asynchronous |
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.
Motivation
Add first-class retry support to the HTTP client so callers can express retry behavior in request options instead of building retry loops around each call. This is aimed at transient failures such as
503 Service Unavailable,429 Too Many Requests, and selected transport errors, while also supporting standardRetry-Afterhandling and request mutation between attempts.Modifications
HTTPClientCapability.RetryStrategyandHTTPRequestOptions.retryStrategy.HTTPClientRetryStrategyHTTPClientRetryActionHTTPClientRetryContextHTTPClientRequestBodyReplayabilityHTTPClientRetryBackoffHTTPClientConditionalRetryStrategyfor closure-based retry decisions andHTTPClientTransientFailureRetryStrategyfor common transient failure handling.HTTPDateFormatterto parse and format RFC 9110 HTTP-date values used byRetry-After.URLSessionHTTPClientto consult the retry strategy before exposing the response to the caller, retry requests with optional delay, and allow the retried request to be mutated.RetryStrategyTestscovering backoff behavior,Retry-Afterhandling, request mutation, and default retry rules for idempotent methods.Result
HTTP client users can now attach retry policies directly to request options and get built-in retry handling for transient server responses and selected transport failures. The default transient failure strategy respects
Retry-After, supports configurable backoff, and keeps non-idempotent methods such asPOSTnon-retryable by default.Test Plan
Added unit and integration coverage in
RetryStrategyTestsfor:Retry-Afterseconds and HTTP-date parsingRetry-AfterPOSTby default