-
Notifications
You must be signed in to change notification settings - Fork 2.1k
5945 retrypolicy response headers #6196
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
Changes from all commits
623d858
430f0ee
b364d94
6e15f75
0df45ce
17e2675
ef1f1ef
7c49953
d6c028d
13924d8
f9ccd1a
9de1f77
92bdf7c
ac5f8ef
2f31255
5ad4b59
975b24a
15ce6b1
a05e7a4
5a55983
851a7aa
c7d6020
e4846df
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,91 @@ | ||
| // Copyright (c) Microsoft Corporation. All rights reserved. | ||
| // Licensed under the MIT License. | ||
|
|
||
| package com.azure.core.http.policy; | ||
|
|
||
| import com.azure.core.annotation.Immutable; | ||
|
|
||
| import java.time.temporal.ChronoUnit; | ||
| import java.util.Objects; | ||
|
|
||
| import static com.azure.core.util.CoreUtils.isNullOrEmpty; | ||
|
|
||
| /** | ||
| * Immutable Configuration options for {@link RetryPolicy}. | ||
| */ | ||
| @Immutable | ||
| public class RetryPolicyOptions { | ||
|
|
||
| private final RetryStrategy retryStrategy; | ||
hemanttanwar marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| private final String retryAfterHeader; | ||
| private final ChronoUnit retryAfterTimeUnit; | ||
|
|
||
| /** | ||
| * Creates a default {@link RetryPolicyOptions} used by a {@link RetryPolicy}. This will use | ||
| * {@link ExponentialBackoff} as the {@link #getRetryStrategy retry strategy} and will ignore retry delay headers. | ||
| */ | ||
| public RetryPolicyOptions() { | ||
| this(new ExponentialBackoff(), null, null); | ||
| } | ||
|
|
||
| /** | ||
| * Creates the {@link RetryPolicyOptions} with provided {@link RetryStrategy} that will be used when a request is | ||
| * retried. It will ignore retry delay headers. | ||
| * | ||
| * @param retryStrategy The {@link RetryStrategy} used for retries. It will default to {@link ExponentialBackoff} | ||
| * if provided value is {@code null} | ||
| */ | ||
| public RetryPolicyOptions(RetryStrategy retryStrategy) { | ||
| this(retryStrategy, null, null); | ||
| } | ||
|
|
||
| /** | ||
| * Creates the {@link RetryPolicyOptions} with provided {@link RetryStrategy}, {@code retryAfterHeader} and | ||
| * {@code retryAfterTimeUnit} that will be used when a request is retried. | ||
| * | ||
| * @param retryStrategy The {@link RetryStrategy} used for retries. It will default to {@link ExponentialBackoff} | ||
| * if provided value is {@code null}. | ||
| * @param retryAfterHeader The HTTP header, such as 'Retry-After' or 'x-ms-retry-after-ms', to lookup for the | ||
| * retry delay. If the value is {@code null}, {@link RetryPolicy} will use the retry strategy to compute the delay | ||
| * and ignore the delay provided in response header. | ||
| * @param retryAfterTimeUnit The time unit to use when applying the retry delay. {@code null} is valid if, and only | ||
| * if, {@code retryAfterHeader} is {@code null}. | ||
| * @throws NullPointerException When {@code retryAfterTimeUnit} is {@code null} and {@code retryAfterHeader} is | ||
| * not {@code null}. | ||
| */ | ||
| public RetryPolicyOptions(RetryStrategy retryStrategy, String retryAfterHeader, ChronoUnit retryAfterTimeUnit) { | ||
|
|
||
| if (Objects.isNull(retryStrategy)) { | ||
| this.retryStrategy = new ExponentialBackoff(); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This overload should throw NPE if
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We tried to avoid many variations on constructor. Strategy cannot be null, Thus defaulting to public RetryPolicyOptions( String retryAfterHeader, ChronoUnit retryAfterTimeUnit) ; |
||
| } else { | ||
| this.retryStrategy = retryStrategy; | ||
| } | ||
| this.retryAfterHeader = retryAfterHeader; | ||
hemanttanwar marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| this.retryAfterTimeUnit = retryAfterTimeUnit; | ||
| if (!isNullOrEmpty(retryAfterHeader)) { | ||
| Objects.requireNonNull(retryAfterTimeUnit, "'retryAfterTimeUnit' cannot be null."); | ||
| } | ||
| } | ||
|
|
||
| /** | ||
| * @return The {@link RetryStrategy} used when retrying requests. | ||
| */ | ||
| public RetryStrategy getRetryStrategy() { | ||
| return retryStrategy; | ||
| } | ||
|
|
||
| /** | ||
| * @return The HTTP header which contains the retry delay returned by the service. | ||
| */ | ||
| public String getRetryAfterHeader() { | ||
| return retryAfterHeader; | ||
| } | ||
|
|
||
| /** | ||
| * @return The {@link ChronoUnit} used when applying request retry delays. | ||
| */ | ||
| public ChronoUnit getRetryAfterTimeUnit() { | ||
| return retryAfterTimeUnit; | ||
| } | ||
|
|
||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.