kinetex - v1.4.0
    Preparing search index...

    Class ConcurrencyLimiter

    A counting semaphore bounding how many requests may be in flight at once.

    The rate limiter is a token bucket: it releases a token at dispatch, so limit: 100 per minute still permits 100 simultaneous sockets. This bounds concurrency instead — a permit is held for the whole request (including its retries) and returned only when it settles.

    Permits are handed directly to the next waiter on release, so releasing never transiently overshoots ConcurrencyLimitConfig.maxConcurrent.

    const limiter = new ConcurrencyLimiter({ maxConcurrent: 4 });
    await limiter.acquire();
    try {
    await doWork();
    } finally {
    limiter.release();
    }
    Index
    • get waiting(): number

      Number of requests currently waiting for a permit.

      Returns number

    • get highWaterMark(): number

      Highest concurrent in-flight count observed.

      Returns number

    • Take a permit, waiting in the queue if the limit is saturated.

      Parameters

      • Optionalsignal: AbortSignal | null

        Optional abort signal; aborting while queued removes the waiter and rejects without ever consuming a permit.

      Returns Promise<void>

      If queueing is disabled or the queue is full.

      With code EABORT if signal aborts while queued — the same contract every other abort path in the library offers, so err.code === "EABORT" and err.isAbort work here too.

    • Return a permit taken by acquire.

      The permit is handed to the longest-waiting caller, so inFlight never exceeds maxConcurrent. Releasing with nothing held is a no-op.

      Returns void

    • Drop every queued waiter, rejecting them with reason.

      Used by Kinetex.destroy so a shutdown cannot leave callers parked on a queue that will never drain.

      Parameters

      • reason: Error = ...

        Error to reject waiters with.

      Returns void