Class RetrySettings
Settings for retrying RPCs.
Inheritance
Inherited Members
Namespace: Google.Api.Gax.Grpc
Assembly: Google.Api.Gax.Grpc.dll
Syntax
public sealed class RetrySettings
Constructors
RetrySettings(BackoffSettings, BackoffSettings, Expiration)
Constructs an instance with the given backoff configuration, the default RPC filter and jitter.
Declaration
public RetrySettings(BackoffSettings retryBackoff, BackoffSettings timeoutBackoff, Expiration totalExpiration)
Parameters
Type | Name | Description |
---|---|---|
BackoffSettings | retryBackoff | The backoff policy for the time between retries. Must not be null. |
BackoffSettings | timeoutBackoff | The backoff policy for timeouts of retries. Must not be null. |
Expiration | totalExpiration | The total expiration, across all retries. Must not be null. |
RetrySettings(BackoffSettings, BackoffSettings, Expiration, Predicate<RpcException>)
Constructs an instance with the given configuration, and the default jitter.
Declaration
public RetrySettings(BackoffSettings retryBackoff, BackoffSettings timeoutBackoff, Expiration totalExpiration, Predicate<RpcException> retryFilter)
Parameters
Type | Name | Description |
---|---|---|
BackoffSettings | retryBackoff | The backoff policy for the time between retries. Must not be null. |
BackoffSettings | timeoutBackoff | The backoff policy for timeouts of retries. Must not be null. |
Expiration | totalExpiration | The total expiration, across all retries. Must not be null. |
System.Predicate<RpcException> | retryFilter | A predicate to determine whether or not a particular exception should cause the operation to be retried, or null for the default filter. |
RetrySettings(BackoffSettings, BackoffSettings, Expiration, Predicate<RpcException>, RetrySettings.IJitter)
Constructs an instance with the given configuration.
Declaration
public RetrySettings(BackoffSettings retryBackoff, BackoffSettings timeoutBackoff, Expiration totalExpiration, Predicate<RpcException> retryFilter, RetrySettings.IJitter delayJitter)
Parameters
Type | Name | Description |
---|---|---|
BackoffSettings | retryBackoff | The backoff policy for the time between retries. Must not be null. |
BackoffSettings | timeoutBackoff | The backoff policy for timeouts of retries. Must not be null. |
Expiration | totalExpiration | The total expiration, across all retries. Must not be null. |
System.Predicate<RpcException> | retryFilter | A predicate to determine whether or not a particular exception should cause the operation to be retried, or null for the default filter. |
RetrySettings.IJitter | delayJitter | The delay jitter to apply for delays, or null for the defautl (random) jitter. |
Properties
DefaultFilter
The default retry filter, which retries operations which fail due to a status code of "not found".
Declaration
public static Predicate<RpcException> DefaultFilter { get; }
Property Value
Type | Description |
---|---|
System.Predicate<RpcException> |
DelayJitter
The delay jitter to apply for delays, defaulting to RandomJitter.
Declaration
public RetrySettings.IJitter DelayJitter { get; }
Property Value
Type | Description |
---|---|
RetrySettings.IJitter |
Remarks
"Jitter" is used to introduce randomness into the pattern of delays. This is to avoid multiple clients performing the same delay pattern starting at the same point in time, leading to higher-than-necessary contention. The default jitter simply takes each maximum delay and returns an actual delay which is a uniformly random value between 0 and the maximum. This is good enough for most applications, but makes precise testing difficult.
NoJitter
A jitter which simply returns the specified maximum delay.
Declaration
public static RetrySettings.IJitter NoJitter { get; }
Property Value
Type | Description |
---|---|
RetrySettings.IJitter |
RandomJitter
The default jitter which returns a uniformly distributed random delay between 0 and the specified maximum.
Declaration
public static RetrySettings.IJitter RandomJitter { get; }
Property Value
Type | Description |
---|---|
RetrySettings.IJitter |
RetryBackoff
The backoff policy for the time between retries. This is never null.
Declaration
public BackoffSettings RetryBackoff { get; }
Property Value
Type | Description |
---|---|
BackoffSettings |
RetryFilter
A predicate to determine whether or not a particular exception should cause the operation to be retried. Usually this is simply a matter of checking the status codes.
Declaration
public Predicate<RpcException> RetryFilter { get; }
Property Value
Type | Description |
---|---|
System.Predicate<RpcException> |
TimeoutBackoff
The backoff policy for timeouts of retries. This is never null.
Declaration
public BackoffSettings TimeoutBackoff { get; }
Property Value
Type | Description |
---|---|
BackoffSettings |
Remarks
This allows an increasing timeout, initially requesting a fast call, then allowing a bit more time, then a bit more, and so on. However, the timeout will also be adjusted to accommodate TotalExpiration.
TotalExpiration
The total expiration, across all retries. This is never null.
Declaration
public Expiration TotalExpiration { get; }
Property Value
Type | Description |
---|---|
Expiration |
Methods
FilterForStatusCodes(StatusCode[])
Creates a retry filter based on status codes.
Declaration
public static Predicate<RpcException> FilterForStatusCodes(params StatusCode[] statusCodes)
Parameters
Type | Name | Description |
---|---|---|
StatusCode[] | statusCodes | The status codes to retry. Must not be null. |
Returns
Type | Description |
---|---|
System.Predicate<RpcException> | A retry filter based on status codes. |
FilterForStatusCodes(IEnumerable<StatusCode>)
Creates a retry filter based on status codes.
Declaration
public static Predicate<RpcException> FilterForStatusCodes(IEnumerable<StatusCode> statusCodes)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IEnumerable<StatusCode> | statusCodes | The status codes to retry. Must not be null. |
Returns
Type | Description |
---|---|
System.Predicate<RpcException> | A retry filter based on status codes. |
WithTotalExpiration(Expiration)
Builds a new RetrySettings which is identical to this one, but with the given expiration.
Declaration
public RetrySettings WithTotalExpiration(Expiration expiration)
Parameters
Type | Name | Description |
---|---|---|
Expiration | expiration | New expiration |
Returns
Type | Description |
---|---|
RetrySettings |