Skip to main content

ExecUtils

Assembly: ServiceStack.Common.dll​
View Source​
Declaration
public static class ExecUtils

Properties​

BaseDelayMs​

Default base sleep time (milliseconds).

View Source​
Declaration
public static int BaseDelayMs { get; set; }

MaxBackOffMs​

Default maximum back-off time before retrying a request

View Source​
Declaration
public static int MaxBackOffMs { get; set; }

MaxRetries​

Maximum retry limit. Avoids integer overflow issues.

View Source​
Declaration
public static int MaxRetries { get; set; }

Methods​

LogError(Type, String, Exception)​

View Source​
Declaration
public static void LogError(Type declaringType, string clientMethodName, Exception ex)
Parameters​
TypeName
System.TypedeclaringType
System.StringclientMethodName
System.Exceptionex

ExecAll<T>(IEnumerable<T>, Action<T>)​

View Source​
Declaration
public static void ExecAll<T>(this IEnumerable<T> instances, Action<T> action)
Parameters​
TypeName
System.Collections.Generic.IEnumerable<<T>>instances
System.Action<<T>>action
Type Parameters​
  • T

ExecAllAsync<T>(IEnumerable<T>, Func<T, Task>)​

View Source​
Declaration
public static async Task ExecAllAsync<T>(this IEnumerable<T> instances, Func<T, Task> action)
Returns​

System.Threading.Tasks.Task

Parameters​
TypeName
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​
Declaration
public static async Task<TReturn> ExecAllReturnFirstAsync<T, TReturn>(this IEnumerable<T> instances, Func<T, Task<TReturn>> action)
Returns​

System.Threading.Tasks.Task<<TReturn>>

Parameters​
TypeName
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​
Declaration
public static void ExecAllWithFirstOut<T, TReturn>(this IEnumerable<T> instances, Func<T, TReturn> action, ref TReturn firstResult)
Parameters​
TypeName
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​
Declaration
public static TReturn ExecReturnFirstWithResult<T, TReturn>(this IEnumerable<T> instances, Func<T, TReturn> action)
Returns​

<TReturn>

Parameters​
TypeName
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​
Declaration
public static async Task<TReturn> ExecReturnFirstWithResultAsync<T, TReturn>(this IEnumerable<T> instances, Func<T, Task<TReturn>> action)
Returns​

System.Threading.Tasks.Task<<TReturn>>

Parameters​
TypeName
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​
Declaration
public static void RetryUntilTrue(Func<bool> action, TimeSpan? timeOut = null)
Parameters​
TypeName
System.Func<System.Boolean>action
System.Nullable<System.TimeSpan>timeOut

RetryUntilTrueAsync(Func<Task<Boolean>>, Nullable<TimeSpan>)​

View Source​
Declaration
public static async Task RetryUntilTrueAsync(Func<Task<bool>> action, TimeSpan? timeOut = null)
Returns​

System.Threading.Tasks.Task

Parameters​
TypeName
System.Func<System.Threading.Tasks.Task<System.Boolean>>action
System.Nullable<System.TimeSpan>timeOut

RetryOnException(Action, Nullable<TimeSpan>)​

View Source​
Declaration
public static void RetryOnException(Action action, TimeSpan? timeOut)
Parameters​
TypeName
System.Actionaction
System.Nullable<System.TimeSpan>timeOut

RetryOnExceptionAsync(Func<Task>, Nullable<TimeSpan>)​

View Source​
Declaration
public static async Task RetryOnExceptionAsync(Func<Task> action, TimeSpan? timeOut)
Returns​

System.Threading.Tasks.Task

Parameters​
TypeName
System.Func<System.Threading.Tasks.Task>action
System.Nullable<System.TimeSpan>timeOut

RetryOnException(Action, Int32)​

View Source​
Declaration
public static void RetryOnException(Action action, int maxRetries)
Parameters​
TypeName
System.Actionaction
System.Int32maxRetries

RetryOnExceptionAsync(Func<Task>, Int32)​

View Source​
Declaration
public static async Task RetryOnExceptionAsync(Func<Task> action, int maxRetries)
Returns​

System.Threading.Tasks.Task

Parameters​
TypeName
System.Func<System.Threading.Tasks.Task>action
System.Int32maxRetries

SleepBackOffMultiplier(Int32)​

How long to sleep before next retry using Exponential BackOff delay with Full Jitter.

View Source​
Declaration
public static void SleepBackOffMultiplier(int retriesAttempted)
Parameters​
TypeName
System.Int32retriesAttempted

DelayBackOffMultiplierAsync(Int32)​

How long to wait before next retry using Exponential BackOff delay with Full Jitter.

View Source​
Declaration
public static Task DelayBackOffMultiplierAsync(int retriesAttempted)
Returns​

System.Threading.Tasks.Task

Parameters​
TypeName
System.Int32retriesAttempted

CalculateFullJitterBackOffDelay(Int32)​

Exponential BackOff Delay with Full Jitter

View Source​
Declaration
public static int CalculateFullJitterBackOffDelay(int retriesAttempted)
Returns​

System.Int32

Parameters​
TypeName
System.Int32retriesAttempted

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​
Declaration
public static int CalculateFullJitterBackOffDelay(int retriesAttempted, int baseDelay, int maxBackOffMs)
Returns​

System.Int32

Parameters​
TypeName
System.Int32retriesAttempted
System.Int32baseDelay
System.Int32maxBackOffMs

CalculateExponentialDelay(Int32)​

Calculate exponential retry back-off.

View Source​
Declaration
public static int CalculateExponentialDelay(int retriesAttempted)
Returns​

System.Int32

Parameters​
TypeName
System.Int32retriesAttempted

CalculateExponentialDelay(Int32, Int32, Int32)​

Calculate exponential retry back-off.

View Source​
Declaration
public static int CalculateExponentialDelay(int retriesAttempted, int baseDelay, int maxBackOffMs)
Returns​

System.Int32

Parameters​
TypeName
System.Int32retriesAttempted
System.Int32baseDelay
System.Int32maxBackOffMs

CalculateMemoryLockDelay(Int32)​

Calculate back-off logic for obtaining an in memory lock

View Source​
Declaration
public static int CalculateMemoryLockDelay(int retries)
Returns​

System.Int32

Parameters​
TypeName
System.Int32retries

ShellExec(String, Dictionary<String, Object>)​

View Source​
Declaration
public static string ShellExec(string command, Dictionary<string, object> args = null)
Returns​

System.String

Parameters​
TypeName
System.Stringcommand
System.Collections.Generic.Dictionary<System.String,System.Object>args