Definition
Assembly: Microsoft.OData.Mcp.Authentication.dll Namespace: Microsoft.OData.Mcp.Authentication.Models Inheritance: System.ObjectSyntax
Summary
Configuration options for retry policies in authentication operations.Remarks
Retry policies help handle transient failures in authentication and token delegation operations, such as network timeouts, temporary service unavailability, or rate limiting from authorization servers.Constructors
.ctor
Initializes a new instance of the RetryPolicyOptions class.Syntax
.ctor Inherited
Inherited from
objectSyntax
Properties
BackoffStrategy
Gets or sets the backoff strategy for calculating retry delays.Syntax
Property Value
Type:Microsoft.OData.Mcp.Authentication.Models.BackoffStrategy
The strategy used to calculate delays between retry attempts.
Remarks
Different backoff strategies provide different trade-offs between recovery speed and load on the target service. Exponential backoff is generally recommended for most scenarios.BaseDelay
Gets or sets the base delay between retry attempts.Syntax
Property Value
Type:System.TimeSpan
The initial delay before the first retry attempt.
Remarks
The actual delay may be modified by the backoff strategy. This value should be chosen based on the expected recovery time for transient failures.CircuitBreakerFailureThreshold
Gets or sets the circuit breaker failure threshold.Syntax
Property Value
Type:int
The number of consecutive failures that will trip the circuit breaker.
Remarks
Once this many consecutive failures occur, the circuit breaker will “open” and prevent further attempts for a period of time. This helps avoid overwhelming a failing service.CircuitBreakerTimeout
Gets or sets the circuit breaker recovery timeout.Syntax
Property Value
Type:System.TimeSpan
The time to wait before attempting to close an open circuit breaker.
Remarks
After the circuit breaker opens, it will remain open for this duration before allowing a test request to check if the service has recovered.Enabled
Gets or sets a value indicating whether retry is enabled.Syntax
Property Value
Type:bool
true if retry is enabled; otherwise, false.
Remarks
When disabled, failed operations will not be retried and will fail immediately. Enabling retries can improve reliability but may increase latency for operations that ultimately fail.JitterFactor
Gets or sets the jitter factor for randomizing retry delays.Syntax
Property Value
Type:double
A value between 0.0 and 1.0 that controls the amount of randomization applied to delays.
Remarks
Jitter helps prevent the “thundering herd” problem when multiple clients retry simultaneously. A value of 0.0 disables jitter, while 1.0 allows delays to vary by up to 100% of the calculated value.MaxAttempts
Gets or sets the maximum number of retry attempts.Syntax
Property Value
Type:int
The maximum number of times to retry a failed operation.
Remarks
This count does not include the initial attempt. For example, a value of 3 means the operation will be attempted up to 4 times total. Higher values provide more resilience but may cause longer delays.MaxDelay
Gets or sets the maximum delay between retry attempts.Syntax
Property Value
Type:System.TimeSpan
The maximum time to wait before a retry attempt.
Remarks
This prevents exponential backoff from creating extremely long delays. The actual delay will be capped at this value regardless of the backoff calculation.RetryableExceptionTypes
Gets or sets the exception types that should trigger retries.Syntax
Property Value
Type:System.Collections.Generic.HashSet<string>
A collection of exception type names that indicate retryable failures.
Remarks
Exceptions of these types will trigger retries. The type names should be the full type name including namespace. This is typically used for network-related exceptions like timeouts and connection failures.RetryableStatusCodes
Gets or sets the HTTP status codes that should trigger retries.Syntax
Property Value
Type:System.Collections.Generic.HashSet<int>
A collection of HTTP status codes that indicate retryable failures.
Remarks
Only failures with these status codes will be retried. Other status codes will cause the operation to fail immediately. Common retryable codes include 429 (Too Many Requests), 502 (Bad Gateway), and 503 (Service Unavailable).UseCircuitBreaker
Gets or sets a value indicating whether to use circuit breaker pattern.Syntax
Property Value
Type:bool
true if circuit breaker should be used; otherwise, false.
Remarks
The circuit breaker pattern prevents cascading failures by temporarily stopping retries when a service is consistently failing. This can improve overall system stability during outages.Methods
CalculateDelay
Calculates the delay for a specific retry attempt.Syntax
Parameters
| Name | Type | Description |
|---|---|---|
attemptNumber | int | The retry attempt number (starting from 1). |
Returns
Type:System.TimeSpan
The delay to wait before the retry attempt.
Equals Inherited Virtual
Inherited from
objectSyntax
Parameters
| Name | Type | Description |
|---|---|---|
obj | object? | - |
Returns
Type:bool
Equals Inherited
Inherited from
objectSyntax
Parameters
| Name | Type | Description |
|---|---|---|
objA | object? | - |
objB | object? | - |
Returns
Type:bool
GetHashCode Inherited Virtual
Inherited from
objectSyntax
Returns
Type:int
GetType Inherited
Inherited from
objectSyntax
Returns
Type:System.Type
MemberwiseClone Inherited
Inherited from
objectSyntax
Returns
Type:object
ReferenceEquals Inherited
Inherited from
objectSyntax
Parameters
| Name | Type | Description |
|---|---|---|
objA | object? | - |
objB | object? | - |
Returns
Type:bool
ShouldRetry
Determines whether an exception should trigger a retry.Syntax
Parameters
| Name | Type | Description |
|---|---|---|
exception | System.Exception | The exception to check. |
Returns
Type:bool
true if the exception should trigger a retry; otherwise, false.
ShouldRetry
Determines whether an HTTP status code should trigger a retry.Syntax
Parameters
| Name | Type | Description |
|---|---|---|
statusCode | int | The HTTP status code to check. |
Returns
Type:bool
true if the status code should trigger a retry; otherwise, false.
ToString Override
Returns a string representation of the retry policy options.Syntax
Returns
Type:string
A summary of the retry policy configuration.
ToString Inherited Virtual
Inherited from
objectSyntax
Returns
Type:string?
Validate
Validates the retry policy options for consistency and completeness.Syntax
Returns
Type:System.Collections.Generic.IEnumerable<string>
A collection of validation errors, or an empty collection if the options are valid.