You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
- 📥 **Smart Caching** Caches requests by converting HTTP requests to smart key strings. ✅
14
-
- 🚧 **Request Holder** Stopping same request to be sent multiple times. ✅
15
-
- 🔌 **Support** Warden can be used with anything but it supports [request](https://github.com/request/request) out of the box. ✅
16
-
- 😎 **Easy Implementation** Warden can be easily implemented with a few lines of codes. ✅
17
-
- 🔁 **Request Retry** Requests will automatically be re-attempted on recoverable errors. 📝
18
-
- 📇 **Schema Parser** Warden uses a schema which can be provided by you for parsing JSON faster. 📝
19
-
- 🚥 **API Queue** Throttles API calls to protect target service. 📝
20
-
- 👻 **Request Shadowing** Copies a fraction of traffic to a new deployment for observation. 📝
21
-
- 🚉 **Reverse Proxy** It can be deployable as an external application which can serve as a reverse proxy. 📝
22
-
- 📛 **Circuit Breaker** Immediately refuses new requests to provide time for the API to become healthy. 📝
13
+
- 📥 **Smart Caching** Caches requests by converting HTTP requests to smart key strings. ✅
14
+
- 🚧 **Request Holder** Stopping same request to be sent multiple times. ✅
15
+
- 🔌 **Support** Warden can be used with anything but it supports [request](https://github.com/request/request) out of the box. ✅
16
+
- 😎 **Easy Implementation** Warden can be easily implemented with a few lines of codes. ✅
17
+
- 🔁 **Request Retry** Requests will automatically be re-attempted on recoverable errors. ✅
18
+
- 📇 **Schema Parser** Warden uses a schema which can be provided by you for parsing JSON faster. 📝
19
+
- 🚥 **API Queue** Throttles API calls to protect target service. 📝
20
+
- 👻 **Request Shadowing** Copies a fraction of traffic to a new deployment for observation. 📝
21
+
- 🚉 **Reverse Proxy** It can be deployable as an external application which can serve as a reverse proxy. 📝
22
+
- 📛 **Circuit Breaker** Immediately refuses new requests to provide time for the API to become healthy. 📝
23
23
24
24

25
25
@@ -29,17 +29,18 @@ Warden is an outgoing request optimizer for creating fast and scalable applicati
29
29
-[Identifier](#identifier)
30
30
-[Registering Route](#registering-route)
31
31
-[Cache](#cache)
32
+
-[Retry](#retry)
32
33
-[Holder](#holder)
33
34
-[Api](#api)
34
35
35
36
### Installing
36
37
37
38
Yarn
38
-
```
39
+
```bash
39
40
yarn add puzzle-warden
40
41
```
41
42
Npm
42
-
```
43
+
```bash
43
44
npm i puzzle-warden --save
44
45
```
45
46
@@ -122,6 +123,8 @@ warden.register('test', {
122
123
});
123
124
```
124
125
126
+
`identifier` is an optional field. If an identifier is not provided warden will be use generic identifier which is `${name}_${url}_${JSON.stringify({cookie, headers, query})}_${method}`.
127
+
125
128
### Cache
126
129
127
130
You can simply enable cache with default values using.
@@ -176,7 +179,36 @@ Simple old school caching. Asks cache plugin if it has a valid cached response.
176
179
### Holder
177
180
178
181
Holder prevents same HTTP requests to be sent at the same time.
179
-
Let's assume we have an identifier for a request: `{query.foo}`. We send a HTTP request `/product?foo=bar`. While waiting for the response, warden received another HTTP request to the same address which means both HTTP requests are converted to the same key. Then Warden stops the second request. After receiving the response from the first request, Warden returns both requests with the same response by sending only one HTTP request.
182
+
Let's assume we have an identifier for a request: `{query.foo}`. We send a HTTP request `/product?foo=bar`. While waiting for the response, warden received another HTTP request to the same address which means both HTTP requests are converted to the same key. Then Warden stops the second request. After receiving the response from the first request, Warden returns both requests with the same response by sending only one HTTP request.
183
+
184
+
### Retry
185
+
186
+
When the connection fails with one of ECONNRESET, ENOTFOUND, ESOCKETTIMEDOUT, ETIMEDOUT, ECONNREFUSED, EHOSTUNREACH, EPIPE, EAI_AGAIN or when an HTTP 5xx or 429 error occurrs, the request will automatically be re-attempted as these are often recoverable errors and will go away on retry.
187
+
188
+
```js
189
+
warden.register('routeName', {
190
+
retry: {
191
+
delay:100,
192
+
count:1,
193
+
logger: (retryCount) => {
194
+
console.log(retryCount);
195
+
}
196
+
}
197
+
});
198
+
199
+
warden.register('routeName', {
200
+
retry:true// default settings
201
+
});
202
+
```
203
+
204
+
Default values and properties
205
+
206
+
| Property | Required | Default Value | Definition |
207
+
| :--- | :---: | ---: | :--- |
208
+
| delay | ❌ | 100 | Warden will wait for 100ms before retry |
209
+
| count | ❌ | 1 | It will try for 1 time by default |
210
+
| logger | ❌ | 1m | Logger will be called on each retry with retry count|
0 commit comments