0.0.1 • Published 4 months ago

@forts/resilience4ts-fallback v0.0.1

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

@forts/resilience4ts-fallback

fallback pattern implementation for resilience4ts.

Installation

npm install @forts/resilience4ts-fallback

Usage

import { Fallback } from '@forts/resilience4ts-fallback';

const fallback = Fallback.of('my-fallback', {
  shouldHandle?: PredicateBuilder,
  fallbackAction: (...args: Parameters<MyDecoratedMethod>[]) => Promise<MyDecoratedMethodReturn> | MyDecoratedMethodReturn,
});

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

Options

const fallback = Fallback.of('my-fallback', {
  shouldHandle?: PredicateBuilder, // PredicateBuilder that determines whether the fallback should be applied.
  fallbackAction: (...args: Parameters<MyDecoratedMethod>[]) => Promise<MyDecoratedMethodReturn> | MyDecoratedMethodReturn, // Function that returns the fallback result. Can accept the same arguments as the decorated method.
});
0.0.1

4 months ago

0.0.0

4 months ago