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
| threshold |`null`|`number`|`25`| Circuit breaker: How many, in %, requests should error before the circuit should trip. Ex; when 25% of requests fail, trip the circuit. |
45
-
| timeout |`null`|`number`|`500`| Circuit breaker: How long, in milliseconds, a request can maximum take. Requests exceeding this limit counts against tripping the circuit. |
46
-
| throwOn400 |`false`|`boolean`|`false`| If the client sahould throw on HTTP 400 errors.If true, HTTP 400 errors will counts against tripping the circuit. |
47
-
| throwOn500 |`false`|`boolean`|`true`| If the client sahould throw on HTTP 500 errors.If true, HTTP 500 errors will counts against tripping the circuit. |
48
-
| reset |`false`|`number`|`2000`| Circuit breaker: How long, in milliseconds, to wait before a tripped circuit should be reset. |
49
-
| logger |`null`|`àb`|`false`| A logger which conform to a log4j interface |
| connections |`50`|`number`| no | See [connections](#connections)|
45
+
| fallback |`undefined`|`function`| no | Function to call when requests fail |
46
+
| keepAliveMaxTimeout |`undefined`|`number`| no | See [keepAliveMaxTimeout](#keepAliveMaxTimeout)|
47
+
| keepAliveTimeout |`undefined`|`number`| no | See [keepAliveTimeout](#keepAliveTimeout)|
48
+
| logger |`undefined `|`object`| no | A logger which conform to a log4j interface |
49
+
| pipelining |`10`|`number`| no | See [pipelining](#pipelining)|
50
+
| reset |`2000`|`number`| no | Circuit breaker: How long, in milliseconds, to wait before a tripped circuit should be reset. |
51
+
| threshold |`25`|`number`| no | Circuit breaker: How many, in %, requests should error before the circuit should trip. Ex; when 25% of requests fail, trip the circuit. |
52
+
| throwOn400 |`false`|`boolean`| no | If the client should throw on HTTP 400 errors.If true, HTTP 400 errors will counts against tripping the circuit. |
53
+
| throwOn500 |`true`|`boolean`| no | If the client should throw on HTTP 500 errors.If true, HTTP 500 errors will counts against tripping the circuit. |
54
+
| timeout |`500`|`number`| no | Circuit breaker: How long, in milliseconds, a request can maximum take. Requests exceeding this limit counts against tripping the circuit. |
50
55
51
56
57
+
##### connections
58
+
Property is sent to the underlying http library.
59
+
See library docs on [connections](https://undici.nodejs.org/#/docs/api/Pool?id=parameter-pooloptions)
60
+
61
+
##### fallback
62
+
63
+
Optional function to run when a request fails.
64
+
65
+
```js
66
+
// TBA
67
+
```
68
+
69
+
##### keepAliveMaxTimeout
70
+
71
+
Property is sent to the underlying http library.
72
+
See library docs on [keepAliveTimeout](https://undici.nodejs.org/#/docs/api/Client?id=parameter-clientoptions)
73
+
74
+
##### keepAliveMaxTimeout
75
+
76
+
Property is sent to the underlying http library.
77
+
See library docs on [keepAliveMaxTimeout](https://undici.nodejs.org/#/docs/api/Client?id=parameter-clientoptions)
78
+
52
79
##### logger
53
80
54
81
Any log4j compatible logger can be passed in and will be used for logging.
@@ -67,13 +94,35 @@ const layout = new Layout({
67
94
Under the hood [abslog] is used to abstract out logging. Please see [abslog] for
68
95
further details.
69
96
97
+
##### pipelining
98
+
99
+
Property is sent to the underlying http library.
100
+
See library docs on [pipelining](https://undici.nodejs.org/#/?id=pipelining)
101
+
102
+
##### reset
103
+
Circuit breaker: How long, in milliseconds, to wait before a tripped circuit should be reset.
104
+
105
+
##### threshold
106
+
107
+
Circuit breaker: How many, in %, requests should error before the circuit should trip. Ex; when 25% of requests fail, trip the circuit.
108
+
109
+
##### timeout
110
+
Circuit breaker: How long, in milliseconds, a request can maximum take. Requests exceeding this limit counts against tripping the circuit.
111
+
112
+
##### throwOn400
113
+
114
+
If the client should throw on http 400 errors. If true, http 400 errors will count against tripping the circuit.
115
+
116
+
##### throwOn500
117
+
If the client should throw on http 500 errors. If true, http 500 errors will count against tripping the circuit.
* @property {Boolean} throwOn400 - If the client should throw on http 400 errors. If true, http 400 errors will counts against tripping the circuit.
14
-
* @property {Boolean} throwOn500 - If the client should throw on http 500 errors. If true, http 500 errors will counts against tripping the circuit.
15
-
* @property {Number} threshold - Circuit breaker: How many, in %, requests should error before the circuit should trip. Ex; when 25% of requests fail, trip the circuit.
16
-
* @property {Number} timeout - Circuit breaker: How long, in milliseconds, a request can maximum take. Requests exceeding this limit counts against tripping the circuit.
* @property {Number} reset - Circuit breaker: How long, in milliseconds, to wait before a tripped circuit should be reset.
14
+
* @property {Boolean} throwOn400 - If the client should throw on http 400 errors. If true, http 400 errors will count against tripping the circuit.
15
+
* @property {Boolean} throwOn500 - If the client should throw on http 500 errors. If true, http 500 errors will count against tripping the circuit.
16
+
* @property {Number} threshold - Circuit breaker: How many, in %, requests should error before the circuit should trip. Ex; when 25% of requests fail, trip the circuit.
17
+
* @property {Number} timeout - Circuit breaker: How long, in milliseconds, a request can maximum take. Requests exceeding this limit counts against tripping the circuit.
18
+
* @property {Function} [fallaback=undefined] - Optional function to call as a fallback when breaker is open.
19
19
**/
20
20
21
-
exportdefaultclassHttpClientextendsEventEmitter{
22
-
#throwOn400;
23
-
#throwOn500;
21
+
exportdefaultclassHttpClient{
22
+
#abortController;
23
+
#agent;
24
24
#breaker;
25
25
#logger;
26
-
#agent;
27
-
#abortController;
26
+
#throwOn400;
27
+
#throwOn500;
28
28
29
29
/**
30
30
* @property {HttpClientOptions} options - options
31
31
*/
32
32
constructor({
33
33
abortController =undefined,
34
34
autoRenewAbortController =false,
35
+
connections =50,
36
+
fallback =undefined,
35
37
keepAliveMaxTimeout =undefined,
36
38
keepAliveTimeout =undefined,
37
-
connections=50,
39
+
logger=undefined,
38
40
pipelining =10,
41
+
reset =20000,
39
42
throwOn400 =false,
40
43
throwOn500 =true,
41
44
threshold =25,
42
45
timeout =500,
43
-
logger =undefined,
44
-
reset =20000,
45
-
fallback =undefined,
46
46
}={}){
47
-
super();
48
47
this.#logger =abslog(logger);
49
48
this.#throwOn400 =throwOn400;
50
49
this.#throwOn500 =throwOn500;
51
-
// Add runtime check
50
+
52
51
this.#abortController =abortController;
53
52
54
53
// TODO; Can we avoid bind here in a nice way?????
0 commit comments