@nsshunt/ststestrunner 1.1.69 → 1.1.70

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.
@@ -172,7 +172,24 @@ var TestCaseFhirBase = class {
172
172
  console.log(chalk.default.green(`[${this.runnerExecutionWorker.id}] Getting existing fhir client`));
173
173
  return fhirClient;
174
174
  }
175
+ if (this.runnerExecutionWorker.GetOnHold("fhirclient") === true) {
176
+ console.log(chalk.default.magenta(`[${this.runnerExecutionWorker.id}] fhir client does not exist - some other client setting up the new client - waiting ...`));
177
+ try {
178
+ await this.runnerExecutionWorker.WaitOnHold("fhirclient", 6e4);
179
+ const fhirClient = this.runnerExecutionWorker.GetFhirClient();
180
+ if (fhirClient) {
181
+ console.log(chalk.default.green(`[${this.runnerExecutionWorker.id}] Getting existing fhir client (post hold release)`));
182
+ return fhirClient;
183
+ } else {
184
+ console.log(chalk.default.red(`[${this.runnerExecutionWorker.id}] Could not get existing fhir client (post hold release)`));
185
+ console.log(chalk.default.red(`continue anyway ...`));
186
+ }
187
+ } catch (error) {
188
+ console.error(chalk.default.red(`GetFhirSocketClient(): Error: [${error}]`));
189
+ }
190
+ }
175
191
  console.log(chalk.default.red(`[${this.runnerExecutionWorker.id}] fhir client does not exist - setting up new client`));
192
+ this.runnerExecutionWorker.SetOnHold("fhirclient");
176
193
  const fhirOptions = this.#options.fhirOptions;
177
194
  const options = {
178
195
  fhirServerEndpoint: fhirOptions.stsfhirserverendpoint,
@@ -194,6 +211,7 @@ var TestCaseFhirBase = class {
194
211
  await fhirClient.WaitForSocketConnected();
195
212
  console.log(chalk.default.red(`[${this.runnerExecutionWorker.id}] setting fhir client into object`));
196
213
  this.runnerExecutionWorker.SetFhirClient(fhirClient);
214
+ this.runnerExecutionWorker.ReleaseOnHold("fhirclient");
197
215
  return fhirClient;
198
216
  } catch (error) {
199
217
  this.LogErrorMessage(error);
@@ -35824,6 +35842,7 @@ var WorkerFhirTestCases = class extends _nsshunt_stsrunnerframework.AbstractRunn
35824
35842
  _resourceDataGenerator;
35825
35843
  fhirClient = void 0;
35826
35844
  _id = crypto.randomUUID();
35845
+ _onHoldKeys = {};
35827
35846
  constructor(options) {
35828
35847
  super();
35829
35848
  this._options = options;
@@ -35860,6 +35879,25 @@ var WorkerFhirTestCases = class extends _nsshunt_stsrunnerframework.AbstractRunn
35860
35879
  myresponsepreterminate: `I got: [${JSON.stringify(messagePayload.payload.data)}]`
35861
35880
  };
35862
35881
  }
35882
+ GetOnHold = (holdKey) => {
35883
+ if (this._onHoldKeys[holdKey]) return true;
35884
+ return false;
35885
+ };
35886
+ WaitOnHold = async (holdKey, timeout) => {
35887
+ const start = performance.now();
35888
+ for (;;) {
35889
+ if (this._onHoldKeys[holdKey]) await (0, _nsshunt_stsutils.Sleep)(100);
35890
+ else break;
35891
+ if (performance.now() - start > timeout) throw new Error(`WaitOnHold timeout: [${timeout}] reached.`);
35892
+ }
35893
+ return true;
35894
+ };
35895
+ SetOnHold = (holdKey) => {
35896
+ this._onHoldKeys[holdKey] = true;
35897
+ };
35898
+ ReleaseOnHold = (holdKey) => {
35899
+ delete this._onHoldKeys[holdKey];
35900
+ };
35863
35901
  };
35864
35902
  //#endregion
35865
35903
  exports.WorkerFhirTestCases = WorkerFhirTestCases;