0.0.1 • Published 4 months ago

@forts/resilience4ts-hedge v0.0.1

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

@forts/resilience4ts-hedge

Hedge pattern implementation for resilience4ts.

Installation

npm install @forts/resilience4ts-hedge

Usage

import { Hedge } from '@forts/resilience4ts-hedge';

const hedge = Hedge.of('my-hedge', {
  delay: 1000,
});

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

Options

const hedge = Hedge.of('my-hedge', {
  shouldHandle?: PredicateBuilder, // PredicateBuilder that determines whether the hedge should be applied.
  delay: number, // Delay in milliseconds before the hedge is executed.
  maxHedgedAttempts?: number, // Maximum number of attempts to execute the decorated method.
  actionGenerator?:
    | (<Args, Ret>(...args: Args extends unknown[] ? Args : [Args]) => Promise<Ret>)
    | null, // Function that returns the fallback result. Can accept the same arguments as the decorated method.
  exceptOnHedge?: boolean, // Whether to throw an exception if the hedge is executed.
});
0.0.1

4 months ago

0.0.0

4 months ago