Options
All
  • Public
  • Public/Protected
  • All
Menu

Module utils/load-balance

Index

Functions

Const loadBalance

  • loadBalance<F, First>(fn: F, values: First[], retries?: number): (...args: Parameters<OmitFirstArg<F>>) => Promise<Await<ReturnType<F>>>
  • Perform a function call with sequenced first argument, useful for load balancing node calls. This will retry up to retries times if an error occurs.

    Type parameters

    • F: (first: First, ...args: any[]) => Promise<any>

    • First

    Parameters

    • fn: F
    • values: First[]
    • retries: number = 3

    Returns (...args: Parameters<OmitFirstArg<F>>) => Promise<Await<ReturnType<F>>>

      • (...args: Parameters<OmitFirstArg<F>>): Promise<Await<ReturnType<F>>>
      • Parameters

        • Rest ...args: Parameters<OmitFirstArg<F>>

        Returns Promise<Await<ReturnType<F>>>

roundRobin

  • roundRobin<T>(array: T[]): Generator<T, T>
  • Loop through an array sequentially. This will create a generator that never completes.

    Type parameters

    • T

    Parameters

    • array: T[]

    Returns Generator<T, T>

Generated using TypeDoc