ExecUtils
Assembly: ServiceStack.Common.dll
View Source
public static class ExecUtils
Properties
BaseDelayMs
Default base sleep time (milliseconds).
View Source
public static int BaseDelayMs { get; set; }
MaxBackOffMs
Default maximum back-off time before retrying a request
View Source
public static int MaxBackOffMs { get; set; }
MaxRetries
Maximum retry limit. Avoids integer overflow issues.
View Source
public static int MaxRetries { get; set; }
Methods
LogError(Type, String, Exception)
View Source
public static void LogError(Type declaringType, string clientMethodName, Exception ex)
Parameters
Type | Name |
---|---|
System.Type | declaringType |
System.String | clientMethodName |
System.Exception | ex |
ExecAll<T>(IEnumerable<T>, Action<T>)
View Source
public static void ExecAll<T>(this IEnumerable<T> instances, Action<T> action)
Parameters
Type | Name |
---|---|
System.Collections.Generic.IEnumerable<<T>> | instances |
System.Action<<T>> | action |
Type Parameters
T
ExecAllAsync<T>(IEnumerable<T>, Func<T, Task>)
View Source
public static async Task ExecAllAsync<T>(this IEnumerable<T> instances, Func<T, Task> action)
Returns
System.Threading.Tasks.Task
Parameters
Type | Name |
---|---|
System.Collections.Generic.IEnumerable<<T>> | instances |
System.Func<<T>,System.Threading.Tasks.Task> | action |
Type Parameters
T
ExecAllReturnFirstAsync<T, TReturn>(IEnumerable<T>, Func<T, Task<TReturn>>)
View Source
public static async Task<TReturn> ExecAllReturnFirstAsync<T, TReturn>(this IEnumerable<T> instances, Func<T, Task<TReturn>> action)
Returns
System.Threading.Tasks.Task<<TReturn>>
Parameters
Type | Name |
---|---|
System.Collections.Generic.IEnumerable<<T>> | instances |
System.Func<<T>,System.Threading.Tasks.Task<<TReturn>>> | action |
Type Parameters
T
TReturn
ExecAllWithFirstOut<T, TReturn>(IEnumerable<T>, Func<T, TReturn>, ref TReturn)
View Source
public static void ExecAllWithFirstOut<T, TReturn>(this IEnumerable<T> instances, Func<T, TReturn> action, ref TReturn firstResult)
Parameters
Type | Name |
---|---|
System.Collections.Generic.IEnumerable<<T>> | instances |
System.Func<<T>,<TReturn>> | action |
<TReturn> | firstResult |
Type Parameters
T
TReturn
ExecReturnFirstWithResult<T, TReturn>(IEnumerable<T>, Func<T, TReturn>)
View Source
public static TReturn ExecReturnFirstWithResult<T, TReturn>(this IEnumerable<T> instances, Func<T, TReturn> action)
Returns
<TReturn>
Parameters
Type | Name |
---|---|
System.Collections.Generic.IEnumerable<<T>> | instances |
System.Func<<T>,<TReturn>> | action |
Type Parameters
T
TReturn
ExecReturnFirstWithResultAsync<T, TReturn>(IEnumerable<T>, Func<T, Task<TReturn>>)
View Source
public static async Task<TReturn> ExecReturnFirstWithResultAsync<T, TReturn>(this IEnumerable<T> instances, Func<T, Task<TReturn>> action)
Returns
System.Threading.Tasks.Task<<TReturn>>
Parameters
Type | Name |
---|---|
System.Collections.Generic.IEnumerable<<T>> | instances |
System.Func<<T>,System.Threading.Tasks.Task<<TReturn>>> | action |
Type Parameters
T
TReturn
RetryUntilTrue(Func<Boolean>, Nullable<TimeSpan>)
View Source
public static void RetryUntilTrue(Func<bool> action, TimeSpan? timeOut = null)
Parameters
Type | Name |
---|---|
System.Func<System.Boolean> | action |
System.Nullable<System.TimeSpan> | timeOut |
RetryUntilTrueAsync(Func<Task<Boolean>>, Nullable<TimeSpan>)
View Source
public static async Task RetryUntilTrueAsync(Func<Task<bool>> action, TimeSpan? timeOut = null)
Returns
System.Threading.Tasks.Task
Parameters
Type | Name |
---|---|
System.Func<System.Threading.Tasks.Task<System.Boolean>> | action |
System.Nullable<System.TimeSpan> | timeOut |
RetryOnException(Action, Nullable<TimeSpan>)
View Source
public static void RetryOnException(Action action, TimeSpan? timeOut)
Parameters
Type | Name |
---|---|
System.Action | action |
System.Nullable<System.TimeSpan> | timeOut |
RetryOnExceptionAsync(Func<Task>, Nullable<TimeSpan>)
View Source
public static async Task RetryOnExceptionAsync(Func<Task> action, TimeSpan? timeOut)
Returns
System.Threading.Tasks.Task
Parameters
Type | Name |
---|---|
System.Func<System.Threading.Tasks.Task> | action |
System.Nullable<System.TimeSpan> | timeOut |
RetryOnException(Action, Int32)
View Source
public static void RetryOnException(Action action, int maxRetries)
Parameters
Type | Name |
---|---|
System.Action | action |
System.Int32 | maxRetries |
RetryOnExceptionAsync(Func<Task>, Int32)
View Source
public static async Task RetryOnExceptionAsync(Func<Task> action, int maxRetries)
Returns
System.Threading.Tasks.Task
Parameters
Type | Name |
---|---|
System.Func<System.Threading.Tasks.Task> | action |
System.Int32 | maxRetries |
SleepBackOffMultiplier(Int32)
How long to sleep before next retry using Exponential BackOff delay with Full Jitter.
View Source
public static void SleepBackOffMultiplier(int retriesAttempted)
Parameters
Type | Name |
---|---|
System.Int32 | retriesAttempted |
DelayBackOffMultiplierAsync(Int32)
How long to wait before next retry using Exponential BackOff delay with Full Jitter.
View Source
public static Task DelayBackOffMultiplierAsync(int retriesAttempted)
Returns
System.Threading.Tasks.Task
Parameters
Type | Name |
---|---|
System.Int32 | retriesAttempted |
CalculateFullJitterBackOffDelay(Int32)
Exponential BackOff Delay with Full Jitter
View Source
public static int CalculateFullJitterBackOffDelay(int retriesAttempted)
Returns
System.Int32
Parameters
Type | Name |
---|---|
System.Int32 | retriesAttempted |
CalculateFullJitterBackOffDelay(Int32, Int32, Int32)
Exponential BackOff Delay with Full Jitter from: https://github.com/aws/aws-sdk-java/blob/master/aws-java-sdk-core/src/main/java/com/amazonaws/retry/PredefinedBackoffStrategies.java
View Source
public static int CalculateFullJitterBackOffDelay(int retriesAttempted, int baseDelay, int maxBackOffMs)
Returns
System.Int32
Parameters
Type | Name |
---|---|
System.Int32 | retriesAttempted |
System.Int32 | baseDelay |
System.Int32 | maxBackOffMs |
CalculateExponentialDelay(Int32)
Calculate exponential retry back-off.
View Source
public static int CalculateExponentialDelay(int retriesAttempted)
Returns
System.Int32
Parameters
Type | Name |
---|---|
System.Int32 | retriesAttempted |
CalculateExponentialDelay(Int32, Int32, Int32)
Calculate exponential retry back-off.
View Source
public static int CalculateExponentialDelay(int retriesAttempted, int baseDelay, int maxBackOffMs)
Returns
System.Int32
Parameters
Type | Name |
---|---|
System.Int32 | retriesAttempted |
System.Int32 | baseDelay |
System.Int32 | maxBackOffMs |
CalculateMemoryLockDelay(Int32)
Calculate back-off logic for obtaining an in memory lock
View Source
public static int CalculateMemoryLockDelay(int retries)
Returns
System.Int32
Parameters
Type | Name |
---|---|
System.Int32 | retries |
ShellExec(String, Dictionary<String, Object>)
View Source
public static string ShellExec(string command, Dictionary<string, object> args = null)
Returns
System.String
Parameters
Type | Name |
---|---|
System.String | command |
System.Collections.Generic.Dictionary<System.String,System.Object> | args |