Table of Contents

Method RunAsync

Namespace
MailFathom.Application.Resilience
Assembly
MailFathom.Application.dll

RunAsync<TResult>(OutboundDependency, string, Func<CancellationToken, Task<TResult>>, CancellationToken)

Runs an operation under the pipeline of one remote instance of a dependency class.

Task<TResult> RunAsync<TResult>(OutboundDependency dependency, string remoteInstance, Func<CancellationToken, Task<TResult>> operation, CancellationToken cancellationToken)

Parameters

dependency OutboundDependency

The dependency class whose configured budget governs the operation.

remoteInstance string

The deployment's own name for the remote instance being called, so one unhealthy endpoint does not stop the others. It must never carry personal data, because it reaches resilience telemetry.

operation Func<CancellationToken, Task<TResult>>

The operation, which must be safe to repeat.

cancellationToken CancellationToken

Cancels the operation and every remaining attempt.

Returns

Task<TResult>

The result of the attempt that succeeded.

Type Parameters

TResult

The result the operation produces.

Remarks

Caller cancellation reaches the caller as OperationCanceledException, and every limit the pipeline itself imposed as a failure the implementation documents.

Exceptions

ArgumentNullException

Thrown when remoteInstance or operation is null.

InvalidOperationException

Thrown when the same dependency class is already executing on this asynchronous flow, which would put one operation's retries inside another's.