0.0.1 • Published 4 months ago

@forts/resilience4ts-concurrent-lock v0.0.1

Weekly downloads
-
License
MIT
Repository
-
Last release
4 months ago

@forts/resilience4ts-concurrent-lock

Concurrent lock pattern implementation for resilience4ts.

Installation

npm install @forts/resilience4ts-concurrent-lock

Usage

import { ConcurrentLock } from '@forts/resilience4ts-concurrent-lock';

const lock = ConcurrentLock.of('my-lock', {
  withKey: (...args: Parameters<MyDecoratedMethod>) => UniqueId,
});

const result = await lock.on(async () => {
  // do something
});

Options

const lock = ConcurrentLock.of('my-lock', {
  withKey: (...args: Parameters<MyDecoratedMethod>) => UniqueId, // Function that returns a unique id for the call from the decorated function args.
  duration: number, // Duration in milliseconds to wait for the lock to be released.
  driftFactor: number, // Drift factor to use for the lock.
  refreshInterval: number, // Interval in milliseconds to refresh the lock for executions that run beyond the configured duration. Only applies if the lock is extensible.
  extensible: boolean, // Whether the lock is extensible.
});
0.0.1

4 months ago

0.0.0

4 months ago