TransientOperationOptions Class
Definition
- Namespace
- Cuemon.Resilience
- Assemblies
- Cuemon.Resilience.dll
Configuration options for TransientOperation.
public class TransientOperationOptions : IValidatableParameterObject, IParameterObject
- Inheritance
-
TransientOperationOptions
- Implements
- Derived
Examples
The following example demonstrates how to configure
using System;
using System.Net.Http;
using Cuemon.Resilience;
namespace MyApp.Examples;
public static class TransientOperationOptionsExample
{
public static void Demonstrate()
{
var options = new TransientOperationOptions
{
RetryAttempts = 3,
RetryStrategy = attempt => TimeSpan.FromSeconds(Math.Pow(2, attempt)),
DetectionStrategy = exception => exception is HttpRequestException,
MaximumAllowedLatency = TimeSpan.FromSeconds(30)
};
options.ValidateOptions();
Console.WriteLine(options.RetryAttempts);
Console.WriteLine(options.EnableRecovery);
Console.WriteLine(options.MaximumAllowedLatency);
Console.WriteLine(options.DetectionStrategy(new HttpRequestException("Network timeout simulated.")));
}
}
Constructors
| Name | Description |
|---|---|
| TransientOperationOptions() | Initializes a new instance of the TransientOperationOptions class. |
Properties
| Name | Description |
|---|---|
| DefaultRetryAttempts | Gets or sets the default amount of retry attempts for transient faults. Default is 5 attempts. |
| DetectionStrategy | Gets or sets the function delegate that determines if an Exception contains clues that would suggest a transient fault. |
| EnableRecovery | Gets or sets a value indicating whether a transient operation should be attempted gracefully recovered in case of a transient fault or simply be invoked like a normal operation. |
| MaximumAllowedLatency | Gets or sets the maximum allowed latency before a LatencyException is raised. |
| RetryAttempts | Gets or sets the amount of retry attempts for transient faults. Default value is DefaultRetryAttempts. |
| RetryStrategy | Gets or sets the function delegate that determines the amount of time to wait for a transient fault to recover gracefully before trying a new attempt. |
Methods
| Name | Description |
|---|---|
| ValidateOptions() | Determines whether the public read-write properties of this instance are in a valid state. |