@hmcts/ccd-case-ui-toolkit 6.19.0-RetryCaseRetrievals.2 → 6.19.0-RetryCaseRetrievals.4

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.
@@ -8089,11 +8089,11 @@
8089
8089
  var RetryUtil = /** @class */ (function () {
8090
8090
  function RetryUtil() {
8091
8091
  this.artificialDelayOn = true;
8092
- this.artificialDelayPeriod = Math.random() > 0.5 ? 60 : 3;
8092
+ this.artificialDelayPeriod = this.pickARandomValue();
8093
8093
  }
8094
8094
  RetryUtil.prototype.switchArtificialDelays = function (status) {
8095
8095
  this.artificialDelayOn = status;
8096
- this.artificialDelayPeriod = Math.random() > 0.5 ? 60 : 2;
8096
+ this.artificialDelayPeriod = this.pickARandomValue();
8097
8097
  };
8098
8098
  RetryUtil.prototype.switchOnArtificialDelays = function () {
8099
8099
  this.switchArtificialDelays(true);
@@ -8104,10 +8104,11 @@
8104
8104
  RetryUtil.prototype.getArtificialDelayTime = function () {
8105
8105
  return this.artificialDelayOn ? this.artificialDelayPeriod : 0;
8106
8106
  };
8107
- RetryUtil.prototype.pipeTimeoutMechanismOn = function (in$, environment, timeoutPeriods) {
8107
+ RetryUtil.prototype.pipeTimeoutMechanismOn = function (in$, artificialDelayOn, timeoutPeriods) {
8108
+ console.info("Piping a retry mechanism with timeouts {" + timeoutPeriods + "}. Artificial delays added: " + artificialDelayOn + ".");
8108
8109
  this.switchOnArtificialDelays();
8109
8110
  var out$ = in$;
8110
- if (environment === 'aat') {
8111
+ if (artificialDelayOn) {
8111
8112
  out$ = this.pipeArtificialDelayOn(out$);
8112
8113
  }
8113
8114
  out$ = this.pipeTimeOutControlOn(out$, timeoutPeriods);
@@ -8150,6 +8151,9 @@
8150
8151
  }));
8151
8152
  return out$;
8152
8153
  };
8154
+ RetryUtil.prototype.pickARandomValue = function () {
8155
+ return Date.now() % 2 == 0 ? 60 : 3;
8156
+ };
8153
8157
  return RetryUtil;
8154
8158
  }());
8155
8159
  RetryUtil.ɵfac = function RetryUtil_Factory(t) { return new (t || RetryUtil)(); };
@@ -8754,7 +8758,7 @@
8754
8758
  .set('Content-Type', 'application/json');
8755
8759
  var loadingToken = this.loadingService.register();
8756
8760
  var http$ = this.http.get(url, { headers: headers, observe: 'body' });
8757
- this.retryUtil.pipeTimeoutMechanismOn(http$, this.appConfig.getEnvironment(), this.appConfig.getCaseRetrievalTimeouts());
8761
+ this.retryUtil.pipeTimeoutMechanismOn(http$, this.appConfig.getEnvironment() === 'aat', this.appConfig.getCaseRetrievalTimeouts());
8758
8762
  http$ = this.pipeErrorProcessor(http$);
8759
8763
  http$ = http$.pipe(operators.finalize(function () { return _this.finalizeGetCaseViewWith(caseId, loadingToken); }));
8760
8764
  return http$;