Class Attempt

Attempt handler. This class organizes a retry context and policy so that handles some attempts

Hierarchy

  • Attempt

Constructors

Properties

requireDebugLogging: boolean = false
retryContext: RetryContext
retryEventListeners: RetryEventLister[] = []

Methods

  • Execute and handle error with retrying.

    Returns

    Type Parameters

    • T

    Parameters

    • producer: (() => T)
        • (): T
        • Returns T

    • Optional another: (() => T)
        • (): T
        • Returns T

    Returns T

  • Trys attempting and handles producers. If another is passed, exhausting attempts, execute another.

    Returns

    Type Parameters

    • T

    Parameters

    • producer: (() => Promise<T>)
        • (): Promise<T>
        • Returns Promise<T>

    • Optional another: (() => Promise<T>)
        • (): Promise<T>
        • Returns Promise<T>

    Returns Promise<T>

  • Executing producer until exhausting along with RetryPolicy.

    Returns

    Throws

    ExhaustedRetryException when exhausting producer.

    Type Parameters

    • T

    Parameters

    • producer: (() => T)
        • (): T
        • Returns T

    Returns T

  • Executing producer until exhausting along with RetryPolicy.

    Returns

    Promise

    Throws

    ExhaustedRetryException when exhausting producer

    Type Parameters

    • T

    Parameters

    • producer: (() => Promise<T>)
        • (): Promise<T>
        • Returns Promise<T>

    Returns Promise<T>

  • Executing producer until exhausting along with RetryPolicy. After exhausted, return default value.

    Returns

    Type Parameters

    • T

    Parameters

    • producer: (() => Promise<T>)
        • (): Promise<T>
        • Returns Promise<T>

    • defaultValue: T

    Returns Promise<T>

  • Executing producer until exhausting along with RetryPolicy. After exhausted, try to evaluate another function.

    Returns

    Type Parameters

    • T

    Parameters

    • producer: (() => Promise<T>)
        • (): Promise<T>
        • Returns Promise<T>

    • another: (() => Promise<T>)
        • (): Promise<T>
        • Returns Promise<T>

    Returns Promise<T>

  • Executing producer until exhausting along with RetryPolicy. Return a result of producer, or default value when exhausted.

    Returns

    Type Parameters

    • T

    Parameters

    • producer: (() => T)

      Producer function

        • (): T
        • Returns T

    • defaultValue: T

      Another result when attempt failed

    Returns T

  • Executing producer until exhausting along with RetryPolicy.

    Returns

    Type Parameters

    • T

    Parameters

    • producer: (() => T)
        • (): T
        • Returns T

    • Optional another: (() => T)
        • (): T
        • Returns T

    Returns T

  • Return true if this attempt has one or more listeners.

    Returns

    Returns boolean

  • Parameters

    • requireDebugLogging: boolean
    • message: string

    Returns void

Generated using TypeDoc