• Factory that constructs a nevermore strategy pipeline from provided options, and returns a createExecutor function. Create a limited version of your function like...

    import { createExecutorStrategy } from "@watchable/nevermore";

    const { createExecutor } = createExecutorStrategy({
    concurrency: 1,
    intervalMs: 100,
    backoffMs: 1000,
    timeoutMs: 3000,
    retries: 3,
    })

    const limitedMyFn = createExecutor(myFn);

    Given your existing, typed async operation, createExecutor creates an identically-typed operation that schedules its execution within the capacity limits and behaviours of the pipeline.

    For example...

    • concurrency, rate-limits: executors will delay if other executors are already using the capacity
    • timeout : if the underlying operation takes too long, the executor will throw a timeout error
    • retry : the underlying operation is retried and the executor only throws when retries are exhausted

    See documentation of NevermoreOptions for more on the available behaviours.

    Parameters

    Returns {
        createExecutor: (<Args, Ret>(op) => ((...args) => Promise<Ret>));
    }

    • createExecutor: (<Args, Ret>(op) => ((...args) => Promise<Ret>))
        • <Args, Ret>(op): ((...args) => Promise<Ret>)
        • Create type-safe substitute for op that executes it in the strategy pipeline associating callbacks that settle eventual result for original caller.

          Type Parameters

          • Args extends unknown[]
          • Ret

          Parameters

          • op: ((...args) => Promise<Ret>)
              • (...args): Promise<Ret>
              • Parameters

                Returns Promise<Ret>

          Returns ((...args) => Promise<Ret>)

            • (...args): Promise<Ret>
            • Parameters

              Returns Promise<Ret>