Skip to content

ResiliencePolicyOptions

Defined in: packages/pipeline-resilience/src/interfaces/resilience-options.interface.ts:231

A named policy for an outbound dependency, declared once in new ResiliencePolicies({ ... }) and shared by every caller through ResiliencePolicies or @InjectResiliencePolicy(name).

It wraps one outbound call, not a handler, so it offers every layer — a circuit breaker per dependency, a fallback value for one call — and needs no replaySafe acknowledgment: the adapter retries only its own call. Retry, circuit breaker and fallback still require handle(error) or handleAllErrors: true.

A payment API shared by several handlers

new ResiliencePolicies({
paymentsApi: {
handle: (error) => error instanceof PaymentGatewayUnavailableError,
retry: { maxAttempts: 2, backoff: { type: 'exponential' } },
circuitBreaker: { halfOpenAfter: 30_000, breaker: { type: 'consecutive', threshold: 5 } },
timeout: { duration: 3_000, strategy: 'cooperative' },
},
});

optional bulkhead?: BulkheadOptions

Defined in: packages/pipeline-resilience/src/interfaces/resilience-options.interface.ts:237

Concurrency limit, shared by every caller of the policy.


optional circuitBreaker?: CircuitBreakerOptions

Defined in: packages/pipeline-resilience/src/interfaces/resilience-options.interface.ts:235

Circuit breaker, shared by every caller of the policy.


optional fallback?: FallbackOptions

Defined in: packages/pipeline-resilience/src/interfaces/resilience-options.interface.ts:241

Value returned in place of a handled failure.


optional handle?: (error) => boolean

Defined in: packages/pipeline-resilience/src/interfaces/resilience-options.interface.ts:243

Selects the errors retry, circuit breaker and fallback act on.

unknown

boolean


optional handleAllErrors?: boolean

Defined in: packages/pipeline-resilience/src/interfaces/resilience-options.interface.ts:245

Acts on every error; set it only deliberately.


optional order?: ResilienceLayer[]

Defined in: packages/pipeline-resilience/src/interfaces/resilience-options.interface.ts:251

Composition order, outermost first.

['fallback', 'retry', 'circuitBreaker', 'bulkhead', 'timeout']

optional retry?: RetryPolicyOptions

Defined in: packages/pipeline-resilience/src/interfaces/resilience-options.interface.ts:233

Retry the call.


optional telemetry?: ResilienceTelemetry

Defined in: packages/pipeline-resilience/src/interfaces/resilience-options.interface.ts:253

Telemetry hooks; every event carries the policy name.


optional timeout?: TimeoutPolicyOptions

Defined in: packages/pipeline-resilience/src/interfaces/resilience-options.interface.ts:239

Timeout of one call.