Class AsyncExecutorExtensions
- Namespace
- Executables
- Assembly
- executables.dll
Extension methods for composing and adapting asynchronous executors.
public static class AsyncExecutorExtensions
- Inheritance
-
AsyncExecutorExtensions
- Inherited Members
Methods
Cache<T1, T2>(IAsyncExecutor<T1, T2>, ICacheStorage<T1, T2>)
Adds asynchronous cache behavior to an executor.
[Pure]
public static IAsyncExecutor<T1, T2> Cache<T1, T2>(this IAsyncExecutor<T1, T2> executor, ICacheStorage<T1, T2> storage)
Parameters
executorIAsyncExecutor<T1, T2>Source asynchronous executor.
storageICacheStorage<T1, T2>Cache storage used to resolve and persist values.
Returns
- IAsyncExecutor<T1, T2>
Asynchronous executor with caching behavior.
Type Parameters
T1T2
Exceptions
- ArgumentNullException
storageis null.
Execute(IAsyncExecutor<Unit, Unit>, CancellationToken)
Executes a parameterless async executor with no result.
public static ValueTask Execute(this IAsyncExecutor<Unit, Unit> executor, CancellationToken token = default)
Parameters
executorIAsyncExecutor<Unit, Unit>tokenCancellationToken
Returns
Execute<T>(IAsyncExecutor<Unit, T>, CancellationToken)
Executes a parameterless async executor.
public static ValueTask<T> Execute<T>(this IAsyncExecutor<Unit, T> executor, CancellationToken token = default)
Parameters
executorIAsyncExecutor<Unit, T>tokenCancellationToken
Returns
- ValueTask<T>
Execution result.
Type Parameters
T
Execute<T1, T2, T3>(IAsyncExecutor<(T1, T2), T3>, T1)
Partially applies the first argument of a two-argument async executor.
public static IAsyncExecutor<T2, T3> Execute<T1, T2, T3>(this IAsyncExecutor<(T1, T2), T3> executor, T1 t1)
Parameters
executorIAsyncExecutor<(T1, T2), T3>t1T1
Returns
- IAsyncExecutor<T2, T3>
Executor waiting for the remaining argument.
Type Parameters
T1T2T3
Execute<T1, T2, T3>(IAsyncExecutor<(T1, T2), T3>, T1, T2, CancellationToken)
Executes a two-argument async executor.
public static ValueTask<T3> Execute<T1, T2, T3>(this IAsyncExecutor<(T1, T2), T3> executor, T1 t1, T2 t2, CancellationToken token = default)
Parameters
executorIAsyncExecutor<(T1, T2), T3>t1T1t2T2tokenCancellationToken
Returns
- ValueTask<T3>
Execution result.
Type Parameters
T1T2T3
Execute<T1, T2, T3, T4>(IAsyncExecutor<(T1, T2, T3), T4>, T1)
Partially applies the first argument of a three-argument async executor.
public static IAsyncExecutor<(T2, T3), T4> Execute<T1, T2, T3, T4>(this IAsyncExecutor<(T1, T2, T3), T4> executor, T1 t1)
Parameters
executorIAsyncExecutor<(T1, T2, T3), T4>t1T1
Returns
- IAsyncExecutor<(T2, T3), T4>
Executor waiting for two remaining arguments.
Type Parameters
T1T2T3T4
Execute<T1, T2, T3, T4>(IAsyncExecutor<(T1, T2, T3), T4>, T1, T2)
Partially applies the first two arguments of a three-argument async executor.
public static IAsyncExecutor<T3, T4> Execute<T1, T2, T3, T4>(this IAsyncExecutor<(T1, T2, T3), T4> executor, T1 t1, T2 t2)
Parameters
executorIAsyncExecutor<(T1, T2, T3), T4>t1T1t2T2
Returns
- IAsyncExecutor<T3, T4>
Executor waiting for the remaining argument.
Type Parameters
T1T2T3T4
Execute<T1, T2, T3, T4>(IAsyncExecutor<(T1, T2, T3), T4>, T1, T2, T3, CancellationToken)
Executes a three-argument async executor.
public static ValueTask<T4> Execute<T1, T2, T3, T4>(this IAsyncExecutor<(T1, T2, T3), T4> executor, T1 t1, T2 t2, T3 t3, CancellationToken token = default)
Parameters
executorIAsyncExecutor<(T1, T2, T3), T4>t1T1t2T2t3T3tokenCancellationToken
Returns
- ValueTask<T4>
Execution result.
Type Parameters
T1T2T3T4
Execute<T1, T2, T3, T4, T5>(IAsyncExecutor<(T1, T2, T3, T4), T5>, T1)
Partially applies the first argument of a four-argument async executor.
public static IAsyncExecutor<(T2, T3, T4), T5> Execute<T1, T2, T3, T4, T5>(this IAsyncExecutor<(T1, T2, T3, T4), T5> executor, T1 t1)
Parameters
executorIAsyncExecutor<(T1, T2, T3, T4), T5>t1T1
Returns
- IAsyncExecutor<(T2, T3, T4), T5>
Executor waiting for three remaining arguments.
Type Parameters
T1T2T3T4T5
Execute<T1, T2, T3, T4, T5>(IAsyncExecutor<(T1, T2, T3, T4), T5>, T1, T2)
Partially applies the first two arguments of a four-argument async executor.
public static IAsyncExecutor<(T3, T4), T5> Execute<T1, T2, T3, T4, T5>(this IAsyncExecutor<(T1, T2, T3, T4), T5> executor, T1 t1, T2 t2)
Parameters
executorIAsyncExecutor<(T1, T2, T3, T4), T5>t1T1t2T2
Returns
- IAsyncExecutor<(T3, T4), T5>
Executor waiting for two remaining arguments.
Type Parameters
T1T2T3T4T5
Execute<T1, T2, T3, T4, T5>(IAsyncExecutor<(T1, T2, T3, T4), T5>, T1, T2, T3)
Partially applies the first three arguments of a four-argument async executor.
public static IAsyncExecutor<T4, T5> Execute<T1, T2, T3, T4, T5>(this IAsyncExecutor<(T1, T2, T3, T4), T5> executor, T1 t1, T2 t2, T3 t3)
Parameters
executorIAsyncExecutor<(T1, T2, T3, T4), T5>t1T1t2T2t3T3
Returns
- IAsyncExecutor<T4, T5>
Executor waiting for the remaining argument.
Type Parameters
T1T2T3T4T5
Execute<T1, T2, T3, T4, T5>(IAsyncExecutor<(T1, T2, T3, T4), T5>, T1, T2, T3, T4, CancellationToken)
Executes a four-argument async executor.
public static ValueTask<T5> Execute<T1, T2, T3, T4, T5>(this IAsyncExecutor<(T1, T2, T3, T4), T5> executor, T1 t1, T2 t2, T3 t3, T4 t4, CancellationToken token = default)
Parameters
executorIAsyncExecutor<(T1, T2, T3, T4), T5>t1T1t2T2t3T3t4T4tokenCancellationToken
Returns
- ValueTask<T5>
Execution result.
Type Parameters
T1T2T3T4T5
MapException<T1, T2, TFrom>(IAsyncExecutor<T1, T2>, Func<TFrom, Exception>)
Maps exceptions of a specific type thrown by an asynchronous executor.
[Pure]
public static IAsyncExecutor<T1, T2> MapException<T1, T2, TFrom>(this IAsyncExecutor<T1, T2> executor, Func<TFrom, Exception> map) where TFrom : Exception
Parameters
executorIAsyncExecutor<T1, T2>Source executor.
mapFunc<TFrom, Exception>Function that maps the caught exception to a new exception.
Returns
- IAsyncExecutor<T1, T2>
Asynchronous executor with exception mapping behavior.
Type Parameters
T1T2TFrom
Exceptions
- ArgumentNullException
mapis null.
Metrics<T1, T2>(IAsyncExecutor<T1, T2>, IMetrics<T1, T2>, string)
Adds asynchronous metrics behavior to an executor.
[Pure]
public static IAsyncExecutor<T1, T2> Metrics<T1, T2>(this IAsyncExecutor<T1, T2> executor, IMetrics<T1, T2> metrics, string tag = null)
Parameters
executorIAsyncExecutor<T1, T2>Source asynchronous executor.
metricsIMetrics<T1, T2>Metrics sink used to record execution information.
tagstringOptional tag passed to all metrics callbacks.
Returns
- IAsyncExecutor<T1, T2>
Asynchronous executor with metrics behavior.
Type Parameters
T1T2
Exceptions
- ArgumentNullException
metricsis null.
SuppressException<T1, T2>(IAsyncExecutor<T1, Optional<T2>>)
Starts configuration of exception suppression for asynchronous executors returning Optional<T>.
[Pure]
public static SuppressExceptionFlattenAsyncExecutorProvider<T1, T2> SuppressException<T1, T2>(this IAsyncExecutor<T1, Optional<T2>> executor)
Parameters
executorIAsyncExecutor<T1, Optional<T2>>Executor to configure.
Returns
- SuppressExceptionFlattenAsyncExecutorProvider<T1, T2>
Provider for selecting exception types to suppress.
Type Parameters
T1T2
SuppressException<T1, T2>(IAsyncExecutor<T1, T2>)
Starts configuration of exception suppression for asynchronous executor results.
[Pure]
public static SuppressExceptionAsyncExecutorProvider<T1, T2> SuppressException<T1, T2>(this IAsyncExecutor<T1, T2> executor)
Parameters
executorIAsyncExecutor<T1, T2>Executor to configure.
Returns
- SuppressExceptionAsyncExecutorProvider<T1, T2>
Provider for selecting exception types to suppress.
Type Parameters
T1T2
Tap<T1, T2>(IAsyncExecutor<T1, T2>, AsyncAction<T2>)
Runs an asynchronous side effect on each result while returning the original result unchanged.
[Pure]
public static IAsyncExecutor<T1, T2> Tap<T1, T2>(this IAsyncExecutor<T1, T2> executor, AsyncAction<T2> action)
Parameters
executorIAsyncExecutor<T1, T2>Executor producing the observed result.
actionAsyncAction<T2>Asynchronous side-effect action invoked with the produced result.
Returns
- IAsyncExecutor<T1, T2>
Asynchronous executor that preserves the original result.
Type Parameters
T1T2
Exceptions
- ArgumentNullException
actionis null.
WithContext<T1, T2>(IAsyncExecutor<T1, T2>, ContextInit)
Executes an asynchronous executor within a newly initialized interaction context.
[Pure]
public static IAsyncExecutor<T1, T2> WithContext<T1, T2>(this IAsyncExecutor<T1, T2> executor, ContextInit init)
Parameters
executorIAsyncExecutor<T1, T2>Executor to run inside the context.
initContextInitContext initialization logic.
Returns
- IAsyncExecutor<T1, T2>
Executor wrapped with contextual execution.
Type Parameters
T1T2
Exceptions
- ArgumentNullException
initis null.
WithPolicy<T1, T2>(IAsyncExecutor<T1, T2>, Action<AsyncPolicyBuilder<T1, T2>>)
Builds and applies an asynchronous policy pipeline to an executor.
[Pure]
public static IAsyncExecutor<T1, T2> WithPolicy<T1, T2>(this IAsyncExecutor<T1, T2> executor, Action<AsyncPolicyBuilder<T1, T2>> building)
Parameters
executorIAsyncExecutor<T1, T2>Executor to wrap with policies.
buildingAction<AsyncPolicyBuilder<T1, T2>>Builder action that configures policies.
Returns
- IAsyncExecutor<T1, T2>
Executor wrapped with configured policies.
Type Parameters
T1T2
Exceptions
- ArgumentNullException
buildingis null.
WithResult<T1, T2>(IAsyncExecutor<T1, Result<T2>>)
Wraps an executor already returning Result<T> so that thrown exceptions are also converted to Result<T>.
[Pure]
public static IAsyncExecutor<T1, Result<T2>> WithResult<T1, T2>(this IAsyncExecutor<T1, Result<T2>> executor)
Parameters
executorIAsyncExecutor<T1, Result<T2>>Executor returning Result<T>.
Returns
- IAsyncExecutor<T1, Result<T2>>
Executor that preserves returned results and converts thrown exceptions to failure results.
Type Parameters
T1T2
WithResult<T1, T2>(IAsyncExecutor<T1, T2>)
Wraps executor result into Result<T> capturing thrown exceptions.
[Pure]
public static IAsyncExecutor<T1, Result<T2>> WithResult<T1, T2>(this IAsyncExecutor<T1, T2> executor)
Parameters
executorIAsyncExecutor<T1, T2>Executor to wrap.
Returns
- IAsyncExecutor<T1, Result<T2>>
Executor returning success or failure result.
Type Parameters
T1T2