@hmcts/ccd-case-ui-toolkit 6.19.0-RetryCaseRetrievals.4 → 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 -36
- 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/retry.service.js +33 -24
- package/fesm2015/hmcts-ccd-case-ui-toolkit.js +36 -33
- 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/retry.service.d.ts +1 -8
- package/lib/shared/services/utils/retry/retry.service.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -8086,33 +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
|
-
|
|
8109
|
-
|
|
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() + ".");
|
|
8110
8124
|
var out$ = in$;
|
|
8111
|
-
if (
|
|
8112
|
-
|
|
8125
|
+
if (artificialDelayContext.shouldApplyArtificialDelay()) {
|
|
8126
|
+
console.info("Preferred artificial delay: " + preferredArtificialDelay + " seconds. Actual delay selected: " + artificialDelayContext.getActualDelay());
|
|
8127
|
+
out$ = this.pipeArtificialDelayOn(out$, artificialDelayContext);
|
|
8113
8128
|
}
|
|
8114
8129
|
out$ = this.pipeTimeOutControlOn(out$, timeoutPeriods);
|
|
8115
|
-
out$ = this.pipeRetryMechanismOn(out
|
|
8130
|
+
out$ = this.pipeRetryMechanismOn(out$, artificialDelayContext);
|
|
8116
8131
|
return out$;
|
|
8117
8132
|
};
|
|
8118
8133
|
RetryUtil.prototype.pipeTimeOutControlOn = function (in$, timeoutPeriods) {
|
|
@@ -8120,14 +8135,13 @@
|
|
|
8120
8135
|
var out$ = in$.pipe(operators.timeout(timeOutAfterSeconds * 1000));
|
|
8121
8136
|
return out$;
|
|
8122
8137
|
};
|
|
8123
|
-
RetryUtil.prototype.pipeRetryMechanismOn = function (in
|
|
8124
|
-
var _this = this;
|
|
8138
|
+
RetryUtil.prototype.pipeRetryMechanismOn = function (in$, artificialDelayContext) {
|
|
8125
8139
|
var retryStrategy = function (errors) {
|
|
8126
8140
|
return errors.pipe(operators.mergeMap(function (error, i) {
|
|
8127
8141
|
console.error("Mapping error " + (error === null || error === void 0 ? void 0 : error.name) + ", " + i);
|
|
8128
8142
|
console.error(error);
|
|
8129
8143
|
if ((error === null || error === void 0 ? void 0 : error.name) === 'TimeoutError' && i === 0) {
|
|
8130
|
-
|
|
8144
|
+
artificialDelayContext.turnOffArtificialDelays();
|
|
8131
8145
|
console.info('Will retry, after a timeout error.');
|
|
8132
8146
|
}
|
|
8133
8147
|
else {
|
|
@@ -8140,20 +8154,16 @@
|
|
|
8140
8154
|
var out$ = in$.pipe(operators.retryWhen(retryStrategy));
|
|
8141
8155
|
return out$;
|
|
8142
8156
|
};
|
|
8143
|
-
RetryUtil.prototype.pipeArtificialDelayOn = function (in
|
|
8144
|
-
var _this = this;
|
|
8157
|
+
RetryUtil.prototype.pipeArtificialDelayOn = function (in$, artificialDelayContext) {
|
|
8145
8158
|
var out$ = in$.pipe(operators.tap(function () {
|
|
8146
|
-
console.log("Artificially delaying for " +
|
|
8159
|
+
console.log("Artificially delaying for " + artificialDelayContext.getActualDelay() + " seconds..");
|
|
8147
8160
|
}));
|
|
8148
|
-
out$ = out$.pipe(operators.delayWhen(function () { return rxjs.timer(
|
|
8161
|
+
out$ = out$.pipe(operators.delayWhen(function () { return rxjs.timer(artificialDelayContext.getActualDelay() * 1000); }));
|
|
8149
8162
|
out$ = out$.pipe(operators.tap(function () {
|
|
8150
|
-
console.log("Artificially delayed for " +
|
|
8163
|
+
console.log("Artificially delayed for " + artificialDelayContext.getActualDelay() + " seconds..");
|
|
8151
8164
|
}));
|
|
8152
8165
|
return out$;
|
|
8153
8166
|
};
|
|
8154
|
-
RetryUtil.prototype.pickARandomValue = function () {
|
|
8155
|
-
return Date.now() % 2 == 0 ? 60 : 3;
|
|
8156
|
-
};
|
|
8157
8167
|
return RetryUtil;
|
|
8158
8168
|
}());
|
|
8159
8169
|
RetryUtil.ɵfac = function RetryUtil_Factory(t) { return new (t || RetryUtil)(); };
|
|
@@ -8758,30 +8768,24 @@
|
|
|
8758
8768
|
.set('Content-Type', 'application/json');
|
|
8759
8769
|
var loadingToken = this.loadingService.register();
|
|
8760
8770
|
var http$ = this.http.get(url, { headers: headers, observe: 'body' });
|
|
8761
|
-
|
|
8771
|
+
var artificialDelay = this.appConfig.getTimeoutsCaseRetrievalArtificialDelay();
|
|
8772
|
+
http$ = this.retryUtil.pipeTimeoutMechanismOn(http$, artificialDelay, this.appConfig.getTimeoutsForCaseRetrieval());
|
|
8762
8773
|
http$ = this.pipeErrorProcessor(http$);
|
|
8763
8774
|
http$ = http$.pipe(operators.finalize(function () { return _this.finalizeGetCaseViewWith(caseId, loadingToken); }));
|
|
8764
8775
|
return http$;
|
|
8765
8776
|
};
|
|
8766
8777
|
CasesService.prototype.pipeErrorProcessor = function (in$) {
|
|
8767
8778
|
var _this = this;
|
|
8768
|
-
var out
|
|
8779
|
+
var out$ = in$.pipe(operators.catchError(function (error) {
|
|
8769
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) + "'");
|
|
8770
8781
|
console.error(error);
|
|
8771
8782
|
_this.errorService.setError(error);
|
|
8772
8783
|
return rxjs.throwError(error);
|
|
8773
8784
|
}));
|
|
8774
|
-
return out
|
|
8775
|
-
};
|
|
8776
|
-
CasesService.prototype.syncWait = function (seconds) {
|
|
8777
|
-
var end = Date.now() + seconds * 1000;
|
|
8778
|
-
while (Date.now() < end)
|
|
8779
|
-
continue;
|
|
8785
|
+
return out$;
|
|
8780
8786
|
};
|
|
8781
8787
|
CasesService.prototype.finalizeGetCaseViewWith = function (caseId, loadingToken) {
|
|
8782
8788
|
console.info("finalizeGetCaseViewWith started for " + caseId + ".");
|
|
8783
|
-
// this.syncWait(15);
|
|
8784
|
-
// throw new Error('++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++');
|
|
8785
8789
|
this.loadingService.unregister(loadingToken);
|
|
8786
8790
|
console.info("finalizeGetCaseViewWith finished for " + caseId + ".");
|
|
8787
8791
|
};
|