@cumulus/db 16.0.2-alpha.0 → 16.0.3-alpha.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/package.json +8 -8
- package/dist/lib/retry.d.ts +0 -7
- package/dist/lib/retry.js +0 -32
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cumulus/db",
|
|
3
|
-
"version": "16.0.
|
|
3
|
+
"version": "16.0.3-alpha.0",
|
|
4
4
|
"description": "Utilities for working with the Cumulus DB",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -29,12 +29,12 @@
|
|
|
29
29
|
"node": ">=16.19.0"
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@cumulus/aws-client": "16.0.
|
|
33
|
-
"@cumulus/common": "16.0.
|
|
34
|
-
"@cumulus/errors": "16.0.
|
|
35
|
-
"@cumulus/logger": "16.0.
|
|
36
|
-
"@cumulus/message": "16.0.
|
|
37
|
-
"@cumulus/types": "16.0.
|
|
32
|
+
"@cumulus/aws-client": "16.0.3-alpha.0",
|
|
33
|
+
"@cumulus/common": "16.0.3-alpha.0",
|
|
34
|
+
"@cumulus/errors": "16.0.3-alpha.0",
|
|
35
|
+
"@cumulus/logger": "16.0.3-alpha.0",
|
|
36
|
+
"@cumulus/message": "16.0.3-alpha.0",
|
|
37
|
+
"@cumulus/types": "16.0.3-alpha.0",
|
|
38
38
|
"crypto-random-string": "^3.2.0",
|
|
39
39
|
"is-valid-hostname": "1.0.2",
|
|
40
40
|
"knex": "2.4.1",
|
|
@@ -46,5 +46,5 @@
|
|
|
46
46
|
"devDependencies": {
|
|
47
47
|
"@types/uuid": "^8.0.0"
|
|
48
48
|
},
|
|
49
|
-
"gitHead": "
|
|
49
|
+
"gitHead": "81be18bf42487473dce42432781672da91fbecd0"
|
|
50
50
|
}
|
package/dist/lib/retry.d.ts
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { Knex } from 'knex';
|
|
2
|
-
import pRetry from 'p-retry';
|
|
3
|
-
import Logger from '@cumulus/logger';
|
|
4
|
-
declare type PromiseReturnType<T> = T extends (method: Promise<any> | Knex.QueryBuilder) => infer R ? Promise<R> : never;
|
|
5
|
-
export declare const RetryOnDbConnectionTerminateError: <T>(method: Promise<any> | Knex.QueryBuilder, retryConfig?: pRetry.Options, log?: Logger) => Promise<PromiseReturnType<T>>;
|
|
6
|
-
export {};
|
|
7
|
-
//# sourceMappingURL=retry.d.ts.map
|
package/dist/lib/retry.js
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.RetryOnDbConnectionTerminateError = void 0;
|
|
7
|
-
const p_retry_1 = __importDefault(require("p-retry"));
|
|
8
|
-
const logger_1 = __importDefault(require("@cumulus/logger"));
|
|
9
|
-
const RetryOnDbConnectionTerminateError = async (method, retryConfig, log) => {
|
|
10
|
-
const logger = log || new logger_1.default({ sender: '@cumulus/db/retry' });
|
|
11
|
-
return await (0, p_retry_1.default)(async () => {
|
|
12
|
-
try {
|
|
13
|
-
const result = await method;
|
|
14
|
-
return result;
|
|
15
|
-
}
|
|
16
|
-
catch (error) {
|
|
17
|
-
if (error.message.includes('Connection terminated unexpectedly')) {
|
|
18
|
-
logger.error(`${error}. Retrying...`);
|
|
19
|
-
throw error;
|
|
20
|
-
}
|
|
21
|
-
throw new p_retry_1.default.AbortError(error);
|
|
22
|
-
}
|
|
23
|
-
}, {
|
|
24
|
-
retries: 3,
|
|
25
|
-
onFailedAttempt: (e) => {
|
|
26
|
-
logger.error(`Error ${e.message}. Attempt ${e.attemptNumber} failed.`);
|
|
27
|
-
},
|
|
28
|
-
...retryConfig,
|
|
29
|
-
});
|
|
30
|
-
};
|
|
31
|
-
exports.RetryOnDbConnectionTerminateError = RetryOnDbConnectionTerminateError;
|
|
32
|
-
//# sourceMappingURL=retry.js.map
|