Table of Contents

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

executor IAsyncExecutor<T1, T2>

Source asynchronous executor.

storage ICacheStorage<T1, T2>

Cache storage used to resolve and persist values.

Returns

IAsyncExecutor<T1, T2>

Asynchronous executor with caching behavior.

Type Parameters

T1
T2

Exceptions

ArgumentNullException

storage is 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

executor IAsyncExecutor<Unit, Unit>
token CancellationToken

Returns

ValueTask

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

executor IAsyncExecutor<Unit, T>
token CancellationToken

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

executor IAsyncExecutor<(T1, T2), T3>
t1 T1

Returns

IAsyncExecutor<T2, T3>

Executor waiting for the remaining argument.

Type Parameters

T1
T2
T3

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

executor IAsyncExecutor<(T1, T2), T3>
t1 T1
t2 T2
token CancellationToken

Returns

ValueTask<T3>

Execution result.

Type Parameters

T1
T2
T3

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

executor IAsyncExecutor<(T1, T2, T3), T4>
t1 T1

Returns

IAsyncExecutor<(T2, T3), T4>

Executor waiting for two remaining arguments.

Type Parameters

T1
T2
T3
T4

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

executor IAsyncExecutor<(T1, T2, T3), T4>
t1 T1
t2 T2

Returns

IAsyncExecutor<T3, T4>

Executor waiting for the remaining argument.

Type Parameters

T1
T2
T3
T4

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

executor IAsyncExecutor<(T1, T2, T3), T4>
t1 T1
t2 T2
t3 T3
token CancellationToken

Returns

ValueTask<T4>

Execution result.

Type Parameters

T1
T2
T3
T4

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

executor IAsyncExecutor<(T1, T2, T3, T4), T5>
t1 T1

Returns

IAsyncExecutor<(T2, T3, T4), T5>

Executor waiting for three remaining arguments.

Type Parameters

T1
T2
T3
T4
T5

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

executor IAsyncExecutor<(T1, T2, T3, T4), T5>
t1 T1
t2 T2

Returns

IAsyncExecutor<(T3, T4), T5>

Executor waiting for two remaining arguments.

Type Parameters

T1
T2
T3
T4
T5

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

executor IAsyncExecutor<(T1, T2, T3, T4), T5>
t1 T1
t2 T2
t3 T3

Returns

IAsyncExecutor<T4, T5>

Executor waiting for the remaining argument.

Type Parameters

T1
T2
T3
T4
T5

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

executor IAsyncExecutor<(T1, T2, T3, T4), T5>
t1 T1
t2 T2
t3 T3
t4 T4
token CancellationToken

Returns

ValueTask<T5>

Execution result.

Type Parameters

T1
T2
T3
T4
T5

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

executor IAsyncExecutor<T1, T2>

Source executor.

map Func<TFrom, Exception>

Function that maps the caught exception to a new exception.

Returns

IAsyncExecutor<T1, T2>

Asynchronous executor with exception mapping behavior.

Type Parameters

T1
T2
TFrom

Exceptions

ArgumentNullException

map is 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

executor IAsyncExecutor<T1, T2>

Source asynchronous executor.

metrics IMetrics<T1, T2>

Metrics sink used to record execution information.

tag string

Optional tag passed to all metrics callbacks.

Returns

IAsyncExecutor<T1, T2>

Asynchronous executor with metrics behavior.

Type Parameters

T1
T2

Exceptions

ArgumentNullException

metrics is 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

executor IAsyncExecutor<T1, Optional<T2>>

Executor to configure.

Returns

SuppressExceptionFlattenAsyncExecutorProvider<T1, T2>

Provider for selecting exception types to suppress.

Type Parameters

T1
T2

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

executor IAsyncExecutor<T1, T2>

Executor to configure.

Returns

SuppressExceptionAsyncExecutorProvider<T1, T2>

Provider for selecting exception types to suppress.

Type Parameters

T1
T2

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

executor IAsyncExecutor<T1, T2>

Executor producing the observed result.

action AsyncAction<T2>

Asynchronous side-effect action invoked with the produced result.

Returns

IAsyncExecutor<T1, T2>

Asynchronous executor that preserves the original result.

Type Parameters

T1
T2

Exceptions

ArgumentNullException

action is 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

executor IAsyncExecutor<T1, T2>

Executor to run inside the context.

init ContextInit

Context initialization logic.

Returns

IAsyncExecutor<T1, T2>

Executor wrapped with contextual execution.

Type Parameters

T1
T2

Exceptions

ArgumentNullException

init is 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

executor IAsyncExecutor<T1, T2>

Executor to wrap with policies.

building Action<AsyncPolicyBuilder<T1, T2>>

Builder action that configures policies.

Returns

IAsyncExecutor<T1, T2>

Executor wrapped with configured policies.

Type Parameters

T1
T2

Exceptions

ArgumentNullException

building is 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

executor IAsyncExecutor<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

T1
T2

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

executor IAsyncExecutor<T1, T2>

Executor to wrap.

Returns

IAsyncExecutor<T1, Result<T2>>

Executor returning success or failure result.

Type Parameters

T1
T2