@nsshunt/stsrunnerframework 1.0.61 → 1.0.63

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, value2) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value2);
10
10
  var __privateSet = (obj, member, value2, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value2) : member.set(obj, value2), value2);
11
11
  var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "access private method"), method);
12
- var _collectorCollectorPort, _runners, _options3, _workerId, _debug, _SetMessagePort, _CreateRunnerEx2RunState, _UpdateRunnerStateById, _GetAllRunners, _CanExecuteNextIterationById, _GetRunnerIterationById, _ResetRunnerIterationById, _IncRunnerIterationById, _GetRunnerInstanceById, _GetRunnerExecutionProfileById, _GetRunnerOptionsById, _SetRunnerOptionsById, _AddRunner, _WorkerInstance_instances, SleepImmediate_fn, _PostMessageToWorkerManagerById, _StartRunner, _StopRunnerByRunnerById, _StopAllRunners, _StopRunner, _TerminateRunner, _PauseRunner, _ResumeRunner, _ResetRunner, _ExecuteRunner, _UpdateOptions, _workersEx, _options4, _STSInstrumentController, _telemetryProcessor, _debug2, _STSWorkerManager_instances, CreateRunnerCopy_fn, _SetRunnerIntoWorker, _ProcessTelemetry, _RunnerStateChange, _ProcessCompleted, _CreateAsyncRunner, _PostMessageToWorkerUsingDefaultChannel, _PostMessageToWorker, _StartRunner2, _ResetRunner2, _ExecuteRunner2, _StopRunner2, _TerminateRunner2, _PauseRunner2, _ResumeRunner2, _BroadcastCommandToAllRunners, _PauseWorker, _ResumeWorker, _StopWorker, _StartWorker, _ResetWorker, _ExecuteWorker, _BroadcastUpdateCommandToAllRunners, _UpdateOptionsWorker, _TerminateWorker, _UpdateOptions2, _options5, _rest01Client, _accessToken2, _agentManager, _authUtilsNode, _GetAccessToken;
12
+ var _collectorCollectorPort, _runners, _options3, _workerId, _debug, _SetMessagePort, _CreateRunnerEx2RunState, _UpdateRunnerStateById, _GetAllRunners, _CanExecuteNextIterationById, _IsCompletedById, _GetRunnerIterationById, _ResetRunnerIterationById, _IncRunnerIterationById, _GetRunnerInstanceById, _GetRunnerExecutionProfileById, _GetRunnerOptionsById, _SetRunnerOptionsById, _AddRunner, _WorkerInstance_instances, SleepImmediate_fn, _PostMessageToWorkerManagerById, _StartRunner, _StopRunnerByRunnerById, _StopAllRunners, _StopRunner, _TerminateRunner, _PauseRunner, _ResumeRunner, _ResetRunner, _ExecuteRunner, _UpdateOptions, _workersEx, _options4, _STSInstrumentController, _telemetryProcessor, _debug2, _STSWorkerManager_instances, CreateRunnerCopy_fn, _SetRunnerIntoWorker, _ProcessTelemetry, _EmitEvent, _RunnerStateChange, _ProcessCompleted, _CreateAsyncRunner, _PostMessageToWorkerUsingDefaultChannel, _PostMessageToWorker, _StartRunner2, _ResetRunner2, _ExecuteRunner2, _StopRunner2, _TerminateRunner2, _PauseRunner2, _ResumeRunner2, _BroadcastCommandToAllRunners, _PauseWorker, _ResumeWorker, _StopWorker, _StartWorker, _ResetWorker, _ExecuteWorker, _BroadcastUpdateCommandToAllRunners, _UpdateOptionsWorker, _TerminateWorker, _UpdateOptions2, _options5, _rest01Client, _accessToken2, _agentManager, _authUtilsNode, _GetAccessToken;
13
13
  import { Sleep, ModelDelimeter, STSAxiosConfig, GetErrorPayload, AgentManager, defaultLogger } from "@nsshunt/stsutils";
14
14
  import { Gauge } from "@nsshunt/stsobservability";
15
15
  import { accessSync, constants as constants$2, readFileSync } from "node:fs";
@@ -1622,6 +1622,13 @@ class WorkerInstance {
1622
1622
  }
1623
1623
  return false;
1624
1624
  });
1625
+ __privateAdd(this, _IsCompletedById, (id) => {
1626
+ const state = __privateGet(this, _runners)[id].runner.state;
1627
+ if (state === IRunnerState.error || state === IRunnerState.completed || state === IRunnerState.stopped || state === IRunnerState.terminated) {
1628
+ return true;
1629
+ }
1630
+ return false;
1631
+ });
1625
1632
  __privateAdd(this, _GetRunnerIterationById, (id) => {
1626
1633
  return __privateGet(this, _runners)[id].runner.iteration;
1627
1634
  });
@@ -1685,8 +1692,10 @@ class WorkerInstance {
1685
1692
  }
1686
1693
  ExecuteLoop();
1687
1694
  } else {
1688
- await Sleep(50);
1689
- ExecuteLoop();
1695
+ if (!__privateGet(this, _IsCompletedById).call(this, runnerId)) {
1696
+ await Sleep(50);
1697
+ ExecuteLoop();
1698
+ }
1690
1699
  }
1691
1700
  } else {
1692
1701
  await __privateGet(this, _GetRunnerInstanceById).call(this, runnerId).Completed();
@@ -1842,6 +1851,7 @@ _CreateRunnerEx2RunState = new WeakMap();
1842
1851
  _UpdateRunnerStateById = new WeakMap();
1843
1852
  _GetAllRunners = new WeakMap();
1844
1853
  _CanExecuteNextIterationById = new WeakMap();
1854
+ _IsCompletedById = new WeakMap();
1845
1855
  _GetRunnerIterationById = new WeakMap();
1846
1856
  _ResetRunnerIterationById = new WeakMap();
1847
1857
  _IncRunnerIterationById = new WeakMap();
@@ -2164,33 +2174,33 @@ class STSWorkerManager {
2164
2174
  runnerEx.instrumentData.message = [];
2165
2175
  }
2166
2176
  __privateGet(this, _telemetryProcessor).ProcessTelemetry(runnerEx.publishInstrumentController, runnerEx.instrumentData);
2167
- if (workerEx.runnersEvents[runner.id]) {
2168
- const runnersEvents = workerEx.runnersEvents[runner.id];
2169
- runnersEvents.forEach((ev) => {
2170
- if (ev.eventName.localeCompare("Telemetry") === 0) {
2171
- ev.cb(runnerEx.instrumentData);
2172
- }
2173
- });
2174
- }
2177
+ __privateGet(this, _EmitEvent).call(this, "Telemetry", workerEx, runner.id);
2175
2178
  }
2176
2179
  });
2180
+ __privateAdd(this, _EmitEvent, (eventName, workerEx, runnerId) => {
2181
+ if (workerEx.runnersEvents[runnerId]) {
2182
+ const runnersEvents = workerEx.runnersEvents[runnerId];
2183
+ runnersEvents.forEach((ev) => {
2184
+ if (ev.eventName.localeCompare(eventName) === 0) {
2185
+ ev.cb(workerEx.runnersEx[runnerId]);
2186
+ }
2187
+ });
2188
+ }
2189
+ });
2190
+ //@@ make this have an event
2191
+ //@@ make refactor event to own method
2192
+ //@@ check for other events to capture
2177
2193
  __privateAdd(this, _RunnerStateChange, (workerEx, payloadContents) => {
2178
2194
  const { runner } = payloadContents;
2179
2195
  if (workerEx.runnersEx[runner.id]) {
2180
2196
  const runnerEx = workerEx.runnersEx[runner.id];
2181
2197
  runnerEx.state = runner.state;
2198
+ __privateGet(this, _EmitEvent).call(this, "StateChange", workerEx, runner.id);
2182
2199
  }
2183
2200
  });
2184
2201
  __privateAdd(this, _ProcessCompleted, (workerEx, payloadContents) => {
2185
2202
  const { runner } = payloadContents;
2186
- if (workerEx.runnersEvents[runner.id]) {
2187
- const runnersEvents = workerEx.runnersEvents[runner.id];
2188
- runnersEvents.forEach((ev) => {
2189
- if (ev.eventName.localeCompare("Completed") === 0) {
2190
- ev.cb(workerEx.runnersEx[runner.id].instrumentData);
2191
- }
2192
- });
2193
- }
2203
+ __privateGet(this, _EmitEvent).call(this, "Completed", workerEx, runner.id);
2194
2204
  console.log(chalk$1.green(`ProcessCompleted: [${JSON.stringify(runner)}]`));
2195
2205
  });
2196
2206
  __privateAdd(this, _CreateAsyncRunner, (workerEx, runnerOptions) => {
@@ -2489,6 +2499,7 @@ CreateRunnerCopy_fn = function(runnerEx) {
2489
2499
  };
2490
2500
  _SetRunnerIntoWorker = new WeakMap();
2491
2501
  _ProcessTelemetry = new WeakMap();
2502
+ _EmitEvent = new WeakMap();
2492
2503
  _RunnerStateChange = new WeakMap();
2493
2504
  _ProcessCompleted = new WeakMap();
2494
2505
  _CreateAsyncRunner = new WeakMap();