Type Alias WithSharedLockFactorySettings<TParameters>

WithSharedLockFactorySettings: {
    key: Invokable<TParameters, string>;
    limit: number;
    lockId?: Invokable<TParameters, string>;
    ttl?: ITimeSpan | null;
    when: SharedLockWhenSetting;
}

Settings for the distributed shared-lock 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 lock key from the wrapped function's arguments. All consumers using the same key share the same lock state.

  • limit: number

    Maximum number of concurrent readers allowed when the lock is acquired in reader mode.

  • OptionallockId?: Invokable<TParameters, string>

    A function or static value that produces a unique identifier for the current lock acquisition attempt. The lock ID distinguishes competing consumers trying to acquire the same lock.

    import { v4 } from "uuid";

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

    Time-to-live for the lock. If null the lock never expires automatically. If omitted the default TTL of the shared-lock factory is used.

  • when: SharedLockWhenSetting

    Whether to acquire the lock in reader or writer mode.

    • "READER" — multiple readers can hold the lock concurrently.
    • "WRITER" — exclusive access; no other reader or writer can hold the lock.