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.
Example
Section titled “Example”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 }), ); }}Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new ResiliencePolicies(
options?,logger?):ResiliencePolicies
Defined in: packages/pipeline-resilience/src/resilience-policies.ts:37
Parameters
Section titled “Parameters”options?
Section titled “options?”Record<string, ResiliencePolicyOptions>
logger?
Section titled “logger?”Returns
Section titled “Returns”ResiliencePolicies
Accessors
Section titled “Accessors”Get Signature
Section titled “Get Signature”get names(): readonly
string[]
Defined in: packages/pipeline-resilience/src/resilience-policies.ts:48
The declared policy names, in declaration order.
Returns
Section titled “Returns”readonly string[]
Methods
Section titled “Methods”execute()
Section titled “execute()”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.
Type Parameters
Section titled “Type Parameters”T
Parameters
Section titled “Parameters”string
(context) => T | PromiseLike<T>
Returns
Section titled “Returns”Promise<T>
Throws
Section titled “Throws”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.
Parameters
Section titled “Parameters”string
Returns
Section titled “Returns”Throws
Section titled “Throws”ResiliencePolicyConfigurationError when no policy has that name.