@nsshunt/stsrunnerframework 1.0.84 → 1.0.85
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.
- package/dist/stsrunnerframework.mjs +73 -26
- package/dist/stsrunnerframework.mjs.map +1 -1
- package/dist/stsrunnerframework.umd.js +73 -26
- package/dist/stsrunnerframework.umd.js.map +1 -1
- package/package.json +1 -1
- package/types/commonTypes.d.ts +6 -0
- package/types/commonTypes.d.ts.map +1 -1
- package/types/workerManager.d.ts.map +1 -1
|
@@ -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,
|
|
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;
|
|
13
13
|
import { defaultLogger, Sleep, ModelDelimeter } from "@nsshunt/stsutils";
|
|
14
14
|
import { Gauge } from "@nsshunt/stsobservability";
|
|
15
15
|
const URI_BASE_VUEUTILS = "/";
|
|
@@ -2281,6 +2281,7 @@ class STSWorkerManager {
|
|
|
2281
2281
|
id: workerId,
|
|
2282
2282
|
workerManagerId: __privateGet(this, _id),
|
|
2283
2283
|
worker: workerFactory.createWorkerThreadWorker(),
|
|
2284
|
+
workerEvents: [],
|
|
2284
2285
|
messagePort: port1,
|
|
2285
2286
|
options: workerOptions,
|
|
2286
2287
|
runnersEx: {},
|
|
@@ -2304,7 +2305,14 @@ class STSWorkerManager {
|
|
|
2304
2305
|
Terminate: () => __privateGet(this, _TerminateWorker).call(this, stsWorkerEx),
|
|
2305
2306
|
Reset: () => __privateGet(this, _ResetWorker).call(this, stsWorkerEx),
|
|
2306
2307
|
Execute: () => __privateGet(this, _ExecuteWorker).call(this, stsWorkerEx),
|
|
2307
|
-
UpdateOptions: (executionProfile) => __privateGet(this, _UpdateOptionsWorker).call(this, stsWorkerEx, executionProfile)
|
|
2308
|
+
UpdateOptions: (executionProfile) => __privateGet(this, _UpdateOptionsWorker).call(this, stsWorkerEx, executionProfile),
|
|
2309
|
+
on: (eventName, cb) => {
|
|
2310
|
+
stsWorkerEx.workerEvents.push({
|
|
2311
|
+
eventName,
|
|
2312
|
+
cb
|
|
2313
|
+
});
|
|
2314
|
+
return stsWorkerEx;
|
|
2315
|
+
}
|
|
2308
2316
|
};
|
|
2309
2317
|
if (__privateGet(this, _STSInstrumentController)) {
|
|
2310
2318
|
__privateGet(this, _STSInstrumentController).LogEx(chalk.yellow(`pid: [${process.pid}] Creating new worker: [${stsWorkerEx.id}]`));
|
|
@@ -2335,17 +2343,45 @@ class STSWorkerManager {
|
|
|
2335
2343
|
if (!stsWorkerEx.options.mocked) {
|
|
2336
2344
|
if (isNode) {
|
|
2337
2345
|
stsWorkerEx.worker.on("exit", (code) => {
|
|
2338
|
-
|
|
2346
|
+
try {
|
|
2347
|
+
console.log(chalk.magenta(`STSWorkerManager:stsWorkerEx.worker.on(exit): Worker exited with code: ${code}`));
|
|
2348
|
+
__privateGet(this, _EmitWorkerEvent).call(this, "exit", stsWorkerEx);
|
|
2349
|
+
if (__privateGet(this, _workersEx)[stsWorkerEx.id]) {
|
|
2350
|
+
delete __privateGet(this, _workersEx)[stsWorkerEx.id];
|
|
2351
|
+
console.log(chalk.magenta(`STSWorkerManager:stsWorkerEx.worker.on(exit): Worker: [${stsWorkerEx.id}] has been removed from the worker collection.`));
|
|
2352
|
+
}
|
|
2353
|
+
} catch (error) {
|
|
2354
|
+
console.error(chalk.red(`STSWorkerManager:stsWorkerEx.worker.on(exit): Error: [${error}] Worker: [${stsWorkerEx.id}]`));
|
|
2355
|
+
}
|
|
2339
2356
|
});
|
|
2340
2357
|
stsWorkerEx.worker.on("error", (error) => {
|
|
2341
|
-
|
|
2358
|
+
try {
|
|
2359
|
+
console.error(chalk.red(`STSWorkerManager:stsWorkerEx.worker.on(error): Worker error: ${error}`));
|
|
2360
|
+
__privateGet(this, _EmitWorkerEvent).call(this, "error", stsWorkerEx);
|
|
2361
|
+
} catch (error2) {
|
|
2362
|
+
console.error(chalk.red(`STSWorkerManager:stsWorkerEx.worker.on(error): Error: [${error2}] Worker: [${stsWorkerEx.id}]`));
|
|
2363
|
+
}
|
|
2342
2364
|
});
|
|
2343
2365
|
} else {
|
|
2344
2366
|
stsWorkerEx.worker.onerror = (error) => {
|
|
2345
|
-
|
|
2367
|
+
try {
|
|
2368
|
+
console.error(chalk.red("STSWorkerManager:stsWorkerEx.worker.onerror(): Error in worker:", error));
|
|
2369
|
+
__privateGet(this, _EmitWorkerEvent).call(this, "onerror", stsWorkerEx);
|
|
2370
|
+
if (__privateGet(this, _workersEx)[stsWorkerEx.id]) {
|
|
2371
|
+
delete __privateGet(this, _workersEx)[stsWorkerEx.id];
|
|
2372
|
+
console.log(chalk.magenta(`STSWorkerManager:stsWorkerEx.worker.onerror(error): Worker: [${stsWorkerEx.id}] has been removed from the worker collection.`));
|
|
2373
|
+
}
|
|
2374
|
+
} catch (error2) {
|
|
2375
|
+
console.error(chalk.red(`STSWorkerManager:stsWorkerEx.worker.onerror(error): Error: [${error2}] Worker: [${stsWorkerEx.id}]`));
|
|
2376
|
+
}
|
|
2346
2377
|
};
|
|
2347
2378
|
stsWorkerEx.worker.onmessageerror = (error) => {
|
|
2348
|
-
|
|
2379
|
+
try {
|
|
2380
|
+
console.error(chalk.red("STSWorkerManager:stsWorkerEx.worker.onmessageerror(): Message error in worker:", error));
|
|
2381
|
+
__privateGet(this, _EmitWorkerEvent).call(this, "onmessageerror", stsWorkerEx);
|
|
2382
|
+
} catch (error2) {
|
|
2383
|
+
console.error(chalk.red(`STSWorkerManager:stsWorkerEx.worker.onmessageerror(error): Error: [${error2}] Worker: [${stsWorkerEx.id}]`));
|
|
2384
|
+
}
|
|
2349
2385
|
};
|
|
2350
2386
|
}
|
|
2351
2387
|
}
|
|
@@ -2414,10 +2450,17 @@ class STSWorkerManager {
|
|
|
2414
2450
|
if (runnerEx.publishInstrumentController && __privateGet(this, _telemetryProcessor)) {
|
|
2415
2451
|
__privateGet(this, _telemetryProcessor).ProcessTelemetry(runnerEx.publishInstrumentController, runnerEx.instrumentData);
|
|
2416
2452
|
}
|
|
2417
|
-
__privateGet(this,
|
|
2453
|
+
__privateGet(this, _EmitRunnerEvent).call(this, "Telemetry", workerEx, runner.id);
|
|
2418
2454
|
}
|
|
2419
2455
|
});
|
|
2420
|
-
__privateAdd(this,
|
|
2456
|
+
__privateAdd(this, _EmitWorkerEvent, (eventName, workerEx) => {
|
|
2457
|
+
workerEx.workerEvents.forEach((ev) => {
|
|
2458
|
+
if (ev.eventName.localeCompare(eventName) === 0) {
|
|
2459
|
+
ev.cb(workerEx);
|
|
2460
|
+
}
|
|
2461
|
+
});
|
|
2462
|
+
});
|
|
2463
|
+
__privateAdd(this, _EmitRunnerEvent, (eventName, workerEx, runnerId) => {
|
|
2421
2464
|
if (workerEx.runnersEvents[runnerId]) {
|
|
2422
2465
|
const runnersEvents = workerEx.runnersEvents[runnerId];
|
|
2423
2466
|
runnersEvents.forEach((ev) => {
|
|
@@ -2442,7 +2485,7 @@ class STSWorkerManager {
|
|
|
2442
2485
|
eventDate: /* @__PURE__ */ new Date(),
|
|
2443
2486
|
runner: { ...runner }
|
|
2444
2487
|
});
|
|
2445
|
-
__privateGet(this,
|
|
2488
|
+
__privateGet(this, _EmitRunnerEvent).call(this, "StateChange", workerEx, runner.id);
|
|
2446
2489
|
}
|
|
2447
2490
|
});
|
|
2448
2491
|
__privateAdd(this, _RemoveRunnerFromCollection, (workerEx, payloadContents) => {
|
|
@@ -2647,6 +2690,24 @@ class STSWorkerManager {
|
|
|
2647
2690
|
__privateAdd(this, _UpdateOptionsWorker, (workerEx, executionProfile) => {
|
|
2648
2691
|
return __privateGet(this, _BroadcastCommandToAllRunners).call(this, workerEx, __privateGet(this, _UpdateOptionsRunner), executionProfile);
|
|
2649
2692
|
});
|
|
2693
|
+
__privateAdd(this, _TerminateWorker, (workerEx) => {
|
|
2694
|
+
try {
|
|
2695
|
+
const retVal = __privateGet(this, _BroadcastCommandToAllRunners).call(this, workerEx, __privateGet(this, _TerminateRunner2));
|
|
2696
|
+
if (workerEx.worker) {
|
|
2697
|
+
workerEx.worker.terminate();
|
|
2698
|
+
__privateGet(this, _debug2).call(this, `Terminated worker: [${workerEx.id}]`);
|
|
2699
|
+
if (__privateGet(this, _workersEx)[workerEx.id]) {
|
|
2700
|
+
delete __privateGet(this, _workersEx)[workerEx.id];
|
|
2701
|
+
console.log(chalk.magenta(`STSWorkerManager:stsWorkerEx.worker.on(exit): Worker: [${workerEx.id}] has been removed from the worker collection.`));
|
|
2702
|
+
}
|
|
2703
|
+
} else {
|
|
2704
|
+
}
|
|
2705
|
+
return retVal;
|
|
2706
|
+
} catch (error) {
|
|
2707
|
+
console.log(`Error in STSTestWorker:TerminateWorker: [${error}]`);
|
|
2708
|
+
return [];
|
|
2709
|
+
}
|
|
2710
|
+
});
|
|
2650
2711
|
__privateAdd(this, _BroadcastCommandToAllRunners, (workerEx, command, executionProfile) => {
|
|
2651
2712
|
try {
|
|
2652
2713
|
const executeCommand = (runnerEx) => {
|
|
@@ -2664,21 +2725,6 @@ class STSWorkerManager {
|
|
|
2664
2725
|
return [];
|
|
2665
2726
|
}
|
|
2666
2727
|
});
|
|
2667
|
-
__privateAdd(this, _TerminateWorker, (workerEx) => {
|
|
2668
|
-
try {
|
|
2669
|
-
const retVal = __privateGet(this, _BroadcastCommandToAllRunners).call(this, workerEx, __privateGet(this, _TerminateRunner2));
|
|
2670
|
-
if (workerEx.worker) {
|
|
2671
|
-
workerEx.worker.terminate();
|
|
2672
|
-
__privateGet(this, _debug2).call(this, `Terminated worker: [${workerEx.id}]`);
|
|
2673
|
-
delete __privateGet(this, _workersEx)[workerEx.id];
|
|
2674
|
-
} else {
|
|
2675
|
-
}
|
|
2676
|
-
return retVal;
|
|
2677
|
-
} catch (error) {
|
|
2678
|
-
console.log(`Error in STSTestWorker:TerminateWorker: [${error}]`);
|
|
2679
|
-
return [];
|
|
2680
|
-
}
|
|
2681
|
-
});
|
|
2682
2728
|
__publicField(this, "GetNextAvailableWorker", () => {
|
|
2683
2729
|
let leastRunnerWorker = null;
|
|
2684
2730
|
for (const [, stsWorker] of Object.entries(this.WorkersEx)) {
|
|
@@ -2815,7 +2861,8 @@ _processLoopExecutor2 = new WeakMap();
|
|
|
2815
2861
|
_debug2 = new WeakMap();
|
|
2816
2862
|
_SetRunnerIntoWorker = new WeakMap();
|
|
2817
2863
|
_ProcessTelemetry = new WeakMap();
|
|
2818
|
-
|
|
2864
|
+
_EmitWorkerEvent = new WeakMap();
|
|
2865
|
+
_EmitRunnerEvent = new WeakMap();
|
|
2819
2866
|
_RunnerStateChange = new WeakMap();
|
|
2820
2867
|
_RemoveRunnerFromCollection = new WeakMap();
|
|
2821
2868
|
_CreateAsyncRunner = new WeakMap();
|
|
@@ -2836,8 +2883,8 @@ _StartWorker = new WeakMap();
|
|
|
2836
2883
|
_ResetWorker = new WeakMap();
|
|
2837
2884
|
_ExecuteWorker = new WeakMap();
|
|
2838
2885
|
_UpdateOptionsWorker = new WeakMap();
|
|
2839
|
-
_BroadcastCommandToAllRunners = new WeakMap();
|
|
2840
2886
|
_TerminateWorker = new WeakMap();
|
|
2887
|
+
_BroadcastCommandToAllRunners = new WeakMap();
|
|
2841
2888
|
_HandleAllWorkers = new WeakMap();
|
|
2842
2889
|
export {
|
|
2843
2890
|
IRunnerState,
|