Table of Contents

Class FixedIntervalStrategy

Namespace
WorkflowForge.Extensions.Resilience.Strategies
Assembly
WorkflowForge.Extensions.Resilience.dll

Implements a resilience strategy with fixed intervals between retry attempts.

public sealed class FixedIntervalStrategy : ResilienceStrategyBase, IWorkflowResilienceStrategy
Inheritance
FixedIntervalStrategy
Implements
Inherited Members

Constructors

FixedIntervalStrategy(TimeSpan, int, Func<Exception, bool>?, IWorkflowForgeLogger?)

Initializes a new instance of the FixedIntervalStrategy class.

public FixedIntervalStrategy(TimeSpan interval, int maxAttempts, Func<Exception, bool>? retryPredicate = null, IWorkflowForgeLogger? logger = null)

Parameters

interval TimeSpan

The fixed interval between retry attempts.

maxAttempts int

The maximum number of attempts (including the initial attempt).

retryPredicate Func<Exception, bool>

Optional predicate to determine if an exception should be retried.

logger IWorkflowForgeLogger

Optional logger for the strategy.

Methods

Default(int, IWorkflowForgeLogger?)

Creates a default fixed interval strategy with 1-second intervals.

public static FixedIntervalStrategy Default(int maxAttempts = 3, IWorkflowForgeLogger? logger = null)

Parameters

maxAttempts int

Maximum number of retry attempts.

logger IWorkflowForgeLogger

Optional logger for strategy events.

Returns

FixedIntervalStrategy

A new fixed interval strategy.

ExecuteAsync(Func<Task>, CancellationToken)

Executes an operation with resilience handling.

public override 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.

Fast(int, IWorkflowForgeLogger?)

Creates a fast fixed interval strategy with 100ms intervals.

public static FixedIntervalStrategy Fast(int maxAttempts = 5, IWorkflowForgeLogger? logger = null)

Parameters

maxAttempts int

Maximum number of retry attempts.

logger IWorkflowForgeLogger

Optional logger for strategy events.

Returns

FixedIntervalStrategy

A new fixed interval strategy.

GetRetryDelay(int, Exception?)

Gets the delay before the next retry attempt.

public override 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.

Slow(int, IWorkflowForgeLogger?)

Creates a slow fixed interval strategy with 5-second intervals.

public static FixedIntervalStrategy Slow(int maxAttempts = 2, IWorkflowForgeLogger? logger = null)

Parameters

maxAttempts int

Maximum number of retry attempts.

logger IWorkflowForgeLogger

Optional logger for strategy events.

Returns

FixedIntervalStrategy

A new fixed interval strategy.