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
dependencyOutboundDependencyThe dependency class whose configured budget governs the operation.
remoteInstancestringThe 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.
operationFunc<CancellationToken, Task<TResult>>The operation, which must be safe to repeat.
cancellationTokenCancellationTokenCancels the operation and every remaining attempt.
Returns
- Task<TResult>
The result of the attempt that succeeded.
Type Parameters
TResultThe 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
remoteInstanceoroperationis 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.