Getting Started with Resilience
This guide walks you through the most common use cases for the Resilience library, from simple function wrapping to adding retries and timeouts.Wrapping Your First Function
Start by wrapping an async function with basic resilience features. The
withResilience function converts any function into a resilient version.The
withResilience function always returns an async function, even if your original function is synchronous.Adding Retries
Network calls can fail temporarily. Add automatic retries to handle transient failures:This will attempt the function up to 4 times total (1 initial attempt + 3 retries) before throwing an error.
Configuring Backoff Strategies
Add delays between retries to avoid overwhelming a failing service.
- Fixed Backoff
- Exponential Backoff
Wait the same amount of time between each retry:
Common Patterns
Database Queries
API Calls
Synchronous Functions
You can wrap synchronous functions too, but note they become async:Next Steps
Metrics Tracking
Learn how to track and monitor your resilient functions
Error Handling
Advanced error handling with retry filters and circuit breakers

