@mimik/request-retry 4.0.10 → 4.0.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -8
- package/index.js +10 -10
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -46,17 +46,17 @@ To ease migration from `request-promise`, the following adjustments are applied
|
|
|
46
46
|
| --- | --- | --- | --- |
|
|
47
47
|
| options | <code>object</code> | | Options for the request (similar to [axios](https://www.npmjs.com/package/axios)). The `validateStatus` option is disabled: an error is thrown for status codes outside **[200, 300)**. An additional option, `resolveWithFullResponse`, controls the return shape: when `true`, the full Axios response object is returned; when `false` or omitted, only `response.data` is returned. |
|
|
48
48
|
| [options.retry] | <code>object</code> | | Retry configuration. |
|
|
49
|
-
| [options.retry.retries] | <code>number</code> | <code>2</code> | Maximum number of retries, independent of the `retryStrategy`.
|
|
50
|
-
| [options.retry.delay] | <code>number</code> | <code>1000</code> | Delay between retries in milliseconds when no `delayStrategy` is provided.
|
|
51
|
-
| [options.retry.delayStrategy] | <code>function</code> | | A function that returns the delay (in milliseconds) to wait before the next retry.
|
|
52
|
-
| [options.retry.retryStrategy] | <code>function</code> | | A function that decides whether to retry. Signature:
|
|
53
|
-
| [options.retry.timeout] | <code>number</code> | <code>50</code> | Request timeout (in seconds) applied to the initial request and all retries.
|
|
54
|
-
| [options.retry.logLevel] | <code>object</code> | | Controls logging behavior.
|
|
49
|
+
| [options.retry.retries] | <code>number</code> | <code>2</code> | Maximum number of retries, independent of the `retryStrategy`. If the value is `< 0`, it is set to `0`; if `> 15`, it is set to `15`. |
|
|
50
|
+
| [options.retry.delay] | <code>number</code> | <code>1000</code> | Delay between retries in milliseconds when no `delayStrategy` is provided. If the value is `< 20`, it is set to `20`; if `> 30000`, it is set to `30000`. |
|
|
51
|
+
| [options.retry.delayStrategy] | <code>function</code> | | A function that returns the delay (in milliseconds) to wait before the next retry. Signature: `(nbRetry, err, options, correlationId)`. Must return a number `> 0` and `< 30000`; otherwise `delay` is used. |
|
|
52
|
+
| [options.retry.retryStrategy] | <code>function</code> | | A function that decides whether to retry. Signature: `(nbRetry, err, options, correlationId)`. Must return a boolean; otherwise it is ignored. |
|
|
53
|
+
| [options.retry.timeout] | <code>number</code> | <code>50</code> | Request timeout (in seconds) applied to the initial request and all retries. If reached, a `TimeoutError` is thrown. Values `< 10` are set to `10`; values `> 120` are set to `120`. |
|
|
54
|
+
| [options.retry.logLevel] | <code>object</code> | | Controls logging behavior. When omitted, requests and responses are logged at `info` with full details, and errors at `warn`. When provided but incomplete, only the provided keys are active; missing keys disable that logging. Non-object values are ignored and defaults apply. |
|
|
55
55
|
| [options.retry.logLevel.response] | <code>string</code> | | Log level for responses. Invalid values fall back to `silly`. |
|
|
56
56
|
| [options.retry.logLevel.error] | <code>string</code> | | Log level for errors. Invalid values fall back to `silly`. |
|
|
57
57
|
| [options.retry.logLevel.request] | <code>string</code> | | Log level for requests. Invalid values fall back to `silly`. |
|
|
58
|
-
| [options.retry.logLevel.responseDetails] | <code>string</code> | <code>"'type'"</code> | Detail level for the response: `count`, `type`, or `full`.
|
|
59
|
-
| [options.retry.logLevel.responseName] | <code>string</code> | <code>"'response'"</code> | Label associated with the response.
|
|
58
|
+
| [options.retry.logLevel.responseDetails] | <code>string</code> | <code>"'type'"</code> | Detail level for the response: `count`, `type`, or `full`. Invalid values fall back to `type`. When `logLevel` is omitted entirely, the default is `full`. |
|
|
59
|
+
| [options.retry.logLevel.responseName] | <code>string</code> | <code>"'response'"</code> | Label associated with the response. Non-string or empty values fall back to `response`. |
|
|
60
60
|
| [options.metrics] | <code>object</code> | | Metrics configuration. |
|
|
61
61
|
| [options.metrics.HTTPRequestDuration] | <code>function</code> | | A `prom-client` metric function to measure request duration. |
|
|
62
62
|
| [options.metrics.url] | <code>string</code> | | Optional URL label for the metric. If omitted, the request URL is used. |
|
package/index.js
CHANGED
|
@@ -51,26 +51,26 @@ Promise.config({ cancellation: true });
|
|
|
51
51
|
* when `true`, the full Axios response object is returned; when `false` or omitted, only `response.data` is returned.
|
|
52
52
|
* @param {object} [options.retry] - Retry configuration.
|
|
53
53
|
* @param {number} [options.retry.retries=2] - Maximum number of retries, independent of the `retryStrategy`.
|
|
54
|
-
*
|
|
54
|
+
* If the value is `< 0`, it is set to `0`; if `> 15`, it is set to `15`.
|
|
55
55
|
* @param {number} [options.retry.delay=1000] - Delay between retries in milliseconds when no `delayStrategy` is provided.
|
|
56
|
-
*
|
|
56
|
+
* If the value is `< 20`, it is set to `20`; if `> 30000`, it is set to `30000`.
|
|
57
57
|
* @param {Function} [options.retry.delayStrategy] - A function that returns the delay (in milliseconds) to wait before the next retry.
|
|
58
|
-
*
|
|
58
|
+
* Signature: `(nbRetry, err, options, correlationId)`. Must return a number `> 0` and `< 30000`; otherwise `delay` is used.
|
|
59
59
|
* @param {Function} [options.retry.retryStrategy] - A function that decides whether to retry. Signature:
|
|
60
|
-
*
|
|
60
|
+
* `(nbRetry, err, options, correlationId)`. Must return a boolean; otherwise it is ignored.
|
|
61
61
|
* @param {number} [options.retry.timeout=50] - Request timeout (in seconds) applied to the initial request and all retries.
|
|
62
|
-
*
|
|
62
|
+
* If reached, a `TimeoutError` is thrown. Values `< 10` are set to `10`; values `> 120` are set to `120`.
|
|
63
63
|
* @param {object} [options.retry.logLevel] - Controls logging behavior.
|
|
64
|
-
*
|
|
65
|
-
*
|
|
66
|
-
*
|
|
64
|
+
* When omitted, requests and responses are logged at `info` with full details, and errors at `warn`.
|
|
65
|
+
* When provided but incomplete, only the provided keys are active; missing keys disable that logging.
|
|
66
|
+
* Non-object values are ignored and defaults apply.
|
|
67
67
|
* @param {string} [options.retry.logLevel.response] - Log level for responses. Invalid values fall back to `silly`.
|
|
68
68
|
* @param {string} [options.retry.logLevel.error] - Log level for errors. Invalid values fall back to `silly`.
|
|
69
69
|
* @param {string} [options.retry.logLevel.request] - Log level for requests. Invalid values fall back to `silly`.
|
|
70
70
|
* @param {string} [options.retry.logLevel.responseDetails='type'] - Detail level for the response: `count`, `type`, or `full`.
|
|
71
|
-
*
|
|
71
|
+
* Invalid values fall back to `type`. When `logLevel` is omitted entirely, the default is `full`.
|
|
72
72
|
* @param {string} [options.retry.logLevel.responseName='response'] - Label associated with the response.
|
|
73
|
-
*
|
|
73
|
+
* Non-string or empty values fall back to `response`.
|
|
74
74
|
* @param {object} [options.metrics] - Metrics configuration.
|
|
75
75
|
* @param {Function} [options.metrics.HTTPRequestDuration] - A `prom-client` metric function to measure request duration.
|
|
76
76
|
* @param {string} [options.metrics.url] - Optional URL label for the metric. If omitted, the request URL is used.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mimik/request-retry",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.11",
|
|
4
4
|
"description": "Request retry wrapping axios",
|
|
5
5
|
"main": "./index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"dependencies": {
|
|
29
29
|
"@mimik/request-helper": "^2.0.6",
|
|
30
30
|
"@mimik/response-helper": "^4.0.11",
|
|
31
|
-
"@mimik/sumologic-winston-logger": "^2.2.
|
|
31
|
+
"@mimik/sumologic-winston-logger": "^2.2.2",
|
|
32
32
|
"axios": "1.13.6",
|
|
33
33
|
"bluebird": "3.7.2"
|
|
34
34
|
},
|
|
@@ -48,6 +48,6 @@
|
|
|
48
48
|
"jsdoc-to-markdown": "9.1.3",
|
|
49
49
|
"mocha": "11.7.5",
|
|
50
50
|
"mochawesome": "7.1.4",
|
|
51
|
-
"sinon": "21.0.
|
|
51
|
+
"sinon": "21.0.3"
|
|
52
52
|
}
|
|
53
53
|
}
|