@hmcts/ccd-case-ui-toolkit 6.19.0-RetryCaseRetrievals.3 → 6.19.0-RetryCaseRetrievals.5
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/bundles/hmcts-ccd-case-ui-toolkit.umd.js +40 -35
- package/bundles/hmcts-ccd-case-ui-toolkit.umd.js.map +1 -1
- package/bundles/hmcts-ccd-case-ui-toolkit.umd.min.js +1 -1
- package/bundles/hmcts-ccd-case-ui-toolkit.umd.min.js.map +1 -1
- package/esm2015/lib/app.config.js +1 -1
- package/esm2015/lib/shared/components/case-editor/services/cases.service.js +5 -11
- package/esm2015/lib/shared/services/utils/retry/index.js +2 -2
- package/esm2015/lib/shared/services/utils/retry/retry.service.js +86 -0
- package/fesm2015/hmcts-ccd-case-ui-toolkit.js +36 -32
- package/fesm2015/hmcts-ccd-case-ui-toolkit.js.map +1 -1
- package/lib/app.config.d.ts +3 -1
- package/lib/app.config.d.ts.map +1 -1
- package/lib/shared/components/case-editor/services/cases.service.d.ts +0 -1
- package/lib/shared/components/case-editor/services/cases.service.d.ts.map +1 -1
- package/lib/shared/services/utils/retry/index.d.ts +1 -1
- package/lib/shared/services/utils/retry/index.d.ts.map +1 -1
- package/lib/shared/services/utils/retry/retry.service.d.ts +11 -0
- package/lib/shared/services/utils/retry/retry.service.d.ts.map +1 -0
- package/package.json +1 -1
- package/esm2015/lib/shared/services/utils/retry/retry-util.service.js +0 -76
- package/lib/shared/services/utils/retry/retry-util.service.d.ts +0 -18
- package/lib/shared/services/utils/retry/retry-util.service.d.ts.map +0 -1
|
@@ -8086,32 +8086,48 @@
|
|
|
8086
8086
|
}], null, null);
|
|
8087
8087
|
})();
|
|
8088
8088
|
|
|
8089
|
-
var
|
|
8090
|
-
function
|
|
8089
|
+
var ArtificialDelayContext = /** @class */ (function () {
|
|
8090
|
+
function ArtificialDelayContext(preferredDelay) {
|
|
8091
|
+
this.preferredDelay = preferredDelay;
|
|
8091
8092
|
this.artificialDelayOn = true;
|
|
8092
|
-
this.
|
|
8093
|
+
this.selectedDelay = this.selectActualDelayTime();
|
|
8093
8094
|
}
|
|
8094
|
-
|
|
8095
|
+
;
|
|
8096
|
+
ArtificialDelayContext.prototype.switchArtificialDelays = function (status) {
|
|
8095
8097
|
this.artificialDelayOn = status;
|
|
8096
|
-
this.
|
|
8098
|
+
this.selectedDelay = this.selectActualDelayTime();
|
|
8097
8099
|
};
|
|
8098
|
-
|
|
8100
|
+
ArtificialDelayContext.prototype.turnOnArtificialDelays = function () {
|
|
8099
8101
|
this.switchArtificialDelays(true);
|
|
8100
8102
|
};
|
|
8101
|
-
|
|
8103
|
+
ArtificialDelayContext.prototype.turnOffArtificialDelays = function () {
|
|
8102
8104
|
this.switchArtificialDelays(false);
|
|
8103
8105
|
};
|
|
8104
|
-
|
|
8105
|
-
return this.artificialDelayOn ? this.
|
|
8106
|
+
ArtificialDelayContext.prototype.getActualDelay = function () {
|
|
8107
|
+
return this.artificialDelayOn ? this.selectedDelay : 0;
|
|
8108
|
+
};
|
|
8109
|
+
ArtificialDelayContext.prototype.shouldApplyArtificialDelay = function () {
|
|
8110
|
+
return this.preferredDelay > 0;
|
|
8111
|
+
};
|
|
8112
|
+
ArtificialDelayContext.prototype.selectActualDelayTime = function () {
|
|
8113
|
+
return Date.now() % 2 == 0 ? this.preferredDelay : 1;
|
|
8106
8114
|
};
|
|
8107
|
-
|
|
8108
|
-
|
|
8115
|
+
return ArtificialDelayContext;
|
|
8116
|
+
}());
|
|
8117
|
+
var RetryUtil = /** @class */ (function () {
|
|
8118
|
+
function RetryUtil() {
|
|
8119
|
+
}
|
|
8120
|
+
RetryUtil.prototype.pipeTimeoutMechanismOn = function (in$, preferredArtificialDelay, timeoutPeriods) {
|
|
8121
|
+
var artificialDelayContext = new ArtificialDelayContext(preferredArtificialDelay);
|
|
8122
|
+
console.info("Piping a retry mechanism with timeouts {" + timeoutPeriods + "}.");
|
|
8123
|
+
console.info("Artificial delay will be applied: " + artificialDelayContext.shouldApplyArtificialDelay() + ".");
|
|
8109
8124
|
var out$ = in$;
|
|
8110
|
-
if (
|
|
8111
|
-
|
|
8125
|
+
if (artificialDelayContext.shouldApplyArtificialDelay()) {
|
|
8126
|
+
console.info("Preferred artificial delay: " + preferredArtificialDelay + " seconds. Actual delay selected: " + artificialDelayContext.getActualDelay());
|
|
8127
|
+
out$ = this.pipeArtificialDelayOn(out$, artificialDelayContext);
|
|
8112
8128
|
}
|
|
8113
8129
|
out$ = this.pipeTimeOutControlOn(out$, timeoutPeriods);
|
|
8114
|
-
out$ = this.pipeRetryMechanismOn(out
|
|
8130
|
+
out$ = this.pipeRetryMechanismOn(out$, artificialDelayContext);
|
|
8115
8131
|
return out$;
|
|
8116
8132
|
};
|
|
8117
8133
|
RetryUtil.prototype.pipeTimeOutControlOn = function (in$, timeoutPeriods) {
|
|
@@ -8119,14 +8135,13 @@
|
|
|
8119
8135
|
var out$ = in$.pipe(operators.timeout(timeOutAfterSeconds * 1000));
|
|
8120
8136
|
return out$;
|
|
8121
8137
|
};
|
|
8122
|
-
RetryUtil.prototype.pipeRetryMechanismOn = function (in
|
|
8123
|
-
var _this = this;
|
|
8138
|
+
RetryUtil.prototype.pipeRetryMechanismOn = function (in$, artificialDelayContext) {
|
|
8124
8139
|
var retryStrategy = function (errors) {
|
|
8125
8140
|
return errors.pipe(operators.mergeMap(function (error, i) {
|
|
8126
8141
|
console.error("Mapping error " + (error === null || error === void 0 ? void 0 : error.name) + ", " + i);
|
|
8127
8142
|
console.error(error);
|
|
8128
8143
|
if ((error === null || error === void 0 ? void 0 : error.name) === 'TimeoutError' && i === 0) {
|
|
8129
|
-
|
|
8144
|
+
artificialDelayContext.turnOffArtificialDelays();
|
|
8130
8145
|
console.info('Will retry, after a timeout error.');
|
|
8131
8146
|
}
|
|
8132
8147
|
else {
|
|
@@ -8139,20 +8154,16 @@
|
|
|
8139
8154
|
var out$ = in$.pipe(operators.retryWhen(retryStrategy));
|
|
8140
8155
|
return out$;
|
|
8141
8156
|
};
|
|
8142
|
-
RetryUtil.prototype.pipeArtificialDelayOn = function (in
|
|
8143
|
-
var _this = this;
|
|
8157
|
+
RetryUtil.prototype.pipeArtificialDelayOn = function (in$, artificialDelayContext) {
|
|
8144
8158
|
var out$ = in$.pipe(operators.tap(function () {
|
|
8145
|
-
console.log("Artificially delaying for " +
|
|
8159
|
+
console.log("Artificially delaying for " + artificialDelayContext.getActualDelay() + " seconds..");
|
|
8146
8160
|
}));
|
|
8147
|
-
out$ = out$.pipe(operators.delayWhen(function () { return rxjs.timer(
|
|
8161
|
+
out$ = out$.pipe(operators.delayWhen(function () { return rxjs.timer(artificialDelayContext.getActualDelay() * 1000); }));
|
|
8148
8162
|
out$ = out$.pipe(operators.tap(function () {
|
|
8149
|
-
console.log("Artificially delayed for " +
|
|
8163
|
+
console.log("Artificially delayed for " + artificialDelayContext.getActualDelay() + " seconds..");
|
|
8150
8164
|
}));
|
|
8151
8165
|
return out$;
|
|
8152
8166
|
};
|
|
8153
|
-
RetryUtil.prototype.pickARandomValue = function () {
|
|
8154
|
-
return Date.now() % 2 == 0 ? 60 : 3;
|
|
8155
|
-
};
|
|
8156
8167
|
return RetryUtil;
|
|
8157
8168
|
}());
|
|
8158
8169
|
RetryUtil.ɵfac = function RetryUtil_Factory(t) { return new (t || RetryUtil)(); };
|
|
@@ -8757,30 +8768,24 @@
|
|
|
8757
8768
|
.set('Content-Type', 'application/json');
|
|
8758
8769
|
var loadingToken = this.loadingService.register();
|
|
8759
8770
|
var http$ = this.http.get(url, { headers: headers, observe: 'body' });
|
|
8760
|
-
|
|
8771
|
+
var artificialDelay = this.appConfig.getTimeoutsCaseRetrievalArtificialDelay();
|
|
8772
|
+
http$ = this.retryUtil.pipeTimeoutMechanismOn(http$, artificialDelay, this.appConfig.getTimeoutsForCaseRetrieval());
|
|
8761
8773
|
http$ = this.pipeErrorProcessor(http$);
|
|
8762
8774
|
http$ = http$.pipe(operators.finalize(function () { return _this.finalizeGetCaseViewWith(caseId, loadingToken); }));
|
|
8763
8775
|
return http$;
|
|
8764
8776
|
};
|
|
8765
8777
|
CasesService.prototype.pipeErrorProcessor = function (in$) {
|
|
8766
8778
|
var _this = this;
|
|
8767
|
-
var out
|
|
8779
|
+
var out$ = in$.pipe(operators.catchError(function (error) {
|
|
8768
8780
|
console.error("Error while getting case view with getCaseViewV2! Error type: '" + typeof error + ", Error name: '" + (error === null || error === void 0 ? void 0 : error.name) + "'");
|
|
8769
8781
|
console.error(error);
|
|
8770
8782
|
_this.errorService.setError(error);
|
|
8771
8783
|
return rxjs.throwError(error);
|
|
8772
8784
|
}));
|
|
8773
|
-
return out
|
|
8774
|
-
};
|
|
8775
|
-
CasesService.prototype.syncWait = function (seconds) {
|
|
8776
|
-
var end = Date.now() + seconds * 1000;
|
|
8777
|
-
while (Date.now() < end)
|
|
8778
|
-
continue;
|
|
8785
|
+
return out$;
|
|
8779
8786
|
};
|
|
8780
8787
|
CasesService.prototype.finalizeGetCaseViewWith = function (caseId, loadingToken) {
|
|
8781
8788
|
console.info("finalizeGetCaseViewWith started for " + caseId + ".");
|
|
8782
|
-
// this.syncWait(15);
|
|
8783
|
-
// throw new Error('++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++');
|
|
8784
8789
|
this.loadingService.unregister(loadingToken);
|
|
8785
8790
|
console.info("finalizeGetCaseViewWith finished for " + caseId + ".");
|
|
8786
8791
|
};
|