Examples

Example 1

import { ResiliencePlugin } from '@setu-ts/resilience-plugin';
import type { IResilienceService } from '@setu-ts/common';

app.register(ResiliencePlugin({
  defaultRetry: { limit: 3, delay: 100, backoff: 'exponential' },
}));

const resilience = ctx.services.get<IResilienceService>('resilience');
const guarded = resilience.wrap(() => externalApi.call(), { retry: true, timeout: 2000 });

Classes

c
BulkheadFullError(message?: string)

Thrown when a bulkhead is at maximum concurrency and its queue is full, so the call is shed (fail-fast load shedding) rather than executed or queued.

c
CircuitOpenError(message?: string)

Thrown when a circuit breaker is open and fails fast without invoking the protected call.

c
TimeoutError(message?: string)

Thrown when a protected call exceeds its per-attempt timeout deadline.

Functions

Interfaces

I
ResiliencePluginOptions

Options passed to ResiliencePlugin(). Each default* policy is consumed when a wrap sets the matching field to true; a wrap requesting true with no matching default configured throws.

Usage

import * as Resilience_patterns_plugin__circuit_breaker__retry__timeout__and_bulkhead_composed_around_an_arbitrary________Promise_T___under_the__CAPABILITIES_RESILIENCE_____resilience____capability__ from "resilience-plugin/src/index.ts";