From 83bd43d37b6f44fcdab7a5ea226756a808095024 Mon Sep 17 00:00:00 2001 From: Logan Ramos Date: Sat, 8 Apr 2023 23:13:25 -0700 Subject: [PATCH] Fix readme (#74) --- readme.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/readme.md b/readme.md index ee4e25d..292de8e 100644 --- a/readme.md +++ b/readme.md @@ -23,18 +23,18 @@ import { database } from './my-db'; // Create a retry policy that'll try whatever function we execute 3 // times with a randomized exponential backoff. -const retry = retry(handleAll, { maxAttempts: 3, backoff: new ExponentialBackoff() }); +const retryPolicy = retry(handleAll, { maxAttempts: 3, backoff: new ExponentialBackoff() }); // Create a circuit breaker that'll stop calling the executed function for 10 // seconds if it fails 5 times in a row. This can give time for e.g. a database // to recover without getting tons of traffic. -const circuitBreaker = circuitBreaker(handleAll, { +const circuitBreakerPolicy = circuitBreaker(handleAll, { halfOpenAfter: 10 * 1000, breaker: new ConsecutiveBreaker(5), }); // Combine these! Create a policy that retries 3 times, calling through the circuit breaker -const retryWithBreaker = wrap(retry, circuitBreaker); +const retryWithBreaker = wrap(retryPolicy, circuitBreakerPolicy); exports.handleRequest = async (req, res) => { // Call your database safely!