Class NoRetryPolicy
Implements an IRetryPolicy that does not attempt to retry operations.
Implements
Namespace: Neon.Retry
Assembly: Neon.Common.dll
Syntax
public class NoRetryPolicy : IRetryPolicy
Constructors
NoRetryPolicy()
Constructor.
Declaration
public NoRetryPolicy()
Properties
Instance
Returns a global invariant instance.
Declaration
public static NoRetryPolicy Instance { get; }
Property Value
Type | Description |
---|---|
NoRetryPolicy |
Timeout
Returns the optional policy timeout. When present, this specifies the maximum time the policy will continue retrying the operation.
Declaration
public TimeSpan? Timeout { get; }
Property Value
Type | Description |
---|---|
TimeSpan? |
Methods
Clone(Func<Exception, bool>)
Returns a copy of the retry policy.
Declaration
public IRetryPolicy Clone(Func<Exception, bool> transientDetector = null)
Parameters
Type | Name | Description |
---|---|---|
Func<Exception, bool> | transientDetector | Optionally specifies a replacement transient detector function that will be set in the cloned policy. |
Returns
Type | Description |
---|---|
IRetryPolicy | The policy copy. |
Invoke(Action, CancellationToken)
Retries a synchronous action that returns no result when it throws exceptions due to transient errors. The classification of what is a transient error, the interval between the retries as well as the number of times the operation are retried are determined by the policy implementation.
Declaration
public void Invoke(Action action, CancellationToken cancellationToken = default)
Parameters
Type | Name | Description |
---|---|---|
Action | action | The synchronous action to be performed. |
CancellationToken | cancellationToken | Optionally specifies a cancellation token. |
InvokeAsync(Func<Task>, CancellationToken)
Retries an asynchronous action that returns no result when it throws exceptions due to transient errors. The classification of what is a transient error, the interval between the retries as well as the number of times the operation are retried are determined by the policy implementation.
Declaration
public Task InvokeAsync(Func<Task> action, CancellationToken cancellationToken = default)
Parameters
Type | Name | Description |
---|---|---|
Func<Task> | action | The asynchronous action to be performed. |
CancellationToken | cancellationToken | Optionally specifies a cancellation token. |
Returns
Type | Description |
---|---|
Task |
InvokeAsync<TResult>(Func<Task<TResult>>, CancellationToken)
Retries an asynchronous action that returns TResult when it throws exceptions due to transient errors. he classification of what is a transient error, the interval between the retries as well as the number of times the operation are retried are determined by the policy implementation.
Declaration
public Task<TResult> InvokeAsync<TResult>(Func<Task<TResult>> action, CancellationToken cancellationToken = default)
Parameters
Type | Name | Description |
---|---|---|
Func<Task<TResult>> | action | The asynchronous action to be performed. |
CancellationToken | cancellationToken | Optionally specifies a cancellation token. |
Returns
Type | Description |
---|---|
Task<TResult> | The action result. |
Type Parameters
Name | Description |
---|---|
TResult | The action result type. |
Invoke<TResult>(Func<TResult>, CancellationToken)
Retries a synchronous action that returns a result when it throws exceptions due to transient errors. The classification of what is a transient error, the interval between the retries as well as the number of times the operation are retried are determined by the policy implementation.
Declaration
public TResult Invoke<TResult>(Func<TResult> action, CancellationToken cancellationToken = default)
Parameters
Type | Name | Description |
---|---|---|
Func<TResult> | action | The synchronous action to be performed. |
CancellationToken | cancellationToken | Optionally specifies a cancellation token. |
Returns
Type | Description |
---|---|
TResult | The action result. |
Type Parameters
Name | Description |
---|---|
TResult | The action result type. |
Events
OnTransient
Used to intercept and handle logging for transient exceptions detected by a retry policy. Handlers can set Handled in the argument passed to prevent subsequent handlers from being invoked and also prevent the transient exception from being logged.
When no handlers are added to this event, the default behavior is to log all transient failures.
Declaration
public event Action<RetryTransientArgs> OnTransient
Event Type
Type | Description |
---|---|
Action<RetryTransientArgs> |