@forts/resilience4ts-concurrent-lock
TypeScript icon, indicating that this package has built-in type declarations

0.0.1 • Public • Published

@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.
});

Readme

Keywords

none

Package Sidebar

Install

npm i @forts/resilience4ts-concurrent-lock

Weekly Downloads

1

Version

0.0.1

License

MIT

Unpacked Size

18.1 kB

Total Files

33

Last publish

Collaborators

  • jmhegarty14