Μετάβαση στο περιεχόμενο

ResiliencePolicies

Αυτό το περιεχόμενο δεν είναι ακόμη διαθέσιμο στη γλώσσα σου.

Defined in: packages/pipeline-resilience/src/resilience-policies.ts:34

The named policies of the application, for outbound adapters: a payment API client, an SMTP sender, a partner webhook.

Every policy declared in the constructor’s options is built once, when this registry is created at startup, and shared by every caller — so a circuit breaker or bulkhead tracks the dependency, whatever handler calls it. An invalid policy fails startup with ResiliencePolicyConfigurationError.

An adapter running its call through a shared policy

export class PaymentsClient {
constructor(private readonly policies: ResiliencePolicies) {}
charge(order: Order): Promise<Receipt> {
return this.policies.execute('paymentsApi', ({ signal }) =>
this.http.post('/charges', order, { signal }),
);
}
}

new ResiliencePolicies(options?, logger?): ResiliencePolicies

Defined in: packages/pipeline-resilience/src/resilience-policies.ts:37

Record<string, ResiliencePolicyOptions>

PipelineLogger

ResiliencePolicies

get names(): readonly string[]

Defined in: packages/pipeline-resilience/src/resilience-policies.ts:48

The declared policy names, in declaration order.

readonly string[]

execute<T>(name, fn): Promise<T>

Defined in: packages/pipeline-resilience/src/resilience-policies.ts:77

Runs fn through the policy declared under name. fn receives the policy’s signal, aborted on a cooperative timeout: pass it to the outbound call so the call really stops. With a fallback, the fallback value is returned in place of a handled failure.

T

string

(context) => T | PromiseLike<T>

Promise<T>

ResiliencePolicyConfigurationError when no policy has that name.


get(name): AnyPolicy

Defined in: packages/pipeline-resilience/src/resilience-policies.ts:57

Returns the shared cockatiel policy declared under name.

string

AnyPolicy

ResiliencePolicyConfigurationError when no policy has that name.