src/Orleans.Core/Async/AsyncExecutorWithRetries.cs
/// <summary>
/// Execute a given <paramref name="function"/> a number of times, based on retry configuration parameters.
/// </summary>
/// <typeparam name="T">
/// The underlying return type of <paramref name="function"/>.
/// </typeparam>
/// <param name="function">
/// Function to execute
/// </param>
/// <param name="maxNumSuccessTries">
/// Maximal number of successful execution attempts. <see cref="ExecuteWithRetries"/> will try to re-execute the given <paramref name="function"/> again if directed so by <paramref name="retryValueFilter"/> .
/// Set to <c>-1</c> for unlimited number of success retries, until <paramref name="retryValueFilter"/> is satisfied. Set to <c>0</c> for only one success attempt, which will cause <paramref name="retryValueFilter"/> to be
/// ignored and the given <paramref name="function"/> executed only once until first success.
/// </param>
/// <param name="maxNumErrorTries">
/// Maximal number of execution attempts due to errors. Set to -1 for unlimited number of error retries, until <paramref name="retryExceptionFilter"/> is satisfied.
/// </param>
/// <param name="retryValueFilter">
/// Filter <paramref name="function"/> to indicate if successful execution should be retried. Set to <see langword="null"/> to disable successful retries.
/// </param>
/// <param name="retryExceptionFilter">
/// Filter <paramref name="function"/> to indicate if error execution should be retried. Set to <see langword="null"/> to disable error retries.
/// </param>
/// <param name="maxExecutionTime">
/// The maximal execution time of the <see cref="ExecuteWithRetries"/> function.
/// </param>
/// <param name="onSuccessBackOff">
/// The backoff provider object, which determines how much to wait between success retries.
/// </param>
/// <param name="onErrorBackOff">
/// The backoff provider object, which determines how much to wait between error retries
/// </param>
/// <returns>
/// The value returned from the successful invocation of <paramref name="function"/>.
/// </returns>
Execute a given  a number of times, based on retry configuration parameters.
Execute a given a number of times based on retry configuration parameters .
public static Task<T> ExecuteWithRetries<T>(
            Func<int, Task<T>> function,
            int maxNumSuccessTries,
            int maxNumErrorTries,
            Func<T, int, bool> retryValueFilter,
            Func<Exception, int, bool> retryExceptionFilter,
            TimeSpan maxExecutionTime = default(TimeSpan),
            IBackoffProvider onSuccessBackOff = null,
            IBackoffProvider onErrorBackOff = null)
        {
            return ExecuteWithRetriesHelper<T>(
                function,
                maxNumSuccessTries,
                maxNumErrorTries,
                maxExecutionTime,
                DateTime.UtcNow,
                retryValueFilter,
                retryExceptionFilter,
                onSuccessBackOff,
                onErrorBackOff);
        }
public static Task < T > ExecuteWithRetries < T > ( Func < int , Task < T > > function , int maxNumSuccessTries , int maxNumErrorTries , Func < T , int , bool > retryValueFilter , Func < Exception , int , bool > retryExceptionFilter , TimeSpan maxExecutionTime = default ( TimeSpan ) , IBackoffProvider onSuccessBackOff = null , IBackoffProvider onErrorBackOff = null ) { return ExecuteWithRetriesHelper < T > ( function , maxNumSuccessTries , maxNumErrorTries , maxExecutionTime , DateTime . UtcNow , retryValueFilter , retryExceptionFilter , onSuccessBackOff , onErrorBackOff ) ; }
Execute a given  a number of times, based on retry configuration parameters.
Execute a given a number of times based on retry configuration parameters .
The value returned from the successful invocation of .
The value returned from the successful invocation of .
function
Func<int, Task<T>>
Function to execute
Function to execute
maxNumSuccessTries
int
Maximal number of successful execution attempts.  will try to re-execute the given  again if directed so by  .
Set to -1 is satisfied. Set to 0 to be
ignored and the given  executed only once until first success.
Maximal number of successful execution attempts . will try to re - execute the given again if directed so by . Set to - 1 is satisfied . Set to 0 to be ignored and the given executed only once until first success .
maxNumErrorTries
int
Maximal number of execution attempts due to errors. Set to -1 for unlimited number of error retries, until  is satisfied.
Maximal number of execution attempts due to errors . Set to - 1 for unlimited number of error retries until is satisfied .
retryValueFilter
Func<T, int, bool>
Filter  to indicate if successful execution should be retried. Set to  to disable successful retries.
Filter to indicate if successful execution should be retried . Set to to disable successful retries .
retryExceptionFilter
Func<Exception, int, bool>
Filter  to indicate if error execution should be retried. Set to  to disable error retries.
Filter to indicate if error execution should be retried . Set to to disable error retries .
maxExecutionTime
TimeSpan
The maximal execution time of the  function.
The maximal execution time of the function .
onSuccessBackOff
IBackoffProvider
The backoff provider object, which determines how much to wait between success retries.
The backoff provider object which determines how much to wait between success retries .
onErrorBackOff
IBackoffProvider
The backoff provider object, which determines how much to wait between error retries
The backoff provider object which determines how much to wait between error retries
typeparam
The underlying return type of .
The underlying return type of .