@factorearth/recordmiddleware-errorhandler 0.0.1-y.25 → 0.0.1-y.26
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/dist/aws-services/dynamodb/determineRetryableDynamo.js +8 -3
- package/dist/aws-services/dynamodb/determineRetryableDynamo.js.map +1 -0
- package/dist/backOff.js +88 -25
- package/dist/backOff.js.map +1 -0
- package/dist/delay.js +7 -2
- package/dist/delay.js.map +1 -0
- package/dist/handler.js +71 -8
- package/dist/handler.js.map +1 -0
- package/dist/index.js +20 -3
- package/dist/index.js.map +1 -0
- package/package.json +11 -7
- package/dist/aws-services/dynamodb/determineRetryableDynamo.d.ts +0 -8
- package/dist/backOff.d.ts +0 -28
- package/dist/delay.d.ts +0 -7
- package/dist/handler.d.ts +0 -10
- package/dist/index.d.ts +0 -3
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.determineRetryableDynamo = void 0;
|
|
1
4
|
/**
|
|
2
5
|
* Given the error from the dynamodb operation, dertermines if we can retry it, based on the information from the dynamodb sdk docs
|
|
3
6
|
* {@link https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Programming.Errors.html}
|
|
@@ -5,10 +8,12 @@
|
|
|
5
8
|
* @param err The error thrown by the dynamodb operation
|
|
6
9
|
* @returns Whether or not we can retry the operation
|
|
7
10
|
*/
|
|
8
|
-
|
|
9
|
-
if (!err
|
|
11
|
+
function determineRetryableDynamo(err) {
|
|
12
|
+
if (!(err === null || err === void 0 ? void 0 : err.name))
|
|
10
13
|
return false;
|
|
11
14
|
// The errors from the link I provided that are marked as retryable
|
|
12
|
-
|
|
15
|
+
var retryableErrors = new Set(["ItemCollectionSizeLimitExceededException", "LimitExceededException", "ProvisionedThroughputExceededException", "RequestLimitExceeded", "ThrottlingException"]);
|
|
13
16
|
return retryableErrors.has(err.name) || (err.$metadata && err.$metadata.httpStatusCode && err.$metadata.httpStatusCode >= 500);
|
|
14
17
|
}
|
|
18
|
+
exports.determineRetryableDynamo = determineRetryableDynamo;
|
|
19
|
+
//# sourceMappingURL=determineRetryableDynamo.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"determineRetryableDynamo.js","sourceRoot":"","sources":["../../../lib/aws-services/dynamodb/determineRetryableDynamo.ts"],"names":[],"mappings":";;;AAAA;;;;;;GAMG;AACH,SAAgB,wBAAwB,CAAC,GAAQ;IAChD,IAAI,CAAC,CAAA,GAAG,aAAH,GAAG,uBAAH,GAAG,CAAE,IAAI,CAAA;QAAE,OAAO,KAAK,CAAC;IAC7B,mEAAmE;IACnE,IAAM,eAAe,GAAgB,IAAI,GAAG,CAAC,CAAC,0CAA0C,EAAE,wBAAwB,EAAE,wCAAwC,EAAE,sBAAsB,EAAE,qBAAqB,CAAC,CAAC,CAAC;IAC9M,OAAO,eAAe,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,SAAS,IAAI,GAAG,CAAC,SAAS,CAAC,cAAc,IAAI,GAAG,CAAC,SAAS,CAAC,cAAc,IAAI,GAAG,CAAC,CAAC;AAChI,CAAC;AALD,4DAKC"}
|
package/dist/backOff.js
CHANGED
|
@@ -1,9 +1,48 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
+
function step(op) {
|
|
16
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
18
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
+
switch (op[0]) {
|
|
21
|
+
case 0: case 1: t = op; break;
|
|
22
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
+
default:
|
|
26
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
+
if (t[2]) _.ops.pop();
|
|
31
|
+
_.trys.pop(); continue;
|
|
32
|
+
}
|
|
33
|
+
op = body.call(thisArg, _);
|
|
34
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.backoff = void 0;
|
|
40
|
+
var delay_1 = require("./delay");
|
|
2
41
|
// Default values
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
42
|
+
var DELAY = 100;
|
|
43
|
+
var NUMBER_OF_ATTEMPTS = 10;
|
|
44
|
+
var MAX_DELAY = Infinity;
|
|
45
|
+
var TIME_MULTIPLE = 2;
|
|
7
46
|
/**
|
|
8
47
|
* Given a task, attempts to execute it a designated number of times, returning the eventual response
|
|
9
48
|
* @author Eric Webb <ewebb@factorearth.com>
|
|
@@ -12,25 +51,49 @@ const TIME_MULTIPLE = 2;
|
|
|
12
51
|
* @param options The configurable options for the module
|
|
13
52
|
* @returns The result of the function
|
|
14
53
|
*/
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
const maxDelay = options?.maxDelay || MAX_DELAY;
|
|
20
|
-
const timeMultiple = options?.timeMultiple || TIME_MULTIPLE;
|
|
21
|
-
while (attemptNumber < maxAttempts) {
|
|
22
|
-
const calculatedDelay = initialDelay * Math.pow(timeMultiple, attemptNumber);
|
|
23
|
-
const delayTime = Math.min(calculatedDelay, maxDelay);
|
|
24
|
-
await delay(delayTime);
|
|
25
|
-
try {
|
|
26
|
-
const taskResult = await task(...taskArguments);
|
|
27
|
-
const evaluatorResult = evaluator(taskResult);
|
|
28
|
-
if (evaluatorResult || !(attemptNumber + 1 < maxAttempts))
|
|
29
|
-
return taskResult;
|
|
30
|
-
}
|
|
31
|
-
catch (err) {
|
|
32
|
-
// recordSentry({ error: err, msg: "Error executing backoff task" });
|
|
33
|
-
}
|
|
34
|
-
attemptNumber++;
|
|
54
|
+
function backoff(task, evaluator, options) {
|
|
55
|
+
var taskArguments = [];
|
|
56
|
+
for (var _i = 3; _i < arguments.length; _i++) {
|
|
57
|
+
taskArguments[_i - 3] = arguments[_i];
|
|
35
58
|
}
|
|
59
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
60
|
+
var attemptNumber, maxAttempts, initialDelay, maxDelay, timeMultiple, calculatedDelay, delayTime, taskResult, evaluatorResult, err_1;
|
|
61
|
+
return __generator(this, function (_a) {
|
|
62
|
+
switch (_a.label) {
|
|
63
|
+
case 0:
|
|
64
|
+
attemptNumber = 0;
|
|
65
|
+
maxAttempts = (options === null || options === void 0 ? void 0 : options.numberOfAttempts) || NUMBER_OF_ATTEMPTS;
|
|
66
|
+
initialDelay = (options === null || options === void 0 ? void 0 : options.delay) || DELAY;
|
|
67
|
+
maxDelay = (options === null || options === void 0 ? void 0 : options.maxDelay) || MAX_DELAY;
|
|
68
|
+
timeMultiple = (options === null || options === void 0 ? void 0 : options.timeMultiple) || TIME_MULTIPLE;
|
|
69
|
+
_a.label = 1;
|
|
70
|
+
case 1:
|
|
71
|
+
if (!(attemptNumber < maxAttempts)) return [3 /*break*/, 7];
|
|
72
|
+
calculatedDelay = initialDelay * Math.pow(timeMultiple, attemptNumber);
|
|
73
|
+
delayTime = Math.min(calculatedDelay, maxDelay);
|
|
74
|
+
return [4 /*yield*/, (0, delay_1.delay)(delayTime)];
|
|
75
|
+
case 2:
|
|
76
|
+
_a.sent();
|
|
77
|
+
_a.label = 3;
|
|
78
|
+
case 3:
|
|
79
|
+
_a.trys.push([3, 5, , 6]);
|
|
80
|
+
return [4 /*yield*/, task.apply(void 0, taskArguments)];
|
|
81
|
+
case 4:
|
|
82
|
+
taskResult = _a.sent();
|
|
83
|
+
evaluatorResult = evaluator(taskResult);
|
|
84
|
+
if (evaluatorResult || !(attemptNumber + 1 < maxAttempts))
|
|
85
|
+
return [2 /*return*/, taskResult];
|
|
86
|
+
return [3 /*break*/, 6];
|
|
87
|
+
case 5:
|
|
88
|
+
err_1 = _a.sent();
|
|
89
|
+
return [3 /*break*/, 6];
|
|
90
|
+
case 6:
|
|
91
|
+
attemptNumber++;
|
|
92
|
+
return [3 /*break*/, 1];
|
|
93
|
+
case 7: return [2 /*return*/];
|
|
94
|
+
}
|
|
95
|
+
});
|
|
96
|
+
});
|
|
36
97
|
}
|
|
98
|
+
exports.backoff = backoff;
|
|
99
|
+
//# sourceMappingURL=backOff.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"backOff.js","sourceRoot":"","sources":["../lib/backOff.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iCAAgC;AAqBhC,iBAAiB;AACjB,IAAM,KAAK,GAAG,GAAG,CAAC;AAClB,IAAM,kBAAkB,GAAG,EAAE,CAAC;AAC9B,IAAM,SAAS,GAAG,QAAQ,CAAC;AAC3B,IAAM,aAAa,GAAG,CAAC,CAAC;AAExB;;;;;;;GAOG;AACH,SAAsB,OAAO,CAA0C,IAAqD,EAAE,SAA8C,EAAE,OAAwB;IAAE,uBAA+B;SAA/B,UAA+B,EAA/B,qBAA+B,EAA/B,IAA+B;QAA/B,sCAA+B;;;;;;;oBAClO,aAAa,GAAG,CAAC,CAAC;oBAChB,WAAW,GAAG,CAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,gBAAgB,KAAI,kBAAkB,CAAC;oBAC9D,YAAY,GAAG,CAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,KAAK,KAAI,KAAK,CAAC;oBACvC,QAAQ,GAAG,CAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,QAAQ,KAAI,SAAS,CAAC;oBAC1C,YAAY,GAAG,CAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,YAAY,KAAI,aAAa,CAAC;;;yBACrD,CAAA,aAAa,GAAG,WAAW,CAAA;oBAC3B,eAAe,GAAG,YAAY,GAAG,IAAI,CAAC,GAAG,CAAC,YAAY,EAAE,aAAa,CAAC,CAAC;oBACvE,SAAS,GAAG,IAAI,CAAC,GAAG,CAAC,eAAe,EAAE,QAAQ,CAAC,CAAC;oBACtD,qBAAM,IAAA,aAAK,EAAC,SAAS,CAAC,EAAA;;oBAAtB,SAAsB,CAAC;;;;oBAES,qBAAM,IAAI,eAAI,aAAa,GAAC;;oBAArD,UAAU,GAAe,SAA4B;oBACrD,eAAe,GAAG,SAAS,CAAC,UAAU,CAAC,CAAC;oBAC9C,IAAI,eAAe,IAAI,CAAC,CAAC,aAAa,GAAG,CAAC,GAAG,WAAW,CAAC;wBAAE,sBAAO,UAAU,EAAC;;;;;;oBAI9E,aAAa,EAAE,CAAC;;;;;;CAEjB;AAnBD,0BAmBC"}
|
package/dist/delay.js
CHANGED
|
@@ -1,9 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.delay = void 0;
|
|
1
4
|
/**
|
|
2
5
|
* Creates a promise that resolvers after a provided number of ms
|
|
3
6
|
* @author Eric Webb <ewebb@factorearth.com>
|
|
4
7
|
* @param millis The number of ms you want to sleep
|
|
5
8
|
* @returns A void promise
|
|
6
9
|
*/
|
|
7
|
-
|
|
8
|
-
return new Promise((resolve, _reject)
|
|
10
|
+
function delay(millis) {
|
|
11
|
+
return new Promise(function (resolve, _reject) { return setTimeout(resolve, millis); });
|
|
9
12
|
}
|
|
13
|
+
exports.delay = delay;
|
|
14
|
+
//# sourceMappingURL=delay.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"delay.js","sourceRoot":"","sources":["../lib/delay.ts"],"names":[],"mappings":";;;AAAA;;;;;GAKG;AACH,SAAgB,KAAK,CAAC,MAAc;IACnC,OAAO,IAAI,OAAO,CAAC,UAAC,OAAO,EAAE,OAAO,IAAK,OAAA,UAAU,CAAC,OAAO,EAAE,MAAM,CAAC,EAA3B,CAA2B,CAAC,CAAC;AACvE,CAAC;AAFD,sBAEC"}
|
package/dist/handler.js
CHANGED
|
@@ -1,5 +1,53 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
+
function step(op) {
|
|
16
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
18
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
+
switch (op[0]) {
|
|
21
|
+
case 0: case 1: t = op; break;
|
|
22
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
+
default:
|
|
26
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
+
if (t[2]) _.ops.pop();
|
|
31
|
+
_.trys.pop(); continue;
|
|
32
|
+
}
|
|
33
|
+
op = body.call(thisArg, _);
|
|
34
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
39
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
40
|
+
if (ar || !(i in from)) {
|
|
41
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
42
|
+
ar[i] = from[i];
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
46
|
+
};
|
|
47
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
48
|
+
exports.handler = void 0;
|
|
49
|
+
var determineRetryableDynamo_1 = require("./aws-services/dynamodb/determineRetryableDynamo");
|
|
50
|
+
var backOff_1 = require("./backOff");
|
|
3
51
|
/**
|
|
4
52
|
* Takes a given error, determines if we can bother retrying the operation, and re-attempts the operation
|
|
5
53
|
* @author Eric Webb <ewebb@factorearth.com>
|
|
@@ -9,11 +57,26 @@ import { backoff } from "./backOff";
|
|
|
9
57
|
* @param taskArguments The arguments we need to pass into the task
|
|
10
58
|
* @returns The result of the task, or the error that prevented it from executing
|
|
11
59
|
*/
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
return result;
|
|
60
|
+
function handler(err, task, evaluator) {
|
|
61
|
+
var taskArguments = [];
|
|
62
|
+
for (var _i = 3; _i < arguments.length; _i++) {
|
|
63
|
+
taskArguments[_i - 3] = arguments[_i];
|
|
17
64
|
}
|
|
18
|
-
return
|
|
65
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
66
|
+
var canBeRetried, result;
|
|
67
|
+
return __generator(this, function (_a) {
|
|
68
|
+
switch (_a.label) {
|
|
69
|
+
case 0:
|
|
70
|
+
canBeRetried = (0, determineRetryableDynamo_1.determineRetryableDynamo)(err);
|
|
71
|
+
if (!canBeRetried) return [3 /*break*/, 2];
|
|
72
|
+
return [4 /*yield*/, backOff_1.backoff.apply(void 0, __spreadArray([task, evaluator, undefined], taskArguments, false))];
|
|
73
|
+
case 1:
|
|
74
|
+
result = _a.sent();
|
|
75
|
+
return [2 /*return*/, result];
|
|
76
|
+
case 2: return [2 /*return*/, err];
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
});
|
|
19
80
|
}
|
|
81
|
+
exports.handler = handler;
|
|
82
|
+
//# sourceMappingURL=handler.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"handler.js","sourceRoot":"","sources":["../lib/handler.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,6FAA4F;AAC5F,qCAAoC;AAEpC;;;;;;;;GAQG;AACH,SAAsB,OAAO,CAA0C,GAAY,EAAE,IAAuD,EAAE,SAA0C;IAAE,uBAA+B;SAA/B,UAA+B,EAA/B,qBAA+B,EAA/B,IAA+B;QAA/B,sCAA+B;;;;;;;oBAClN,YAAY,GAAG,IAAA,mDAAwB,EAAC,GAAG,CAAC,CAAC;yBAC/C,YAAY,EAAZ,wBAAY;oBACA,qBAAM,iBAAO,8BAAC,IAAI,EAAE,SAAS,EAAE,SAAS,GAAK,aAAa,WAAC;;oBAApE,MAAM,GAAG,SAA2D;oBAC1E,sBAAO,MAAM,EAAC;wBAEf,sBAAO,GAAG,EAAC;;;;CACX;AAPD,0BAOC"}
|
package/dist/index.js
CHANGED
|
@@ -1,3 +1,20 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./aws-services/dynamodb/determineRetryableDynamo"), exports);
|
|
18
|
+
__exportStar(require("./backOff"), exports);
|
|
19
|
+
__exportStar(require("./handler"), exports);
|
|
20
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../lib/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,mFAAiE;AACjE,4CAA0B;AAC1B,4CAA0B"}
|
package/package.json
CHANGED
|
@@ -1,22 +1,26 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@factorearth/recordmiddleware-errorhandler",
|
|
3
|
-
"version": "0.0.1-y.
|
|
3
|
+
"version": "0.0.1-y.26",
|
|
4
4
|
"description": "A module for handling CRUD errors in lambda",
|
|
5
5
|
"author": "madtrx <marlin.makori@gmail.com>",
|
|
6
6
|
"homepage": "https://github.com/FactorEarth/RecordMiddleware#readme",
|
|
7
7
|
"license": "ISC",
|
|
8
|
-
"main": "dist/index
|
|
9
|
-
"types": "dist/index
|
|
8
|
+
"main": "dist/index",
|
|
9
|
+
"types": "dist/index",
|
|
10
10
|
"files": [
|
|
11
11
|
"dist"
|
|
12
12
|
],
|
|
13
|
+
"scripts": {
|
|
14
|
+
"build": "npm run clean && npm run compile",
|
|
15
|
+
"clean": "rm -rf ./dist && rm -rf tsconfig.build.tsbuildinfo",
|
|
16
|
+
"compile": "tsc -b tsconfig.build.json",
|
|
17
|
+
"test": "node ./__tests__/errorHandler.test.js",
|
|
18
|
+
"prepublishOnly": "npm run build"
|
|
19
|
+
},
|
|
13
20
|
"repository": {
|
|
14
21
|
"type": "git",
|
|
15
22
|
"url": "git+https://github.com/FactorEarth/RecordMiddleware.git"
|
|
16
23
|
},
|
|
17
|
-
"scripts": {
|
|
18
|
-
"test": "node ./__tests__/errorHandler.test.js"
|
|
19
|
-
},
|
|
20
24
|
"bugs": {
|
|
21
25
|
"url": "https://github.com/FactorEarth/RecordMiddleware/issues"
|
|
22
26
|
},
|
|
@@ -24,5 +28,5 @@
|
|
|
24
28
|
"access": "public",
|
|
25
29
|
"registry": "https://registry.npmjs.org/"
|
|
26
30
|
},
|
|
27
|
-
"gitHead": "
|
|
31
|
+
"gitHead": "df6f3f954d6db402b0dfe78dbfc386ba9684f824"
|
|
28
32
|
}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Given the error from the dynamodb operation, dertermines if we can retry it, based on the information from the dynamodb sdk docs
|
|
3
|
-
* {@link https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Programming.Errors.html}
|
|
4
|
-
* @author Eric Webb <ewebb@factorearth.com>
|
|
5
|
-
* @param err The error thrown by the dynamodb operation
|
|
6
|
-
* @returns Whether or not we can retry the operation
|
|
7
|
-
*/
|
|
8
|
-
export declare function determineRetryableDynamo(err: any): boolean;
|
package/dist/backOff.d.ts
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
interface BackoffOptions {
|
|
2
|
-
/**
|
|
3
|
-
* The initial delay you want to apply. Default to 100ms
|
|
4
|
-
*/
|
|
5
|
-
delay?: number;
|
|
6
|
-
/**
|
|
7
|
-
* The number of times you want to attempt the function. Default 10
|
|
8
|
-
*/
|
|
9
|
-
numberOfAttempts?: number;
|
|
10
|
-
/**
|
|
11
|
-
* An optional max delay
|
|
12
|
-
*/
|
|
13
|
-
maxDelay?: number;
|
|
14
|
-
/**
|
|
15
|
-
* An initial multiplier to be taken to the power of the attempt number when deciding how long to wait. Default value of 2
|
|
16
|
-
*/
|
|
17
|
-
timeMultiple?: number;
|
|
18
|
-
}
|
|
19
|
-
/**
|
|
20
|
-
* Given a task, attempts to execute it a designated number of times, returning the eventual response
|
|
21
|
-
* @author Eric Webb <ewebb@factorearth.com>
|
|
22
|
-
* @param task The task we want to retry potentially
|
|
23
|
-
* @param evaluator A function to evaluate if the task executed successfully, or if it needs to be retried. Needs to return boolean
|
|
24
|
-
* @param options The configurable options for the module
|
|
25
|
-
* @returns The result of the function
|
|
26
|
-
*/
|
|
27
|
-
export declare function backoff<TaskResult, TaskArguments extends any[]>(task: (...args: TaskArguments) => Promise<TaskResult>, evaluator: (taskResult: TaskResult) => boolean, options?: BackoffOptions, ...taskArguments: TaskArguments): Promise<TaskResult | void>;
|
|
28
|
-
export {};
|
package/dist/delay.d.ts
DELETED
package/dist/handler.d.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Takes a given error, determines if we can bother retrying the operation, and re-attempts the operation
|
|
3
|
-
* @author Eric Webb <ewebb@factorearth.com>
|
|
4
|
-
* @param err The error thrown by the dynamodb sdk
|
|
5
|
-
* @param task The task that we need to try and perform, if it can be retried
|
|
6
|
-
* @param evaluator The function that evaluates the success of the task
|
|
7
|
-
* @param taskArguments The arguments we need to pass into the task
|
|
8
|
-
* @returns The result of the task, or the error that prevented it from executing
|
|
9
|
-
*/
|
|
10
|
-
export declare function handler<TaskResult, TaskArguments extends any[]>(err: unknown, task: (...args: TaskArguments[]) => Promise<TaskResult>, evaluator: (result: TaskResult) => boolean, ...taskArguments: TaskArguments): Promise<unknown>;
|
package/dist/index.d.ts
DELETED