Search Results for

    Show / Hide Table of Contents

    Class RetrySupport

    This class provides the retry utility functions.

    Inheritance
    object
    RetrySupport
    Inherited Members
    object.Equals(object)
    object.Equals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    object.ReferenceEquals(object, object)
    object.ToString()
    Namespace: Akka.Pattern
    Assembly: Akka.dll
    Syntax
    public static class RetrySupport

    Methods

    | Edit this page View Source

    Retry<T>(Func<Task<T>>, int)

    Given a function, returns an internally retrying Task. The first attempt will be made immediately, each subsequent attempt will be made immediately if the previous attempt failed.

    If attempts are exhausted the returned Task is simply the result of invoking attempt.

    Declaration
    public static Task<T> Retry<T>(Func<Task<T>> attempt, int attempts)
    Parameters
    Type Name Description
    Func<Task<T>> attempt

    A function that produces the Task<TResult> to execute on each try.

    int attempts

    Maximum number of attempts to make before giving up.

    Returns
    Type Description
    Task<T>
    Type Parameters
    Name Description
    T
    | Edit this page View Source

    Retry<T>(Func<Task<T>>, int, Func<int, Option<TimeSpan>>, IScheduler)

    Given a function, returns an internally retrying Task. The first attempt will be made immediately, each subsequent attempt will be made after the 'delay' return by `delayFunction`(the input next attempt count start from 1). Returns None for no delay. A scheduler (eg Context.System.Scheduler) must be provided to delay each retry. You could provide a function to generate the next delay duration after first attempt, this function should never return `null`, otherwise an InvalidOperationException will be through.

    If attempts are exhausted the returned Task is simply the result of invoking attempt.

    Declaration
    public static Task<T> Retry<T>(Func<Task<T>> attempt, int attempts, Func<int, Option<TimeSpan>> delayFunction, IScheduler scheduler)
    Parameters
    Type Name Description
    Func<Task<T>> attempt

    A function that produces the Task<TResult> to execute on each try.

    int attempts

    Maximum number of attempts to make before giving up.

    Func<int, Option<TimeSpan>> delayFunction

    A function that receives the next attempt number (starting from 1) and returns an Option<T> delay before that attempt. Return None for no delay.

    IScheduler scheduler

    The scheduler instance to use.

    Returns
    Type Description
    Task<T>
    Type Parameters
    Name Description
    T
    | Edit this page View Source

    Retry<T>(Func<Task<T>>, int, TimeSpan, IScheduler)

    Given a function, returns an internally retrying Task. The first attempt will be made immediately, each subsequent attempt will be made after 'delay'. A scheduler (eg Context.System.Scheduler) must be provided to delay each retry.

    If attempts are exhausted the returned future is simply the result of invoking attempt.

    Declaration
    public static Task<T> Retry<T>(Func<Task<T>> attempt, int attempts, TimeSpan delay, IScheduler scheduler)
    Parameters
    Type Name Description
    Func<Task<T>> attempt

    A function that produces the Task<TResult> to execute on each try.

    int attempts

    Maximum number of attempts to make before giving up.

    TimeSpan delay

    The fixed duration to wait between retry attempts.

    IScheduler scheduler

    The scheduler instance to use.

    Returns
    Type Description
    Task<T>
    Type Parameters
    Name Description
    T
    | Edit this page View Source

    Retry<T>(Func<Task<T>>, int, TimeSpan, TimeSpan, double, IScheduler)

    Given a function, returns an internally retrying Task. The first attempt will be made immediately, each subsequent attempt will be made with a backoff time, if the previous attempt failed.

    If attempts are exhausted the returned Task is simply the result of invoking attempt.

    Declaration
    public static Task<T> Retry<T>(Func<Task<T>> attempt, int attempts, TimeSpan minBackoff, TimeSpan maxBackoff, double randomFactor, IScheduler scheduler)
    Parameters
    Type Name Description
    Func<Task<T>> attempt

    A function that produces the Task<TResult> to execute on each try.

    int attempts

    Maximum number of attempts to make before giving up.

    TimeSpan minBackoff

    minimum (initial) duration until the child actor will started again, if it is terminated.

    TimeSpan maxBackoff

    the exponential back-off is capped to this duration.

    double randomFactor

    after calculation of the exponential back-off an additional random delay based on this factor is added, e.g. 0.2 adds up to 20% delay. In order to skip this additional delay pass in 0.

    IScheduler scheduler

    The scheduler instance to use.

    Returns
    Type Description
    Task<T>
    Type Parameters
    Name Description
    T
    In this article
    • githubEdit this page
    • View Source
    Back to top
    Contribute
    • Project Chat
    • Discussion Forum
    • Source Code
    Support
    • Akka.NET Support Plans
    • Akka.NET Observability Tools
    • Akka.NET Training & Consulting
    Maintained By
    • Petabridge - The Akka.NET Company
    • Learn Akka.NET