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

0.0.1 • Public • Published

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

Readme

Keywords

none

Package Sidebar

Install

npm i @forts/resilience4ts-fallback

Weekly Downloads

0

Version

0.0.1

License

MIT

Unpacked Size

11.6 kB

Total Files

18

Last publish

Collaborators

  • jmhegarty14