A class that can be used to make async calls with concurrency and retry logic.

This is useful for making calls to any kind of "expensive" external resource, be it because it's rate-limited, subject to network issues, etc.

Concurrent calls are limited by the maxConcurrency parameter, which defaults to Infinity. This means that by default, all calls will be made in parallel.

Retries are limited by the maxRetries parameter, which defaults to 6. This means that by default, each call will be retried up to 6 times, with an exponential backoff between each attempt.

Hierarchy

  • AsyncCaller

Constructors

Properties

queue: default<any, any>
maxConcurrency: undefined | number
maxRetries: undefined | number
onFailedAttempt: undefined | FailedAttemptHandler

Methods

  • Type Parameters

    • A extends any[]

    • T extends ((...args) => Promise<any>)

    Parameters

    • callable: T
    • Rest ...args: Parameters<T>

    Returns Promise<Awaited<ReturnType<T>>>

  • Type Parameters

    • A extends any[]

    • T extends ((...args) => Promise<any>)

    Parameters

    Returns Promise<Awaited<ReturnType<T>>>

Generated using TypeDoc