Table of Contents

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

string

Methods

ExecuteAsync(Func<Task>, CancellationToken)

Executes an operation with resilience handling.

Task ExecuteAsync(Func<Task> operation, CancellationToken cancellationToken = default)

Parameters

operation Func<Task>

The operation to execute.

cancellationToken CancellationToken

The 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

operation Func<Task<T>>

The operation to execute.

cancellationToken CancellationToken

The cancellation token.

Returns

Task<T>

A task representing the asynchronous operation with a result.

Type Parameters

T

The type of the result.

GetRetryDelay(int, Exception?)

Gets the delay before the next retry attempt.

TimeSpan GetRetryDelay(int attemptNumber, Exception? exception)

Parameters

attemptNumber int

The current attempt number (1-based).

exception Exception

The 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

attemptNumber int

The current attempt number (1-based).

exception Exception

The exception that occurred, if any.

cancellationToken CancellationToken

The cancellation token.

Returns

Task<bool>

True if a retry should be attempted; otherwise, false.