Understand the IPolicy interface
masterAll Cockatiel fault handling policies (fallbacks, circuit breakers, bulkheads, timeouts, retries) implement the IPolicy interface.
Key features:
execute<T>(fn, signal): The primary method to run a function through the policy's behavior. It returns aPromise<T>. You can optionally pass anAbortSignal.onSuccess: An event that fires when a request successfully completes. In a retry policy, this fires once even if multiple retries occurred.onFailure: An event that fires when a request fails due to a handled reason. Cockatiel does not treat all thrown errors as failures; you must define which errors the policy should handle.
Note: The context object passed to the function in execute contains metadata (like AbortSignal or retry attempt numbers) depending on the policies applied.