@webex/internal-plugin-ediscovery 3.0.0-beta.9 → 3.0.0-bnr.0
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 +7 -5
- package/dist/config.js +0 -2
- package/dist/config.js.map +1 -1
- package/dist/ediscovery-error.js +2 -24
- package/dist/ediscovery-error.js.map +1 -1
- package/dist/ediscovery.js +236 -370
- package/dist/ediscovery.js.map +1 -1
- package/dist/index.js +4 -28
- package/dist/index.js.map +1 -1
- package/dist/internal-plugin-ediscovery.d.ts +50 -0
- package/dist/report-request.js +0 -6
- package/dist/report-request.js.map +1 -1
- package/dist/retry.js +27 -43
- package/dist/retry.js.map +1 -1
- package/dist/transforms.js +81 -104
- package/dist/transforms.js.map +1 -1
- package/dist/tsdoc-metadata.json +11 -0
- package/dist/types/config.d.ts +11 -0
- package/dist/types/ediscovery-error.d.ts +11 -0
- package/dist/types/ediscovery.d.ts +6 -0
- package/dist/types/index.d.ts +4 -0
- package/dist/types/report-request.d.ts +29 -0
- package/dist/types/retry.d.ts +2 -0
- package/dist/types/transforms.d.ts +35 -0
- package/package.json +10 -10
- package/src/config.js +6 -4
- package/src/ediscovery.js +2 -2
- package/src/index.js +35 -22
- package/src/report-request.js +10 -1
- package/src/retry.js +23 -14
- package/src/transforms.js +483 -214
- package/test/integration/spec/ediscovery.js +62 -43
- package/test/unit/spec/content.js +304 -166
- package/test/unit/spec/report.js +76 -77
- package/test/unit/spec/transforms.js +227 -152
package/src/retry.js
CHANGED
|
@@ -1,24 +1,33 @@
|
|
|
1
1
|
const retryErrors = [429, 502, 503, 504];
|
|
2
2
|
|
|
3
|
-
async function requestWithRetries(
|
|
3
|
+
async function requestWithRetries(
|
|
4
|
+
ctx,
|
|
5
|
+
func,
|
|
6
|
+
args,
|
|
7
|
+
retryCount = 0,
|
|
8
|
+
retryIntervalInSeconds = 0,
|
|
9
|
+
maxRetries = 3
|
|
10
|
+
) {
|
|
4
11
|
await timeout(retryIntervalInSeconds);
|
|
5
12
|
|
|
6
|
-
return func.apply(ctx, args)
|
|
7
|
-
.
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
13
|
+
return func.apply(ctx, args).catch((reason) => {
|
|
14
|
+
if (retryErrors.includes(reason.statusCode) && retryCount < maxRetries) {
|
|
15
|
+
retryCount += 1;
|
|
16
|
+
// eslint-disable-next-line no-shadow
|
|
17
|
+
let retryIntervalInSeconds = (retryCount + 1) ** 2; // 4, 9 and 16 second delays as default
|
|
11
18
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
}
|
|
15
|
-
console.error(`Request #${retryCount} error: ${reason.statusCode}. Attempting retry #${retryCount} in ${retryIntervalInSeconds} seconds`);
|
|
16
|
-
|
|
17
|
-
return requestWithRetries(ctx, func, args, retryCount, retryIntervalInSeconds, maxRetries);
|
|
19
|
+
if (reason.headers && reason.headers['retry-after']) {
|
|
20
|
+
retryIntervalInSeconds = reason.headers['retry-after'];
|
|
18
21
|
}
|
|
22
|
+
console.error(
|
|
23
|
+
`Request #${retryCount} error: ${reason.statusCode}. Attempting retry #${retryCount} in ${retryIntervalInSeconds} seconds`
|
|
24
|
+
);
|
|
25
|
+
|
|
26
|
+
return requestWithRetries(ctx, func, args, retryCount, retryIntervalInSeconds, maxRetries);
|
|
27
|
+
}
|
|
19
28
|
|
|
20
|
-
|
|
21
|
-
|
|
29
|
+
return Promise.reject(reason);
|
|
30
|
+
});
|
|
22
31
|
}
|
|
23
32
|
|
|
24
33
|
function timeout(sec) {
|