@spine-event-engine/server 2.0.0-snapshot.21 → 2.0.0-snapshot.23
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 +104 -7
- package/REFERENCE.md +199 -19
- package/dist/agent/agent-admission.d.ts +80 -0
- package/dist/agent/agent-admission.d.ts.map +1 -0
- package/dist/agent/agent-admission.js +127 -0
- package/dist/agent/agent-admission.js.map +1 -0
- package/dist/agent/agent-ai-binding.d.ts +24 -0
- package/dist/agent/agent-ai-binding.d.ts.map +1 -0
- package/dist/agent/agent-ai-binding.js +48 -0
- package/dist/agent/agent-ai-binding.js.map +1 -0
- package/dist/agent/agent-ai-runtime.d.ts +76 -0
- package/dist/agent/agent-ai-runtime.d.ts.map +1 -0
- package/dist/agent/agent-ai-runtime.js +1269 -0
- package/dist/agent/agent-ai-runtime.js.map +1 -0
- package/dist/agent/agent-execution-capacity.d.ts +43 -0
- package/dist/agent/agent-execution-capacity.d.ts.map +1 -0
- package/dist/agent/agent-execution-capacity.js +147 -0
- package/dist/agent/agent-execution-capacity.js.map +1 -0
- package/dist/agent/agent-execution-fault.d.ts +18 -0
- package/dist/agent/agent-execution-fault.d.ts.map +1 -0
- package/dist/agent/agent-execution-fault.js +31 -0
- package/dist/agent/agent-execution-fault.js.map +1 -0
- package/dist/agent/agent-execution-session.d.ts +103 -0
- package/dist/agent/agent-execution-session.d.ts.map +1 -0
- package/dist/agent/agent-execution-session.js +238 -0
- package/dist/agent/agent-execution-session.js.map +1 -0
- package/dist/agent/agent-history.d.ts +148 -0
- package/dist/agent/agent-history.d.ts.map +1 -0
- package/dist/agent/agent-history.js +340 -0
- package/dist/agent/agent-history.js.map +1 -0
- package/dist/agent/agent-interaction-audit.d.ts +58 -0
- package/dist/agent/agent-interaction-audit.d.ts.map +1 -0
- package/dist/agent/agent-interaction-audit.js +114 -0
- package/dist/agent/agent-interaction-audit.js.map +1 -0
- package/dist/agent/agent-interaction-events.d.ts +40 -0
- package/dist/agent/agent-interaction-events.d.ts.map +1 -0
- package/dist/agent/agent-interaction-events.js +129 -0
- package/dist/agent/agent-interaction-events.js.map +1 -0
- package/dist/agent/agent-mcp-budget.d.ts +125 -0
- package/dist/agent/agent-mcp-budget.d.ts.map +1 -0
- package/dist/agent/agent-mcp-budget.js +566 -0
- package/dist/agent/agent-mcp-budget.js.map +1 -0
- package/dist/agent/agent-mcp-host.d.ts +125 -0
- package/dist/agent/agent-mcp-host.d.ts.map +1 -0
- package/dist/agent/agent-mcp-host.js +15 -0
- package/dist/agent/agent-mcp-host.js.map +1 -0
- package/dist/agent/agent-mcp-runtime.d.ts +199 -0
- package/dist/agent/agent-mcp-runtime.d.ts.map +1 -0
- package/dist/agent/agent-mcp-runtime.js +621 -0
- package/dist/agent/agent-mcp-runtime.js.map +1 -0
- package/dist/agent/agent-model-selection.d.ts +129 -0
- package/dist/agent/agent-model-selection.d.ts.map +1 -0
- package/dist/agent/agent-model-selection.js +342 -0
- package/dist/agent/agent-model-selection.js.map +1 -0
- package/dist/agent/agent-read-runtime.d.ts +70 -0
- package/dist/agent/agent-read-runtime.d.ts.map +1 -0
- package/dist/agent/agent-read-runtime.js +320 -0
- package/dist/agent/agent-read-runtime.js.map +1 -0
- package/dist/agent/agent-revisions.d.ts +35 -0
- package/dist/agent/agent-revisions.d.ts.map +1 -0
- package/dist/agent/agent-revisions.js +133 -0
- package/dist/agent/agent-revisions.js.map +1 -0
- package/dist/agent/agent-scheduler.d.ts +99 -0
- package/dist/agent/agent-scheduler.d.ts.map +1 -0
- package/dist/agent/agent-scheduler.js +398 -0
- package/dist/agent/agent-scheduler.js.map +1 -0
- package/dist/bus/command-bus.d.ts +62 -0
- package/dist/bus/command-bus.d.ts.map +1 -1
- package/dist/bus/command-bus.js +51 -2
- package/dist/bus/command-bus.js.map +1 -1
- package/dist/bus/event-bus.d.ts +137 -3
- package/dist/bus/event-bus.d.ts.map +1 -1
- package/dist/bus/event-bus.js +133 -2
- package/dist/bus/event-bus.js.map +1 -1
- package/dist/bus/saved-dispatcher-binding.d.ts +96 -0
- package/dist/bus/saved-dispatcher-binding.d.ts.map +1 -0
- package/dist/bus/saved-dispatcher-binding.js +35 -0
- package/dist/bus/saved-dispatcher-binding.js.map +1 -0
- package/dist/context/bounded-context.d.ts +36 -2
- package/dist/context/bounded-context.d.ts.map +1 -1
- package/dist/context/bounded-context.js +253 -54
- package/dist/context/bounded-context.js.map +1 -1
- package/dist/context/entity-inbox.d.ts.map +1 -1
- package/dist/context/entity-inbox.js +5 -5
- package/dist/context/entity-inbox.js.map +1 -1
- package/dist/context/projection-handoff.d.ts.map +1 -1
- package/dist/context/projection-handoff.js +2 -1
- package/dist/context/projection-handoff.js.map +1 -1
- package/dist/context/tenant-index.d.ts +25 -0
- package/dist/context/tenant-index.d.ts.map +1 -1
- package/dist/context/tenant-index.js +45 -1
- package/dist/context/tenant-index.js.map +1 -1
- package/dist/delivery/delivery.d.ts.map +1 -1
- package/dist/delivery/delivery.js +4 -3
- package/dist/delivery/delivery.js.map +1 -1
- package/dist/delivery/inbox-records.d.ts +13 -0
- package/dist/delivery/inbox-records.d.ts.map +1 -1
- package/dist/delivery/inbox-records.js +204 -30
- package/dist/delivery/inbox-records.js.map +1 -1
- package/dist/delivery/inbox-storage.d.ts.map +1 -1
- package/dist/delivery/inbox-storage.js +26 -5
- package/dist/delivery/inbox-storage.js.map +1 -1
- package/dist/delivery/inbox.d.ts +7 -7
- package/dist/delivery/inbox.d.ts.map +1 -1
- package/dist/delivery/inbox.js +1 -2
- package/dist/delivery/inbox.js.map +1 -1
- package/dist/delivery/sharded-work-registry.d.ts +1 -0
- package/dist/delivery/sharded-work-registry.d.ts.map +1 -1
- package/dist/delivery/sharded-work-registry.js +3 -1
- package/dist/delivery/sharded-work-registry.js.map +1 -1
- package/dist/entity/entity-transaction.d.ts.map +1 -1
- package/dist/entity/entity-transaction.js +2 -6
- package/dist/entity/entity-transaction.js.map +1 -1
- package/dist/entity/entity.d.ts +82 -3
- package/dist/entity/entity.d.ts.map +1 -1
- package/dist/entity/entity.js +121 -22
- package/dist/entity/entity.js.map +1 -1
- package/dist/handler/generated-handler-registry.js +8 -3
- package/dist/handler/generated-handler-registry.js.map +1 -1
- package/dist/handler/handler-metadata.d.ts +17 -1
- package/dist/handler/handler-metadata.d.ts.map +1 -1
- package/dist/handler/handler-metadata.js +10 -4
- package/dist/handler/handler-metadata.js.map +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/integration/third-party-context.d.ts +5 -0
- package/dist/integration/third-party-context.d.ts.map +1 -1
- package/dist/integration/third-party-context.js +7 -6
- package/dist/integration/third-party-context.js.map +1 -1
- package/dist/repository/commit-fence.d.ts +11 -0
- package/dist/repository/commit-fence.d.ts.map +1 -1
- package/dist/repository/commit-fence.js +13 -0
- package/dist/repository/commit-fence.js.map +1 -1
- package/dist/repository/repository.d.ts +222 -13
- package/dist/repository/repository.d.ts.map +1 -1
- package/dist/repository/repository.js +2329 -137
- package/dist/repository/repository.js.map +1 -1
- package/dist/runtime/signal-metadata.d.ts +7 -47
- package/dist/runtime/signal-metadata.d.ts.map +1 -1
- package/dist/runtime/signal-metadata.js +8 -62
- package/dist/runtime/signal-metadata.js.map +1 -1
- package/dist/runtime/signal-publisher.d.ts +6 -0
- package/dist/runtime/signal-publisher.d.ts.map +1 -1
- package/dist/runtime/signal-publisher.js +13 -0
- package/dist/runtime/signal-publisher.js.map +1 -1
- package/dist/runtime/standalone-handler-runtime.d.ts +7 -0
- package/dist/runtime/standalone-handler-runtime.d.ts.map +1 -1
- package/dist/runtime/standalone-handler-runtime.js +148 -11
- package/dist/runtime/standalone-handler-runtime.js.map +1 -1
- package/dist/server/managed-server-application.d.ts +36 -6
- package/dist/server/managed-server-application.d.ts.map +1 -1
- package/dist/server/managed-server-application.js +257 -4
- package/dist/server/managed-server-application.js.map +1 -1
- package/dist/server/server.d.ts +9 -0
- package/dist/server/server.d.ts.map +1 -1
- package/dist/server/server.js +13 -1
- package/dist/server/server.js.map +1 -1
- package/dist/stand/subscription-registry.d.ts.map +1 -1
- package/dist/stand/subscription-registry.js +9 -8
- package/dist/stand/subscription-registry.js.map +1 -1
- package/dist/testing/index.d.ts +57 -1
- package/dist/testing/index.d.ts.map +1 -1
- package/dist/testing/index.js +87 -0
- package/dist/testing/index.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +14 -12
|
@@ -61,11 +61,11 @@ export interface ManagedServerApplicationOptions {
|
|
|
61
61
|
*
|
|
62
62
|
* Builds one complete local application server in a child process.
|
|
63
63
|
*
|
|
64
|
-
* The framework
|
|
64
|
+
* The framework manages the returned `Server` for the child lifetime.
|
|
65
65
|
* Every assembled Bounded Context must use its actual
|
|
66
66
|
* `InMemorySubscriptionRegistry`: managed mode rejects persistent and custom
|
|
67
67
|
* registries, then closes the assembled server before the child can report
|
|
68
|
-
* READY. This prevents child-local
|
|
68
|
+
* READY. This prevents durable subscriptions in a child-local registry.
|
|
69
69
|
*
|
|
70
70
|
* @param options Supplies the child-only loopback listener address.
|
|
71
71
|
* @returns The assembled local application server.
|
|
@@ -126,10 +126,10 @@ export declare const ManagedServerApplication: Readonly<{
|
|
|
126
126
|
/**
|
|
127
127
|
*
|
|
128
128
|
* Starts a managed parent and complete-replica children without taking
|
|
129
|
-
* process-signal
|
|
129
|
+
* process-signal handling.
|
|
130
130
|
*
|
|
131
131
|
* The caller closes the returned handle. This is for an embedding host that
|
|
132
|
-
* already
|
|
132
|
+
* already handles `SIGINT` and `SIGTERM`.
|
|
133
133
|
*
|
|
134
134
|
* @param options Configures the managed application replicas.
|
|
135
135
|
* @returns The started managed application handle.
|
|
@@ -255,14 +255,14 @@ export declare class ManagedServerCoordinator {
|
|
|
255
255
|
/**
|
|
256
256
|
* Records an exact native subscription whose activation started for a member.
|
|
257
257
|
*
|
|
258
|
-
* @param member
|
|
258
|
+
* @param member Identifies the member whose child subscription is activating.
|
|
259
259
|
* @param subscription Supplies the activating native subscription.
|
|
260
260
|
*/
|
|
261
261
|
onChildSubscriptionActivated(member: ReadyCoordinatorMember, subscription: Subscription): void;
|
|
262
262
|
/**
|
|
263
263
|
* Clears a pending child-installation wait after cancellation.
|
|
264
264
|
*
|
|
265
|
-
* @param member
|
|
265
|
+
* @param member Identifies the member whose child subscription was cancelled.
|
|
266
266
|
* @param subscription Supplies the cancelled native subscription.
|
|
267
267
|
*/
|
|
268
268
|
onChildSubscriptionCancelled(member: ReadyCoordinatorMember, subscription: Subscription): void;
|
|
@@ -309,7 +309,19 @@ type ReadyMember = ReadyCoordinatorMember;
|
|
|
309
309
|
* @internal
|
|
310
310
|
*/
|
|
311
311
|
export declare const managedServerCoordinatorAccess: Readonly<{
|
|
312
|
+
/**
|
|
313
|
+
* Returns currently ready members for private coordinator inspection.
|
|
314
|
+
*
|
|
315
|
+
* @param coordinator The managed coordinator to inspect.
|
|
316
|
+
* @returns The currently ready coordinator members.
|
|
317
|
+
*/
|
|
312
318
|
readyMembers(coordinator: ManagedServerCoordinator): readonly ReadyMember[];
|
|
319
|
+
/**
|
|
320
|
+
* Returns the private coordinator endpoint when available.
|
|
321
|
+
*
|
|
322
|
+
* @param coordinator The managed coordinator to inspect.
|
|
323
|
+
* @returns The loopback endpoint when the coordinator is open.
|
|
324
|
+
*/
|
|
313
325
|
coordinatorEndpoint(coordinator: ManagedServerCoordinator): string | undefined;
|
|
314
326
|
}>;
|
|
315
327
|
/**
|
|
@@ -319,8 +331,26 @@ export declare const managedServerCoordinatorAccess: Readonly<{
|
|
|
319
331
|
* @internal
|
|
320
332
|
*/
|
|
321
333
|
export declare const managedServerApplicationAccess: Readonly<{
|
|
334
|
+
/**
|
|
335
|
+
* Returns currently ready members for private coordinator inspection.
|
|
336
|
+
*
|
|
337
|
+
* @param handle The application handle to inspect.
|
|
338
|
+
* @returns The currently ready coordinator members.
|
|
339
|
+
*/
|
|
322
340
|
readyMembers(handle: ManagedServerApplicationHandle): readonly ReadyMember[];
|
|
341
|
+
/**
|
|
342
|
+
* Returns the private coordinator endpoint when available.
|
|
343
|
+
*
|
|
344
|
+
* @param handle The application handle to inspect.
|
|
345
|
+
* @returns The loopback endpoint when the coordinator is open.
|
|
346
|
+
*/
|
|
323
347
|
coordinatorEndpoint(handle: ManagedServerApplicationHandle): string | undefined;
|
|
348
|
+
/**
|
|
349
|
+
* Associates in-memory registries with an assembled test server.
|
|
350
|
+
*
|
|
351
|
+
* @param server The assembled child server to inspect.
|
|
352
|
+
* @param registries The registries supplied by a test server.
|
|
353
|
+
*/
|
|
324
354
|
installRegistriesForTest(server: RunningServer, registries: readonly InMemorySubscriptionRegistry[]): void;
|
|
325
355
|
}>;
|
|
326
356
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"managed-server-application.d.ts","sourceRoot":"","sources":["../../src/server/managed-server-application.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"managed-server-application.d.ts","sourceRoot":"","sources":["../../src/server/managed-server-application.ts"],"names":[],"mappings":"AAeA,OAAO,EAAQ,KAAK,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAI7D,OAAO,EAAuB,KAAK,aAAa,EAAE,MAAM,aAAa,CAAC;AAEtE,OAAO,EAAE,eAAe,EAAE,KAAK,sBAAsB,EAAE,MAAM,uBAAuB,CAAC;AAGrF,OAAO,EAAE,4BAA4B,EAAE,MAAM,mCAAmC,CAAC;AACjF,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kCAAkC,CAAC;AAyBrE;;;GAGG;AACH,MAAM,WAAW,2BAA2B;IAG1C;;;OAGG;IACH,QAAQ,CAAC,cAAc,CAAC,EAAE,MAAM,CAAC;IAEjC;;;OAGG;IACH,QAAQ,CAAC,cAAc,CAAC,EAAE,MAAM,CAAC;IAEjC;;;OAGG;IACH,QAAQ,CAAC,cAAc,CAAC,EAAE,MAAM,CAAC;IAEjC;;;OAGG;IACH,QAAQ,CAAC,gBAAgB,CAAC,EAAE,MAAM,CAAC;CACpC;AAED;;;GAGG;AACH,MAAM,WAAW,+BAA+B;IAG9C;;;OAGG;IACH,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAE9B;;;OAGG;IACH,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IAEvB;;;;;;OAMG;IACH,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAEtB;;;OAGG;IACH,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAE3B;;;;;;;;;;;;OAYG;IACH,QAAQ,CAAC,YAAY,EAAE,CAAC,OAAO,EAAE;QAG/B;;;WAGG;QACH,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;QAEtB;;;WAGG;QACH,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;KACvB,KAAK,OAAO,CAAC,aAAa,CAAC,CAAC;IAE7B;;;;;;;;;;OAUG;IACH,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IAE3C;;;OAGG;IACH,QAAQ,CAAC,OAAO,CAAC,EAAE,2BAA2B,CAAC;CAChD;AAED;;;GAGG;AACH,MAAM,WAAW,8BAA8B;IAG7C;;;OAGG;IACH,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC;IAExB;;;;;OAKG;IACH,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CACxB;AAED;;;GAGG;AACH,eAAO,MAAM,wBAAwB,EAAE,QAAQ,CAAC;IAG9C;;;;;;;;;;OAUG;IACH,KAAK,CAAC,OAAO,EAAE,+BAA+B,GAAG,OAAO,CAAC,8BAA8B,CAAC,CAAC;IAEzF;;;;;;;OAOG;IACH,GAAG,CAAC,OAAO,EAAE,+BAA+B,GAAG,OAAO,CAAC,8BAA8B,CAAC,CAAC;CACxF,CAoBC,CAAC;AAyRH;;;;;GAKG;AACH,MAAM,WAAW,oCAAoC;IAGnD;;;OAGG;IACH,QAAQ,CAAC,KAAK,EAAE;QAGd;;;;;WAKG;QACH,GAAG,IAAI,MAAM,CAAC;QAEd;;;;;;;WAOG;QACH,UAAU,CAAC,SAAS,EAAE,MAAM,IAAI,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC;QAE1D;;;;;WAKG;QACH,YAAY,CAAC,KAAK,EAAE,OAAO,GAAG,IAAI,CAAC;KACpC,CAAC;IAEF;;;;;;;;OAQG;IACH,QAAQ,CAAC,KAAK,EAAE,CAAC,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,KAAK,YAAY,CAAC;IAEvF;;;;;;OAMG;IACH,QAAQ,CAAC,eAAe,CAAC,EAAE,CAAC,OAAO,EAAE;QACnC,QAAQ,CAAC,OAAO,EAAE,wBAAwB,CAAC;QAC3C,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;QACvB,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;KACxB,KAAK,OAAO,CAAC,eAAe,CAAC,CAAC;CAChC;AAED,KAAK,+BAA+B,GAAG,IAAI,CAAC,+BAA+B,EAAE,MAAM,CAAC,GAAG;IACrF,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,oBAAoB,CAAC,EAAE,OAAO,CAAC;CACzC,CAAC;AAEF;;;;;GAKG;AACH,qBAAa,wBAAwB;;IA6BnC;;;;;;OAMG;gBAED,OAAO,EAAE,+BAA+B,EACxC,YAAY,GAAE,oCAAkF;IAelG;;;;;OAKG;IACG,KAAK,IAAI,OAAO,CAAC,8BAA8B,CAAC;IA2PtD;;;;;OAKG;IACH,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IA0GtB;;;;;;OAMG;IACH,YAAY,IAAI,SAAS,sBAAsB,EAAE;IAIjD;;;;OAIG;IACH,YAAY,IAAI,SAAS,sBAAsB,EAAE;IAIjD;;;;;OAKG;IACH,4BAA4B,CAAC,MAAM,EAAE,sBAAsB,EAAE,YAAY,EAAE,YAAY,GAAG,IAAI;IAO9F;;;;;OAKG;IACH,4BAA4B,CAAC,MAAM,EAAE,sBAAsB,EAAE,YAAY,EAAE,YAAY,GAAG,IAAI;IAM9F;;;;OAIG;IACG,mBAAmB,IAAI,OAAO,CAAC,IAAI,CAAC;IA+E1C;;;;;;OAMG;IACH,oBAAoB,CAAC,QAAQ,EAAE,MAAM,IAAI,GAAG,MAAM,IAAI;IAKtD;;;;;OAKG;IACH,oBAAoB,CAAC,QAAQ,EAAE,MAAM,IAAI,GAAG,MAAM,IAAI;IAItD;;;;;OAKG;IACH,mBAAmB,IAAI,MAAM,GAAG,SAAS;CA6C1C;AAED;;;;;GAKG;AACH,KAAK,WAAW,GAAG,sBAAsB,CAAC;AAE1C;;;;;GAKG;AACH,eAAO,MAAM,8BAA8B,EAAE,QAAQ,CAAC;IACpD;;;;;OAKG;IACH,YAAY,CAAC,WAAW,EAAE,wBAAwB,GAAG,SAAS,WAAW,EAAE,CAAC;IAE5E;;;;;OAKG;IACH,mBAAmB,CAAC,WAAW,EAAE,wBAAwB,GAAG,MAAM,GAAG,SAAS,CAAC;CAChF,CAoBC,CAAC;AAEH;;;;;GAKG;AACH,eAAO,MAAM,8BAA8B,EAAE,QAAQ,CAAC;IACpD;;;;;OAKG;IACH,YAAY,CAAC,MAAM,EAAE,8BAA8B,GAAG,SAAS,WAAW,EAAE,CAAC;IAE7E;;;;;OAKG;IACH,mBAAmB,CAAC,MAAM,EAAE,8BAA8B,GAAG,MAAM,GAAG,SAAS,CAAC;IAEhF;;;;;OAKG;IACH,wBAAwB,CACtB,MAAM,EAAE,aAAa,EACrB,UAAU,EAAE,SAAS,4BAA4B,EAAE,GAClD,IAAI,CAAC;CACT,CAiCC,CAAC"}
|
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
* or implied. See the License for the specific language governing permissions and limitations under
|
|
12
12
|
* the License.
|
|
13
13
|
*/
|
|
14
|
+
import { Time } from "@spine-event-engine/core/time";
|
|
14
15
|
import { fork } from "node:child_process";
|
|
15
16
|
import { randomUUID } from "node:crypto";
|
|
16
17
|
import { fileURLToPath } from "node:url";
|
|
@@ -48,14 +49,33 @@ const lifecycleLogger = new LogLayer({
|
|
|
48
49
|
* Starts a managed parent and its complete-replica child processes.
|
|
49
50
|
*/
|
|
50
51
|
export const ManagedServerApplication = Object.freeze({
|
|
52
|
+
/**
|
|
53
|
+
* Validates replica count and port, then starts the parent coordinator or child application.
|
|
54
|
+
*
|
|
55
|
+
* @param options The replica count, listener, child module, and assembly callback.
|
|
56
|
+
* @returns The started application handle.
|
|
57
|
+
*/
|
|
51
58
|
async start(options) {
|
|
52
59
|
return ManagedServerValues.start(options, false);
|
|
53
60
|
},
|
|
61
|
+
/**
|
|
62
|
+
* Starts managed replicas and installs process signal handling.
|
|
63
|
+
*
|
|
64
|
+
* @param options The replica count, listener, and child assembly settings.
|
|
65
|
+
* @returns The started application handle.
|
|
66
|
+
*/
|
|
54
67
|
async run(options) {
|
|
55
68
|
return ManagedServerValues.start(options, true);
|
|
56
69
|
},
|
|
57
70
|
});
|
|
58
71
|
const ManagedServerValues = Object.freeze({
|
|
72
|
+
/**
|
|
73
|
+
* Validates replica count and port, then starts the parent coordinator or child application.
|
|
74
|
+
*
|
|
75
|
+
* @param options The replica count, listener, child module, and assembly callback.
|
|
76
|
+
* @param manageProcessSignals Whether the parent installs SIGINT and SIGTERM handlers.
|
|
77
|
+
* @returns The started application handle.
|
|
78
|
+
*/
|
|
59
79
|
async start(options, manageProcessSignals) {
|
|
60
80
|
if (!Number.isSafeInteger(options.processCount) || options.processCount < 1) {
|
|
61
81
|
throw new Error("Managed server processCount must be a positive safe integer.");
|
|
@@ -65,6 +85,12 @@ const ManagedServerValues = Object.freeze({
|
|
|
65
85
|
return ManagedServerValues.child(options);
|
|
66
86
|
return ManagedServerValues.parent(options, manageProcessSignals);
|
|
67
87
|
},
|
|
88
|
+
/**
|
|
89
|
+
* Creates a child server, checks volatile registries, synchronizes, and participates in parent IPC.
|
|
90
|
+
*
|
|
91
|
+
* @param options The child server assembly and synchronization settings.
|
|
92
|
+
* @returns The active child application handle.
|
|
93
|
+
*/
|
|
68
94
|
async child(options) {
|
|
69
95
|
const server = await options.createServer({ host: "127.0.0.1", port: 0 });
|
|
70
96
|
try {
|
|
@@ -81,7 +107,7 @@ const ManagedServerValues = Object.freeze({
|
|
|
81
107
|
throw error;
|
|
82
108
|
}
|
|
83
109
|
// Node may emit an IPC EPIPE after a parent has already disappeared. The
|
|
84
|
-
// disconnect handler below
|
|
110
|
+
// disconnect handler below handles shutdown; this listener prevents that
|
|
85
111
|
// transport detail from becoming an unhandled child-process exception.
|
|
86
112
|
const containIpcError = () => undefined;
|
|
87
113
|
process.on("error", containIpcError);
|
|
@@ -190,9 +216,21 @@ const ManagedServerValues = Object.freeze({
|
|
|
190
216
|
close,
|
|
191
217
|
};
|
|
192
218
|
},
|
|
219
|
+
/**
|
|
220
|
+
* Starts a coordinator for the configured complete-replica cohort.
|
|
221
|
+
*
|
|
222
|
+
* @param options The parent cohort and listener settings.
|
|
223
|
+
* @param manageProcessSignals Whether the parent installs SIGINT and SIGTERM handlers.
|
|
224
|
+
* @returns The started parent cohort handle.
|
|
225
|
+
*/
|
|
193
226
|
parent(options, manageProcessSignals) {
|
|
194
227
|
return new ManagedServerCoordinator({ ...options, manageProcessSignals }).start();
|
|
195
228
|
},
|
|
229
|
+
/**
|
|
230
|
+
* Starts child shutdown after an IPC close or disconnect event and logs failure.
|
|
231
|
+
*
|
|
232
|
+
* @param close The child shutdown callback.
|
|
233
|
+
*/
|
|
196
234
|
closeFromEvent(close) {
|
|
197
235
|
// spine-log-boundary: server.managed_replica_child_close
|
|
198
236
|
void close().catch(() => {
|
|
@@ -202,12 +240,23 @@ const ManagedServerValues = Object.freeze({
|
|
|
202
240
|
});
|
|
203
241
|
});
|
|
204
242
|
},
|
|
243
|
+
/**
|
|
244
|
+
* Rejects child servers without exclusively in-memory subscription registries.
|
|
245
|
+
*
|
|
246
|
+
* @param server The assembled child server to inspect.
|
|
247
|
+
*/
|
|
205
248
|
requireVolatileRegistries(server) {
|
|
206
249
|
const registries = runningServerAccess.subscriptionRegistries(server) ?? managedTestRegistries.get(server);
|
|
207
250
|
if (registries === undefined ||
|
|
208
251
|
registries.some((registry) => !(registry instanceof InMemorySubscriptionRegistry)))
|
|
209
252
|
throw new Error("Managed application replicas require an in-memory Stand subscription registry.");
|
|
210
253
|
},
|
|
254
|
+
/**
|
|
255
|
+
* Sends a child lifecycle notification over the connected parent IPC channel.
|
|
256
|
+
*
|
|
257
|
+
* @param message The child lifecycle notification to send.
|
|
258
|
+
* @returns Completion after the parent IPC channel acknowledges the send.
|
|
259
|
+
*/
|
|
211
260
|
send(message) {
|
|
212
261
|
return new Promise((resolve, reject) => {
|
|
213
262
|
if (process.send === undefined || !process.connected) {
|
|
@@ -312,6 +361,11 @@ export class ManagedServerCoordinator {
|
|
|
312
361
|
handleMembers.set(handle, this);
|
|
313
362
|
return handle;
|
|
314
363
|
}
|
|
364
|
+
/**
|
|
365
|
+
* Starts a child for an available slot while respecting the concurrent-start limit.
|
|
366
|
+
*
|
|
367
|
+
* @param slot The replica slot to start or update.
|
|
368
|
+
*/
|
|
315
369
|
#start(slot) {
|
|
316
370
|
if (this.#closing ||
|
|
317
371
|
slot.starting ||
|
|
@@ -366,6 +420,13 @@ export class ManagedServerCoordinator {
|
|
|
366
420
|
this.#onError(slot, replica);
|
|
367
421
|
});
|
|
368
422
|
}
|
|
423
|
+
/**
|
|
424
|
+
* Processes a matching child lifecycle notification and updates readiness or shutdown state.
|
|
425
|
+
*
|
|
426
|
+
* @param slot The replica slot to start or update.
|
|
427
|
+
* @param replica The child incarnation associated with the event.
|
|
428
|
+
* @param message The untrusted child IPC notification.
|
|
429
|
+
*/
|
|
369
430
|
#onMessage(slot, replica, message) {
|
|
370
431
|
const closeResult = ManagedServerCoordinatorValues.closeResultMessage(message, slot.slot, replica.incarnation);
|
|
371
432
|
if (closeResult !== undefined) {
|
|
@@ -419,6 +480,12 @@ export class ManagedServerCoordinator {
|
|
|
419
480
|
this.#notifyReadyMembers();
|
|
420
481
|
this.#drainStarts();
|
|
421
482
|
}
|
|
483
|
+
/**
|
|
484
|
+
* Retires an exited incarnation and schedules replacement after an unexpected exit.
|
|
485
|
+
*
|
|
486
|
+
* @param slot The replica slot to start or update.
|
|
487
|
+
* @param replica The child incarnation associated with the event.
|
|
488
|
+
*/
|
|
422
489
|
#onExit(slot, replica) {
|
|
423
490
|
if (slot.replica !== replica || replica.terminal)
|
|
424
491
|
return;
|
|
@@ -447,6 +514,12 @@ export class ManagedServerCoordinator {
|
|
|
447
514
|
this.#scheduleReplacement(slot);
|
|
448
515
|
this.#drainStarts();
|
|
449
516
|
}
|
|
517
|
+
/**
|
|
518
|
+
* Retires a child after a process error and starts bounded termination.
|
|
519
|
+
*
|
|
520
|
+
* @param slot The replica slot to start or update.
|
|
521
|
+
* @param replica The child incarnation associated with the event.
|
|
522
|
+
*/
|
|
450
523
|
#onError(slot, replica) {
|
|
451
524
|
if (slot.replica !== replica || replica.terminal)
|
|
452
525
|
return;
|
|
@@ -455,6 +528,11 @@ export class ManagedServerCoordinator {
|
|
|
455
528
|
this.#onExit(slot, replica);
|
|
456
529
|
this.#terminateUnexpected(replica);
|
|
457
530
|
}
|
|
531
|
+
/**
|
|
532
|
+
* Schedules exponential replacement delay capped by the configured maximum.
|
|
533
|
+
*
|
|
534
|
+
* @param slot The replica slot to start or update.
|
|
535
|
+
*/
|
|
458
536
|
#scheduleReplacement(slot) {
|
|
459
537
|
slot.failures++;
|
|
460
538
|
const delay = Math.min(this.#restart.initialDelayMs * 2 ** Math.max(0, slot.failures - 1), this.#restart.maximumDelayMs);
|
|
@@ -471,6 +549,10 @@ export class ManagedServerCoordinator {
|
|
|
471
549
|
delay: String(delay),
|
|
472
550
|
});
|
|
473
551
|
}
|
|
552
|
+
/**
|
|
553
|
+
* Fills available concurrent-start capacity with unscheduled empty slots.
|
|
554
|
+
*
|
|
555
|
+
*/
|
|
474
556
|
#drainStarts() {
|
|
475
557
|
for (const slot of this.#slots) {
|
|
476
558
|
if (this.#starts >= this.#restart.concurrentStarts)
|
|
@@ -527,18 +609,41 @@ export class ManagedServerCoordinator {
|
|
|
527
609
|
});
|
|
528
610
|
return close;
|
|
529
611
|
}
|
|
612
|
+
/**
|
|
613
|
+
* Closes the current replica through the bounded child shutdown procedure.
|
|
614
|
+
*
|
|
615
|
+
* @param replica The child incarnation associated with the event.
|
|
616
|
+
* @returns Completion after child shutdown.
|
|
617
|
+
*/
|
|
530
618
|
#closeReplica(replica) {
|
|
531
619
|
return ManagedServerCoordinatorValues.close(replica, this.#dependencies.clock);
|
|
532
620
|
}
|
|
621
|
+
/**
|
|
622
|
+
* Terminates a retired replica and removes it from the pending set.
|
|
623
|
+
*
|
|
624
|
+
* @param replica The child incarnation associated with the event.
|
|
625
|
+
* @returns Completion after the retired process exits.
|
|
626
|
+
*/
|
|
533
627
|
async #closeRetired(replica) {
|
|
534
628
|
replica.expectedExit = true;
|
|
535
629
|
await this.#terminateRetired(replica);
|
|
536
630
|
this.#retired.delete(replica);
|
|
537
631
|
}
|
|
632
|
+
/**
|
|
633
|
+
* Records a failed child for bounded background termination.
|
|
634
|
+
*
|
|
635
|
+
* @param replica The child incarnation associated with the event.
|
|
636
|
+
*/
|
|
538
637
|
#terminateUnexpected(replica) {
|
|
539
638
|
this.#retired.add(replica);
|
|
540
639
|
void this.#terminateRetired(replica);
|
|
541
640
|
}
|
|
641
|
+
/**
|
|
642
|
+
* Reuses or starts bounded termination for one retired incarnation.
|
|
643
|
+
*
|
|
644
|
+
* @param replica The child incarnation associated with the event.
|
|
645
|
+
* @returns The shared termination attempt for this child.
|
|
646
|
+
*/
|
|
542
647
|
#terminateRetired(replica) {
|
|
543
648
|
const prior = this.#retireTerminations.get(replica);
|
|
544
649
|
if (prior !== undefined)
|
|
@@ -581,7 +686,7 @@ export class ManagedServerCoordinator {
|
|
|
581
686
|
/**
|
|
582
687
|
* Records an exact native subscription whose activation started for a member.
|
|
583
688
|
*
|
|
584
|
-
* @param member
|
|
689
|
+
* @param member Identifies the member whose child subscription is activating.
|
|
585
690
|
* @param subscription Supplies the activating native subscription.
|
|
586
691
|
*/
|
|
587
692
|
onChildSubscriptionActivated(member, subscription) {
|
|
@@ -594,7 +699,7 @@ export class ManagedServerCoordinator {
|
|
|
594
699
|
/**
|
|
595
700
|
* Clears a pending child-installation wait after cancellation.
|
|
596
701
|
*
|
|
597
|
-
* @param member
|
|
702
|
+
* @param member Identifies the member whose child subscription was cancelled.
|
|
598
703
|
* @param subscription Supplies the cancelled native subscription.
|
|
599
704
|
*/
|
|
600
705
|
onChildSubscriptionCancelled(member, subscription) {
|
|
@@ -617,15 +722,33 @@ export class ManagedServerCoordinator {
|
|
|
617
722
|
if (!replica.terminal && replica.synchronizing && replica.readyAt === undefined)
|
|
618
723
|
replica.child.send({ type: "activate" }, () => undefined);
|
|
619
724
|
}
|
|
725
|
+
/**
|
|
726
|
+
* Finds the current replica only when both slot and incarnation match.
|
|
727
|
+
*
|
|
728
|
+
* @param member The member slot and incarnation to resolve.
|
|
729
|
+
* @returns The matching current replica, if any.
|
|
730
|
+
*/
|
|
620
731
|
#replica(member) {
|
|
621
732
|
const replica = this.#slots[member.slot]?.replica;
|
|
622
733
|
return replica?.incarnation === member.incarnation ? replica : undefined;
|
|
623
734
|
}
|
|
735
|
+
/**
|
|
736
|
+
* Rejects pending subscription installation waits after a child exits.
|
|
737
|
+
*
|
|
738
|
+
* @param replica The child incarnation associated with the event.
|
|
739
|
+
* @param error The error reported to pending subscription waits.
|
|
740
|
+
*/
|
|
624
741
|
#clearSubscriptionWaiters(replica, error) {
|
|
625
742
|
for (const waiter of replica.subscriptionWaiters.values())
|
|
626
743
|
waiter.reject(error);
|
|
627
744
|
replica.subscriptionWaiters.clear();
|
|
628
745
|
}
|
|
746
|
+
/**
|
|
747
|
+
* Completes and removes the pending installation wait for a subscription ID.
|
|
748
|
+
*
|
|
749
|
+
* @param replica The child incarnation associated with the event.
|
|
750
|
+
* @param id The installed subscription identifier.
|
|
751
|
+
*/
|
|
629
752
|
#settleSubscriptionWaiter(replica, id) {
|
|
630
753
|
const waiter = replica.subscriptionWaiters.get(id);
|
|
631
754
|
if (waiter === undefined)
|
|
@@ -633,6 +756,12 @@ export class ManagedServerCoordinator {
|
|
|
633
756
|
replica.subscriptionWaiters.delete(id);
|
|
634
757
|
waiter.resolve(undefined);
|
|
635
758
|
}
|
|
759
|
+
/**
|
|
760
|
+
* Collects active child facts eligible for routing or relay synchronization.
|
|
761
|
+
*
|
|
762
|
+
* @param includeDraining Whether synchronizing and draining replicas may participate in relay membership.
|
|
763
|
+
* @returns The eligible child members with endpoint and process ID.
|
|
764
|
+
*/
|
|
636
765
|
#members(includeDraining) {
|
|
637
766
|
return this.#slots.flatMap((slot) => {
|
|
638
767
|
const replica = slot.replica;
|
|
@@ -680,10 +809,18 @@ export class ManagedServerCoordinator {
|
|
|
680
809
|
coordinatorEndpoint() {
|
|
681
810
|
return this.#nodeCoordinator?.baseUrl;
|
|
682
811
|
}
|
|
812
|
+
/**
|
|
813
|
+
* Calls listeners after the available child membership changes.
|
|
814
|
+
*
|
|
815
|
+
*/
|
|
683
816
|
#notifyReadyMembers() {
|
|
684
817
|
for (const listener of this.#memberListeners)
|
|
685
818
|
listener();
|
|
686
819
|
}
|
|
820
|
+
/**
|
|
821
|
+
* Registers managed shutdown handlers for SIGINT and SIGTERM once.
|
|
822
|
+
*
|
|
823
|
+
*/
|
|
687
824
|
#installSignalHandlers() {
|
|
688
825
|
if (this.#onSignal !== undefined)
|
|
689
826
|
return;
|
|
@@ -704,6 +841,10 @@ export class ManagedServerCoordinator {
|
|
|
704
841
|
process.on("SIGINT", this.#onSignal);
|
|
705
842
|
process.on("SIGTERM", this.#onSignal);
|
|
706
843
|
}
|
|
844
|
+
/**
|
|
845
|
+
* Unregisters managed shutdown handlers when the coordinator closes.
|
|
846
|
+
*
|
|
847
|
+
*/
|
|
707
848
|
#removeSignalHandlers() {
|
|
708
849
|
if (this.#onSignal === undefined)
|
|
709
850
|
return;
|
|
@@ -719,9 +860,21 @@ export class ManagedServerCoordinator {
|
|
|
719
860
|
* @internal
|
|
720
861
|
*/
|
|
721
862
|
export const managedServerCoordinatorAccess = Object.freeze({
|
|
863
|
+
/**
|
|
864
|
+
* Returns currently ready members for private coordinator inspection.
|
|
865
|
+
*
|
|
866
|
+
* @param coordinator The managed coordinator to inspect.
|
|
867
|
+
* @returns The currently ready coordinator members.
|
|
868
|
+
*/
|
|
722
869
|
readyMembers(coordinator) {
|
|
723
870
|
return coordinator.readyMembers();
|
|
724
871
|
},
|
|
872
|
+
/**
|
|
873
|
+
* Returns the private coordinator endpoint when available.
|
|
874
|
+
*
|
|
875
|
+
* @param coordinator The managed coordinator to inspect.
|
|
876
|
+
* @returns The loopback endpoint when the coordinator is open.
|
|
877
|
+
*/
|
|
725
878
|
coordinatorEndpoint(coordinator) {
|
|
726
879
|
return coordinator.coordinatorEndpoint();
|
|
727
880
|
},
|
|
@@ -733,17 +886,41 @@ export const managedServerCoordinatorAccess = Object.freeze({
|
|
|
733
886
|
* @internal
|
|
734
887
|
*/
|
|
735
888
|
export const managedServerApplicationAccess = Object.freeze({
|
|
889
|
+
/**
|
|
890
|
+
* Returns currently ready members for private coordinator inspection.
|
|
891
|
+
*
|
|
892
|
+
* @param handle The application handle to inspect.
|
|
893
|
+
* @returns The currently ready coordinator members.
|
|
894
|
+
*/
|
|
736
895
|
readyMembers(handle) {
|
|
737
896
|
return handleMembers.get(handle)?.readyMembers() ?? [];
|
|
738
897
|
},
|
|
898
|
+
/**
|
|
899
|
+
* Returns the private coordinator endpoint when available.
|
|
900
|
+
*
|
|
901
|
+
* @param handle The application handle to inspect.
|
|
902
|
+
* @returns The loopback endpoint when the coordinator is open.
|
|
903
|
+
*/
|
|
739
904
|
coordinatorEndpoint(handle) {
|
|
740
905
|
return handleMembers.get(handle)?.coordinatorEndpoint();
|
|
741
906
|
},
|
|
907
|
+
/**
|
|
908
|
+
* Associates in-memory registries with an assembled test server.
|
|
909
|
+
*
|
|
910
|
+
* @param server The assembled child server to inspect.
|
|
911
|
+
* @param registries The registries supplied by a test server.
|
|
912
|
+
*/
|
|
742
913
|
installRegistriesForTest(server, registries) {
|
|
743
914
|
managedTestRegistries.set(server, registries);
|
|
744
915
|
},
|
|
745
916
|
});
|
|
746
917
|
const ManagedServerCoordinatorValues = Object.freeze({
|
|
918
|
+
/**
|
|
919
|
+
* Creates a promise with separately accessible resolve and reject callbacks.
|
|
920
|
+
*
|
|
921
|
+
* @typeParam Value The eventual result carried by the deferred promise.
|
|
922
|
+
* @returns The promise and its settlement callbacks.
|
|
923
|
+
*/
|
|
747
924
|
deferred() {
|
|
748
925
|
let resolve;
|
|
749
926
|
let reject;
|
|
@@ -753,6 +930,12 @@ const ManagedServerCoordinatorValues = Object.freeze({
|
|
|
753
930
|
});
|
|
754
931
|
return { promise, resolve, reject };
|
|
755
932
|
},
|
|
933
|
+
/**
|
|
934
|
+
* Checks that the front-facing listener port is a safe integer from zero through 65535.
|
|
935
|
+
*
|
|
936
|
+
* @param value The candidate front-facing listener port.
|
|
937
|
+
* @returns The validated listener port.
|
|
938
|
+
*/
|
|
756
939
|
coordinatorPort(value) {
|
|
757
940
|
if (!Number.isSafeInteger(value) || value < 0 || value > 65_535)
|
|
758
941
|
throw new Error("Managed server Coordinator port must be a safe integer between 0 and 65535.");
|
|
@@ -760,7 +943,7 @@ const ManagedServerCoordinatorValues = Object.freeze({
|
|
|
760
943
|
},
|
|
761
944
|
dependencies: {
|
|
762
945
|
clock: {
|
|
763
|
-
now: () =>
|
|
946
|
+
now: () => Time.currentTimeMillis(),
|
|
764
947
|
setTimeout: (onTimeout, delay) => setTimeout(onTimeout, delay),
|
|
765
948
|
clearTimeout: (timer) => {
|
|
766
949
|
clearTimeout(timer);
|
|
@@ -777,6 +960,12 @@ const ManagedServerCoordinatorValues = Object.freeze({
|
|
|
777
960
|
}),
|
|
778
961
|
openCoordinator: (options) => NodeCoordinator.open(options),
|
|
779
962
|
},
|
|
963
|
+
/**
|
|
964
|
+
* Validates restart delays and concurrent-start bounds after applying defaults.
|
|
965
|
+
*
|
|
966
|
+
* @param options The requested process count and restart settings.
|
|
967
|
+
* @returns The validated restart policy with defaults applied.
|
|
968
|
+
*/
|
|
780
969
|
restart(options) {
|
|
781
970
|
const restart = {
|
|
782
971
|
initialDelayMs: options.restart?.initialDelayMs ?? initialRestartDelayMs,
|
|
@@ -794,6 +983,14 @@ const ManagedServerCoordinatorValues = Object.freeze({
|
|
|
794
983
|
throw new Error("Managed server restart concurrentStarts must not exceed processCount.");
|
|
795
984
|
return restart;
|
|
796
985
|
},
|
|
986
|
+
/**
|
|
987
|
+
* Checks a READY notification against the expected slot, incarnation, and loopback endpoint.
|
|
988
|
+
*
|
|
989
|
+
* @param message The candidate child IPC notification.
|
|
990
|
+
* @param slot The expected replica slot.
|
|
991
|
+
* @param incarnation The expected child incarnation token.
|
|
992
|
+
* @returns Whether the message is a valid READY notification.
|
|
993
|
+
*/
|
|
797
994
|
readyMessage(message, slot, incarnation) {
|
|
798
995
|
if (typeof message !== "object" || message === null)
|
|
799
996
|
return false;
|
|
@@ -804,6 +1001,14 @@ const ManagedServerCoordinatorValues = Object.freeze({
|
|
|
804
1001
|
typeof candidate.endpoint === "string" &&
|
|
805
1002
|
canonicalLoopbackEndpoint(candidate.endpoint) !== undefined);
|
|
806
1003
|
},
|
|
1004
|
+
/**
|
|
1005
|
+
* Checks a SYNCHRONIZING notification against the expected child and endpoint.
|
|
1006
|
+
*
|
|
1007
|
+
* @param message The candidate child IPC notification.
|
|
1008
|
+
* @param slot The expected replica slot.
|
|
1009
|
+
* @param incarnation The expected child incarnation token.
|
|
1010
|
+
* @returns Whether the message is a valid SYNCHRONIZING notification.
|
|
1011
|
+
*/
|
|
807
1012
|
synchronizingMessage(message, slot, incarnation) {
|
|
808
1013
|
if (typeof message !== "object" || message === null)
|
|
809
1014
|
return false;
|
|
@@ -814,6 +1019,14 @@ const ManagedServerCoordinatorValues = Object.freeze({
|
|
|
814
1019
|
typeof candidate.endpoint === "string" &&
|
|
815
1020
|
canonicalLoopbackEndpoint(candidate.endpoint) !== undefined);
|
|
816
1021
|
},
|
|
1022
|
+
/**
|
|
1023
|
+
* Checks a subscription-installed notification for the expected child and nonblank ID.
|
|
1024
|
+
*
|
|
1025
|
+
* @param message The candidate child IPC notification.
|
|
1026
|
+
* @param slot The expected replica slot.
|
|
1027
|
+
* @param incarnation The expected child incarnation token.
|
|
1028
|
+
* @returns Whether the message is a matching subscription notification.
|
|
1029
|
+
*/
|
|
817
1030
|
subscriptionInstalledMessage(message, slot, incarnation) {
|
|
818
1031
|
if (typeof message !== "object" || message === null)
|
|
819
1032
|
return false;
|
|
@@ -824,6 +1037,14 @@ const ManagedServerCoordinatorValues = Object.freeze({
|
|
|
824
1037
|
typeof candidate.subscriptionId === "string" &&
|
|
825
1038
|
candidate.subscriptionId.length > 0);
|
|
826
1039
|
},
|
|
1040
|
+
/**
|
|
1041
|
+
* Checks a DRAINING notification against the expected slot and incarnation.
|
|
1042
|
+
*
|
|
1043
|
+
* @param message The candidate child IPC notification.
|
|
1044
|
+
* @param slot The expected replica slot.
|
|
1045
|
+
* @param incarnation The expected child incarnation token.
|
|
1046
|
+
* @returns Whether the message is a matching DRAINING notification.
|
|
1047
|
+
*/
|
|
827
1048
|
drainingMessage(message, slot, incarnation) {
|
|
828
1049
|
if (typeof message !== "object" || message === null)
|
|
829
1050
|
return false;
|
|
@@ -832,6 +1053,14 @@ const ManagedServerCoordinatorValues = Object.freeze({
|
|
|
832
1053
|
candidate.slot === String(slot) &&
|
|
833
1054
|
candidate.incarnation === incarnation);
|
|
834
1055
|
},
|
|
1056
|
+
/**
|
|
1057
|
+
* Matches a CLOSED or CLOSE-FAILED notification from the expected child.
|
|
1058
|
+
*
|
|
1059
|
+
* @param message The candidate child IPC notification.
|
|
1060
|
+
* @param slot The expected replica slot.
|
|
1061
|
+
* @param incarnation The expected child incarnation token.
|
|
1062
|
+
* @returns The close outcome for a matching notification, or undefined.
|
|
1063
|
+
*/
|
|
835
1064
|
closeResultMessage(message, slot, incarnation) {
|
|
836
1065
|
if (typeof message !== "object" || message === null)
|
|
837
1066
|
return undefined;
|
|
@@ -842,6 +1071,13 @@ const ManagedServerCoordinatorValues = Object.freeze({
|
|
|
842
1071
|
return undefined;
|
|
843
1072
|
return candidate.type;
|
|
844
1073
|
},
|
|
1074
|
+
/**
|
|
1075
|
+
* Closes a child after bounded graceful shutdown and signal escalation.
|
|
1076
|
+
*
|
|
1077
|
+
* @param replica The replica to close, if still present.
|
|
1078
|
+
* @param clock The clock and timer adapter for bounded waits.
|
|
1079
|
+
* @returns Completion after the child exits or a shutdown error is reported.
|
|
1080
|
+
*/
|
|
845
1081
|
async close(replica, clock) {
|
|
846
1082
|
if (replica === undefined)
|
|
847
1083
|
return;
|
|
@@ -883,6 +1119,15 @@ const ManagedServerCoordinatorValues = Object.freeze({
|
|
|
883
1119
|
replica.closeAttempt = undefined;
|
|
884
1120
|
}
|
|
885
1121
|
},
|
|
1122
|
+
/**
|
|
1123
|
+
* Waits for child exit, then escalates through SIGTERM and SIGKILL within bounded intervals.
|
|
1124
|
+
*
|
|
1125
|
+
* @param child The child process to terminate.
|
|
1126
|
+
* @param clock The clock and timer adapter for bounded waits.
|
|
1127
|
+
* @param knownExit An existing promise for child exit, when available.
|
|
1128
|
+
* @param allowGrace Whether to wait for graceful exit before signaling.
|
|
1129
|
+
* @returns Completion after child exit or failure to terminate.
|
|
1130
|
+
*/
|
|
886
1131
|
async terminate(child, clock, knownExit, allowGrace = true) {
|
|
887
1132
|
if (child.exitCode !== null || child.signalCode !== null)
|
|
888
1133
|
return;
|
|
@@ -900,6 +1145,14 @@ const ManagedServerCoordinatorValues = Object.freeze({
|
|
|
900
1145
|
return;
|
|
901
1146
|
throw new Error("Managed child did not exit after SIGKILL.");
|
|
902
1147
|
},
|
|
1148
|
+
/**
|
|
1149
|
+
* Checks whether a promise settles before the supplied timer fires.
|
|
1150
|
+
*
|
|
1151
|
+
* @param promise The asynchronous operation to await.
|
|
1152
|
+
* @param delay The maximum wait in milliseconds.
|
|
1153
|
+
* @param clock The clock and timer adapter for bounded waits.
|
|
1154
|
+
* @returns Whether the promise settled within the delay.
|
|
1155
|
+
*/
|
|
903
1156
|
within(promise, delay, clock) {
|
|
904
1157
|
return new Promise((resolve) => {
|
|
905
1158
|
const timer = clock.setTimeout(() => {
|