@nsshunt/stsrunnerframework 1.0.73 → 1.0.75

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, _StopRunnerByRunnerById, _StopAllRunners, _StopRunner, _TerminateRunner, _PauseRunner, _ResumeRunner, _ResetRunner, _ExecuteRunner, _UpdateOptions, _workersEx, _options2, _STSInstrumentController, _telemetryProcessor, _archiveList, _STSWorkerManager_instances, CreateRunnerCopyNoHistory_fn, CreateRunnerCopy_fn, CreateWorkerCopy_fn, _processLoopExecutor2, _debug2, _SetRunnerIntoWorker, _ProcessTelemetry, _EmitEvent, _RunnerStateChange, _RemoveRunnerFromCollection, _CreateAsyncRunner, _PostMessageToWorkerUsingDefaultChannel, _PostMessageToWorker, _StartRunner2, _ResetRunner2, _ExecuteRunner2, _StopRunner2, _TerminateRunner2, _PauseRunner2, _ResumeRunner2, _BroadcastCommandToAllRunners, _PauseWorker, _ResumeWorker, _StopWorker, _StartWorker, _ResetWorker, _ExecuteWorker, _BroadcastUpdateCommandToAllRunners, _UpdateOptionsWorker, _TerminateWorker, _UpdateOptions2;
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, _StopRunnerByRunnerById, _StopAllRunners, _StopRunner, _TerminateRunner, _PauseRunner, _ResumeRunner, _ResetRunner, _ExecuteRunner, _UpdateOptions, _workersEx, _options2, _STSInstrumentController, _telemetryProcessor, _archiveList, _processLoopExecutor2, _debug2, _SetRunnerIntoWorker, _ProcessTelemetry, _EmitEvent, _RunnerStateChange, _RemoveRunnerFromCollection, _CreateAsyncRunner, _PostMessageToWorkerUsingDefaultChannel, _PostMessageToWorker, _StartRunner2, _ResetRunner2, _ExecuteRunner2, _StopRunner2, _TerminateRunner2, _PauseRunner2, _ResumeRunner2, _BroadcastCommandToAllRunners, _PauseWorker, _ResumeWorker, _StopWorker, _StartWorker, _ResetWorker, _ExecuteWorker, _BroadcastUpdateCommandToAllRunners, _UpdateOptionsWorker, _TerminateWorker, _UpdateOptions2;
13
13
  import { defaultLogger, Sleep, ModelDelimeter } from "@nsshunt/stsutils";
14
14
  import { Gauge } from "@nsshunt/stsobservability";
15
15
  const URI_BASE_VUEUTILS = "/";
@@ -2019,7 +2019,6 @@ function v4(options, buf, offset) {
2019
2019
  chalk.level = 3;
2020
2020
  class STSWorkerManager {
2021
2021
  constructor(options) {
2022
- __privateAdd(this, _STSWorkerManager_instances);
2023
2022
  //#agentSession: string = null;
2024
2023
  __privateAdd(this, _workersEx, {});
2025
2024
  __privateAdd(this, _options2);
@@ -2052,7 +2051,7 @@ class STSWorkerManager {
2052
2051
  await runnerEx.publishInstrumentController.EndPublish();
2053
2052
  await Sleep(250);
2054
2053
  }
2055
- const runner = __privateMethod(this, _STSWorkerManager_instances, CreateRunnerCopy_fn).call(this, runnerEx);
2054
+ const runner = this.CreateRunnerCopy(runnerEx);
2056
2055
  __privateGet(this, _archiveList).push(runner);
2057
2056
  if (__privateGet(this, _archiveList).length > __privateGet(this, _options2).maxArchiveListLength) {
2058
2057
  __privateGet(this, _archiveList).shift();
@@ -2073,7 +2072,7 @@ class STSWorkerManager {
2073
2072
  __privateAdd(this, _debug2, (message) => {
2074
2073
  console.log(chalk.cyan(`pid: [${process.pid}] STSWorkerManager::${message}`));
2075
2074
  });
2076
- __publicField(this, "AddWorker", async (useWorkerFactory) => {
2075
+ __publicField(this, "AddWorker", async (workerOptions, useWorkerFactory) => {
2077
2076
  let workerFactory;
2078
2077
  if (useWorkerFactory) {
2079
2078
  workerFactory = useWorkerFactory;
@@ -2091,7 +2090,7 @@ class STSWorkerManager {
2091
2090
  id: workerId,
2092
2091
  worker: workerFactory.createWorkerThreadWorker(),
2093
2092
  messagePort: port1,
2094
- workerThreadWorkerOptions: workerFactory.workerThreadWorkerOptions,
2093
+ options: workerOptions,
2095
2094
  runnersEx: {},
2096
2095
  runnersEvents: {},
2097
2096
  GetRunner: (id) => __privateGet(this, _workersEx)[workerId].GetRunner(id),
@@ -2120,13 +2119,13 @@ class STSWorkerManager {
2120
2119
  }
2121
2120
  __privateGet(this, _debug2).call(this, `Adding worker: [${stsWorkerEx.id}]`);
2122
2121
  __privateGet(this, _debug2).call(this, `AddWorker::workerThreadWorkerOptions: [${stsWorkerEx.id}]`);
2123
- if (stsWorkerEx.workerThreadWorkerOptions.mocked) {
2122
+ if (stsWorkerEx.options.mocked) {
2124
2123
  stsWorkerEx.worker.SetPort({
2125
2124
  command: eIWMessageCommands.MessagePort,
2126
2125
  payload: {
2127
2126
  port: port2,
2128
2127
  options: {
2129
- ...stsWorkerEx.workerThreadWorkerOptions
2128
+ ...stsWorkerEx.options
2130
2129
  },
2131
2130
  workerId
2132
2131
  }
@@ -2136,12 +2135,12 @@ class STSWorkerManager {
2136
2135
  port: port2,
2137
2136
  //applicationStoreState: stateCopy,
2138
2137
  options: {
2139
- ...stsWorkerEx.workerThreadWorkerOptions
2138
+ ...stsWorkerEx.options
2140
2139
  },
2141
2140
  workerId
2142
2141
  }, port2);
2143
2142
  }
2144
- if (!stsWorkerEx.workerThreadWorkerOptions.mocked) {
2143
+ if (!stsWorkerEx.options.mocked) {
2145
2144
  if (isNode) {
2146
2145
  stsWorkerEx.worker.on("exit", (code) => {
2147
2146
  console.log(chalk.magenta(`STSWorkerManager:stsWorkerEx.worker.on(exit): Worker exited with code: ${code}`));
@@ -2206,7 +2205,7 @@ class STSWorkerManager {
2206
2205
  });
2207
2206
  __privateAdd(this, _SetRunnerIntoWorker, (workerEx, runnerEx) => {
2208
2207
  const payload = {
2209
- runner: __privateMethod(this, _STSWorkerManager_instances, CreateRunnerCopyNoHistory_fn).call(this, runnerEx)
2208
+ runner: this.CreateRunnerCopyNoHistory(runnerEx)
2210
2209
  };
2211
2210
  __privateGet(this, _PostMessageToWorker).call(this, workerEx, eIWMessageCommands.AddRunner, payload);
2212
2211
  });
@@ -2272,10 +2271,10 @@ class STSWorkerManager {
2272
2271
  const asyncRunnerContext = {
2273
2272
  // [level1]@[level2]^[level3]|[level4]
2274
2273
  // [hostName]@[agentId]-[userAgent]^[workerId]|[runnerId]
2275
- nid: `${workerEx.workerThreadWorkerOptions.hostName}${ModelDelimeter.COMPONENT_SEPERATOR}${workerEx.workerThreadWorkerOptions.agentId}-${workerEx.workerThreadWorkerOptions.userAgent}${ModelDelimeter.NID_SEPERATOR}${workerEx.id}${ModelDelimeter.SEPERATOR}${runnerId}`,
2276
- hostName: workerEx.workerThreadWorkerOptions.hostName,
2274
+ nid: `${workerEx.options.hostName}${ModelDelimeter.COMPONENT_SEPERATOR}${workerEx.options.agentId}-${workerEx.options.userAgent}${ModelDelimeter.NID_SEPERATOR}${workerEx.id}${ModelDelimeter.SEPERATOR}${runnerId}`,
2275
+ hostName: workerEx.options.hostName,
2277
2276
  // level 1 (e.g. host name)
2278
- agentName: `${workerEx.workerThreadWorkerOptions.agentId}-${workerEx.workerThreadWorkerOptions.userAgent}`,
2277
+ agentName: `${workerEx.options.agentId}-${workerEx.options.userAgent}`,
2279
2278
  // level 2 (e.g. service instance ID or user agent type and tab or instance)
2280
2279
  threadId: `${workerEx.id}`,
2281
2280
  // level 3 (web worker)
@@ -2346,43 +2345,43 @@ class STSWorkerManager {
2346
2345
  });
2347
2346
  __privateAdd(this, _StartRunner2, async (workerEx, runnerEx) => {
2348
2347
  __privateGet(this, _PostMessageToWorker).call(this, workerEx, eIWMessageCommands.StartRunner, {
2349
- runner: __privateMethod(this, _STSWorkerManager_instances, CreateRunnerCopyNoHistory_fn).call(this, runnerEx)
2348
+ runner: this.CreateRunnerCopyNoHistory(runnerEx)
2350
2349
  });
2351
2350
  return true;
2352
2351
  });
2353
2352
  __privateAdd(this, _ResetRunner2, async (workerEx, runnerEx) => {
2354
2353
  __privateGet(this, _PostMessageToWorker).call(this, workerEx, eIWMessageCommands.ResetRunner, {
2355
- runner: __privateMethod(this, _STSWorkerManager_instances, CreateRunnerCopyNoHistory_fn).call(this, runnerEx)
2354
+ runner: this.CreateRunnerCopyNoHistory(runnerEx)
2356
2355
  });
2357
2356
  return true;
2358
2357
  });
2359
2358
  __privateAdd(this, _ExecuteRunner2, async (workerEx, runnerEx) => {
2360
2359
  __privateGet(this, _PostMessageToWorker).call(this, workerEx, eIWMessageCommands.ExecuteRunner, {
2361
- runner: __privateMethod(this, _STSWorkerManager_instances, CreateRunnerCopyNoHistory_fn).call(this, runnerEx)
2360
+ runner: this.CreateRunnerCopyNoHistory(runnerEx)
2362
2361
  });
2363
2362
  return true;
2364
2363
  });
2365
2364
  __privateAdd(this, _StopRunner2, async (workerEx, runnerEx) => {
2366
2365
  __privateGet(this, _PostMessageToWorker).call(this, workerEx, eIWMessageCommands.StopRunner, {
2367
- runner: __privateMethod(this, _STSWorkerManager_instances, CreateRunnerCopyNoHistory_fn).call(this, runnerEx)
2366
+ runner: this.CreateRunnerCopyNoHistory(runnerEx)
2368
2367
  });
2369
2368
  return true;
2370
2369
  });
2371
2370
  __privateAdd(this, _TerminateRunner2, async (workerEx, runnerEx) => {
2372
2371
  __privateGet(this, _PostMessageToWorker).call(this, workerEx, eIWMessageCommands.TerminateRunner, {
2373
- runner: __privateMethod(this, _STSWorkerManager_instances, CreateRunnerCopyNoHistory_fn).call(this, runnerEx)
2372
+ runner: this.CreateRunnerCopyNoHistory(runnerEx)
2374
2373
  });
2375
2374
  return true;
2376
2375
  });
2377
2376
  __privateAdd(this, _PauseRunner2, async (workerEx, runnerEx) => {
2378
2377
  __privateGet(this, _PostMessageToWorker).call(this, workerEx, eIWMessageCommands.PauseRunner, {
2379
- runner: __privateMethod(this, _STSWorkerManager_instances, CreateRunnerCopyNoHistory_fn).call(this, runnerEx)
2378
+ runner: this.CreateRunnerCopyNoHistory(runnerEx)
2380
2379
  });
2381
2380
  return true;
2382
2381
  });
2383
2382
  __privateAdd(this, _ResumeRunner2, async (workerEx, runnerEx) => {
2384
2383
  __privateGet(this, _PostMessageToWorker).call(this, workerEx, eIWMessageCommands.ResumeRunner, {
2385
- runner: __privateMethod(this, _STSWorkerManager_instances, CreateRunnerCopyNoHistory_fn).call(this, runnerEx)
2384
+ runner: this.CreateRunnerCopyNoHistory(runnerEx)
2386
2385
  });
2387
2386
  return true;
2388
2387
  });
@@ -2464,7 +2463,7 @@ class STSWorkerManager {
2464
2463
  __privateAdd(this, _UpdateOptions2, async (workerEx, runnerEx, executionProfile) => {
2465
2464
  runnerEx.options.executionProfile = { ...executionProfile };
2466
2465
  __privateGet(this, _PostMessageToWorker).call(this, workerEx, eIWMessageCommands.UpdateOptions, {
2467
- runner: __privateMethod(this, _STSWorkerManager_instances, CreateRunnerCopyNoHistory_fn).call(this, runnerEx)
2466
+ runner: this.CreateRunnerCopyNoHistory(runnerEx)
2468
2467
  });
2469
2468
  return true;
2470
2469
  });
@@ -2561,10 +2560,40 @@ class STSWorkerManager {
2561
2560
  }
2562
2561
  __privateGet(this, _processLoopExecutor2).call(this);
2563
2562
  }
2563
+ CreateRunnerCopyNoHistory(runnerEx) {
2564
+ return {
2565
+ id: runnerEx.id,
2566
+ asyncRunnerContext: { ...runnerEx.asyncRunnerContext },
2567
+ instrumentData: { ...runnerEx.instrumentData },
2568
+ iteration: runnerEx.iteration,
2569
+ options: { ...runnerEx.options },
2570
+ state: runnerEx.state,
2571
+ workerId: runnerEx.workerId
2572
+ };
2573
+ }
2574
+ CreateRunnerCopy(runnerEx) {
2575
+ const retVal = this.CreateRunnerCopyNoHistory(runnerEx);
2576
+ if (runnerEx.runnerHistory) {
2577
+ retVal.runnerHistory = [...runnerEx.runnerHistory];
2578
+ }
2579
+ return retVal;
2580
+ }
2581
+ CreateWorkerCopy(workerEx) {
2582
+ const { id, options, runnersEx } = workerEx;
2583
+ const workerCopy = {
2584
+ id,
2585
+ options: { ...options },
2586
+ runners: {}
2587
+ };
2588
+ for (const [, runnerEx] of Object.entries(runnersEx)) {
2589
+ workerCopy.runners[runnerEx.id] = this.CreateRunnerCopy(runnerEx);
2590
+ }
2591
+ return workerCopy;
2592
+ }
2564
2593
  get Workers() {
2565
2594
  const retVal = {};
2566
2595
  for (const [, workerEx] of Object.entries(__privateGet(this, _workersEx))) {
2567
- retVal[workerEx.id] = __privateMethod(this, _STSWorkerManager_instances, CreateWorkerCopy_fn).call(this, workerEx);
2596
+ retVal[workerEx.id] = this.CreateWorkerCopy(workerEx);
2568
2597
  }
2569
2598
  return retVal;
2570
2599
  }
@@ -2586,37 +2615,6 @@ _options2 = new WeakMap();
2586
2615
  _STSInstrumentController = new WeakMap();
2587
2616
  _telemetryProcessor = new WeakMap();
2588
2617
  _archiveList = new WeakMap();
2589
- _STSWorkerManager_instances = new WeakSet();
2590
- CreateRunnerCopyNoHistory_fn = function(runnerEx) {
2591
- return {
2592
- id: runnerEx.id,
2593
- asyncRunnerContext: { ...runnerEx.asyncRunnerContext },
2594
- instrumentData: { ...runnerEx.instrumentData },
2595
- iteration: runnerEx.iteration,
2596
- options: { ...runnerEx.options },
2597
- state: runnerEx.state,
2598
- workerId: runnerEx.workerId
2599
- };
2600
- };
2601
- CreateRunnerCopy_fn = function(runnerEx) {
2602
- const retVal = __privateMethod(this, _STSWorkerManager_instances, CreateRunnerCopyNoHistory_fn).call(this, runnerEx);
2603
- if (runnerEx.runnerHistory) {
2604
- retVal.runnerHistory = [...runnerEx.runnerHistory];
2605
- }
2606
- return retVal;
2607
- };
2608
- CreateWorkerCopy_fn = function(workerEx) {
2609
- const { id, workerThreadWorkerOptions, runnersEx } = workerEx;
2610
- const workerCopy = {
2611
- id,
2612
- workerThreadWorkerOptions: { ...workerThreadWorkerOptions },
2613
- runners: {}
2614
- };
2615
- for (const [, runnerEx] of Object.entries(runnersEx)) {
2616
- workerCopy.runners[runnerEx.id] = __privateMethod(this, _STSWorkerManager_instances, CreateRunnerCopy_fn).call(this, runnerEx);
2617
- }
2618
- return workerCopy;
2619
- };
2620
2618
  _processLoopExecutor2 = new WeakMap();
2621
2619
  _debug2 = new WeakMap();
2622
2620
  _SetRunnerIntoWorker = new WeakMap();