@nsshunt/ststestrunner 1.1.67 → 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.
@@ -168,7 +168,28 @@ var TestCaseFhirBase = class {
168
168
  console.log(`-----------------------------------------------------------------------------------------------------------------`);
169
169
  }
170
170
  let fhirClient = this.runnerExecutionWorker.GetFhirClient();
171
- if (fhirClient) return fhirClient;
171
+ if (fhirClient) {
172
+ console.log(chalk.default.green(`[${this.runnerExecutionWorker.id}] Getting existing fhir client`));
173
+ return fhirClient;
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
+ }
191
+ console.log(chalk.default.red(`[${this.runnerExecutionWorker.id}] fhir client does not exist - setting up new client`));
192
+ this.runnerExecutionWorker.SetOnHold("fhirclient");
172
193
  const fhirOptions = this.#options.fhirOptions;
173
194
  const options = {
174
195
  fhirServerEndpoint: fhirOptions.stsfhirserverendpoint,
@@ -188,7 +209,9 @@ var TestCaseFhirBase = class {
188
209
  if (this.runner.options.fhirOptions.stsfhirsocketclientmode === "socket-client-all-in-one") fhirClient = new _nsshunt_stsfhirclient.FhirSocketClientAllInOne("FhirSocketClient", options);
189
210
  else fhirClient = new _nsshunt_stsfhirclient.FhirSocketClientIndividual("FhirSocketClient", options);
190
211
  await fhirClient.WaitForSocketConnected();
212
+ console.log(chalk.default.red(`[${this.runnerExecutionWorker.id}] setting fhir client into object`));
191
213
  this.runnerExecutionWorker.SetFhirClient(fhirClient);
214
+ this.runnerExecutionWorker.ReleaseOnHold("fhirclient");
192
215
  return fhirClient;
193
216
  } catch (error) {
194
217
  this.LogErrorMessage(error);
@@ -35819,6 +35842,7 @@ var WorkerFhirTestCases = class extends _nsshunt_stsrunnerframework.AbstractRunn
35819
35842
  _resourceDataGenerator;
35820
35843
  fhirClient = void 0;
35821
35844
  _id = crypto.randomUUID();
35845
+ _onHoldKeys = {};
35822
35846
  constructor(options) {
35823
35847
  super();
35824
35848
  this._options = options;
@@ -35855,6 +35879,25 @@ var WorkerFhirTestCases = class extends _nsshunt_stsrunnerframework.AbstractRunn
35855
35879
  myresponsepreterminate: `I got: [${JSON.stringify(messagePayload.payload.data)}]`
35856
35880
  };
35857
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
+ };
35858
35901
  };
35859
35902
  //#endregion
35860
35903
  exports.WorkerFhirTestCases = WorkerFhirTestCases;