AsyncExecutorWithRetries.ExecuteWithRetries 方法

定义

重载

ExecuteWithRetries(Func<Int32,Task>, Int32, Func<Exception,Int32,Boolean>, TimeSpan, IBackoffProvider)

根据重试配置参数多次执行给定函数。

ExecuteWithRetries<T>(Func<Int32,Task<T>>, Int32, Func<Exception,Int32,Boolean>, TimeSpan, IBackoffProvider)

根据重试配置参数多次执行给定函数。

ExecuteWithRetries<T>(Func<Int32,Task<T>>, Int32, Int32, Func<T, Int32,Boolean>, Func<Exception,Int32,Boolean>, TimeSpan, IBackoffProvider, IBackoffProvider)

根据重试配置参数执行给定 function 的次数。

ExecuteWithRetries(Func<Int32,Task>, Int32, Func<Exception,Int32,Boolean>, TimeSpan, IBackoffProvider)

Source:
AsyncExecutorWithRetries.cs

根据重试配置参数多次执行给定函数。

public static System.Threading.Tasks.Task ExecuteWithRetries (Func<int,System.Threading.Tasks.Task> action, int maxNumErrorTries, Func<Exception,int,bool> retryExceptionFilter, TimeSpan maxExecutionTime, Orleans.Internal.IBackoffProvider onErrorBackOff);
static member ExecuteWithRetries : Func<int, System.Threading.Tasks.Task> * int * Func<Exception, int, bool> * TimeSpan * Orleans.Internal.IBackoffProvider -> System.Threading.Tasks.Task
Public Shared Function ExecuteWithRetries (action As Func(Of Integer, Task), maxNumErrorTries As Integer, retryExceptionFilter As Func(Of Exception, Integer, Boolean), maxExecutionTime As TimeSpan, onErrorBackOff As IBackoffProvider) As Task

参数

action
Func<Int32,Task>

要执行的操作。

maxNumErrorTries
Int32

最大重试次数。

retryExceptionFilter
Func<Exception,Int32,Boolean>

重试异常筛选器。

maxExecutionTime
TimeSpan

最大执行时间。

onErrorBackOff
IBackoffProvider

退避提供程序。

返回

一个 Task 表示操作的 。

适用于

ExecuteWithRetries<T>(Func<Int32,Task<T>>, Int32, Func<Exception,Int32,Boolean>, TimeSpan, IBackoffProvider)

Source:
AsyncExecutorWithRetries.cs

根据重试配置参数多次执行给定函数。

public static System.Threading.Tasks.Task<T> ExecuteWithRetries<T> (Func<int,System.Threading.Tasks.Task<T>> function, int maxNumErrorTries, Func<Exception,int,bool> retryExceptionFilter, TimeSpan maxExecutionTime, Orleans.Internal.IBackoffProvider onErrorBackOff);
static member ExecuteWithRetries : Func<int, System.Threading.Tasks.Task<'T>> * int * Func<Exception, int, bool> * TimeSpan * Orleans.Internal.IBackoffProvider -> System.Threading.Tasks.Task<'T>
Public Shared Function ExecuteWithRetries(Of T) (function As Func(Of Integer, Task(Of T)), maxNumErrorTries As Integer, retryExceptionFilter As Func(Of Exception, Integer, Boolean), maxExecutionTime As TimeSpan, onErrorBackOff As IBackoffProvider) As Task(Of T)

类型参数

T

参数

function
Func<Int32,Task<T>>

要执行的委托。

maxNumErrorTries
Int32

最大重试次数。

retryExceptionFilter
Func<Exception,Int32,Boolean>

重试异常筛选器。

maxExecutionTime
TimeSpan

最大执行时间。

onErrorBackOff
IBackoffProvider

退避提供程序。

返回

Task<T>

成功调用提供的函数后返回的值。

适用于

ExecuteWithRetries<T>(Func<Int32,Task<T>>, Int32, Int32, Func<T, Int32,Boolean>, Func<Exception,Int32,Boolean>, TimeSpan, IBackoffProvider, IBackoffProvider)

Source:
AsyncExecutorWithRetries.cs

根据重试配置参数执行给定 function 的次数。

public static System.Threading.Tasks.Task<T> ExecuteWithRetries<T> (Func<int,System.Threading.Tasks.Task<T>> function, int maxNumSuccessTries, int maxNumErrorTries, Func<T,int,bool> retryValueFilter, Func<Exception,int,bool> retryExceptionFilter, TimeSpan maxExecutionTime = default, Orleans.Internal.IBackoffProvider onSuccessBackOff = default, Orleans.Internal.IBackoffProvider onErrorBackOff = default);
static member ExecuteWithRetries : Func<int, System.Threading.Tasks.Task<'T>> * int * int * Func<'T, int, bool> * Func<Exception, int, bool> * TimeSpan * Orleans.Internal.IBackoffProvider * Orleans.Internal.IBackoffProvider -> System.Threading.Tasks.Task<'T>
Public Shared Function ExecuteWithRetries(Of T) (function As Func(Of Integer, Task(Of T)), maxNumSuccessTries As Integer, maxNumErrorTries As Integer, retryValueFilter As Func(Of T, Integer, Boolean), retryExceptionFilter As Func(Of Exception, Integer, Boolean), Optional maxExecutionTime As TimeSpan = Nothing, Optional onSuccessBackOff As IBackoffProvider = Nothing, Optional onErrorBackOff As IBackoffProvider = Nothing) As Task(Of T)

类型参数

T

的基础返回类型 function

参数

function
Func<Int32,Task<T>>

要执行的函数

maxNumSuccessTries
Int32

成功执行尝试的最大次数。 ExecuteWithRetries(Func<Int32,Task>, Int32, Func<Exception,Int32,Boolean>, TimeSpan, IBackoffProvider) 如果由 指示,将尝试再次重新执行给定 functionretryValueFilter-1对于无限次的成功重试,将 设置为 ,直到retryValueFilter满足 。 0对于一次成功尝试,将 设置为 ,这将导致retryValueFilter被忽略,给定function的 仅在第一次成功之前执行一次。

maxNumErrorTries
Int32

由于错误而导致的最大执行尝试次数。 对于无限次的错误重试,设置为 -1,直到 retryExceptionFilter 满足 为止。

retryValueFilter
Func<T,Int32,Boolean>

用于指示是否应重试成功执行的筛选器 function 。 设置为 null 可禁用成功的重试。

retryExceptionFilter
Func<Exception,Int32,Boolean>

用于指示是否应重试错误执行的筛选器 function 。 设置为 null 可禁用错误重试。

onSuccessBackOff
IBackoffProvider

退避提供程序对象,用于确定在成功重试之间等待多少时间。

onErrorBackOff
IBackoffProvider

退避提供程序对象,用于确定错误重试之间的等待时间

返回

Task<T>

成功调用 function后返回的值。

适用于