1 | 'use strict';
|
2 |
|
3 | const getProfile = require('./profile').getProfile;
|
4 | const retry = require('promise-retry');
|
5 |
|
6 | async function getRetryOptions() {
|
7 | const profile = await getProfile();
|
8 | const retryOptions = {
|
9 | retries: profile.retries,
|
10 | factor: 2,
|
11 | minTimeout: 1 * 1000,
|
12 | randomize: true
|
13 | };
|
14 |
|
15 | return retryOptions;
|
16 | }
|
17 |
|
18 | async function promiseRetry(fn) {
|
19 | const retryOptions = await getRetryOptions();
|
20 | return retry(fn, retryOptions);
|
21 | }
|
22 |
|
23 | module.exports = promiseRetry; |
\ | No newline at end of file |