Make any Async function that returns a promise retryable by with a configurable number of retries and interval between retries.
By default the function will retry 3 times with an interval of 500ms between retries. When the function still fails after the
configured number of retries the last error is thrown as inner exception.
When you do not want to throw an exception but return a default value instead you can specify the resolveOnTimeout option.
When this is ser with a value the function will return the specified value when the function still fails after the configured number of retries.
Type Parameters
T extends ((...args) => Promise<TReturn>)
TArgs = any
TReturn = any
Parameters
Optionaloptions: RetryableOptions<any>
An optional options object to configure the retry behavior
Returns MethodDecorator
MethodDecorator
Example
classMyClass { @retryable({ maxRetries:3, interval:500 }) asyncmyMethod() { // do something that might fail } }
Make any Async function that returns a promise retryable by with a configurable number of retries and interval between retries.
By default the function will retry 3 times with an interval of 500ms between retries. When the function still fails after the configured number of retries the last error is thrown as inner exception.
When you do not want to throw an exception but return a default value instead you can specify the
resolveOnTimeout
option. When this is ser with a value the function will return the specified value when the function still fails after the configured number of retries.