@nsshunt/stsrunnerframework 1.0.200 → 2.0.1
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/README.md +1059 -1
- package/dist/stsrunnerframework.mjs +8263 -4105
- package/dist/stsrunnerframework.mjs.map +1 -1
- package/dist/stsrunnerframework.umd.js +8288 -4119
- package/dist/stsrunnerframework.umd.js.map +1 -1
- package/package.json +4 -4
- package/types/abstractRunnerExecutionWorker.d.ts +194 -0
- package/types/abstractRunnerExecutionWorker.d.ts.map +1 -0
- package/types/archiveManager.d.ts +172 -0
- package/types/archiveManager.d.ts.map +1 -0
- package/types/asyncRunnerInstanceManager.d.ts +108 -0
- package/types/asyncRunnerInstanceManager.d.ts.map +1 -0
- package/types/commonTypes.d.ts +115 -35
- package/types/commonTypes.d.ts.map +1 -1
- package/types/index.d.ts +1 -1
- package/types/index.d.ts.map +1 -1
- package/types/messageBroker.d.ts +324 -0
- package/types/messageBroker.d.ts.map +1 -0
- package/types/runnerInstance.d.ts +245 -0
- package/types/runnerInstance.d.ts.map +1 -0
- package/types/runnerLifecycleManager.d.ts +210 -0
- package/types/runnerLifecycleManager.d.ts.map +1 -0
- package/types/telemetryProcessor.d.ts +67 -0
- package/types/telemetryProcessor.d.ts.map +1 -1
- package/types/testing/mockedWorkerTestRunner01.d.ts +129 -2
- package/types/testing/mockedWorkerTestRunner01.d.ts.map +1 -1
- package/types/testing/testCase01.d.ts +222 -2
- package/types/testing/testCase01.d.ts.map +1 -1
- package/types/testing/testCase02.d.ts +206 -2
- package/types/testing/testCase02.d.ts.map +1 -1
- package/types/testing/wmwokerProcess.test.d.ts +1 -0
- package/types/testing/wmwokerProcess2.test.d.ts +1 -0
- package/types/workerCommandCoordinator.d.ts +152 -0
- package/types/workerCommandCoordinator.d.ts.map +1 -0
- package/types/workerInstance.d.ts +340 -16
- package/types/workerInstance.d.ts.map +1 -1
- package/types/workerInstanceMannager.d.ts +170 -0
- package/types/workerInstanceMannager.d.ts.map +1 -0
- package/types/workerManager.d.ts +335 -24
- package/types/workerManager.d.ts.map +1 -1
- package/types/workerRegistry.d.ts +251 -0
- package/types/workerRegistry.d.ts.map +1 -0
- package/types/workerStateSynchroniser.d.ts +161 -0
- package/types/workerStateSynchroniser.d.ts.map +1 -0
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
|
|
2
|
+
/**
|
|
3
|
+
* WorkerStateSynchroniser
|
|
4
|
+
* =======================
|
|
5
|
+
*
|
|
6
|
+
* Synchronises the manager-side in-memory worker/runner model with the current
|
|
7
|
+
* state held inside the actual worker runtimes.
|
|
8
|
+
*
|
|
9
|
+
* Architectural role
|
|
10
|
+
* ------------------
|
|
11
|
+
* The manager-side registry (`WorkerRegistry`) stores live `IWorkerEx` and
|
|
12
|
+
* `IRunnerEx` objects. However, the true current runner state is maintained
|
|
13
|
+
* inside the actual worker runtime until it is pushed back or explicitly queried.
|
|
14
|
+
*
|
|
15
|
+
* `WorkerStateSynchroniser` provides the "pull" side of that synchronisation:
|
|
16
|
+
*
|
|
17
|
+
* - it asks each worker for its current runners via `GetRunners`
|
|
18
|
+
* - it applies the returned runner snapshots to the live manager-side runner objects
|
|
19
|
+
* - it then returns either:
|
|
20
|
+
* - the full worker map, or
|
|
21
|
+
* - the reduced/core worker map
|
|
22
|
+
*
|
|
23
|
+
* Responsibilities
|
|
24
|
+
* ----------------
|
|
25
|
+
* - issue `GetRunners` requests to all live workers
|
|
26
|
+
* - await all worker responses
|
|
27
|
+
* - apply returned runner state into the manager-side runtime graph
|
|
28
|
+
* - expose synchronised full and reduced worker views
|
|
29
|
+
*
|
|
30
|
+
* Design notes
|
|
31
|
+
* ------------
|
|
32
|
+
* - This class does not own workers or runners directly.
|
|
33
|
+
* - It relies on:
|
|
34
|
+
* - {@link WorkerRegistry} for the live manager-side object graph
|
|
35
|
+
* - {@link STSMessageBroker} for request/response communication
|
|
36
|
+
* - {@link RunnerLifecycleManager} for applying runner state updates consistently
|
|
37
|
+
*
|
|
38
|
+
* Typical usage
|
|
39
|
+
* -------------
|
|
40
|
+
* - `GetSyncedWorkers()` when you want the full current worker/runners model
|
|
41
|
+
* - `GetSyncedWorkersCore(states)` when you want a lighter summary view,
|
|
42
|
+
* optionally filtered by runner state
|
|
43
|
+
*/
|
|
44
|
+
import { IRunnerState, IWorkers, IWorkerCore } from './commonTypes';
|
|
45
|
+
import { STSMessageBroker } from './messageBroker';
|
|
46
|
+
import { WorkerRegistry } from './workerRegistry';
|
|
47
|
+
import { RunnerLifecycleManager } from './runnerLifecycleManager';
|
|
48
|
+
import { ISTSLogger } from '@nsshunt/stsutils';
|
|
49
|
+
/**
|
|
50
|
+
* Constructor options for {@link WorkerStateSynchroniser}.
|
|
51
|
+
*/
|
|
52
|
+
export interface IWorkerStateSynchroniserOptions {
|
|
53
|
+
/**
|
|
54
|
+
* Logger used for diagnostics and error reporting.
|
|
55
|
+
*/
|
|
56
|
+
logger: ISTSLogger;
|
|
57
|
+
/**
|
|
58
|
+
* Shared live worker/runner registry.
|
|
59
|
+
*
|
|
60
|
+
* This contains the manager-side runtime graph that will be updated during synchronisation.
|
|
61
|
+
*/
|
|
62
|
+
workerRegistry: WorkerRegistry;
|
|
63
|
+
/**
|
|
64
|
+
* Shared message broker used to send `GetRunners` requests to workers and await responses.
|
|
65
|
+
*/
|
|
66
|
+
messageBroker: STSMessageBroker;
|
|
67
|
+
/**
|
|
68
|
+
* Runner lifecycle manager used to apply incoming runner snapshots to live
|
|
69
|
+
* manager-side runner objects in a consistent way.
|
|
70
|
+
*/
|
|
71
|
+
runnerLifecycleManager: RunnerLifecycleManager;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Synchronises live manager-side worker/runner state with the actual worker runtimes.
|
|
75
|
+
*/
|
|
76
|
+
export declare class WorkerStateSynchroniser {
|
|
77
|
+
/**
|
|
78
|
+
* Immutable runtime configuration and dependencies.
|
|
79
|
+
*/
|
|
80
|
+
private readonly options;
|
|
81
|
+
/**
|
|
82
|
+
* Construct a new worker state synchroniser.
|
|
83
|
+
*
|
|
84
|
+
* @param options Logger, registry, message broker, and runner lifecycle collaborators.
|
|
85
|
+
*/
|
|
86
|
+
constructor(options: IWorkerStateSynchroniserOptions);
|
|
87
|
+
/**
|
|
88
|
+
* Synchronise all live workers from their current worker-runtime state.
|
|
89
|
+
*
|
|
90
|
+
* Behaviour
|
|
91
|
+
* ---------
|
|
92
|
+
* 1. Resolve all live workers from the registry
|
|
93
|
+
* 2. Send `GetRunners` to each worker through the message broker
|
|
94
|
+
* 3. Await all worker responses
|
|
95
|
+
* 4. For each returned runner snapshot:
|
|
96
|
+
* - resolve the owning worker from the registry
|
|
97
|
+
* - resolve that worker's live runner map
|
|
98
|
+
* - if the runner exists in the registry, apply the snapshot to the live runner
|
|
99
|
+
* object using `RunnerLifecycleManager.SyncRunnerData(...)`
|
|
100
|
+
*
|
|
101
|
+
* Important notes
|
|
102
|
+
* ---------------
|
|
103
|
+
* - This method only updates existing manager-side runner objects.
|
|
104
|
+
* - It does not create missing runners if a worker returns a runner id that is
|
|
105
|
+
* not already present in the registry.
|
|
106
|
+
* - It assumes the manager-side registry and worker runtime are already aligned
|
|
107
|
+
* in terms of which runners exist.
|
|
108
|
+
*
|
|
109
|
+
* Error handling
|
|
110
|
+
* --------------
|
|
111
|
+
* - Logs and re-throws unexpected errors.
|
|
112
|
+
*
|
|
113
|
+
* @returns Resolves when all workers have been queried and all returned runner snapshots
|
|
114
|
+
* have been applied to the manager-side runtime graph.
|
|
115
|
+
* @throws Re-throws unexpected errors after logging.
|
|
116
|
+
*/
|
|
117
|
+
private SyncAllWorkers;
|
|
118
|
+
/**
|
|
119
|
+
* Get the full synchronised workers model.
|
|
120
|
+
*
|
|
121
|
+
* Behaviour
|
|
122
|
+
* ---------
|
|
123
|
+
* - First synchronises all workers by querying their current runtime state
|
|
124
|
+
* - Then returns the full serialisable workers map from the registry
|
|
125
|
+
*
|
|
126
|
+
* Returned model
|
|
127
|
+
* --------------
|
|
128
|
+
* The returned `IWorkers` structure includes:
|
|
129
|
+
* - all live workers
|
|
130
|
+
* - each worker's full serialisable runner set
|
|
131
|
+
*
|
|
132
|
+
* @returns Fully synchronised full workers model.
|
|
133
|
+
* @throws Re-throws unexpected errors after logging.
|
|
134
|
+
*/
|
|
135
|
+
GetSyncedWorkers: () => Promise<IWorkers>;
|
|
136
|
+
/**
|
|
137
|
+
* Get the reduced/core synchronised workers model.
|
|
138
|
+
*
|
|
139
|
+
* Behaviour
|
|
140
|
+
* ---------
|
|
141
|
+
* - First synchronises all workers by querying their current runtime state
|
|
142
|
+
* - Then returns the reduced/core workers map from the registry
|
|
143
|
+
*
|
|
144
|
+
* Runner state filtering
|
|
145
|
+
* ----------------------
|
|
146
|
+
* - `undefined` => include all runners
|
|
147
|
+
* - `[]` => include all runners
|
|
148
|
+
* - populated array => include only runners whose state matches one of the supplied states
|
|
149
|
+
*
|
|
150
|
+
* Returned model
|
|
151
|
+
* --------------
|
|
152
|
+
* The returned structure includes a reduced representation of each worker and runner,
|
|
153
|
+
* suitable for lightweight status/dashboard style views.
|
|
154
|
+
*
|
|
155
|
+
* @param states Optional runner-state filter.
|
|
156
|
+
* @returns Fully synchronised reduced/core workers model.
|
|
157
|
+
* @throws Re-throws unexpected errors after logging.
|
|
158
|
+
*/
|
|
159
|
+
GetSyncedWorkersCore: (states?: IRunnerState[]) => Promise<Record<string, IWorkerCore>>;
|
|
160
|
+
}
|
|
161
|
+
//# sourceMappingURL=workerStateSynchroniser.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workerStateSynchroniser.d.ts","sourceRoot":"","sources":["../src/workerStateSynchroniser.ts"],"names":[],"mappings":";AAEA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;AAGH,OAAO,EAEH,YAAY,EAGZ,QAAQ,EACR,WAAW,EACd,MAAM,eAAe,CAAC;AAEvB,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AACnD,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAClE,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAE/C;;GAEG;AACH,MAAM,WAAW,+BAA+B;IAC5C;;OAEG;IACH,MAAM,EAAE,UAAU,CAAC;IAEnB;;;;OAIG;IACH,cAAc,EAAE,cAAc,CAAC;IAE/B;;OAEG;IACH,aAAa,EAAE,gBAAgB,CAAC;IAEhC;;;OAGG;IACH,sBAAsB,EAAE,sBAAsB,CAAC;CAClD;AAED;;GAEG;AACH,qBAAa,uBAAuB;IAChC;;OAEG;IACH,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAkC;IAE1D;;;;OAIG;gBACS,OAAO,EAAE,+BAA+B;IAIpD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA6BG;IACH,OAAO,CAAC,cAAc,CAwDpB;IAEF;;;;;;;;;;;;;;;;OAgBG;IACH,gBAAgB,QAAa,OAAO,CAAC,QAAQ,CAAC,CAQ5C;IAEF;;;;;;;;;;;;;;;;;;;;;;OAsBG;IACH,oBAAoB,GAAU,SAAS,YAAY,EAAE,KAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC,CAQ1F;CACL"}
|