@zlink-systems/framework 0.30.0 → 0.30.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/LICENSE +150 -68
- package/dist/.tsbuildinfo +1 -1
- package/dist/contracts/Actors/ZLinkActorClient.d.ts +2 -1
- package/dist/contracts/Channels/Calls.d.ts +2 -1
- package/dist/contracts/Common/ZLinkMessageMetadata.js +11 -5
- package/dist/contracts/Handlers/Attributes.d.ts +5 -13
- package/dist/contracts/Handlers/Attributes.js +7 -11
- package/dist/contracts/Handlers/JsonContract.d.ts +2 -46
- package/dist/contracts/Handlers/JsonContract.js +4 -153
- package/dist/contracts/Spots/Contracts.d.ts +2 -1
- package/dist/nest-integration.d.ts +1 -1
- package/dist/nest-integration.js +2 -1
- package/dist/runtime/actors/actor-client.d.ts +1 -1
- package/dist/runtime/actors/actor-client.js +14 -12
- package/dist/runtime/actors/actor-handoff.d.ts +1 -1
- package/dist/runtime/actors/actor-handoff.js +7 -4
- package/dist/runtime/actors/actor-join-relocation.d.ts +1 -0
- package/dist/runtime/actors/actor-local-native-join.js +9 -12
- package/dist/runtime/actors/actor-remote-wire.js +15 -0
- package/dist/runtime/actors/actor-routed-join-transport.d.ts +6 -2
- package/dist/runtime/actors/actor-routed-json-request.d.ts +2 -0
- package/dist/runtime/actors/index.d.ts +2 -1
- package/dist/runtime/actors/index.js +18 -6
- package/dist/runtime/actors/spot-actor-dispatch.js +2 -2
- package/dist/runtime/admission.d.ts +1 -1
- package/dist/runtime/admission.js +15 -5
- package/dist/runtime/application-jobs/application-ingress-record-owner.d.ts +6 -8
- package/dist/runtime/application-jobs/application-ingress-record-owner.js +39 -22
- package/dist/runtime/application-jobs/application-job-queue-scope.d.ts +2 -1
- package/dist/runtime/application-jobs/application-job-queue-scope.js +37 -22
- package/dist/runtime/application-jobs/contracts.d.ts +10 -1
- package/dist/runtime/backend/contracts/index.d.ts +18 -9
- package/dist/runtime/backend/mesh-completion-table.d.ts +9 -1
- package/dist/runtime/backend/mesh-completion-table.js +149 -49
- package/dist/runtime/backend/mesh-dispatch-pump.d.ts +3 -0
- package/dist/runtime/backend/mesh-dispatch-pump.js +32 -11
- package/dist/runtime/backend/node/node-backend-adapter-support.d.ts +2 -2
- package/dist/runtime/backend/node/node-backend-adapter-support.js +16 -9
- package/dist/runtime/backend/node/node-dealer-channel-client-transport.d.ts +1 -1
- package/dist/runtime/backend/node/node-dealer-channel-client-transport.js +5 -2
- package/dist/runtime/backend/node/node-raw-binding-port.js +42 -22
- package/dist/runtime/backend/node/node-raw-mesh-backend.d.ts +13 -5
- package/dist/runtime/backend/node/node-raw-mesh-backend.js +69 -51
- package/dist/runtime/backend/node/node-socket-backend-adapter.js +6 -6
- package/dist/runtime/backend/raw-binding-port.d.ts +2 -2
- package/dist/runtime/backend/runtime-message.d.ts +1 -0
- package/dist/runtime/backend/runtime-message.js +5 -0
- package/dist/runtime/backend/runtime-values.d.ts +1 -0
- package/dist/runtime/backend/runtime-values.js +2 -1
- package/dist/runtime/channels/channel-clients.d.ts +1 -0
- package/dist/runtime/channels/channel-clients.js +58 -21
- package/dist/runtime/channels/channel-dispatch-pipeline.d.ts +3 -2
- package/dist/runtime/channels/channel-dispatch-pipeline.js +20 -11
- package/dist/runtime/channels/channel-dispatch-services.d.ts +1 -0
- package/dist/runtime/channels/channel-dispatch-services.js +45 -0
- package/dist/runtime/channels/channel-dispatchers.d.ts +1 -1
- package/dist/runtime/channels/channel-dispatchers.js +27 -26
- package/dist/runtime/channels/channel-envelope-inspection.d.ts +1 -2
- package/dist/runtime/channels/channel-envelope-inspection.js +1 -16
- package/dist/runtime/channels/channel-envelope.d.ts +1 -0
- package/dist/runtime/channels/channel-envelope.js +83 -8
- package/dist/runtime/channels/channel-outbound-operations.d.ts +2 -2
- package/dist/runtime/channels/channel-outbound-operations.js +8 -8
- package/dist/runtime/channels/channel-runtime-manager.d.ts +6 -6
- package/dist/runtime/channels/channel-runtime-manager.js +12 -12
- package/dist/runtime/channels/channel-transports.d.ts +18 -15
- package/dist/runtime/channels/channel-transports.js +48 -31
- package/dist/runtime/channels/local-spot-route-transport.d.ts +1 -1
- package/dist/runtime/channels/local-spot-route-transport.js +2 -1
- package/dist/runtime/channels/router-socket-spot-route-transport.d.ts +2 -2
- package/dist/runtime/channels/router-socket-spot-route-transport.js +4 -4
- package/dist/runtime/channels/source-spot-router.d.ts +2 -2
- package/dist/runtime/channels/source-spot-router.js +4 -4
- package/dist/runtime/channels/spot-node-route-transport.d.ts +2 -2
- package/dist/runtime/channels/spot-node-route-transport.js +4 -4
- package/dist/runtime/channels/spot-route-bridge-transport.d.ts +2 -2
- package/dist/runtime/channels/spot-route-bridge-transport.js +4 -4
- package/dist/runtime/channels/spot-route-dispatch-strategy.d.ts +5 -4
- package/dist/runtime/channels/spot-route-dispatch-strategy.js +18 -18
- package/dist/runtime/execution/serial-execution-queue.d.ts +1 -0
- package/dist/runtime/execution/serial-execution-queue.js +1 -0
- package/dist/runtime/foundation/actor-join-recovery-codec.js +2 -2
- package/dist/runtime/foundation/durable-service-request.d.ts +14 -0
- package/dist/runtime/foundation/durable-service-request.js +98 -0
- package/dist/runtime/foundation/operation-identity.d.ts +1 -0
- package/dist/runtime/foundation/operation-identity.js +5 -1
- package/dist/runtime/foundation/raw-service-mesh-runtime.d.ts +22 -5
- package/dist/runtime/foundation/raw-service-mesh-runtime.js +356 -232
- package/dist/runtime/foundation/service-relocation-object-owner.d.ts +1 -0
- package/dist/runtime/foundation/service-relocation-object-owner.js +1 -0
- package/dist/runtime/foundation/service-relocation-runtime.d.ts +2 -0
- package/dist/runtime/foundation/service-relocation-runtime.js +13 -1
- package/dist/runtime/foundation/service-runtime-contracts.d.ts +2 -0
- package/dist/runtime/foundation/service-stateful-runtime.d.ts +4 -4
- package/dist/runtime/foundation/service-stateful-runtime.js +44 -103
- package/dist/runtime/foundation/service-stateful-wire-codec.d.ts +0 -5
- package/dist/runtime/foundation/service-topology-registry.d.ts +12 -2
- package/dist/runtime/foundation/service-topology-registry.js +61 -27
- package/dist/runtime/foundation/service-wire-m6a-codec.d.ts +3 -3
- package/dist/runtime/foundation/service-wire-m6a-codec.js +36 -38
- package/dist/runtime/handlers/handler-instance-scope.d.ts +8 -0
- package/dist/runtime/handlers/handler-instance-scope.js +54 -11
- package/dist/runtime/host/actor-runtime-options-factory.js +2 -2
- package/dist/runtime/host/application-job-queue.d.ts +19 -7
- package/dist/runtime/host/application-job-queue.js +150 -42
- package/dist/runtime/host/entry-actor-runtime.d.ts +1 -0
- package/dist/runtime/host/entry-actor-runtime.js +3 -0
- package/dist/runtime/host/index.d.ts +7 -1
- package/dist/runtime/host/index.js +142 -118
- package/dist/runtime/host/remote-bound-session-relay.js +2 -18
- package/dist/runtime/host/route-mesh-runtime.js +1 -1
- package/dist/runtime/host/service-relocation-control.d.ts +1 -0
- package/dist/runtime/host/service-relocation-control.js +10 -4
- package/dist/runtime/host/service-relocation-host-runtime.d.ts +6 -8
- package/dist/runtime/host/service-relocation-host-runtime.js +213 -241
- package/dist/runtime/host/spot-address-transport.js +3 -2
- package/dist/runtime/host/spot-runtime-options-factory.js +1 -0
- package/dist/runtime/locations/actor-location-claims.d.ts +2 -2
- package/dist/runtime/locations/actor-location-claims.js +34 -19
- package/dist/runtime/locations/lifecycle.d.ts +1 -2
- package/dist/runtime/locations/lifecycle.js +2 -5
- package/dist/runtime/locations/runtime.d.ts +1 -1
- package/dist/runtime/locations/runtime.js +24 -23
- package/dist/runtime/messaging/framework-json-v1.d.ts +4 -6
- package/dist/runtime/messaging/framework-json-v1.js +38 -294
- package/dist/runtime/messaging/packet-name.d.ts +1 -1
- package/dist/runtime/messaging/packet-name.js +8 -24
- package/dist/runtime/messaging/request-result.d.ts +2 -0
- package/dist/runtime/messaging/request-result.js +54 -0
- package/dist/runtime/messaging/submission-result.d.ts +1 -0
- package/dist/runtime/messaging/submission-result.js +5 -2
- package/dist/runtime/protocol/service_wire_codec.generated.d.ts +15 -0
- package/dist/runtime/protocol/service_wire_codec.generated.js +144 -0
- package/dist/runtime/protocol/service_wire_pilot_codec.generated.d.ts +9 -0
- package/dist/runtime/protocol/service_wire_pilot_codec.generated.js +14 -1
- package/dist/runtime/spots/formal-remote-actor-admission-registry.d.ts +7 -2
- package/dist/runtime/spots/formal-remote-actor-admission-registry.js +33 -19
- package/dist/runtime/spots/index.d.ts +3 -0
- package/dist/runtime/spots/index.js +9 -2
- package/dist/runtime/spots/spot-activation.d.ts +1 -0
- package/dist/runtime/spots/spot-activation.js +17 -8
- package/dist/runtime/spots/spot-entry-activation.js +6 -2
- package/dist/runtime/spots/spot-handler-registry.d.ts +3 -1
- package/dist/runtime/spots/spot-handler-registry.js +18 -8
- package/dist/runtime/spots/spot-node-autoconnect.js +4 -3
- package/dist/runtime/spots/spot-outbound.d.ts +3 -0
- package/dist/runtime/spots/spot-outbound.js +24 -15
- package/dist/runtime/spots/spot-routed-spot-packet-dispatch.d.ts +1 -0
- package/dist/runtime/spots/spot-routed-spot-packet-dispatch.js +1 -1
- package/dist/runtime/spots/spot-runtime-ports.d.ts +1 -0
- package/dist/runtime/spots/spot-subscription-dispatch.js +0 -3
- package/dist/runtime/spots/spot-timer.js +1 -0
- package/dist/runtime/streams/stream-session-runtime.d.ts +1 -1
- package/dist/runtime/streams/stream-session-runtime.js +13 -27
- package/package.json +2 -2
- package/src/contracts/Actors/ZLinkActorClient.ts +2 -1
- package/src/contracts/Channels/Calls.ts +2 -1
- package/src/contracts/Common/ZLinkMessageMetadata.ts +13 -8
- package/src/contracts/Handlers/Attributes.ts +14 -21
- package/src/contracts/Handlers/JsonContract.ts +8 -216
- package/src/contracts/Spots/Contracts.ts +2 -1
- package/src/nest-integration.ts +1 -0
- package/src/runtime/actors/actor-client.ts +40 -16
- package/src/runtime/actors/actor-handoff.ts +9 -4
- package/src/runtime/actors/actor-join-relocation.ts +1 -0
- package/src/runtime/actors/actor-local-native-join.ts +17 -26
- package/src/runtime/actors/actor-remote-wire.ts +17 -0
- package/src/runtime/actors/actor-routed-join-transport.ts +14 -4
- package/src/runtime/actors/actor-routed-json-request.ts +10 -2
- package/src/runtime/actors/index.ts +19 -5
- package/src/runtime/actors/spot-actor-dispatch.ts +4 -2
- package/src/runtime/admission.ts +18 -5
- package/src/runtime/application-jobs/application-ingress-record-owner.ts +41 -25
- package/src/runtime/application-jobs/application-job-queue-scope.ts +51 -22
- package/src/runtime/application-jobs/contracts.ts +14 -1
- package/src/runtime/backend/contracts/index.ts +53 -14
- package/src/runtime/backend/mesh-completion-table.ts +156 -57
- package/src/runtime/backend/mesh-dispatch-pump.ts +40 -10
- package/src/runtime/backend/node/node-backend-adapter-support.ts +17 -8
- package/src/runtime/backend/node/node-dealer-channel-client-transport.ts +12 -2
- package/src/runtime/backend/node/node-raw-binding-port.ts +57 -30
- package/src/runtime/backend/node/node-raw-mesh-backend.ts +128 -65
- package/src/runtime/backend/node/node-socket-backend-adapter.ts +21 -6
- package/src/runtime/backend/raw-binding-port.ts +7 -2
- package/src/runtime/backend/runtime-message.ts +6 -0
- package/src/runtime/backend/runtime-values.ts +1 -0
- package/src/runtime/channels/channel-clients.ts +90 -41
- package/src/runtime/channels/channel-dispatch-pipeline.ts +69 -34
- package/src/runtime/channels/channel-dispatch-services.ts +69 -1
- package/src/runtime/channels/channel-dispatchers.ts +29 -27
- package/src/runtime/channels/channel-envelope-inspection.ts +2 -16
- package/src/runtime/channels/channel-envelope.ts +133 -8
- package/src/runtime/channels/channel-outbound-operations.ts +22 -8
- package/src/runtime/channels/channel-runtime-manager.ts +29 -12
- package/src/runtime/channels/channel-transports.ts +128 -60
- package/src/runtime/channels/local-spot-route-transport.ts +3 -1
- package/src/runtime/channels/router-socket-spot-route-transport.ts +13 -4
- package/src/runtime/channels/source-spot-router.ts +8 -4
- package/src/runtime/channels/spot-node-route-transport.ts +8 -4
- package/src/runtime/channels/spot-route-bridge-transport.ts +6 -4
- package/src/runtime/channels/spot-route-dispatch-strategy.ts +47 -18
- package/src/runtime/execution/serial-execution-queue.ts +2 -0
- package/src/runtime/foundation/actor-join-recovery-codec.ts +2 -2
- package/src/runtime/foundation/durable-service-request.ts +137 -0
- package/src/runtime/foundation/operation-identity.ts +5 -1
- package/src/runtime/foundation/raw-service-mesh-runtime.ts +484 -293
- package/src/runtime/foundation/service-relocation-object-owner.ts +2 -0
- package/src/runtime/foundation/service-relocation-runtime.ts +18 -1
- package/src/runtime/foundation/service-runtime-contracts.ts +7 -1
- package/src/runtime/foundation/service-stateful-runtime.ts +67 -125
- package/src/runtime/foundation/service-stateful-wire-codec.ts +0 -5
- package/src/runtime/foundation/service-topology-registry.ts +91 -36
- package/src/runtime/foundation/service-wire-m6a-codec.ts +57 -38
- package/src/runtime/handlers/handler-instance-scope.ts +67 -16
- package/src/runtime/host/actor-runtime-options-factory.ts +13 -2
- package/src/runtime/host/application-job-queue.ts +175 -41
- package/src/runtime/host/entry-actor-runtime.ts +4 -0
- package/src/runtime/host/index.ts +201 -156
- package/src/runtime/host/remote-bound-session-relay.ts +2 -23
- package/src/runtime/host/route-mesh-runtime.ts +1 -1
- package/src/runtime/host/service-relocation-control.ts +11 -5
- package/src/runtime/host/service-relocation-host-runtime.ts +315 -291
- package/src/runtime/host/spot-address-transport.ts +4 -2
- package/src/runtime/host/spot-runtime-options-factory.ts +2 -0
- package/src/runtime/locations/actor-location-claims.ts +52 -30
- package/src/runtime/locations/lifecycle.ts +8 -26
- package/src/runtime/locations/runtime.ts +28 -24
- package/src/runtime/messaging/framework-json-v1.ts +5 -325
- package/src/runtime/messaging/packet-name.ts +5 -25
- package/src/runtime/messaging/request-result.ts +58 -0
- package/src/runtime/messaging/submission-result.ts +5 -1
- package/src/runtime/protocol/service_wire_codec.generated.ts +131 -1
- package/src/runtime/protocol/service_wire_pilot_codec.generated.ts +4 -4
- package/src/runtime/spots/formal-remote-actor-admission-registry.ts +43 -23
- package/src/runtime/spots/index.ts +14 -2
- package/src/runtime/spots/spot-activation.ts +28 -10
- package/src/runtime/spots/spot-entry-activation.ts +9 -2
- package/src/runtime/spots/spot-handler-registry.ts +41 -8
- package/src/runtime/spots/spot-node-autoconnect.ts +6 -2
- package/src/runtime/spots/spot-outbound.ts +36 -16
- package/src/runtime/spots/spot-routed-spot-packet-dispatch.ts +2 -1
- package/src/runtime/spots/spot-runtime-ports.ts +1 -0
- package/src/runtime/spots/spot-subscription-dispatch.ts +0 -3
- package/src/runtime/spots/spot-timer.ts +5 -1
- package/src/runtime/streams/stream-session-runtime.ts +12 -29
|
@@ -16,6 +16,9 @@ class ZLinkEntryActorRuntimeService {
|
|
|
16
16
|
resolveActor(actorId) {
|
|
17
17
|
return this.options.actorManager()?.getState(actorId)?.actor;
|
|
18
18
|
}
|
|
19
|
+
async releaseMembers(meshName) {
|
|
20
|
+
await this.options.actorManager()?.releaseSpotActorMembers(meshName);
|
|
21
|
+
}
|
|
19
22
|
async commitActorTransaction(actor, onJoined) {
|
|
20
23
|
const state = this.options.actorManager()?.getState(actor.context.actorId);
|
|
21
24
|
const entryNode = this.options.spotNodeRuntime()?.primaryMeshNode;
|
|
@@ -30,7 +30,7 @@ export declare class ZLinkFrameworkRuntimeHost implements ZLinkFrameworkRuntimeL
|
|
|
30
30
|
private readonly lifecycleSink?;
|
|
31
31
|
private executionState?;
|
|
32
32
|
private runtimeState;
|
|
33
|
-
private
|
|
33
|
+
private runtimeStatus?;
|
|
34
34
|
private readonly runtimeObservationSource;
|
|
35
35
|
private runtimeDeadline?;
|
|
36
36
|
private shutdownDeadline?;
|
|
@@ -95,6 +95,7 @@ export declare class ZLinkFrameworkRuntimeHost implements ZLinkFrameworkRuntimeL
|
|
|
95
95
|
constructor(options: ZLinkFrameworkRuntimeHostOptions, internalOptions?: unknown);
|
|
96
96
|
get isStarted(): boolean;
|
|
97
97
|
get status(): ZLinkFrameworkRuntimeStatus;
|
|
98
|
+
private buildRuntimeStatus;
|
|
98
99
|
private listenerRecords;
|
|
99
100
|
getListenerStatus(kind: ZLinkListenerKind, name: string): ZLinkListenerStatus;
|
|
100
101
|
observe(signal?: AbortSignal): AsyncIterable<ZLinkObservedStatus<ZLinkFrameworkRuntimeStatus>>;
|
|
@@ -109,6 +110,7 @@ export declare class ZLinkFrameworkRuntimeHost implements ZLinkFrameworkRuntimeL
|
|
|
109
110
|
private recordRelocationResult;
|
|
110
111
|
private completeTermination;
|
|
111
112
|
private setRuntimeState;
|
|
113
|
+
private publishCurrentRuntimeStatus;
|
|
112
114
|
private publishRuntimeStatus;
|
|
113
115
|
private notifyTopologyHostStateChanged;
|
|
114
116
|
private stopTopologyObservers;
|
|
@@ -163,7 +165,11 @@ export declare class ZLinkFrameworkRuntimeHost implements ZLinkFrameworkRuntimeL
|
|
|
163
165
|
private actorRuntimeOptionsFactory;
|
|
164
166
|
private createChannelRuntimeOptions;
|
|
165
167
|
private createSpotNodeRuntimeOptions;
|
|
168
|
+
private dispatchMeshNodeRecord;
|
|
169
|
+
private dispatchMeshNodePayload;
|
|
170
|
+
private completeFormalSourceLeave;
|
|
166
171
|
private dispatchMeshRecord;
|
|
172
|
+
private dispatchMeshActorBinding;
|
|
167
173
|
private submitLocalMeshRoute;
|
|
168
174
|
private dispatchMeshSpotRecord;
|
|
169
175
|
private createDispatchErrorReporter;
|
|
@@ -7,6 +7,7 @@ const application_job_queue_scope_1 = require("../application-jobs/application-j
|
|
|
7
7
|
const location_store_pages_1 = require("../locations/location-store-pages");
|
|
8
8
|
const stream_wire_1 = require("@zlink-systems/stream-wire");
|
|
9
9
|
const node_crypto_1 = require("node:crypto");
|
|
10
|
+
const node_util_1 = require("node:util");
|
|
10
11
|
const contracts_1 = require("../../contracts");
|
|
11
12
|
const ConfigurationException_1 = require("../../contracts/Configuration/ConfigurationException");
|
|
12
13
|
const DiagnosticsValidation_1 = require("../../contracts/Configuration/DiagnosticsValidation");
|
|
@@ -77,7 +78,7 @@ class ZLinkFrameworkRuntimeHost {
|
|
|
77
78
|
lifecycleSink;
|
|
78
79
|
executionState;
|
|
79
80
|
runtimeState = contracts_1.ZLinkFrameworkRuntimeState.Preparing;
|
|
80
|
-
|
|
81
|
+
runtimeStatus;
|
|
81
82
|
runtimeObservationSource = Symbol('zlink.framework-runtime');
|
|
82
83
|
runtimeDeadline;
|
|
83
84
|
shutdownDeadline;
|
|
@@ -153,16 +154,8 @@ class ZLinkFrameworkRuntimeHost {
|
|
|
153
154
|
this.runtimeEventPublisher =
|
|
154
155
|
options.runtimeEventPublisher ?? new diagnostics_1.DefaultZLinkRuntimeEventPublisher();
|
|
155
156
|
this.metrics = new diagnostics_1.ZLinkRuntimeMetrics(options.registration.metrics?.meterProvider);
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
return (this.options.providerResolver
|
|
159
|
-
?.get?.(application_job_queue_handler_start_gate_1.ZLINK_INTERNAL_APPLICATION_JOB_QUEUE_HANDLER_START_GATE)
|
|
160
|
-
?.shouldHoldPermitBeforeHandler() === true);
|
|
161
|
-
}
|
|
162
|
-
catch {
|
|
163
|
-
return false;
|
|
164
|
-
}
|
|
165
|
-
}, (error) => (this.errorSink ?? this.preStartErrorSink).reportRuntimeTaskException('logger-provider', error));
|
|
157
|
+
const handlerStartGate = options.providerResolver?.get?.(application_job_queue_handler_start_gate_1.ZLINK_INTERNAL_APPLICATION_JOB_QUEUE_HANDLER_START_GATE);
|
|
158
|
+
this.applicationJobQueue = new application_job_queue_1.ApplicationJobQueue((0, application_job_queue_1.resolveApplicationJobQueueConfiguration)(options.registration.applicationJobQueue, () => (0, application_job_queue_1.nodeEffectiveProcessorCount)(options.registration.worker?.maxThreads)), undefined, handlerStartGate?.shouldHoldPermitBeforeHandler.bind(handlerStartGate), (error) => (this.errorSink ?? this.preStartErrorSink).reportRuntimeTaskException('logger-provider', error));
|
|
166
159
|
this.capacityStatus = new host_capacity_status_1.HostCapacityStatusProjection(options.registration.coreHwm, this.applicationJobQueue);
|
|
167
160
|
this.clientServerRuntime = new topology_runtime_projections_1.ZLinkClientServerRuntimeProjection(() => this.channelRuntime, () => this.runtimeState);
|
|
168
161
|
this.fanoutRuntime = new topology_runtime_projections_1.ZLinkFanoutRuntimeProjection(() => this.channelRuntime, () => this.runtimeState);
|
|
@@ -509,6 +502,7 @@ class ZLinkFrameworkRuntimeHost {
|
|
|
509
502
|
this.serviceRelocation = new service_relocation_host_runtime_1.ZLinkHostServiceRelocationRuntime({
|
|
510
503
|
registration: options.registration,
|
|
511
504
|
targetAdmissionSealed: () => this.shutdownOperationStartedAt !== undefined,
|
|
505
|
+
sourceQuiescenceChanged: () => this.publishCurrentRuntimeStatus(),
|
|
512
506
|
providerResolver: options.providerResolver,
|
|
513
507
|
locationStore: () => this.locationOwner.currentStores?.locationStore,
|
|
514
508
|
currentOwner: () => this.locationOwner.currentRuntime?.currentOwnerToken,
|
|
@@ -582,6 +576,9 @@ class ZLinkFrameworkRuntimeHost {
|
|
|
582
576
|
return this.executionState !== undefined && !this.executionState.abortController.signal.aborted;
|
|
583
577
|
}
|
|
584
578
|
get status() {
|
|
579
|
+
return this.publishCurrentRuntimeStatus();
|
|
580
|
+
}
|
|
581
|
+
buildRuntimeStatus() {
|
|
585
582
|
return {
|
|
586
583
|
state: this.runtimeState,
|
|
587
584
|
isReady: (0, runtime_state_projections_1.runtimeStateIsReady)(this.runtimeState),
|
|
@@ -591,8 +588,8 @@ class ZLinkFrameworkRuntimeHost {
|
|
|
591
588
|
deadline: this.runtimeDeadline,
|
|
592
589
|
relocationResult: this.runtimeRelocationResult,
|
|
593
590
|
terminationResult: this.runtimeTerminationResult,
|
|
594
|
-
sequence: this.
|
|
595
|
-
observedAt: new Date()
|
|
591
|
+
sequence: this.runtimeStatus?.sequence ?? 0n,
|
|
592
|
+
observedAt: this.runtimeStatus?.observedAt ?? new Date()
|
|
596
593
|
};
|
|
597
594
|
}
|
|
598
595
|
// Bound listener records of the current runtime generation.
|
|
@@ -605,10 +602,11 @@ class ZLinkFrameworkRuntimeHost {
|
|
|
605
602
|
return { kind, name, endpoint, observedAt: new Date() };
|
|
606
603
|
}
|
|
607
604
|
observe(signal) {
|
|
605
|
+
const status = this.status;
|
|
608
606
|
const queue = new runtime_observation_queue_1.RuntimeEventQueue(undefined, signal);
|
|
609
607
|
this.runtimeObservers.add(queue);
|
|
610
608
|
queue.onClose(() => this.runtimeObservers.delete(queue));
|
|
611
|
-
this.publishRuntimeStatus(queue,
|
|
609
|
+
this.publishRuntimeStatus(queue, status);
|
|
612
610
|
return queue;
|
|
613
611
|
}
|
|
614
612
|
resetCapacityMetrics() {
|
|
@@ -771,6 +769,9 @@ class ZLinkFrameworkRuntimeHost {
|
|
|
771
769
|
const shutdown = this.routeMeshCoordinator.shutdownHost(this.runtimeDeadline, this.shutdownDeadline.signal);
|
|
772
770
|
const drain = await shutdown;
|
|
773
771
|
await unscopedStreamDrain;
|
|
772
|
+
if (drain.kind === 'forceStopped' && drain.error !== undefined) {
|
|
773
|
+
this.runtimeOrPreStartErrorSink.reportRuntimeTaskException('host shutdown', drain.error);
|
|
774
|
+
}
|
|
774
775
|
await this.stop();
|
|
775
776
|
if (drain.kind === 'forceStopped') {
|
|
776
777
|
return this.completeTermination({
|
|
@@ -892,12 +893,24 @@ class ZLinkFrameworkRuntimeHost {
|
|
|
892
893
|
if (this.runtimeState === state)
|
|
893
894
|
return;
|
|
894
895
|
this.runtimeState = state;
|
|
895
|
-
this.runtimeSequence += 1n;
|
|
896
896
|
this.notifyTopologyHostStateChanged();
|
|
897
|
-
|
|
897
|
+
this.publishCurrentRuntimeStatus();
|
|
898
|
+
}
|
|
899
|
+
publishCurrentRuntimeStatus() {
|
|
900
|
+
const current = this.buildRuntimeStatus();
|
|
901
|
+
if (this.runtimeStatus !== undefined && (0, node_util_1.isDeepStrictEqual)(this.runtimeStatus, current)) {
|
|
902
|
+
return this.runtimeStatus;
|
|
903
|
+
}
|
|
904
|
+
const status = {
|
|
905
|
+
...current,
|
|
906
|
+
sequence: (this.runtimeStatus?.sequence ?? 0n) + 1n,
|
|
907
|
+
observedAt: new Date()
|
|
908
|
+
};
|
|
909
|
+
this.runtimeStatus = status;
|
|
898
910
|
for (const observer of this.runtimeObservers) {
|
|
899
911
|
this.publishRuntimeStatus(observer, status);
|
|
900
912
|
}
|
|
913
|
+
return status;
|
|
901
914
|
}
|
|
902
915
|
publishRuntimeStatus(observer, status) {
|
|
903
916
|
if ((0, runtime_state_projections_1.runtimeObservationIsTerminal)(status.state)) {
|
|
@@ -1969,92 +1982,45 @@ class ZLinkFrameworkRuntimeHost {
|
|
|
1969
1982
|
activationConcurrency: (meshName) => this.activationAdmission.current(meshName)
|
|
1970
1983
|
};
|
|
1971
1984
|
}
|
|
1972
|
-
|
|
1985
|
+
dispatchMeshNodeRecord(meshName, record, signal) {
|
|
1986
|
+
const control = this.serviceRelocation.tryHandleControl(meshName, record, signal);
|
|
1987
|
+
if (control instanceof Promise)
|
|
1988
|
+
return control.then((handled) => handled ? undefined : this.dispatchMeshNodePayload(meshName, record, signal));
|
|
1989
|
+
if (!control)
|
|
1990
|
+
return this.dispatchMeshNodePayload(meshName, record, signal);
|
|
1991
|
+
}
|
|
1992
|
+
dispatchMeshNodePayload(meshName, record, signal) {
|
|
1993
|
+
if (record.kind === service_runtime_contracts_1.ReceiveKind.NodeRequest && record.parts.length === 1) {
|
|
1994
|
+
const terminal = (0, actors_1.decodeRemoteActorSourceLeaveTerminal)(record.parts[0].data());
|
|
1995
|
+
if (terminal !== undefined) {
|
|
1996
|
+
return this.completeFormalSourceLeave(record, terminal);
|
|
1997
|
+
}
|
|
1998
|
+
}
|
|
1999
|
+
const channelRuntime = this.channelRuntime;
|
|
2000
|
+
if (channelRuntime === undefined) {
|
|
2001
|
+
throw new ConfigurationException_1.ZLinkConfigurationException('MeshNode node-direct dispatch requires the channel runtime.');
|
|
2002
|
+
}
|
|
2003
|
+
return channelRuntime.dispatchMeshRoute(meshName, record, signal);
|
|
2004
|
+
}
|
|
2005
|
+
async completeFormalSourceLeave(record, terminal) {
|
|
2006
|
+
const completed = await this.spotManager?.completeFormalSourceLeaveTerminal(terminal.actorId, terminal.transferId, terminal.succeeded);
|
|
2007
|
+
if (completed !== true) {
|
|
2008
|
+
throw new ConfigurationException_1.ZLinkConfigurationException(`Actor '${terminal.actorId}' has no matching formal transfer terminal gate.`);
|
|
2009
|
+
}
|
|
2010
|
+
if (record.reply(Buffer.alloc(0)) !== runtime_values_1.SubmitResult.Ok) {
|
|
2011
|
+
throw new ConfigurationException_1.ZLinkConfigurationException(`Actor '${terminal.actorId}' formal transfer terminal acknowledgement failed.`);
|
|
2012
|
+
}
|
|
2013
|
+
return;
|
|
2014
|
+
}
|
|
2015
|
+
dispatchMeshRecord(applicationJobOrigin, meshName, owner, record, signal) {
|
|
1973
2016
|
if (record.operationKind === service_runtime_contracts_1.OperationKind.ActorJoin) {
|
|
1974
2017
|
if (this.spotManager === undefined) {
|
|
1975
2018
|
throw new ConfigurationException_1.ZLinkConfigurationException('MeshNode Actor join dispatch requires the Spot manager.');
|
|
1976
2019
|
}
|
|
1977
2020
|
return this.spotManager.dispatchMeshActorJoin(meshName, owner, record);
|
|
1978
2021
|
}
|
|
1979
|
-
if (record.kind === service_runtime_contracts_1.ReceiveKind.ActorBinding)
|
|
1980
|
-
|
|
1981
|
-
throw new ConfigurationException_1.ZLinkConfigurationException('MeshNode Actor binding record has no binding generation.');
|
|
1982
|
-
}
|
|
1983
|
-
const binding = record.kindData;
|
|
1984
|
-
const replyBindingFailure = (kind) => {
|
|
1985
|
-
const terminal = (0, framework_errors_internal_1.internalFrameworkWireReply)(kind);
|
|
1986
|
-
if (record.replyFailure?.(terminal.terminalResult, terminal.failureCode) !== runtime_values_1.SubmitResult.Ok) {
|
|
1987
|
-
throw new ConfigurationException_1.ZLinkConfigurationException(`MeshNode Actor binding target '${binding.actor.actorId}' failure acknowledgement failed.`);
|
|
1988
|
-
}
|
|
1989
|
-
};
|
|
1990
|
-
const replyBindingSuccess = () => {
|
|
1991
|
-
if (record.reply(Buffer.alloc(0)) !== runtime_values_1.SubmitResult.Ok) {
|
|
1992
|
-
throw new ConfigurationException_1.ZLinkConfigurationException(`MeshNode Actor binding target '${binding.actor.actorId}' acknowledgement failed.`);
|
|
1993
|
-
}
|
|
1994
|
-
};
|
|
1995
|
-
const state = this.actorManager?.getState(binding.actor.actorId);
|
|
1996
|
-
const nativeActorRef = state?.nativeActorRef;
|
|
1997
|
-
if (state === undefined ||
|
|
1998
|
-
nativeActorRef === undefined ||
|
|
1999
|
-
nativeActorRef.actorId !== binding.actor.actorId ||
|
|
2000
|
-
!(0, routing_id_1.routingIdsEqual)(nativeActorRef.nodeRid, binding.actor.nodeRid)) {
|
|
2001
|
-
replyBindingFailure(framework_errors_internal_1.ZLinkFrameworkInternalErrorKind.ActorLocationStale);
|
|
2002
|
-
return;
|
|
2003
|
-
}
|
|
2004
|
-
if (nativeActorRef.generation !== binding.actor.generation) {
|
|
2005
|
-
replyBindingFailure(framework_errors_internal_1.ZLinkFrameworkInternalErrorKind.ActorGenerationStale);
|
|
2006
|
-
return;
|
|
2007
|
-
}
|
|
2008
|
-
const node = state.meshName === meshName ? this.spotNodeRuntime?.meshNode(meshName) : undefined;
|
|
2009
|
-
const localStatus = node?.status();
|
|
2010
|
-
// ownsLocation tracks local cleanup responsibility, not Actor authority.
|
|
2011
|
-
// A relocation target can exact-read committed authority without owning that cleanup.
|
|
2012
|
-
if (localStatus === undefined ||
|
|
2013
|
-
!(0, routing_id_1.routingIdsEqual)(localStatus.routingId, binding.actor.nodeRid) ||
|
|
2014
|
-
localStatus.lifecycleGeneration !== binding.actorNodeGeneration ||
|
|
2015
|
-
state.locationGeneration !== binding.authorityOwnerGeneration ||
|
|
2016
|
-
state.isMoving) {
|
|
2017
|
-
replyBindingFailure(framework_errors_internal_1.ZLinkFrameworkInternalErrorKind.ActorLocationStale);
|
|
2018
|
-
return;
|
|
2019
|
-
}
|
|
2020
|
-
const sessionOwnerIsLocal = (0, routing_id_1.routingIdsEqual)(localStatus.routingId, binding.sessionNodeRid) &&
|
|
2021
|
-
localStatus.lifecycleGeneration === binding.sessionOwnerNodeGeneration;
|
|
2022
|
-
if (binding.transition === 'tombstone') {
|
|
2023
|
-
const actorRef = {
|
|
2024
|
-
actorId: binding.actor.actorId,
|
|
2025
|
-
objectGeneration: binding.actor.generation,
|
|
2026
|
-
meshName,
|
|
2027
|
-
nodeRid: binding.actor.nodeRid
|
|
2028
|
-
};
|
|
2029
|
-
if (sessionOwnerIsLocal) {
|
|
2030
|
-
(0, application_job_queue_scope_2.releaseApplicationJobPermitBeforeHandler)();
|
|
2031
|
-
await this.streamBindingRuntime.retireRemoteBinding(actorRef, binding.sessionRid, binding.bindingGeneration, signal);
|
|
2032
|
-
}
|
|
2033
|
-
state.retireBoundSessionBinding(binding);
|
|
2034
|
-
replyBindingSuccess();
|
|
2035
|
-
return;
|
|
2036
|
-
}
|
|
2037
|
-
const target = this.boundSessionRelay.boundSessions.resolveRemoteBoundSessionTarget(binding.sessionNodeRid, binding.sessionRid);
|
|
2038
|
-
if (target === undefined) {
|
|
2039
|
-
replyBindingFailure(framework_errors_internal_1.ZLinkFrameworkInternalErrorKind.ActorLocationStale);
|
|
2040
|
-
return;
|
|
2041
|
-
}
|
|
2042
|
-
const installed = state.installBoundSessionBinding({
|
|
2043
|
-
...target,
|
|
2044
|
-
sessionNodeRid: binding.sessionNodeRid,
|
|
2045
|
-
sessionRid: binding.sessionRid,
|
|
2046
|
-
sessionOwnerNodeGeneration: binding.sessionOwnerNodeGeneration,
|
|
2047
|
-
sessionOwnerId: binding.sessionOwnerId,
|
|
2048
|
-
sessionOwnerLeaseGeneration: binding.sessionOwnerLeaseGeneration,
|
|
2049
|
-
bindingGeneration: binding.bindingGeneration
|
|
2050
|
-
});
|
|
2051
|
-
if (!installed) {
|
|
2052
|
-
replyBindingFailure(framework_errors_internal_1.ZLinkFrameworkInternalErrorKind.ActorLocationStale);
|
|
2053
|
-
return;
|
|
2054
|
-
}
|
|
2055
|
-
replyBindingSuccess();
|
|
2056
|
-
return Promise.resolve();
|
|
2057
|
-
}
|
|
2022
|
+
if (record.kind === service_runtime_contracts_1.ReceiveKind.ActorBinding)
|
|
2023
|
+
return this.dispatchMeshActorBinding(meshName, record, signal);
|
|
2058
2024
|
switch (record.kind) {
|
|
2059
2025
|
case service_runtime_contracts_1.ReceiveKind.TransferControl:
|
|
2060
2026
|
if (record.kindData?.kind !== 'transferControl') {
|
|
@@ -2071,28 +2037,7 @@ class ZLinkFrameworkRuntimeHost {
|
|
|
2071
2037
|
}
|
|
2072
2038
|
case service_runtime_contracts_1.ReceiveKind.NodeSend:
|
|
2073
2039
|
case service_runtime_contracts_1.ReceiveKind.NodeRequest: {
|
|
2074
|
-
return this.admission.run(meshName, 'RouteMesh node dispatch',
|
|
2075
|
-
if (await this.serviceRelocation.tryHandleControl(meshName, record, signal)) {
|
|
2076
|
-
return;
|
|
2077
|
-
}
|
|
2078
|
-
if (record.kind === service_runtime_contracts_1.ReceiveKind.NodeRequest && record.parts.length === 1) {
|
|
2079
|
-
const terminal = (0, actors_1.decodeRemoteActorSourceLeaveTerminal)(record.parts[0].data());
|
|
2080
|
-
if (terminal !== undefined) {
|
|
2081
|
-
if ((await this.spotManager?.completeFormalSourceLeaveTerminal(terminal.actorId, terminal.transferId, terminal.succeeded)) !== true) {
|
|
2082
|
-
throw new ConfigurationException_1.ZLinkConfigurationException(`Actor '${terminal.actorId}' has no matching formal transfer terminal gate.`);
|
|
2083
|
-
}
|
|
2084
|
-
if (record.reply(Buffer.alloc(0)) !== runtime_values_1.SubmitResult.Ok) {
|
|
2085
|
-
throw new ConfigurationException_1.ZLinkConfigurationException(`Actor '${terminal.actorId}' formal transfer terminal acknowledgement failed.`);
|
|
2086
|
-
}
|
|
2087
|
-
return;
|
|
2088
|
-
}
|
|
2089
|
-
}
|
|
2090
|
-
const channelRuntime = this.channelRuntime;
|
|
2091
|
-
if (channelRuntime === undefined) {
|
|
2092
|
-
throw new ConfigurationException_1.ZLinkConfigurationException('MeshNode node-direct dispatch requires the channel runtime.');
|
|
2093
|
-
}
|
|
2094
|
-
return await channelRuntime.dispatchMeshRoute(meshName, record, signal);
|
|
2095
|
-
});
|
|
2040
|
+
return this.admission.run(meshName, 'RouteMesh node dispatch', () => this.dispatchMeshNodeRecord(meshName, record, signal));
|
|
2096
2041
|
}
|
|
2097
2042
|
case service_runtime_contracts_1.ReceiveKind.SpotSend:
|
|
2098
2043
|
case service_runtime_contracts_1.ReceiveKind.SpotRequest:
|
|
@@ -2120,6 +2065,85 @@ class ZLinkFrameworkRuntimeHost {
|
|
|
2120
2065
|
throw new ConfigurationException_1.ZLinkConfigurationException(`MeshNode record kind '${record.kind}' does not yet have a registered framework consumer.`);
|
|
2121
2066
|
}
|
|
2122
2067
|
}
|
|
2068
|
+
async dispatchMeshActorBinding(meshName, record, signal) {
|
|
2069
|
+
if (record.kindData?.kind !== 'actorBinding') {
|
|
2070
|
+
throw new ConfigurationException_1.ZLinkConfigurationException('MeshNode Actor binding record has no binding generation.');
|
|
2071
|
+
}
|
|
2072
|
+
const binding = record.kindData;
|
|
2073
|
+
const replyBindingFailure = (kind) => {
|
|
2074
|
+
const terminal = (0, framework_errors_internal_1.internalFrameworkWireReply)(kind);
|
|
2075
|
+
if (record.replyFailure?.(terminal.terminalResult, terminal.failureCode) !== runtime_values_1.SubmitResult.Ok) {
|
|
2076
|
+
throw new ConfigurationException_1.ZLinkConfigurationException(`MeshNode Actor binding target '${binding.actor.actorId}' failure acknowledgement failed.`);
|
|
2077
|
+
}
|
|
2078
|
+
};
|
|
2079
|
+
const replyBindingSuccess = () => {
|
|
2080
|
+
if (record.reply(Buffer.alloc(0)) !== runtime_values_1.SubmitResult.Ok) {
|
|
2081
|
+
throw new ConfigurationException_1.ZLinkConfigurationException(`MeshNode Actor binding target '${binding.actor.actorId}' acknowledgement failed.`);
|
|
2082
|
+
}
|
|
2083
|
+
};
|
|
2084
|
+
const state = this.actorManager?.getState(binding.actor.actorId);
|
|
2085
|
+
const nativeActorRef = state?.nativeActorRef;
|
|
2086
|
+
if (state === undefined ||
|
|
2087
|
+
nativeActorRef === undefined ||
|
|
2088
|
+
nativeActorRef.actorId !== binding.actor.actorId ||
|
|
2089
|
+
!(0, routing_id_1.routingIdsEqual)(nativeActorRef.nodeRid, binding.actor.nodeRid)) {
|
|
2090
|
+
replyBindingFailure(framework_errors_internal_1.ZLinkFrameworkInternalErrorKind.ActorLocationStale);
|
|
2091
|
+
return;
|
|
2092
|
+
}
|
|
2093
|
+
if (nativeActorRef.generation !== binding.actor.generation) {
|
|
2094
|
+
replyBindingFailure(framework_errors_internal_1.ZLinkFrameworkInternalErrorKind.ActorGenerationStale);
|
|
2095
|
+
return;
|
|
2096
|
+
}
|
|
2097
|
+
const node = state.meshName === meshName ? this.spotNodeRuntime?.meshNode(meshName) : undefined;
|
|
2098
|
+
const localStatus = node?.status();
|
|
2099
|
+
// ownsLocation tracks local cleanup responsibility, not Actor authority.
|
|
2100
|
+
// A relocation target can exact-read committed authority without owning that cleanup.
|
|
2101
|
+
if (localStatus === undefined ||
|
|
2102
|
+
!(0, routing_id_1.routingIdsEqual)(localStatus.routingId, binding.actor.nodeRid) ||
|
|
2103
|
+
localStatus.lifecycleGeneration !== binding.actorNodeGeneration ||
|
|
2104
|
+
state.locationGeneration !== binding.authorityOwnerGeneration ||
|
|
2105
|
+
state.isMoving) {
|
|
2106
|
+
replyBindingFailure(framework_errors_internal_1.ZLinkFrameworkInternalErrorKind.ActorLocationStale);
|
|
2107
|
+
return;
|
|
2108
|
+
}
|
|
2109
|
+
const sessionOwnerIsLocal = (0, routing_id_1.routingIdsEqual)(localStatus.routingId, binding.sessionNodeRid) &&
|
|
2110
|
+
localStatus.lifecycleGeneration === binding.sessionOwnerNodeGeneration;
|
|
2111
|
+
if (binding.transition === 'tombstone') {
|
|
2112
|
+
const actorRef = {
|
|
2113
|
+
actorId: binding.actor.actorId,
|
|
2114
|
+
objectGeneration: binding.actor.generation,
|
|
2115
|
+
meshName,
|
|
2116
|
+
nodeRid: binding.actor.nodeRid
|
|
2117
|
+
};
|
|
2118
|
+
if (sessionOwnerIsLocal) {
|
|
2119
|
+
(0, application_job_queue_scope_2.releaseApplicationJobPermitBeforeHandler)();
|
|
2120
|
+
await this.streamBindingRuntime.retireRemoteBinding(actorRef, binding.sessionRid, binding.bindingGeneration, signal);
|
|
2121
|
+
}
|
|
2122
|
+
state.retireBoundSessionBinding(binding);
|
|
2123
|
+
replyBindingSuccess();
|
|
2124
|
+
return;
|
|
2125
|
+
}
|
|
2126
|
+
const target = this.boundSessionRelay.boundSessions.resolveRemoteBoundSessionTarget(binding.sessionNodeRid, binding.sessionRid);
|
|
2127
|
+
if (target === undefined) {
|
|
2128
|
+
replyBindingFailure(framework_errors_internal_1.ZLinkFrameworkInternalErrorKind.ActorLocationStale);
|
|
2129
|
+
return;
|
|
2130
|
+
}
|
|
2131
|
+
const installed = state.installBoundSessionBinding({
|
|
2132
|
+
...target,
|
|
2133
|
+
sessionNodeRid: binding.sessionNodeRid,
|
|
2134
|
+
sessionRid: binding.sessionRid,
|
|
2135
|
+
sessionOwnerNodeGeneration: binding.sessionOwnerNodeGeneration,
|
|
2136
|
+
sessionOwnerId: binding.sessionOwnerId,
|
|
2137
|
+
sessionOwnerLeaseGeneration: binding.sessionOwnerLeaseGeneration,
|
|
2138
|
+
bindingGeneration: binding.bindingGeneration
|
|
2139
|
+
});
|
|
2140
|
+
if (!installed) {
|
|
2141
|
+
replyBindingFailure(framework_errors_internal_1.ZLinkFrameworkInternalErrorKind.ActorLocationStale);
|
|
2142
|
+
return;
|
|
2143
|
+
}
|
|
2144
|
+
replyBindingSuccess();
|
|
2145
|
+
return Promise.resolve();
|
|
2146
|
+
}
|
|
2123
2147
|
submitLocalMeshRoute(meshName, sourceNodeRid, parts) {
|
|
2124
2148
|
const state = this.executionState;
|
|
2125
2149
|
const channelRuntime = this.channelRuntime;
|
|
@@ -520,33 +520,17 @@ function serviceWireBarrierKey(value) {
|
|
|
520
520
|
return (0, service_stateful_wire_codec_1.serviceSessionRelocationIdentityKey)(value);
|
|
521
521
|
}
|
|
522
522
|
function validateSessionRelocationRouteAgainstSeal(route, sealed) {
|
|
523
|
-
const
|
|
524
|
-
route.coordinator.leaseGeneration === sealed.coordinator.leaseGeneration &&
|
|
525
|
-
route.coordinator.nodeRid === sealed.coordinator.nodeRid &&
|
|
526
|
-
route.coordinator.nodeGeneration === sealed.coordinator.nodeGeneration &&
|
|
527
|
-
route.coordinator.expectedAuthorityStoreVersion ===
|
|
528
|
-
sealed.coordinator.expectedAuthorityStoreVersion;
|
|
529
|
-
const sameSession = route.session.sessionOwnerNodeRid === sealed.session.sessionOwnerNodeRid &&
|
|
523
|
+
const sameSession = (0, routing_id_1.routingIdsEqual)(route.session.sessionOwnerNodeRid, sealed.session.sessionOwnerNodeRid) &&
|
|
530
524
|
route.session.sessionOwnerNodeGeneration === sealed.session.sessionOwnerNodeGeneration &&
|
|
531
525
|
route.session.sessionOwnerId === sealed.session.sessionOwnerId &&
|
|
532
526
|
route.session.sessionOwnerLeaseGeneration === sealed.session.sessionOwnerLeaseGeneration &&
|
|
533
|
-
route.session.sessionRid
|
|
527
|
+
(0, routing_id_1.routingIdsEqual)(route.session.sessionRid, sealed.session.sessionRid) &&
|
|
534
528
|
route.session.bindingGeneration === sealed.session.bindingGeneration;
|
|
535
529
|
if (route.relocation.high !== sealed.relocation.high ||
|
|
536
530
|
route.relocation.low !== sealed.relocation.low ||
|
|
537
|
-
!sameCoordinator ||
|
|
538
531
|
!sameSession ||
|
|
539
532
|
route.actor.actorId !== sealed.actor.actor.actorId ||
|
|
540
533
|
route.actor.generation !== sealed.actor.actor.generation) {
|
|
541
534
|
throw new service_wire_m6a_codec_1.ServiceWireProtocolError(`Session relocation '${serviceWireBarrierKey(route)}' changed its command 42 fence.`);
|
|
542
535
|
}
|
|
543
|
-
if (route.route.action === 'commit') {
|
|
544
|
-
if (route.route.previousAuthorityOwnerGeneration !== sealed.actor.authorityOwnerGeneration) {
|
|
545
|
-
throw new service_wire_m6a_codec_1.ServiceWireProtocolError(`Session relocation '${serviceWireBarrierKey(route)}' changed its source authority fence.`);
|
|
546
|
-
}
|
|
547
|
-
return;
|
|
548
|
-
}
|
|
549
|
-
if (route.route.currentAuthorityOwnerGeneration !== sealed.actor.authorityOwnerGeneration) {
|
|
550
|
-
throw new service_wire_m6a_codec_1.ServiceWireProtocolError(`Session relocation '${serviceWireBarrierKey(route)}' abort changed its authority fence.`);
|
|
551
|
-
}
|
|
552
536
|
}
|
|
@@ -409,7 +409,7 @@ class ZLinkRouteMeshRuntimeCoordinator {
|
|
|
409
409
|
? 'deadline_exceeded'
|
|
410
410
|
: classified;
|
|
411
411
|
await Promise.all(entries.map(([meshName]) => this.options.forceStopResources(meshName).catch(() => undefined)));
|
|
412
|
-
result = { kind: 'forceStopped', reason };
|
|
412
|
+
result = { kind: 'forceStopped', reason, error };
|
|
413
413
|
for (const [meshName, state] of entries) {
|
|
414
414
|
this.transition(meshName, state, contracts_1.ZLinkTopologyState.Failed);
|
|
415
415
|
}
|
|
@@ -3,5 +3,6 @@ export type ZLinkServiceRelocationControlRequest = ServiceMaintenanceRelocationC
|
|
|
3
3
|
export type ZLinkServiceRelocationControlResponse = ServiceMaintenanceRelocationControl;
|
|
4
4
|
export declare function encodeServiceRelocationControlRequest(request: ZLinkServiceRelocationControlRequest): Buffer;
|
|
5
5
|
export declare function decodeServiceRelocationControlRequest(payload: Uint8Array): ZLinkServiceRelocationControlRequest | undefined;
|
|
6
|
+
export declare function serviceRelocationControlCommand(payload: Uint8Array): number | undefined;
|
|
6
7
|
export declare function encodeServiceRelocationControlResponse(response: ZLinkServiceRelocationControlResponse): Buffer;
|
|
7
8
|
export declare function decodeServiceRelocationControlResponse(payload: Uint8Array): ZLinkServiceRelocationControlResponse;
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.encodeServiceRelocationControlRequest = encodeServiceRelocationControlRequest;
|
|
4
4
|
exports.decodeServiceRelocationControlRequest = decodeServiceRelocationControlRequest;
|
|
5
|
+
exports.serviceRelocationControlCommand = serviceRelocationControlCommand;
|
|
5
6
|
exports.encodeServiceRelocationControlResponse = encodeServiceRelocationControlResponse;
|
|
6
7
|
exports.decodeServiceRelocationControlResponse = decodeServiceRelocationControlResponse;
|
|
7
8
|
const service_wire_binary_primitives_1 = require("../foundation/service-wire-binary-primitives");
|
|
@@ -14,13 +15,18 @@ function decodeServiceRelocationControlRequest(payload) {
|
|
|
14
15
|
const bytes = Buffer.isBuffer(payload)
|
|
15
16
|
? payload
|
|
16
17
|
: Buffer.from(payload.buffer, payload.byteOffset, payload.byteLength);
|
|
17
|
-
if (bytes
|
|
18
|
-
bytes[0] !== service_wire_constants_generated_1.SERVICE_WIRE_MAGIC[0] ||
|
|
19
|
-
bytes[1] !== service_wire_constants_generated_1.SERVICE_WIRE_MAGIC[1] ||
|
|
20
|
-
bytes[service_wire_binary_primitives_1.SERVICE_WIRE_MAJOR_OFFSET] !== service_wire_constants_generated_1.SERVICE_WIRE_MAJOR)
|
|
18
|
+
if (serviceRelocationControlCommand(bytes) === undefined)
|
|
21
19
|
return undefined;
|
|
22
20
|
return (0, service_stateful_wire_codec_1.decodeMaintenanceRelocationControl)(bytes);
|
|
23
21
|
}
|
|
22
|
+
function serviceRelocationControlCommand(payload) {
|
|
23
|
+
if (payload.byteLength < service_wire_binary_primitives_1.SERVICE_WIRE_PREFIX_SIZE ||
|
|
24
|
+
payload[0] !== service_wire_constants_generated_1.SERVICE_WIRE_MAGIC[0] ||
|
|
25
|
+
payload[1] !== service_wire_constants_generated_1.SERVICE_WIRE_MAGIC[1] ||
|
|
26
|
+
payload[service_wire_binary_primitives_1.SERVICE_WIRE_MAJOR_OFFSET] !== service_wire_constants_generated_1.SERVICE_WIRE_MAJOR)
|
|
27
|
+
return undefined;
|
|
28
|
+
return payload[service_wire_binary_primitives_1.SERVICE_WIRE_COMMAND_OFFSET];
|
|
29
|
+
}
|
|
24
30
|
function encodeServiceRelocationControlResponse(response) {
|
|
25
31
|
return (0, service_stateful_wire_codec_1.encodeMaintenanceRelocationControl)(response);
|
|
26
32
|
}
|
|
@@ -24,6 +24,7 @@ interface ZLinkHostRelocationOptions {
|
|
|
24
24
|
readonly locationStore: () => ZLinkLocationStore | undefined;
|
|
25
25
|
readonly currentOwner: () => ZLinkLocationOwnerToken | undefined;
|
|
26
26
|
readonly targetAdmissionSealed?: () => boolean;
|
|
27
|
+
readonly sourceQuiescenceChanged?: () => void;
|
|
27
28
|
readonly liveDescriptors: (meshName: string, signal?: AbortSignal) => Promise<readonly ZLinkMeshNodeDescriptor[]>;
|
|
28
29
|
readonly localDescriptor?: (meshName: string) => ZLinkMeshNodeDescriptor | undefined;
|
|
29
30
|
readonly meshNode: (meshName: string) => ZLinkBackendMeshNode | undefined;
|
|
@@ -97,7 +98,8 @@ export declare class ZLinkHostServiceRelocationRuntime implements ZLinkActorJoin
|
|
|
97
98
|
completeActorJoinSourceCleanup(actorId: string): void;
|
|
98
99
|
private finalizeActorJoinSource;
|
|
99
100
|
relocateMesh(meshName: string, targetApplicationVersion?: bigint, signal?: AbortSignal, stopStartingSignal?: AbortSignal): Promise<void>;
|
|
100
|
-
tryHandleControl(meshName: string, record: ReceiveRecord, signal?: AbortSignal): Promise<boolean>;
|
|
101
|
+
tryHandleControl(meshName: string, record: ReceiveRecord, signal?: AbortSignal): boolean | Promise<boolean>;
|
|
102
|
+
private handleControl;
|
|
101
103
|
/** Sends the Ready reply once the async restore finished; failures replay on resend. */
|
|
102
104
|
private deliverTargetReady;
|
|
103
105
|
/** Cleans up a Ready reply that never delivered within the Restore validity window. */
|
|
@@ -153,11 +155,7 @@ export declare class ZLinkHostServiceRelocationRuntime implements ZLinkActorJoin
|
|
|
153
155
|
/** The authority settlement ended: the retained batch copy is released. */
|
|
154
156
|
private closeSourceCutoverWindow;
|
|
155
157
|
private releaseSourceCutoverWindow;
|
|
156
|
-
/**
|
|
157
|
-
* Sends the whole boundary batch and cutover again after a failed submit
|
|
158
|
-
* or an observed loss of the target connection (spec 28 §4.4). The target
|
|
159
|
-
* replaces its partial span with the whole batch.
|
|
160
|
-
*/
|
|
158
|
+
/** Relocation flow §4.4: replay the whole batch on a different ready route. */
|
|
161
159
|
private resendSourceCutover;
|
|
162
160
|
/**
|
|
163
161
|
* The one source authority settlement after Ready (Location runtime
|
|
@@ -167,8 +165,8 @@ export declare class ZLinkHostServiceRelocationRuntime implements ZLinkActorJoin
|
|
|
167
165
|
* excludes a late target commit. `target`: the
|
|
168
166
|
* target committed. `source`: Preserve fenced the target out while the
|
|
169
167
|
* source owner lease was valid. `lost`: the source owner lease ended first
|
|
170
|
-
* or another authority owns the object. An uncertain
|
|
171
|
-
* keeps the work retained and repeats the same decision.
|
|
168
|
+
* or authority is Missing or another authority owns the object. An uncertain
|
|
169
|
+
* Store or lease result keeps the work retained and repeats the same decision.
|
|
172
170
|
*/
|
|
173
171
|
private settleSourceAuthority;
|
|
174
172
|
private readSourceSettlement;
|