@nsshunt/stsrunnerframework 1.0.88 → 1.0.90

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.
@@ -9,7 +9,7 @@ var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read fr
9
9
  var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
10
10
  var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
11
11
  var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "access private method"), method);
12
- var _collectorCollectorPort, _runners, _options, _workerId, _debug, _error, _processLoopExecutor, _SetMessagePort, _CreateRunnerEx2RunState, _UpdateRunnerStateById, _GetAllRunners, _CanExecuteNextIterationById, _IsCompletedById, _GetRunnerIterationById, _ResetRunnerIterationById, _IncRunnerIterationById, _GetRunnerInstanceById, _GetRunnerExecutionProfileById, _GetRunnerOptionsById, _SetRunnerOptionsById, _AddRunner, _WorkerInstance_instances, SleepImmediate_fn, _PostMessageToWorkerManagerById, _StartRunner, _StopRunnerByRunnerId, _StopAllRunners, _StopRunner, _TerminateRunner, _PauseRunner, _ResumeRunner, _ResetRunner, _ExecuteRunner, _UpdateOptions, _workersEx, _options2, _STSInstrumentController, _telemetryProcessor, _archiveList, _id, _processLoopExecutor2, _debug2, _SetRunnerIntoWorker, _ProcessTelemetry, _EmitWorkerEvent, _EmitRunnerEvent, _RunnerStateChange, _RemoveRunnerFromCollection, _CreateAsyncRunner, _PostMessageToWorkerUsingDefaultChannel, _PostMessageToWorker, _StartRunner2, _ResetRunner2, _ExecuteRunner2, _StopRunner2, _TerminateRunner2, _PauseRunner2, _ResumeRunner2, _UpdateOptionsRunner, _PauseWorker, _ResumeWorker, _StopWorker, _StartWorker, _ResetWorker, _ExecuteWorker, _UpdateOptionsWorker, _TerminateWorker, _BroadcastCommandToAllRunners, _HandleAllWorkers;
12
+ var _collectorCollectorPort, _runners, _options, _workerId, _debug, _error, _processLoopExecutor, _SetMessagePort, _CreateRunnerEx2RunState, _UpdateRunnerStateById, _GetAllRunners, _CanExecuteNextIterationById, _IsCompletedById, _GetRunnerIterationById, _ResetRunnerIterationById, _IncRunnerIterationById, _GetRunnerInstanceById, _GetRunnerExecutionProfileById, _GetRunnerOptionsById, _SetRunnerOptionsById, _AddRunner, _WorkerInstance_instances, SleepImmediate_fn, _PostMessageToWorkerManagerById, _PostRunnersToWorkerManager, _StartRunner, _StopRunnerByRunnerId, _StopAllRunners, _StopRunner, _TerminateRunner, _PauseRunner, _ResumeRunner, _ResetRunner, _ExecuteRunner, _UpdateOptions, _workersEx, _options2, _STSInstrumentController, _telemetryProcessor, _archiveList, _id, _messages, _processLoopExecutor2, _debug2, _SetRunnerIntoWorker, _ProcessTelemetry, _EmitWorkerEvent, _EmitRunnerEvent, _RunnerStateChange, _RemoveRunnerFromCollection, _CreateAsyncRunner, _PostMessageToWorkerUsingDefaultChannel, _PostMessageToWorker, _StartRunner2, _ResetRunner2, _ExecuteRunner2, _StopRunner2, _TerminateRunner2, _PauseRunner2, _ResumeRunner2, _UpdateOptionsRunner, _PauseWorker, _ResumeWorker, _StopWorker, _StartWorker, _ResetWorker, _ExecuteWorker, _UpdateOptionsWorker, _TerminateWorker, _BroadcastCommandToAllRunners, _HandleAllWorkers, _STSWorkerManager_instances, GetRunnersResponse_fn, _PostMessageToWorkerGetRunners;
13
13
  import { defaultLogger, Sleep, ModelDelimeter } from "@nsshunt/stsutils";
14
14
  import { Gauge } from "@nsshunt/stsobservability";
15
15
  const URI_BASE_VUEUTILS = "/";
@@ -32,6 +32,7 @@ var eIWMessageCommands = /* @__PURE__ */ ((eIWMessageCommands2) => {
32
32
  eIWMessageCommands2["TerminateRunner"] = "__STS__TerminateRunner";
33
33
  eIWMessageCommands2["RunnerStateChange"] = "__STS__RunnerStateChange";
34
34
  eIWMessageCommands2["RemoveRunnerFromCollection"] = "__STS__RemoveRunnerFromCollection";
35
+ eIWMessageCommands2["GetRunners"] = "__STS__GetRunners";
35
36
  return eIWMessageCommands2;
36
37
  })(eIWMessageCommands || {});
37
38
  var IRunnerState = /* @__PURE__ */ ((IRunnerState2) => {
@@ -1543,7 +1544,7 @@ class WorkerInstance {
1543
1544
  const promArray = [];
1544
1545
  for (const [, runner] of Object.entries(__privateGet(this, _runners))) {
1545
1546
  if (runner.runner.state === IRunnerState.completed || runner.runner.state === IRunnerState.error || runner.runner.state === IRunnerState.stopped || runner.runner.state === IRunnerState.terminated) {
1546
- promArray.push(__privateGet(this, _PostMessageToWorkerManagerById).call(this, eIWMessageCommands.RemoveRunnerFromCollection, runner.runner.id));
1547
+ promArray.push(__privateGet(this, _PostMessageToWorkerManagerById).call(this, eIWMessageCommands.RemoveRunnerFromCollection, runner.runner.id, false));
1547
1548
  removeList.push(runner.runner.id);
1548
1549
  }
1549
1550
  }
@@ -1574,7 +1575,7 @@ class WorkerInstance {
1574
1575
  return;
1575
1576
  });
1576
1577
  __publicField(this, "PostTelemetryById", (id) => {
1577
- __privateGet(this, _PostMessageToWorkerManagerById).call(this, eIWMessageCommands.InstrumentTelemetry, id);
1578
+ __privateGet(this, _PostMessageToWorkerManagerById).call(this, eIWMessageCommands.InstrumentTelemetry, id, false);
1578
1579
  });
1579
1580
  __privateAdd(this, _SetMessagePort, (workerMessagePort) => {
1580
1581
  try {
@@ -1617,7 +1618,7 @@ class WorkerInstance {
1617
1618
  try {
1618
1619
  if (__privateGet(this, _runners)[id]) {
1619
1620
  __privateGet(this, _runners)[id].runner.state = state;
1620
- __privateGet(this, _PostMessageToWorkerManagerById).call(this, eIWMessageCommands.RunnerStateChange, id);
1621
+ __privateGet(this, _PostMessageToWorkerManagerById).call(this, eIWMessageCommands.RunnerStateChange, id, false);
1621
1622
  } else {
1622
1623
  console.warn(`#UpdateRunnerStateById(): Runner ID: [${id}] not found`);
1623
1624
  }
@@ -1764,14 +1765,14 @@ class WorkerInstance {
1764
1765
  console.error(`#AddRunner(): [${error}]`);
1765
1766
  }
1766
1767
  });
1767
- __privateAdd(this, _PostMessageToWorkerManagerById, async (command, id) => {
1768
+ __privateAdd(this, _PostMessageToWorkerManagerById, async (command, runnerId, response) => {
1768
1769
  try {
1769
1770
  if (__privateGet(this, _collectorCollectorPort)) {
1770
- if (__privateGet(this, _runners)[id]) {
1771
+ if (__privateGet(this, _runners)[runnerId]) {
1771
1772
  const message = {
1772
1773
  command,
1773
1774
  payload: {
1774
- runner: __privateGet(this, _runners)[id].runner
1775
+ runner: __privateGet(this, _runners)[runnerId].runner
1775
1776
  }
1776
1777
  };
1777
1778
  __privateGet(this, _collectorCollectorPort).postMessage(message);
@@ -1782,6 +1783,24 @@ class WorkerInstance {
1782
1783
  console.error(`#PostMessageToWorkerManagerById(): [${error}]`);
1783
1784
  }
1784
1785
  });
1786
+ __privateAdd(this, _PostRunnersToWorkerManager, async (command, messagePayload) => {
1787
+ try {
1788
+ if (__privateGet(this, _collectorCollectorPort)) {
1789
+ const message = {
1790
+ command,
1791
+ payload: {
1792
+ messageId: messagePayload.payload.messageId,
1793
+ workerId: __privateGet(this, _workerId),
1794
+ runners: Object.values(__privateGet(this, _runners)).map((runnerEx) => runnerEx.runner)
1795
+ }
1796
+ };
1797
+ __privateGet(this, _collectorCollectorPort).postMessage(message);
1798
+ await Sleep(0);
1799
+ }
1800
+ } catch (error) {
1801
+ console.error(`#PostRunnersToWorkerManager(): [${error}]`);
1802
+ }
1803
+ });
1785
1804
  __privateAdd(this, _StartRunner, async (testRunnerTelemetryPayload) => {
1786
1805
  var _a;
1787
1806
  try {
@@ -1995,6 +2014,10 @@ class WorkerInstance {
1995
2014
  __privateGet(this, _debug).call(this, `ProcessMessage::UpdateOptions`);
1996
2015
  __privateGet(this, _UpdateOptions).call(this, payloadMessage.payload);
1997
2016
  break;
2017
+ case eIWMessageCommands.GetRunners:
2018
+ __privateGet(this, _debug).call(this, `ProcessMessage::UpdateOptions`);
2019
+ __privateGet(this, _PostRunnersToWorkerManager).call(this, eIWMessageCommands.GetRunners, payloadMessage);
2020
+ break;
1998
2021
  default:
1999
2022
  __privateGet(this, _debug).call(this, `ProcessMessage::default`);
2000
2023
  __privateGet(this, _debug).call(this, `Invalid payloadMessage.command: [${payloadMessage.command}] - Ignoring`);
@@ -2042,6 +2065,7 @@ SleepImmediate_fn = function() {
2042
2065
  });
2043
2066
  };
2044
2067
  _PostMessageToWorkerManagerById = new WeakMap();
2068
+ _PostRunnersToWorkerManager = new WeakMap();
2045
2069
  _StartRunner = new WeakMap();
2046
2070
  _StopRunnerByRunnerId = new WeakMap();
2047
2071
  _StopAllRunners = new WeakMap();
@@ -2196,6 +2220,7 @@ function v4(options, buf, offset) {
2196
2220
  chalk.level = 3;
2197
2221
  class STSWorkerManager {
2198
2222
  constructor(options) {
2223
+ __privateAdd(this, _STSWorkerManager_instances);
2199
2224
  //#agentSession: string = null;
2200
2225
  __privateAdd(this, _workersEx, {});
2201
2226
  __privateAdd(this, _options2);
@@ -2203,6 +2228,7 @@ class STSWorkerManager {
2203
2228
  __privateAdd(this, _telemetryProcessor, null);
2204
2229
  __privateAdd(this, _archiveList, []);
2205
2230
  __privateAdd(this, _id);
2231
+ __privateAdd(this, _messages, {});
2206
2232
  __privateAdd(this, _processLoopExecutor2, async () => {
2207
2233
  const removeList = [];
2208
2234
  for (const [, workerEx] of Object.entries(__privateGet(this, _workersEx))) {
@@ -2405,6 +2431,10 @@ class STSWorkerManager {
2405
2431
  __privateGet(this, _debug2).call(this, `AddWorker:processMessage():eIWMessageCommands.RemoveRunnerFromCollection`);
2406
2432
  __privateGet(this, _debug2).call(this, `${JSON.stringify(publishMessagePayload2.payload)}`);
2407
2433
  __privateGet(this, _RemoveRunnerFromCollection).call(this, stsWorkerEx, publishMessagePayload2.payload);
2434
+ case eIWMessageCommands.GetRunners:
2435
+ __privateGet(this, _debug2).call(this, `AddWorker:processMessage():eIWMessageCommands.GetRunners`);
2436
+ __privateGet(this, _debug2).call(this, `${JSON.stringify(publishMessagePayload2.payload)}`);
2437
+ __privateMethod(this, _STSWorkerManager_instances, GetRunnersResponse_fn).call(this, stsWorkerEx, publishMessagePayload2.payload);
2408
2438
  break;
2409
2439
  default:
2410
2440
  __privateGet(this, _debug2).call(this, `processMessage::default`);
@@ -2489,6 +2519,8 @@ class STSWorkerManager {
2489
2519
  eventDate: /* @__PURE__ */ new Date(),
2490
2520
  runner: { ...runner }
2491
2521
  });
2522
+ runnerEx.instrumentData = { ...runner.instrumentData };
2523
+ runnerEx.iteration = runner.iteration;
2492
2524
  __privateGet(this, _debug2).call(this, `STSWorkerManager:#RunnerStateChange(): Worker: [${workerEx.id}] Runner: [${runner.id}]`);
2493
2525
  __privateGet(this, _debug2).call(this, `STSWorkerManager:#RunnerStateChange(): --> Runner iteration (payload): [${runner.iteration}]`);
2494
2526
  __privateGet(this, _debug2).call(this, `STSWorkerManager:#RunnerStateChange(): --> Runner instrumentData.requestCount (payload): [${runner.instrumentData.requestCount}]`);
@@ -2804,6 +2836,42 @@ class STSWorkerManager {
2804
2836
  __publicField(this, "UpdateAllWorkers", (options) => {
2805
2837
  return __privateGet(this, _HandleAllWorkers).call(this, "UpdateOptions", options);
2806
2838
  });
2839
+ __publicField(this, "GetWorkersEx", async () => {
2840
+ const retVal = await Promise.all(Object.values(__privateGet(this, _workersEx)).map((workerEx) => __privateGet(this, _PostMessageToWorkerGetRunners).call(this, workerEx, eIWMessageCommands.GetRunners)));
2841
+ retVal.forEach((messagePayload) => {
2842
+ const payload = messagePayload.payload;
2843
+ const runnersEx = __privateGet(this, _workersEx)[payload.workerId].runnersEx;
2844
+ payload.runners.forEach((runner) => {
2845
+ runnersEx[runner.id].iteration = runner.iteration;
2846
+ runnersEx[runner.id].state = runner.state;
2847
+ runnersEx[runner.id].instrumentData = { ...runner.instrumentData };
2848
+ });
2849
+ });
2850
+ return retVal;
2851
+ });
2852
+ __privateAdd(this, _PostMessageToWorkerGetRunners, async (workerEx, command) => {
2853
+ return new Promise((resolve, reject) => {
2854
+ try {
2855
+ __privateGet(this, _debug2).call(this, `#PostMessageToWorker`);
2856
+ const messageId = v4();
2857
+ __privateGet(this, _messages)[messageId] = {
2858
+ timeout: setTimeout(() => {
2859
+ delete __privateGet(this, _messages)[messageId];
2860
+ reject(`message response timeout for message id: [${messageId}], command: [${command}]`);
2861
+ }, 5e3),
2862
+ resolveMessage: (payload2) => {
2863
+ resolve(payload2);
2864
+ }
2865
+ };
2866
+ const payload = {
2867
+ messageId
2868
+ };
2869
+ workerEx.messagePort.postMessage({ command, payload });
2870
+ } catch (error) {
2871
+ console.error(`#PostMessageToWorkerGetRunners(): Error: [${error}]`);
2872
+ }
2873
+ });
2874
+ });
2807
2875
  __privateSet(this, _id, v4());
2808
2876
  if (options) {
2809
2877
  __privateSet(this, _options2, options);
@@ -2867,6 +2935,7 @@ _STSInstrumentController = new WeakMap();
2867
2935
  _telemetryProcessor = new WeakMap();
2868
2936
  _archiveList = new WeakMap();
2869
2937
  _id = new WeakMap();
2938
+ _messages = new WeakMap();
2870
2939
  _processLoopExecutor2 = new WeakMap();
2871
2940
  _debug2 = new WeakMap();
2872
2941
  _SetRunnerIntoWorker = new WeakMap();
@@ -2896,6 +2965,33 @@ _UpdateOptionsWorker = new WeakMap();
2896
2965
  _TerminateWorker = new WeakMap();
2897
2966
  _BroadcastCommandToAllRunners = new WeakMap();
2898
2967
  _HandleAllWorkers = new WeakMap();
2968
+ _STSWorkerManager_instances = new WeakSet();
2969
+ //GetWorkersEx = async (messageId: string, workerEx: IWorkerEx): Promise<IWorkers> => {
2970
+ //const retVal2 = await this.#PostMessageToWorkerGetRunners(workerEx, eIWMessageCommands.GetRunners);
2971
+ //});
2972
+ //}
2973
+ GetRunnersResponse_fn = function(stsWorkerEx, payload) {
2974
+ try {
2975
+ const messageId = payload.messageId;
2976
+ if (__privateGet(this, _messages)[messageId]) {
2977
+ const messageRecord = __privateGet(this, _messages)[messageId];
2978
+ clearTimeout(messageRecord.timeout);
2979
+ const returnPayload = {
2980
+ command: eIWMessageCommands.GetRunners,
2981
+ payload: {
2982
+ messageId,
2983
+ workerId: stsWorkerEx.id,
2984
+ runners: payload.runners
2985
+ }
2986
+ };
2987
+ delete __privateGet(this, _messages)[messageId];
2988
+ messageRecord.resolveMessage(returnPayload);
2989
+ }
2990
+ } catch (error) {
2991
+ console.error(`#GetRunnersResponse(): Error: [${error}]`);
2992
+ }
2993
+ };
2994
+ _PostMessageToWorkerGetRunners = new WeakMap();
2899
2995
  export {
2900
2996
  IRunnerState,
2901
2997
  IWorkerState,