Odoo GraphQL Subscription using Node, Express JS for Sample
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

1 lines
9.6 KiB

{"version":3,"file":"retry.cjs","sources":["delayFunction.js","retryFunction.js","retryLink.js"],"sourcesContent":["export function buildDelayFunction(delayOptions) {\n var _a = delayOptions || {}, _b = _a.initial, initial = _b === void 0 ? 300 : _b, _c = _a.jitter, jitter = _c === void 0 ? true : _c, _d = _a.max, max = _d === void 0 ? Infinity : _d;\n // If we're jittering, baseDelay is half of the maximum delay for that\n // attempt (and is, on average, the delay we will encounter).\n // If we're not jittering, adjust baseDelay so that the first attempt\n // lines up with initialDelay, for everyone's sanity.\n var baseDelay = jitter ? initial : initial / 2;\n return function delayFunction(count) {\n var delay = Math.min(max, baseDelay * Math.pow(2, count));\n if (jitter) {\n // We opt for a full jitter approach for a mostly uniform distribution,\n // but bound it within initialDelay and delay for everyone's sanity.\n delay = Math.random() * delay;\n }\n return delay;\n };\n}\n//# sourceMappingURL=delayFunction.js.map","export function buildRetryFunction(retryOptions) {\n var _a = retryOptions || {}, retryIf = _a.retryIf, _b = _a.max, max = _b === void 0 ? 5 : _b;\n return function retryFunction(count, operation, error) {\n if (count >= max)\n return false;\n return retryIf ? retryIf(error, operation) : !!error;\n };\n}\n//# sourceMappingURL=retryFunction.js.map","import { __awaiter, __extends, __generator } from \"tslib\";\nimport { ApolloLink } from \"../core/index.js\";\nimport { Observable } from \"../../utilities/index.js\";\nimport { buildDelayFunction } from \"./delayFunction.js\";\nimport { buildRetryFunction } from \"./retryFunction.js\";\n/**\n * Tracking and management of operations that may be (or currently are) retried.\n */\nvar RetryableOperation = /** @class */ (function () {\n function RetryableOperation(observer, operation, forward, delayFor, retryIf) {\n var _this = this;\n this.observer = observer;\n this.operation = operation;\n this.forward = forward;\n this.delayFor = delayFor;\n this.retryIf = retryIf;\n this.retryCount = 0;\n this.currentSubscription = null;\n this.onError = function (error) { return __awaiter(_this, void 0, void 0, function () {\n var shouldRetry;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0:\n this.retryCount += 1;\n return [4 /*yield*/, this.retryIf(this.retryCount, this.operation, error)];\n case 1:\n shouldRetry = _a.sent();\n if (shouldRetry) {\n this.scheduleRetry(this.delayFor(this.retryCount, this.operation, error));\n return [2 /*return*/];\n }\n this.observer.error(error);\n return [2 /*return*/];\n }\n });\n }); };\n this.try();\n }\n /**\n * Stop retrying for the operation, and cancel any in-progress requests.\n */\n RetryableOperation.prototype.cancel = function () {\n if (this.currentSubscription) {\n this.currentSubscription.unsubscribe();\n }\n clearTimeout(this.timerId);\n this.timerId = undefined;\n this.currentSubscription = null;\n };\n RetryableOperation.prototype.try = function () {\n this.currentSubscription = this.forward(this.operation).subscribe({\n next: this.observer.next.bind(this.observer),\n error: this.onError,\n complete: this.observer.complete.bind(this.observer),\n });\n };\n RetryableOperation.prototype.scheduleRetry = function (delay) {\n var _this = this;\n if (this.timerId) {\n throw new Error(\"RetryLink BUG! Encountered overlapping retries\");\n }\n this.timerId = setTimeout(function () {\n _this.timerId = undefined;\n _this.try();\n }, delay);\n };\n return RetryableOperation;\n}());\nvar RetryLink = /** @class */ (function (_super) {\n __extends(RetryLink, _super);\n function RetryLink(options) {\n var _this = _super.call(this) || this;\n var _a = options || {}, attempts = _a.attempts, delay = _a.delay;\n _this.delayFor =\n typeof delay === \"function\" ? delay : buildDelayFunction(delay);\n _this.retryIf =\n typeof attempts === \"function\" ? attempts : buildRetryFunction(attempts);\n return _this;\n }\n RetryLink.prototype.request = function (operation, nextLink) {\n var _this = this;\n return new Observable(function (observer) {\n var retryable = new RetryableOperation(observer, operation, nextLink, _this.delayFor, _this.retryIf);\n return function () {\n retryable.cancel();\n };\n });\n };\n return RetryLink;\n}(ApolloLink));\nexport { RetryLink };\n//# sourceMappingURL=retryLink.js.map"],"names":["__awaiter","__generator","__extends","Observable","ApolloLink"],"mappings":";;;;;;;;AAAO,SAAS,kBAAkB,CAAC,YAAY,EAAE;AACjD,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