RetryPolicy
How a Graph retries a request that failed for a
transient reason. Set it with
Graph.WithRetryPolicy. Each kind
of failure has its own RetryDelay; a null delay makes that kind of failure throw
at once. The defaults and the status codes behind each kind are in the
C# SDK guide.
RetryPolicy
public sealed class RetryPolicyControls how a Graph retries a request to the workspace that failed for a transient reason. Set it with WithRetryPolicy.
Remarks
Each kind of failure has its own delay. Setting a delay to null stops retrying that kind of failure: the request then fails on the first occurrence. Failures that are never transient - an invalid token (403), an unknown endpoint (404), a bad request (400) or an error the server reports in its response - are never retried.
Examples
var graph = Graph.Connect("https://example.com", "my-token", "my-connector")
.WithRetryPolicy(new RetryPolicy
{
MaxRetries = 5,
ServerError = RetryDelay.Between(TimeSpan.FromSeconds(5), TimeSpan.FromSeconds(15)),
NetworkError = RetryDelay.Fixed(TimeSpan.FromSeconds(10)),
Timeout = null, // fail on the first timeout
});
- Namespace
- Curiosity.Library
Properties
| Name | Description |
|---|---|
| MaxRetries | How many times a request is retried after its first attempt before it fails. Defaults to 31. Zero disables retrying. |
| RateLimited | Delay after the server answered 429 (Too Many Requests). Defaults to a random delay between 1 and 6 seconds. |
| ServerError | Delay after the server answered 500, 503, 504, 520 or 521, or reported a database deadlock. Defaults to a random delay between 60 and 120 seconds. |
| RetryIfUnavailable | Whether a 503 (Service Unavailable) is retried, with the ServerError delay. Defaults to true. Set it to false to fail on the first 503 while still retrying the other server errors - for example when a workspace that is down or starting up should stop the run instead of holding it for minutes. |
| NetworkError | Delay after the request could not reach the server (an HttpRequestException). Defaults to a random delay between 60 and 120 seconds. |
| Timeout | Delay after the request did not complete within the timeout set with WithTimeout. Defaults to a random delay between 60 and 360 seconds. |
| Default | The policy a Graph uses unless told otherwise. |
| None | A policy that never retries: every request fails on its first transient error. |
public int MaxRetries { get; set; }How many times a request is retried after its first attempt before it fails. Defaults to 31. Zero disables retrying.
public RetryDelay? RateLimited { get; set; }Delay after the server answered 429 (Too Many Requests). Defaults to a random delay between 1 and 6 seconds.
public RetryDelay? ServerError { get; set; }Delay after the server answered 500, 503, 504, 520 or 521, or reported a database deadlock. Defaults to a random delay between 60 and 120 seconds.
public RetryDelay? NetworkError { get; set; }Delay after the request could not reach the server (an HttpRequestException). Defaults to a random delay between 60 and 120 seconds.
public RetryDelay? Timeout { get; set; }Delay after the request did not complete within the timeout set with WithTimeout. Defaults to a random delay between 60 and 360 seconds.
public static RetryPolicy Default {get; }The policy a Graph uses unless told otherwise.
RetryDelay
public readonly struct RetryDelayHow long a RetryPolicy waits before retrying: a random delay between Min and Max. The randomness spreads out retries from many connectors that failed at the same moment.
- Namespace
- Curiosity.Library
Properties
Methods
public static RetryDelay Between(TimeSpan min, TimeSpan max)A random delay between min and max.