Class TransientOperationOptions
- Namespace
- Cuemon.Resilience
- Assembly
- Cuemon.Resilience.dll
Configuration options for TransientOperation.
public class TransientOperationOptions : IValidatableParameterObject, IParameterObject
- Inheritance
-
TransientOperationOptions
- Implements
- Derived
Constructors
TransientOperationOptions()
Initializes a new instance of the TransientOperationOptions class.
public TransientOperationOptions()
Remarks
The following table shows the initial property values for an instance of TransientOperationOptions.
Property | Initial Value |
---|---|
RetryAttempts | DefaultRetryAttempts |
EnableRecovery | RetryAttempts > 0 |
RetryStrategy | retry + 2^ to a maximum of 5; eg. 1, 2, 4, 8, 16 to a total of 31 seconds |
DetectionStrategy | exception => false |
MaximumAllowedLatency | 5 minutes |
Properties
DefaultRetryAttempts
Gets or sets the default amount of retry attempts for transient faults. Default is 5 attempts.
public static byte DefaultRetryAttempts { get; set; }
Property Value
- Byte
The default amount of retry attempts for transient faults.
DetectionStrategy
Gets or sets the function delegate that determines if an Exception contains clues that would suggest a transient fault.
public Func<Exception, bool> DetectionStrategy { get; set; }
Property Value
- Func<Exception, Boolean>
A Func<TResult> that determines if an Exception contains clues that would suggest a transient fault.
Remarks
Default implementation is fixed to none-transient failure.
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.
public bool EnableRecovery { get; set; }
Property Value
- Boolean
true
if a transient operation should be attempted gracefully recovered in case of a transient fault; otherwise,false
.
Remarks
For testing or diagnostic purposes, it can sometimes come in handy to turn off transient fault recovery.
MaximumAllowedLatency
Gets or sets the maximum allowed latency before a LatencyException is raised.
public TimeSpan MaximumAllowedLatency { get; set; }
Property Value
RetryAttempts
Gets or sets the amount of retry attempts for transient faults. Default value is DefaultRetryAttempts.
public int RetryAttempts { get; set; }
Property Value
- Int32
The retry attempts for transient faults.
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.
public Func<int, TimeSpan> RetryStrategy { get; set; }
Property Value
- Func<Int32, TimeSpan>
A Func<TResult> that determines the amount of time to wait for a transient fault to recover gracefully.
Remarks
Default implementation is Int32 + 2^ to a maximum of 5; eg. 1, 2, 4, 8, 16 to a total of 32 seconds.
Methods
ValidateOptions()
Determines whether the public read-write properties of this instance are in a valid state.
public void ValidateOptions()
Remarks
This method is expected to throw exceptions when one or more conditions fails to be in a valid state.
Exceptions
- InvalidOperationException
RetryStrategy cannot be null.