1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | const promiseRetry = require("promise-retry");
|
4 | const logger_1 = require("../internal/util/logger");
|
5 |
|
6 |
|
7 |
|
8 | exports.DefaultRetryOptions = {
|
9 | retries: 5,
|
10 | factor: 3,
|
11 | minTimeout: 1 * 500,
|
12 | maxTimeout: 5 * 1000,
|
13 | randomize: true,
|
14 | };
|
15 |
|
16 |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 | function doWithRetry(what, description, opts = {}) {
|
24 | const retryOptions = Object.assign({}, exports.DefaultRetryOptions, opts);
|
25 | logger_1.logger.debug(`${description} with retry options '%j'`, retryOptions);
|
26 | return promiseRetry(retryOptions, retry => {
|
27 | return what()
|
28 | .catch(err => {
|
29 | logger_1.logger.warn(`Error occurred attempting '${description}': ${err.message}`);
|
30 | retry(err);
|
31 | });
|
32 | });
|
33 | }
|
34 | exports.doWithRetry = doWithRetry;
|
35 |
|
\ | No newline at end of file |