Interface IWorkflowResilienceStrategy
- Namespace
- WorkflowForge.Extensions.Resilience.Abstractions
- Assembly
- WorkflowForge.Extensions.Resilience.dll
Interface for resilience strategies that handle retry logic and failure recovery for workflows.
public interface IWorkflowResilienceStrategy
Properties
Name
Gets the name of the resilience strategy.
string Name { get; }
Property Value
Methods
ExecuteAsync(Func<Task>, CancellationToken)
Executes an operation with resilience handling.
Task ExecuteAsync(Func<Task> operation, CancellationToken cancellationToken = default)
Parameters
operationFunc<Task>The operation to execute.
cancellationTokenCancellationTokenThe cancellation token.
Returns
- Task
A task representing the asynchronous operation.
ExecuteAsync<T>(Func<Task<T>>, CancellationToken)
Executes an operation with resilience handling and returns a result.
Task<T> ExecuteAsync<T>(Func<Task<T>> operation, CancellationToken cancellationToken = default)
Parameters
operationFunc<Task<T>>The operation to execute.
cancellationTokenCancellationTokenThe cancellation token.
Returns
- Task<T>
A task representing the asynchronous operation with a result.
Type Parameters
TThe type of the result.
GetRetryDelay(int, Exception?)
Gets the delay before the next retry attempt.
TimeSpan GetRetryDelay(int attemptNumber, Exception? exception)
Parameters
attemptNumberintThe current attempt number (1-based).
exceptionExceptionThe exception that occurred, if any.
Returns
- TimeSpan
The delay before the next retry attempt.
ShouldRetryAsync(int, Exception?, CancellationToken)
Determines whether a retry should be attempted based on the current attempt and exception.
Task<bool> ShouldRetryAsync(int attemptNumber, Exception? exception, CancellationToken cancellationToken = default)
Parameters
attemptNumberintThe current attempt number (1-based).
exceptionExceptionThe exception that occurred, if any.
cancellationTokenCancellationTokenThe cancellation token.