@nsshunt/stsrunnerframework 1.0.84 → 1.0.86
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 +80 -30
- package/dist/stsrunnerframework.mjs.map +1 -1
- package/dist/stsrunnerframework.umd.js +80 -30
- 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 = "/";
|
|
@@ -2226,10 +2226,12 @@ class STSWorkerManager {
|
|
|
2226
2226
|
__privateGet(this, _debug2).call(this, chalk.grey(`Ending publish for runner: [${JSON.stringify(runnerEx.asyncRunnerContext)}]`));
|
|
2227
2227
|
runnerEx.publishInstrumentController.EndPublish();
|
|
2228
2228
|
}
|
|
2229
|
-
|
|
2230
|
-
|
|
2231
|
-
|
|
2232
|
-
__privateGet(this, _archiveList).
|
|
2229
|
+
if (runnerEx.state !== IRunnerState.terminated) {
|
|
2230
|
+
const runner = this.CreateRunnerCopy(runnerEx);
|
|
2231
|
+
__privateGet(this, _archiveList).push(runner);
|
|
2232
|
+
if (__privateGet(this, _archiveList).length > __privateGet(this, _options2).maxArchiveListLength) {
|
|
2233
|
+
__privateGet(this, _archiveList).shift();
|
|
2234
|
+
}
|
|
2233
2235
|
}
|
|
2234
2236
|
delete workerEx.runnersEx[removeList[i].runnerId];
|
|
2235
2237
|
}
|
|
@@ -2281,6 +2283,7 @@ class STSWorkerManager {
|
|
|
2281
2283
|
id: workerId,
|
|
2282
2284
|
workerManagerId: __privateGet(this, _id),
|
|
2283
2285
|
worker: workerFactory.createWorkerThreadWorker(),
|
|
2286
|
+
workerEvents: [],
|
|
2284
2287
|
messagePort: port1,
|
|
2285
2288
|
options: workerOptions,
|
|
2286
2289
|
runnersEx: {},
|
|
@@ -2304,7 +2307,14 @@ class STSWorkerManager {
|
|
|
2304
2307
|
Terminate: () => __privateGet(this, _TerminateWorker).call(this, stsWorkerEx),
|
|
2305
2308
|
Reset: () => __privateGet(this, _ResetWorker).call(this, stsWorkerEx),
|
|
2306
2309
|
Execute: () => __privateGet(this, _ExecuteWorker).call(this, stsWorkerEx),
|
|
2307
|
-
UpdateOptions: (executionProfile) => __privateGet(this, _UpdateOptionsWorker).call(this, stsWorkerEx, executionProfile)
|
|
2310
|
+
UpdateOptions: (executionProfile) => __privateGet(this, _UpdateOptionsWorker).call(this, stsWorkerEx, executionProfile),
|
|
2311
|
+
on: (eventName, cb) => {
|
|
2312
|
+
stsWorkerEx.workerEvents.push({
|
|
2313
|
+
eventName,
|
|
2314
|
+
cb
|
|
2315
|
+
});
|
|
2316
|
+
return stsWorkerEx;
|
|
2317
|
+
}
|
|
2308
2318
|
};
|
|
2309
2319
|
if (__privateGet(this, _STSInstrumentController)) {
|
|
2310
2320
|
__privateGet(this, _STSInstrumentController).LogEx(chalk.yellow(`pid: [${process.pid}] Creating new worker: [${stsWorkerEx.id}]`));
|
|
@@ -2335,17 +2345,45 @@ class STSWorkerManager {
|
|
|
2335
2345
|
if (!stsWorkerEx.options.mocked) {
|
|
2336
2346
|
if (isNode) {
|
|
2337
2347
|
stsWorkerEx.worker.on("exit", (code) => {
|
|
2338
|
-
|
|
2348
|
+
try {
|
|
2349
|
+
console.log(chalk.magenta(`STSWorkerManager:stsWorkerEx.worker.on(exit): Worker exited with code: ${code}`));
|
|
2350
|
+
__privateGet(this, _EmitWorkerEvent).call(this, "exit", stsWorkerEx);
|
|
2351
|
+
if (__privateGet(this, _workersEx)[stsWorkerEx.id]) {
|
|
2352
|
+
delete __privateGet(this, _workersEx)[stsWorkerEx.id];
|
|
2353
|
+
console.log(chalk.magenta(`STSWorkerManager:stsWorkerEx.worker.on(exit): Worker: [${stsWorkerEx.id}] has been removed from the worker collection.`));
|
|
2354
|
+
}
|
|
2355
|
+
} catch (error) {
|
|
2356
|
+
console.error(chalk.red(`STSWorkerManager:stsWorkerEx.worker.on(exit): Error: [${error}] Worker: [${stsWorkerEx.id}]`));
|
|
2357
|
+
}
|
|
2339
2358
|
});
|
|
2340
2359
|
stsWorkerEx.worker.on("error", (error) => {
|
|
2341
|
-
|
|
2360
|
+
try {
|
|
2361
|
+
console.error(chalk.red(`STSWorkerManager:stsWorkerEx.worker.on(error): Worker error: ${error}`));
|
|
2362
|
+
__privateGet(this, _EmitWorkerEvent).call(this, "error", stsWorkerEx);
|
|
2363
|
+
} catch (error2) {
|
|
2364
|
+
console.error(chalk.red(`STSWorkerManager:stsWorkerEx.worker.on(error): Error: [${error2}] Worker: [${stsWorkerEx.id}]`));
|
|
2365
|
+
}
|
|
2342
2366
|
});
|
|
2343
2367
|
} else {
|
|
2344
2368
|
stsWorkerEx.worker.onerror = (error) => {
|
|
2345
|
-
|
|
2369
|
+
try {
|
|
2370
|
+
console.error(chalk.red("STSWorkerManager:stsWorkerEx.worker.onerror(): Error in worker:", error));
|
|
2371
|
+
__privateGet(this, _EmitWorkerEvent).call(this, "onerror", stsWorkerEx);
|
|
2372
|
+
if (__privateGet(this, _workersEx)[stsWorkerEx.id]) {
|
|
2373
|
+
delete __privateGet(this, _workersEx)[stsWorkerEx.id];
|
|
2374
|
+
console.log(chalk.magenta(`STSWorkerManager:stsWorkerEx.worker.onerror(error): Worker: [${stsWorkerEx.id}] has been removed from the worker collection.`));
|
|
2375
|
+
}
|
|
2376
|
+
} catch (error2) {
|
|
2377
|
+
console.error(chalk.red(`STSWorkerManager:stsWorkerEx.worker.onerror(error): Error: [${error2}] Worker: [${stsWorkerEx.id}]`));
|
|
2378
|
+
}
|
|
2346
2379
|
};
|
|
2347
2380
|
stsWorkerEx.worker.onmessageerror = (error) => {
|
|
2348
|
-
|
|
2381
|
+
try {
|
|
2382
|
+
console.error(chalk.red("STSWorkerManager:stsWorkerEx.worker.onmessageerror(): Message error in worker:", error));
|
|
2383
|
+
__privateGet(this, _EmitWorkerEvent).call(this, "onmessageerror", stsWorkerEx);
|
|
2384
|
+
} catch (error2) {
|
|
2385
|
+
console.error(chalk.red(`STSWorkerManager:stsWorkerEx.worker.onmessageerror(error): Error: [${error2}] Worker: [${stsWorkerEx.id}]`));
|
|
2386
|
+
}
|
|
2349
2387
|
};
|
|
2350
2388
|
}
|
|
2351
2389
|
}
|
|
@@ -2414,10 +2452,17 @@ class STSWorkerManager {
|
|
|
2414
2452
|
if (runnerEx.publishInstrumentController && __privateGet(this, _telemetryProcessor)) {
|
|
2415
2453
|
__privateGet(this, _telemetryProcessor).ProcessTelemetry(runnerEx.publishInstrumentController, runnerEx.instrumentData);
|
|
2416
2454
|
}
|
|
2417
|
-
__privateGet(this,
|
|
2455
|
+
__privateGet(this, _EmitRunnerEvent).call(this, "Telemetry", workerEx, runner.id);
|
|
2418
2456
|
}
|
|
2419
2457
|
});
|
|
2420
|
-
__privateAdd(this,
|
|
2458
|
+
__privateAdd(this, _EmitWorkerEvent, (eventName, workerEx) => {
|
|
2459
|
+
workerEx.workerEvents.forEach((ev) => {
|
|
2460
|
+
if (ev.eventName.localeCompare(eventName) === 0) {
|
|
2461
|
+
ev.cb(workerEx);
|
|
2462
|
+
}
|
|
2463
|
+
});
|
|
2464
|
+
});
|
|
2465
|
+
__privateAdd(this, _EmitRunnerEvent, (eventName, workerEx, runnerId) => {
|
|
2421
2466
|
if (workerEx.runnersEvents[runnerId]) {
|
|
2422
2467
|
const runnersEvents = workerEx.runnersEvents[runnerId];
|
|
2423
2468
|
runnersEvents.forEach((ev) => {
|
|
@@ -2442,7 +2487,7 @@ class STSWorkerManager {
|
|
|
2442
2487
|
eventDate: /* @__PURE__ */ new Date(),
|
|
2443
2488
|
runner: { ...runner }
|
|
2444
2489
|
});
|
|
2445
|
-
__privateGet(this,
|
|
2490
|
+
__privateGet(this, _EmitRunnerEvent).call(this, "StateChange", workerEx, runner.id);
|
|
2446
2491
|
}
|
|
2447
2492
|
});
|
|
2448
2493
|
__privateAdd(this, _RemoveRunnerFromCollection, (workerEx, payloadContents) => {
|
|
@@ -2647,6 +2692,25 @@ class STSWorkerManager {
|
|
|
2647
2692
|
__privateAdd(this, _UpdateOptionsWorker, (workerEx, executionProfile) => {
|
|
2648
2693
|
return __privateGet(this, _BroadcastCommandToAllRunners).call(this, workerEx, __privateGet(this, _UpdateOptionsRunner), executionProfile);
|
|
2649
2694
|
});
|
|
2695
|
+
__privateAdd(this, _TerminateWorker, (workerEx) => {
|
|
2696
|
+
try {
|
|
2697
|
+
const retVal = __privateGet(this, _BroadcastCommandToAllRunners).call(this, workerEx, __privateGet(this, _TerminateRunner2));
|
|
2698
|
+
if (workerEx.worker) {
|
|
2699
|
+
setTimeout(() => {
|
|
2700
|
+
workerEx.worker.terminate();
|
|
2701
|
+
__privateGet(this, _debug2).call(this, `Terminated worker: [${workerEx.id}]`);
|
|
2702
|
+
if (__privateGet(this, _workersEx)[workerEx.id]) {
|
|
2703
|
+
delete __privateGet(this, _workersEx)[workerEx.id];
|
|
2704
|
+
console.log(chalk.magenta(`STSWorkerManager:stsWorkerEx.worker.on(exit): Worker: [${workerEx.id}] has been removed from the worker collection.`));
|
|
2705
|
+
}
|
|
2706
|
+
}, 500);
|
|
2707
|
+
}
|
|
2708
|
+
return retVal;
|
|
2709
|
+
} catch (error) {
|
|
2710
|
+
console.log(`Error in STSTestWorker:TerminateWorker: [${error}]`);
|
|
2711
|
+
return [];
|
|
2712
|
+
}
|
|
2713
|
+
});
|
|
2650
2714
|
__privateAdd(this, _BroadcastCommandToAllRunners, (workerEx, command, executionProfile) => {
|
|
2651
2715
|
try {
|
|
2652
2716
|
const executeCommand = (runnerEx) => {
|
|
@@ -2664,21 +2728,6 @@ class STSWorkerManager {
|
|
|
2664
2728
|
return [];
|
|
2665
2729
|
}
|
|
2666
2730
|
});
|
|
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
2731
|
__publicField(this, "GetNextAvailableWorker", () => {
|
|
2683
2732
|
let leastRunnerWorker = null;
|
|
2684
2733
|
for (const [, stsWorker] of Object.entries(this.WorkersEx)) {
|
|
@@ -2815,7 +2864,8 @@ _processLoopExecutor2 = new WeakMap();
|
|
|
2815
2864
|
_debug2 = new WeakMap();
|
|
2816
2865
|
_SetRunnerIntoWorker = new WeakMap();
|
|
2817
2866
|
_ProcessTelemetry = new WeakMap();
|
|
2818
|
-
|
|
2867
|
+
_EmitWorkerEvent = new WeakMap();
|
|
2868
|
+
_EmitRunnerEvent = new WeakMap();
|
|
2819
2869
|
_RunnerStateChange = new WeakMap();
|
|
2820
2870
|
_RemoveRunnerFromCollection = new WeakMap();
|
|
2821
2871
|
_CreateAsyncRunner = new WeakMap();
|
|
@@ -2836,8 +2886,8 @@ _StartWorker = new WeakMap();
|
|
|
2836
2886
|
_ResetWorker = new WeakMap();
|
|
2837
2887
|
_ExecuteWorker = new WeakMap();
|
|
2838
2888
|
_UpdateOptionsWorker = new WeakMap();
|
|
2839
|
-
_BroadcastCommandToAllRunners = new WeakMap();
|
|
2840
2889
|
_TerminateWorker = new WeakMap();
|
|
2890
|
+
_BroadcastCommandToAllRunners = new WeakMap();
|
|
2841
2891
|
_HandleAllWorkers = new WeakMap();
|
|
2842
2892
|
export {
|
|
2843
2893
|
IRunnerState,
|