Type Alias WithSemaphoreSettings<TParameters>

WithSemaphoreSettings: {
    key: Invokable<TParameters, string>;
    limit: number;
    slotId?: Invokable<TParameters, string>;
    ttl?: ITimeSpan | null;
}

Settings for the distributed-semaphore middleware.

Type Parameters

  • TParameters extends unknown[] = unknown[]

    Tuple type of the wrapped function's parameters.

Type declaration

  • key: Invokable<TParameters, string>

    A function or static value that produces the semaphore key from the wrapped function's arguments. All consumers using the same key share the same semaphore limit.

  • limit: number

    Maximum number of concurrent slots (consumers) allowed for the semaphore key.

  • OptionalslotId?: Invokable<TParameters, string>

    A function or static value that produces a unique slot identifier for the current acquisition attempt. Each concurrent consumer needs a distinct slot ID.

    import { v4 } from "uuid";

    () => v4()
  • Optionalttl?: ITimeSpan | null

    Time-to-live for each acquired slot. If null slots never expire automatically. If omitted the default TTL of the semaphore factory is used.