Class RetryUtil
Utilities for retries.
Inherited Members
Namespace: Cognite.Extractor.Common
Assembly: Cognite.Common.dll
Syntax
public static class RetryUtil
Methods
| Edit this page View SourceRetryAsync(string, Action, RetryUtilConfig, Func<Exception, bool>, ILogger, CancellationToken)
Retry the given method based on config
.
Declaration
public static Task RetryAsync(string name, Action generator, RetryUtilConfig config, Func<Exception, bool> shouldRetry, ILogger logger, CancellationToken token)
Parameters
Type | Name | Description |
---|---|---|
string | name | Name of the task being retried, for logging. |
Action | generator | Method called once per retry. |
RetryUtilConfig | config | Retry config |
Func<Exception, bool> | shouldRetry | A method returning true if the method should continue after the given exception was thrown. |
ILogger | logger | Logger logging information about retries. |
CancellationToken | token | Cancellation token |
Returns
Type | Description |
---|---|
Task |
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
RetryAsync(string, Action, RetryUtilConfig, CancellationToken)
Retry the given method based on config
.
Declaration
public static Task RetryAsync(string name, Action generator, RetryUtilConfig config, CancellationToken token)
Parameters
Type | Name | Description |
---|---|---|
string | name | Name of the task being retried, for logging. |
Action | generator | Method called once per retry. |
RetryUtilConfig | config | Retry config |
CancellationToken | token | Cancellation token |
Returns
Type | Description |
---|---|
Task |
RetryAsync(string, Func<Task>, RetryUtilConfig, Func<Exception, bool>, ILogger, CancellationToken)
Retry the given method based on config
.
Declaration
public static Task RetryAsync(string name, Func<Task> generator, RetryUtilConfig config, Func<Exception, bool> shouldRetry, ILogger logger, CancellationToken token)
Parameters
Type | Name | Description |
---|---|---|
string | name | Name of the task being retried, for logging. |
Func<Task> | generator | Method returning a task, called once per retry. |
RetryUtilConfig | config | Retry config |
Func<Exception, bool> | shouldRetry | A method returning true if the method should continue after the given exception was thrown. |
ILogger | logger | Logger logging information about retries. |
CancellationToken | token | Cancellation token |
Returns
Type | Description |
---|---|
Task |
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
RetryAsync(string, Func<Task>, RetryUtilConfig, CancellationToken)
Retry the given method based on config
.
Declaration
public static Task RetryAsync(string name, Func<Task> generator, RetryUtilConfig config, CancellationToken token)
Parameters
Type | Name | Description |
---|---|---|
string | name | Name of the task being retried, for logging. |
Func<Task> | generator | Method returning a task, called once per retry. |
RetryUtilConfig | config | Retry config |
CancellationToken | token | Cancellation token |
Returns
Type | Description |
---|---|
Task |
RetryResultAsync<T>(string, Func<Task<T>>, RetryUtilConfig, Func<Exception, bool>, ILogger, CancellationToken)
Retry the given method based on config
, return a result of type T
.
Declaration
public static Task<T> RetryResultAsync<T>(string name, Func<Task<T>> generator, RetryUtilConfig config, Func<Exception, bool> shouldRetry, ILogger logger, CancellationToken token)
Parameters
Type | Name | Description |
---|---|---|
string | name | Name of the task being retried, for logging. |
Func<Task<T>> | generator | Method returning a task, called once per retry. |
RetryUtilConfig | config | Retry config |
Func<Exception, bool> | shouldRetry | A method returning true if the method should continue after the given exception was thrown. |
ILogger | logger | Logger logging information about retries. |
CancellationToken | token | Cancellation token |
Returns
Type | Description |
---|---|
Task<T> |
Type Parameters
Name | Description |
---|---|
T |
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
RetryResultAsync<T>(string, Func<Task<T>>, RetryUtilConfig, CancellationToken)
Retry the given method based on config
, return a result of type T
.
Declaration
public static Task<T> RetryResultAsync<T>(string name, Func<Task<T>> generator, RetryUtilConfig config, CancellationToken token)
Parameters
Type | Name | Description |
---|---|---|
string | name | Name of the task being retried, for logging. |
Func<Task<T>> | generator | Method returning a task, called once per retry. |
RetryUtilConfig | config | Retry config |
CancellationToken | token | Cancellation token |
Returns
Type | Description |
---|---|
Task<T> |
Type Parameters
Name | Description |
---|---|
T |
RetryResultAsync<T>(string, Func<T>, RetryUtilConfig, Func<Exception, bool>, ILogger, CancellationToken)
Retry the given method based on config
, return a result of type T
.
Declaration
public static Task<T> RetryResultAsync<T>(string name, Func<T> generator, RetryUtilConfig config, Func<Exception, bool> shouldRetry, ILogger logger, CancellationToken token)
Parameters
Type | Name | Description |
---|---|---|
string | name | Name of the task being retried, for logging. |
Func<T> | generator | Method called once per retry. |
RetryUtilConfig | config | Retry config |
Func<Exception, bool> | shouldRetry | A method returning true if the method should continue after the given exception was thrown. |
ILogger | logger | Logger logging information about retries. |
CancellationToken | token | Cancellation token |
Returns
Type | Description |
---|---|
Task<T> |
Type Parameters
Name | Description |
---|---|
T |
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
RetryResultAsync<T>(string, Func<T>, RetryUtilConfig, CancellationToken)
Retry the given method based on config
, return a result of type T
.
Declaration
public static Task<T> RetryResultAsync<T>(string name, Func<T> generator, RetryUtilConfig config, CancellationToken token)
Parameters
Type | Name | Description |
---|---|---|
string | name | Name of the task being retried, for logging. |
Func<T> | generator | Method called once per retry. |
RetryUtilConfig | config | Retry config |
CancellationToken | token | Cancellation token |
Returns
Type | Description |
---|---|
Task<T> |
Type Parameters
Name | Description |
---|---|
T |