You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: articles/storage/blobs/storage-retry-policy-go.md
+31-14Lines changed: 31 additions & 14 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -27,27 +27,44 @@ The following table lists the fields available to configure in a [RetryOptions](
27
27
|`MaxRetries`|`int32`| Optional. Specifies the maximum number of attempts a failed operation is retried before producing an error. A value less than zero means one try and no retries. | 3 |
28
28
|`TryTimeout`|`time.Duration`| Optional. Indicates the maximum time allowed for any single try of an HTTP request. Specify a value greater than zero to enable. Note: Setting this to a small value might cause premature HTTP request timeouts. | Disabled by default. |
29
29
|`RetryDelay`|`time.Duration`| Optional. Specifies the initial amount of delay to use before retrying an operation. The value is used only if the HTTP response does not contain a Retry-After header. The delay increases exponentially with each retry up to the maximum specified by MaxRetryDelay. A value less than zero means no delay between retries. | 4 seconds |
30
-
|`MaxRetryDelay`|`time.Duration`| Optional. Specifies the maximum delay allowed before retrying an operation. Typically, the value is greater than or equal to the value specified in `RetryDelay`. A value less than zero means there is no maximum. | 60 seconds |
31
-
|`StatusCodes`|[]int | Optional. Specifies the HTTP status codes that indicate the operation should be retried. Specifying values will replace the default values. Specifying an empty slice disables retries for HTTP status codes. | 408 - http.StatusRequestTimeout</br>429 - http.StatusTooManyRequests</br>500 - http.StatusInternalServerError</br>502 - http.StatusBadGateway</br>503 - http.StatusServiceUnavailable</br>504 - http.StatusGatewayTimeout |
32
-
|`ShouldRetry`|`func(*http.Response, error) bool`| Optional. evaluates if the retry policy should retry the request. When specified, the function overrides comparison against the list of HTTP status codes and error checking within the retry policy. `Context` and `NonRetriable` errors remain evaluated before calling `ShouldRetry`. The `*http.Response` and `error` parameters are mutually exclusive, that is, if one is nil, the other is not nil. A return value of true means the retry policy should retry. ||
30
+
|`MaxRetryDelay`|`time.Duration`| Optional. Specifies the maximum delay allowed before retrying an operation. Typically, the value is greater than or equal to the value specified in `RetryDelay`. A value less than zero means there's no maximum. | 60 seconds |
31
+
|`StatusCodes`|[]int | Optional. Specifies the HTTP status codes that indicate the operation should be retried. Specifying values replaces the default values. Specifying an empty slice disables retries for HTTP status codes. | 408 - http.StatusRequestTimeout</br>429 - http.StatusTooManyRequests</br>500 - http.StatusInternalServerError</br>502 - http.StatusBadGateway</br>503 - http.StatusServiceUnavailable</br>504 - http.StatusGatewayTimeout |
32
+
|`ShouldRetry`|`func(*http.Response, error) bool`| Optional. evaluates if the retry policy should retry the request. When specified, the function overrides comparison against the list of HTTP status codes and error checking within the retry policy. `Context` and `NonRetriable` errors remain evaluated before calling `ShouldRetry`. The `*http.Response` and `error` parameters are mutually exclusive, that is, if one is `nil`, the other isn't `nil`. A return value of true means the retry policy should retry. ||
33
+
34
+
To work with the code example in this article, add the following `import` paths to your code:
In the following code example, we configure the retry options in an instance of [RetryOptions](https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azcore/policy#RetryOptions), include it in a [ClientOptions](https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azcore/policy#ClientOptions) instance, and create a new client object:
In this example, each service request issued from `client` uses the retry options as defined in the `RetryOptions` struct. This policy applies to client requests. You can configure various retry strategies for service clients based on the needs of your app.
0 commit comments