@zlink-systems/framework 0.24.0 → 0.26.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/.tsbuildinfo +1 -1
- package/dist/contracts/Channels/IZLinkFanoutClient.d.ts +0 -6
- package/dist/contracts/RouteMesh/RuntimeTopology.d.ts +8 -0
- package/dist/internal.d.ts +1 -0
- package/dist/internal.js +1 -0
- package/dist/runtime/activation-admission.d.ts +29 -0
- package/dist/runtime/activation-admission.js +61 -0
- package/dist/runtime/actors/actor-context.js +6 -6
- package/dist/runtime/actors/actor-handoff.d.ts +9 -3
- package/dist/runtime/actors/actor-handoff.js +28 -17
- package/dist/runtime/actors/actor-local-native-join.js +2 -18
- package/dist/runtime/actors/actor-remote-joiner.d.ts +2 -2
- package/dist/runtime/actors/actor-remote-joiner.js +6 -8
- package/dist/runtime/actors/actor-runtime-contracts.d.ts +4 -2
- package/dist/runtime/actors/actor-source-transfer.d.ts +5 -5
- package/dist/runtime/actors/deferred-join-completion.d.ts +14 -0
- package/dist/runtime/actors/deferred-join-completion.js +20 -0
- package/dist/runtime/actors/index.d.ts +1 -1
- package/dist/runtime/actors/index.js +15 -5
- package/dist/runtime/admission.d.ts +5 -1
- package/dist/runtime/admission.js +4 -0
- package/dist/runtime/backend/contracts/index.d.ts +2 -10
- package/dist/runtime/backend/mesh-actor-session-node-adapter.js +2 -9
- package/dist/runtime/backend/node/node-backend-adapter-factory.d.ts +1 -2
- package/dist/runtime/backend/node/node-backend-adapter-factory.js +4 -18
- package/dist/runtime/backend/node/node-backend-adapter-support.d.ts +6 -3
- package/dist/runtime/backend/node/node-backend-adapter-support.js +12 -28
- package/dist/runtime/backend/node/node-event-loop-poller.d.ts +1 -1
- package/dist/runtime/backend/node/node-event-loop-poller.js +8 -2
- package/dist/runtime/backend/node/node-raw-binding-port.d.ts +1 -1
- package/dist/runtime/backend/node/node-raw-binding-port.js +11 -3
- package/dist/runtime/backend/node/node-raw-mesh-backend.d.ts +12 -9
- package/dist/runtime/backend/node/node-raw-mesh-backend.js +61 -29
- package/dist/runtime/backend/node/node-socket-backend-adapter.js +1 -1
- package/dist/runtime/backend/raw-binding-port.d.ts +12 -0
- package/dist/runtime/channels/channel-clients.d.ts +0 -1
- package/dist/runtime/channels/channel-clients.js +0 -8
- package/dist/runtime/channels/channel-outbound-operations.js +2 -10
- package/dist/runtime/channels/channel-runtime-manager.d.ts +2 -5
- package/dist/runtime/channels/channel-runtime-manager.js +1 -12
- package/dist/runtime/channels/channel-socket-registry.d.ts +17 -4
- package/dist/runtime/channels/channel-socket-registry.js +49 -62
- package/dist/runtime/channels/channel-transports.d.ts +0 -3
- package/dist/runtime/channels/fanout-location-runtime.js +3 -9
- package/dist/runtime/execution/index.d.ts +18 -8
- package/dist/runtime/execution/index.js +55 -29
- package/dist/runtime/execution/serial-execution-queue.d.ts +5 -6
- package/dist/runtime/execution/serial-execution-queue.js +49 -15
- package/dist/runtime/foundation/listener-records.d.ts +11 -0
- package/dist/runtime/foundation/listener-records.js +20 -0
- package/dist/runtime/foundation/raw-service-mesh-runtime.d.ts +10 -21
- package/dist/runtime/foundation/raw-service-mesh-runtime.js +66 -392
- package/dist/runtime/foundation/service-authority-payload-codec.d.ts +1 -0
- package/dist/runtime/foundation/service-authority-payload-codec.js +8 -0
- package/dist/runtime/foundation/service-maintenance-runtime.js +23 -2
- package/dist/runtime/foundation/service-relocation-coordinator.d.ts +9 -0
- package/dist/runtime/foundation/service-relocation-coordinator.js +14 -1
- package/dist/runtime/foundation/service-relocation-object-owner.d.ts +8 -0
- package/dist/runtime/foundation/service-relocation-object-owner.js +16 -4
- package/dist/runtime/foundation/service-session-binding-ingress-port.d.ts +6 -13
- package/dist/runtime/foundation/service-stateful-runtime.d.ts +10 -7
- package/dist/runtime/foundation/service-stateful-runtime.js +100 -60
- package/dist/runtime/foundation/service-stateful-wire-codec.d.ts +9 -4
- package/dist/runtime/foundation/service-stateful-wire-codec.js +153 -90
- package/dist/runtime/foundation/service-topology-registry.d.ts +1 -2
- package/dist/runtime/foundation/service-topology-registry.js +6 -30
- package/dist/runtime/host/actor-transfer-runtime.d.ts +17 -15
- package/dist/runtime/host/actor-transfer-runtime.js +73 -86
- package/dist/runtime/host/index.d.ts +6 -2
- package/dist/runtime/host/index.js +63 -37
- package/dist/runtime/host/remote-bound-session-relay.js +4 -3
- package/dist/runtime/host/route-mesh-runtime.d.ts +2 -0
- package/dist/runtime/host/route-mesh-runtime.js +7 -5
- package/dist/runtime/host/service-relocation-host-runtime.d.ts +50 -8
- package/dist/runtime/host/service-relocation-host-runtime.js +343 -270
- package/dist/runtime/host/spot-runtime-options-factory.d.ts +7 -4
- package/dist/runtime/host/spot-runtime-options-factory.js +4 -8
- package/dist/runtime/host/stateful-authority-route-runtime.js +6 -2
- package/dist/runtime/host/user-spot-creation-coordinator.d.ts +11 -3
- package/dist/runtime/host/user-spot-creation-coordinator.js +85 -87
- package/dist/runtime/locations/in-memory-provider-location-store.js +8 -6
- package/dist/runtime/locations/lifecycle.d.ts +1 -1
- package/dist/runtime/locations/lifecycle.js +2 -2
- package/dist/runtime/locations/resolvers.js +7 -2
- package/dist/runtime/locations/spot-location-claims.d.ts +2 -2
- package/dist/runtime/locations/spot-location-claims.js +3 -27
- package/dist/runtime/protocol/service_wire_codec.generated.d.ts +1 -0
- package/dist/runtime/protocol/service_wire_codec.generated.js +5 -1
- package/dist/runtime/protocol/service_wire_pilot_codec.generated.d.ts +1 -0
- package/dist/runtime/protocol/service_wire_pilot_codec.generated.js +3 -2
- package/dist/runtime/spots/formal-remote-actor-admission-registry.d.ts +3 -3
- package/dist/runtime/spots/formal-remote-actor-admission-registry.js +4 -4
- package/dist/runtime/spots/formal-remote-actor-transfer-registry.d.ts +3 -3
- package/dist/runtime/spots/index.d.ts +25 -19
- package/dist/runtime/spots/index.js +207 -205
- package/dist/runtime/spots/spot-activation-registry.d.ts +4 -2
- package/dist/runtime/spots/spot-activation-registry.js +34 -31
- package/dist/runtime/spots/spot-activation-state.d.ts +2 -11
- package/dist/runtime/spots/spot-activation-state.js +4 -17
- package/dist/runtime/spots/spot-activation.d.ts +8 -6
- package/dist/runtime/spots/spot-activation.js +54 -49
- package/dist/runtime/spots/spot-actor-admission-coordinator.d.ts +1 -1
- package/dist/runtime/spots/spot-actor-admission-coordinator.js +1 -1
- package/dist/runtime/spots/spot-actor-join-dispatch.d.ts +2 -2
- package/dist/runtime/spots/spot-actor-join-dispatch.js +3 -5
- package/dist/runtime/spots/spot-actor-lifecycle-drain.js +2 -2
- package/dist/runtime/spots/spot-actor-membership.d.ts +4 -0
- package/dist/runtime/spots/spot-actor-membership.js +26 -12
- package/dist/runtime/spots/spot-entry-activation.d.ts +1 -2
- package/dist/runtime/spots/spot-entry-activation.js +0 -1
- package/dist/runtime/spots/spot-manager-public.js +1 -1
- package/dist/runtime/spots/spot-native-actor-join-admission.d.ts +1 -1
- package/dist/runtime/spots/spot-native-actor-join-admission.js +2 -2
- package/dist/runtime/spots/spot-node-runtime-manager.d.ts +5 -5
- package/dist/runtime/spots/spot-node-runtime-manager.js +7 -11
- package/dist/runtime/spots/spot-outbound.js +1 -29
- package/dist/runtime/spots/spot-routed-actor-admission.d.ts +1 -0
- package/dist/runtime/spots/spot-routed-actor-admission.js +10 -0
- package/dist/runtime/spots/spot-routed-frame-dispatch.d.ts +2 -6
- package/dist/runtime/spots/spot-routed-frame-dispatch.js +2 -70
- package/dist/runtime/spots/spot-runtime-ports.d.ts +3 -5
- package/dist/runtime/spots/spot-serial-executor.d.ts +5 -0
- package/dist/runtime/spots/spot-serial-executor.js +8 -1
- package/dist/runtime/spots/spot-serial-turn-executor.d.ts +3 -0
- package/dist/runtime/spots/spot-serial-turn-executor.js +8 -4
- package/dist/runtime/streams/actor-session-binding-registry.d.ts +13 -15
- package/dist/runtime/streams/actor-session-binding-registry.js +19 -171
- package/dist/runtime/streams/actor-session-binding-runtime-owner.d.ts +3 -4
- package/dist/runtime/streams/bound-session-service.js +1 -18
- package/dist/runtime/streams/index.d.ts +2 -0
- package/dist/runtime/streams/index.js +19 -19
- package/dist/runtime/streams/session-serial-executor.js +2 -2
- package/package.json +3 -3
- package/src/contracts/Channels/IZLinkFanoutClient.ts +0 -7
- package/src/contracts/RouteMesh/RuntimeTopology.ts +10 -0
- package/src/internal.ts +1 -0
- package/src/runtime/activation-admission.ts +78 -0
- package/src/runtime/actors/actor-context.ts +6 -6
- package/src/runtime/actors/actor-handoff.ts +31 -23
- package/src/runtime/actors/actor-local-native-join.ts +3 -42
- package/src/runtime/actors/actor-remote-joiner.ts +6 -25
- package/src/runtime/actors/actor-runtime-contracts.ts +4 -10
- package/src/runtime/actors/actor-source-transfer.ts +5 -18
- package/src/runtime/actors/deferred-join-completion.ts +40 -0
- package/src/runtime/actors/index.ts +22 -9
- package/src/runtime/admission.ts +5 -1
- package/src/runtime/backend/contracts/index.ts +2 -13
- package/src/runtime/backend/mesh-actor-session-node-adapter.ts +2 -10
- package/src/runtime/backend/node/node-backend-adapter-factory.ts +5 -25
- package/src/runtime/backend/node/node-backend-adapter-support.ts +9 -29
- package/src/runtime/backend/node/node-event-loop-poller.ts +14 -2
- package/src/runtime/backend/node/node-raw-binding-port.ts +17 -3
- package/src/runtime/backend/node/node-raw-mesh-backend.ts +65 -32
- package/src/runtime/backend/node/node-socket-backend-adapter.ts +2 -2
- package/src/runtime/backend/raw-binding-port.ts +13 -0
- package/src/runtime/channels/channel-clients.ts +0 -11
- package/src/runtime/channels/channel-outbound-operations.ts +3 -11
- package/src/runtime/channels/channel-runtime-manager.ts +4 -15
- package/src/runtime/channels/channel-socket-registry.ts +69 -71
- package/src/runtime/channels/channel-transports.ts +0 -3
- package/src/runtime/channels/fanout-location-runtime.ts +4 -16
- package/src/runtime/execution/index.ts +68 -30
- package/src/runtime/execution/serial-execution-queue.ts +52 -20
- package/src/runtime/foundation/listener-records.ts +21 -0
- package/src/runtime/foundation/raw-service-mesh-runtime.ts +66 -466
- package/src/runtime/foundation/service-authority-payload-codec.ts +10 -0
- package/src/runtime/foundation/service-maintenance-runtime.ts +30 -9
- package/src/runtime/foundation/service-relocation-coordinator.ts +13 -0
- package/src/runtime/foundation/service-relocation-object-owner.ts +18 -5
- package/src/runtime/foundation/service-session-binding-ingress-port.ts +6 -14
- package/src/runtime/foundation/service-stateful-runtime.ts +151 -89
- package/src/runtime/foundation/service-stateful-wire-codec.ts +203 -121
- package/src/runtime/foundation/service-topology-registry.ts +8 -48
- package/src/runtime/host/actor-transfer-runtime.ts +94 -166
- package/src/runtime/host/index.ts +119 -54
- package/src/runtime/host/remote-bound-session-relay.ts +4 -3
- package/src/runtime/host/route-mesh-runtime.ts +9 -5
- package/src/runtime/host/service-relocation-host-runtime.ts +495 -376
- package/src/runtime/host/spot-runtime-options-factory.ts +24 -13
- package/src/runtime/host/stateful-authority-route-runtime.ts +8 -4
- package/src/runtime/host/user-spot-creation-coordinator.ts +147 -142
- package/src/runtime/locations/in-memory-provider-location-store.ts +11 -7
- package/src/runtime/locations/lifecycle.ts +3 -2
- package/src/runtime/locations/resolvers.ts +19 -13
- package/src/runtime/locations/spot-location-claims.ts +5 -34
- package/src/runtime/protocol/service_wire_codec.generated.ts +9 -2
- package/src/runtime/protocol/service_wire_pilot_codec.generated.ts +4 -4
- package/src/runtime/spots/formal-remote-actor-admission-registry.ts +6 -6
- package/src/runtime/spots/formal-remote-actor-transfer-registry.ts +3 -3
- package/src/runtime/spots/index.ts +341 -295
- package/src/runtime/spots/spot-activation-registry.ts +41 -31
- package/src/runtime/spots/spot-activation-state.ts +4 -16
- package/src/runtime/spots/spot-activation.ts +102 -80
- package/src/runtime/spots/spot-actor-admission-coordinator.ts +2 -2
- package/src/runtime/spots/spot-actor-join-dispatch.ts +6 -7
- package/src/runtime/spots/spot-actor-lifecycle-drain.ts +20 -18
- package/src/runtime/spots/spot-actor-membership.ts +81 -17
- package/src/runtime/spots/spot-entry-activation.ts +0 -3
- package/src/runtime/spots/spot-manager-public.ts +8 -4
- package/src/runtime/spots/spot-native-actor-join-admission.ts +2 -2
- package/src/runtime/spots/spot-node-runtime-manager.ts +12 -18
- package/src/runtime/spots/spot-outbound.ts +4 -47
- package/src/runtime/spots/spot-routed-actor-admission.ts +20 -0
- package/src/runtime/spots/spot-routed-frame-dispatch.ts +6 -76
- package/src/runtime/spots/spot-runtime-ports.ts +6 -17
- package/src/runtime/spots/spot-serial-executor.ts +9 -1
- package/src/runtime/spots/spot-serial-turn-executor.ts +10 -4
- package/src/runtime/streams/actor-session-binding-registry.ts +20 -308
- package/src/runtime/streams/actor-session-binding-runtime-owner.ts +2 -12
- package/src/runtime/streams/bound-session-service.ts +2 -36
- package/src/runtime/streams/index.ts +29 -27
- package/src/runtime/streams/session-serial-executor.ts +2 -2
- package/dist/runtime/actors/deferred-join-accepted-journal.d.ts +0 -47
- package/dist/runtime/actors/deferred-join-accepted-journal.js +0 -992
- package/src/runtime/actors/deferred-join-accepted-journal.ts +0 -1346
|
@@ -20,13 +20,16 @@ export interface ZLinkSpotActorMembershipOptions {
|
|
|
20
20
|
readonly entrySpotIdProvider?: (meshName: string) => string | undefined;
|
|
21
21
|
readonly spotRouteResolver?: ZLinkSpotRouteResolver;
|
|
22
22
|
readonly actorTransferRuntime?: ZLinkSpotActorTransferRuntime;
|
|
23
|
+
readonly isSpotClosing?: (activation: ZLinkSpotActivation) => boolean;
|
|
23
24
|
}
|
|
24
25
|
export type ZLinkActorJoinRollback = () => Promise<void> | void;
|
|
25
26
|
export declare class ZLinkSpotActorMembership {
|
|
26
27
|
private readonly options;
|
|
27
28
|
constructor(options: ZLinkSpotActorMembershipOptions);
|
|
28
29
|
admitActorJoin(spotId: RoutingId, actor: ZLinkActor, request: Message, commit: (spot: ZLinkSpot) => Promise<ZLinkActorJoinRollback | void> | ZLinkActorJoinRollback | void, signal?: AbortSignal, leaveSource?: () => Promise<void>, contentType?: string): Promise<ZLinkSpotActorJoinResult>;
|
|
30
|
+
private admitActorJoinCore;
|
|
29
31
|
leaveActor(spotId: RoutingId, actor: ZLinkActor, signal?: AbortSignal, meshName?: string): Promise<void>;
|
|
32
|
+
private leaveActorCore;
|
|
30
33
|
notifyActorLeftAfterTransfer(spotId: RoutingId, actor: ZLinkActor, signal?: AbortSignal): Promise<void>;
|
|
31
34
|
prepareActorLeaveForTransfer(spotId: RoutingId, actor: ZLinkActor, signal?: AbortSignal): Promise<void>;
|
|
32
35
|
commitActorLeaveAfterTransfer(spotId: RoutingId, actorId: string): Promise<void>;
|
|
@@ -35,5 +38,6 @@ export declare class ZLinkSpotActorMembership {
|
|
|
35
38
|
cancelActorTransfer(spotId: RoutingId, actorId: string): Promise<void>;
|
|
36
39
|
notifyJoinedActorDisconnected(spotId: RoutingId, actor: ZLinkActor, signal?: AbortSignal): Promise<boolean>;
|
|
37
40
|
private requireActivation;
|
|
41
|
+
private runLifecycleOperation;
|
|
38
42
|
private createActorDispatcher;
|
|
39
43
|
}
|
|
@@ -5,6 +5,7 @@ const contracts_1 = require("../../contracts");
|
|
|
5
5
|
const abort_1 = require("../abort");
|
|
6
6
|
const runtime_message_1 = require("../backend/runtime-message");
|
|
7
7
|
const configuration_1 = require("../configuration");
|
|
8
|
+
const framework_errors_internal_1 = require("../framework-errors-internal");
|
|
8
9
|
const actors_1 = require("../actors");
|
|
9
10
|
const payload_codec_1 = require("../messaging/payload-codec");
|
|
10
11
|
const routing_id_1 = require("../routing-id");
|
|
@@ -16,6 +17,14 @@ class ZLinkSpotActorMembership {
|
|
|
16
17
|
async admitActorJoin(spotId, actor, request, commit, signal, leaveSource, contentType = 'application/json') {
|
|
17
18
|
(0, abort_1.throwIfAborted)(signal);
|
|
18
19
|
const activation = this.requireActivation(spotId);
|
|
20
|
+
return await this.runLifecycleOperation(activation, async () => {
|
|
21
|
+
if (this.options.isSpotClosing?.(activation) === true) {
|
|
22
|
+
throw (0, framework_errors_internal_1.createInternalFrameworkException)(framework_errors_internal_1.ZLinkFrameworkInternalErrorKind.RequestRejected, `User Spot '${String(spotId)}' is closing.`);
|
|
23
|
+
}
|
|
24
|
+
return await this.admitActorJoinCore(activation, actor, request, commit, signal, leaveSource, contentType);
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
async admitActorJoinCore(activation, actor, request, commit, signal, leaveSource, contentType) {
|
|
19
28
|
const dispatcher = this.createActorDispatcher(activation);
|
|
20
29
|
const transaction = { committed: false };
|
|
21
30
|
let response;
|
|
@@ -54,6 +63,9 @@ class ZLinkSpotActorMembership {
|
|
|
54
63
|
async leaveActor(spotId, actor, signal, meshName) {
|
|
55
64
|
(0, abort_1.throwIfAborted)(signal);
|
|
56
65
|
const activation = this.requireActivation(spotId, meshName);
|
|
66
|
+
await this.runLifecycleOperation(activation, () => this.leaveActorCore(activation, actor, signal, meshName));
|
|
67
|
+
}
|
|
68
|
+
async leaveActorCore(activation, actor, signal, meshName) {
|
|
57
69
|
const localEntryNodeRid = (meshName === undefined ? undefined : this.options.nodeRidProvider?.(meshName)) ??
|
|
58
70
|
this.options.entryNodeRidProvider?.() ??
|
|
59
71
|
this.options.entryNodeRid ??
|
|
@@ -109,40 +121,36 @@ class ZLinkSpotActorMembership {
|
|
|
109
121
|
async notifyActorLeftAfterTransfer(spotId, actor, signal) {
|
|
110
122
|
(0, abort_1.throwIfAborted)(signal);
|
|
111
123
|
const activation = this.requireActivation(spotId);
|
|
112
|
-
await activation.serial.execute(async () => {
|
|
124
|
+
await this.runLifecycleOperation(activation, () => activation.serial.execute(async () => {
|
|
113
125
|
activation.beginActorTransfer(actor.context.actorId);
|
|
114
126
|
await activation.spot.onLeaveActor(actor);
|
|
115
127
|
activation.commitActorDeparture(actor.context.actorId);
|
|
116
|
-
});
|
|
128
|
+
}));
|
|
117
129
|
}
|
|
118
130
|
async prepareActorLeaveForTransfer(spotId, actor, signal) {
|
|
119
131
|
(0, abort_1.throwIfAborted)(signal);
|
|
120
132
|
const activation = this.requireActivation(spotId);
|
|
121
|
-
await activation.serial.execute(() => activation.spot.onLeaveActor(actor));
|
|
133
|
+
await this.runLifecycleOperation(activation, () => activation.serial.execute(() => activation.spot.onLeaveActor(actor)));
|
|
122
134
|
}
|
|
123
135
|
async commitActorLeaveAfterTransfer(spotId, actorId) {
|
|
124
136
|
const activation = this.requireActivation(spotId);
|
|
125
|
-
await activation.serial.execute(() => activation.commitActorDeparture(actorId));
|
|
137
|
+
await this.runLifecycleOperation(activation, () => activation.serial.execute(() => activation.commitActorDeparture(actorId)));
|
|
126
138
|
}
|
|
127
139
|
async restoreActorAfterFailedTransfer(spotId, actor, signal) {
|
|
128
140
|
(0, abort_1.throwIfAborted)(signal);
|
|
129
141
|
const activation = this.requireActivation(spotId);
|
|
130
|
-
await activation.serial.execute(async () => {
|
|
142
|
+
await this.runLifecycleOperation(activation, () => activation.serial.execute(async () => {
|
|
131
143
|
activation.cancelActorTransfer(actor.context.actorId);
|
|
132
144
|
await activation.spot.onJoinedActor(actor);
|
|
133
|
-
});
|
|
145
|
+
}));
|
|
134
146
|
}
|
|
135
147
|
async beginActorTransfer(spotId, actorId) {
|
|
136
148
|
const activation = this.requireActivation(spotId);
|
|
137
|
-
await activation.serial.execute(() =>
|
|
138
|
-
activation.beginActorTransfer(actorId);
|
|
139
|
-
});
|
|
149
|
+
await this.runLifecycleOperation(activation, () => activation.serial.execute(() => activation.beginActorTransfer(actorId)));
|
|
140
150
|
}
|
|
141
151
|
async cancelActorTransfer(spotId, actorId) {
|
|
142
152
|
const activation = this.requireActivation(spotId);
|
|
143
|
-
await activation.serial.execute(() =>
|
|
144
|
-
activation.cancelActorTransfer(actorId);
|
|
145
|
-
});
|
|
153
|
+
await this.runLifecycleOperation(activation, () => activation.serial.execute(() => activation.cancelActorTransfer(actorId)));
|
|
146
154
|
}
|
|
147
155
|
async notifyJoinedActorDisconnected(spotId, actor, signal) {
|
|
148
156
|
(0, abort_1.throwIfAborted)(signal);
|
|
@@ -164,6 +172,12 @@ class ZLinkSpotActorMembership {
|
|
|
164
172
|
}
|
|
165
173
|
return activation;
|
|
166
174
|
}
|
|
175
|
+
async runLifecycleOperation(activation, operation) {
|
|
176
|
+
const pending = activation.serial.executeLifecycleOperation(operation);
|
|
177
|
+
return activation.serial.isCurrentTurn
|
|
178
|
+
? await activation.serial.currentTurn.yieldFrameworkPromise(pending)
|
|
179
|
+
: await pending;
|
|
180
|
+
}
|
|
167
181
|
createActorDispatcher(activation) {
|
|
168
182
|
return new actors_1.ZLinkSpotActorDispatcher({
|
|
169
183
|
registry: activation.actorHandlers,
|
|
@@ -3,7 +3,7 @@ import type { ZLinkProviderResolver } from '../../contracts/Common/ZLinkProvider
|
|
|
3
3
|
import type { ZLinkRuntimeEventPublisher } from '../diagnostics';
|
|
4
4
|
import type { ZLinkEntrySpotActorRequestHandlerRegistration, ZLinkEntrySpotActorSendHandlerRegistration, ZLinkEntrySpotPacketHandlerRegistration, ZLinkEntrySpotSubscriptionHandlerRegistration, ZLinkEntrySpotTimerHandlerRegistration } from '../../contracts/Configuration/RegistrationTypes';
|
|
5
5
|
import type { Message } from '../../contracts/Common/Message';
|
|
6
|
-
import type {
|
|
6
|
+
import type { ZLinkBackendSpot, ZLinkBackendSpotNode, ZLinkBackendTopicMessage } from '../backend/contracts';
|
|
7
7
|
import type { ZLinkDispatchErrorReporter } from '../channels';
|
|
8
8
|
import { ZLinkWorkerRuntime } from '../workers';
|
|
9
9
|
import { type ZLinkActorPacketDelivery } from './spot-actor-packet-dispatch';
|
|
@@ -21,7 +21,6 @@ interface ZLinkEntrySpotActivationOptions {
|
|
|
21
21
|
readonly actorRequestHandlers?: readonly ZLinkEntrySpotActorRequestHandlerRegistration[];
|
|
22
22
|
readonly nativeSpot: ZLinkBackendSpot;
|
|
23
23
|
readonly nativeNode: ZLinkBackendSpotNode;
|
|
24
|
-
readonly createReceived: () => ZLinkBackendReceived;
|
|
25
24
|
readonly createTopicMessage: () => ZLinkBackendTopicMessage;
|
|
26
25
|
readonly nodeRid: RoutingId;
|
|
27
26
|
readonly spotNodeName: string;
|
|
@@ -223,7 +223,6 @@ class ZLinkEntrySpotActivation {
|
|
|
223
223
|
attachActorJoinDispatch() {
|
|
224
224
|
const dispatch = new spot_actor_join_dispatch_1.ZLinkSpotActorJoinDispatch({
|
|
225
225
|
nativeSpot: this.options.nativeSpot,
|
|
226
|
-
createReceived: this.options.createReceived,
|
|
227
226
|
createTopicMessage: this.options.createTopicMessage,
|
|
228
227
|
serial: this.serial,
|
|
229
228
|
actors: {
|
|
@@ -51,7 +51,7 @@ class ZLinkPublicSpotManager {
|
|
|
51
51
|
return false;
|
|
52
52
|
const current = resolved.spot;
|
|
53
53
|
if (this.options.isLocalNode(current.meshName, current.nodeRid)) {
|
|
54
|
-
const closed = await this.options.coordinator.close(spot, (local) => this.options.local.
|
|
54
|
+
const closed = await this.options.coordinator.close(spot, (local, beginAuthority) => this.options.local.closeUserWithAuthority(local.meshName, local.spotId, beginAuthority, signal), signal);
|
|
55
55
|
if (closed)
|
|
56
56
|
this.options.resolver()?.invalidate?.(spot.spotId);
|
|
57
57
|
return closed;
|
|
@@ -19,7 +19,7 @@ interface ZLinkSpotNativeActorJoinAdmissionOptions {
|
|
|
19
19
|
export declare class ZLinkSpotNativeActorJoinAdmission {
|
|
20
20
|
private readonly options;
|
|
21
21
|
constructor(options: ZLinkSpotNativeActorJoinAdmissionOptions);
|
|
22
|
-
admit(request: ZLinkBackendActorJoinRequest): Promise<void>;
|
|
22
|
+
admit(request: ZLinkBackendActorJoinRequest, rejectClosing?: boolean): Promise<void>;
|
|
23
23
|
private decodeNativeActorJoinRequest;
|
|
24
24
|
private reportHandlerException;
|
|
25
25
|
}
|
|
@@ -10,7 +10,7 @@ class ZLinkSpotNativeActorJoinAdmission {
|
|
|
10
10
|
constructor(options) {
|
|
11
11
|
this.options = options;
|
|
12
12
|
}
|
|
13
|
-
async admit(request) {
|
|
13
|
+
async admit(request, rejectClosing = false) {
|
|
14
14
|
const actorId = request.info.targetActor.actorId;
|
|
15
15
|
let accepted = false;
|
|
16
16
|
let acceptedActor;
|
|
@@ -21,7 +21,7 @@ class ZLinkSpotNativeActorJoinAdmission {
|
|
|
21
21
|
throw new Error('Remote actor join requires the two-phase routed transfer protocol.');
|
|
22
22
|
}
|
|
23
23
|
const actor = this.options.resolveActor(actorId);
|
|
24
|
-
if (actor !== undefined) {
|
|
24
|
+
if (!rejectClosing && actor !== undefined) {
|
|
25
25
|
const target = this.options.getTarget();
|
|
26
26
|
const joinRequest = request.message;
|
|
27
27
|
const joinPayload = (0, payload_codec_1.wrapFrameworkPayloadMessage)(joinRequest, this.options.messageSerializers);
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { ZLinkListenerRecords } from '../foundation/listener-records';
|
|
1
2
|
import type { ZLinkLocationOptionOverrides } from '../../contracts/Locations/Options';
|
|
2
3
|
import type { ActorRef, RoutingId, ZLinkActor, ZLinkChannelClient, ZLinkFanoutClient, ZLinkMessage, ZLinkMeshNodeDescriptor, ZLinkMessageSerializer, ZLinkSpotPublisherClient } from '../../contracts';
|
|
3
4
|
import type { ZLinkProviderResolver } from '../../contracts/Common/ZLinkProviderResolver';
|
|
@@ -18,9 +19,11 @@ import type { ZLinkDetachedTaskRunner } from './spot-actor-join-dispatch';
|
|
|
18
19
|
import type { ZLinkSpotRoutedTransport } from './spot-outbound';
|
|
19
20
|
import type { ZLinkSpotRouteResolver } from './spot-routing-internal';
|
|
20
21
|
import type { ZLinkEntryActorRuntime, ZLinkSpotActorTransferRuntime, ZLinkSpotActorHandoffRuntime, ZLinkSpotBoundSessionRuntime } from './spot-runtime-ports';
|
|
22
|
+
import type { ZLinkActivationConcurrency } from '../activation-admission';
|
|
21
23
|
import type { ServiceMessageFollowRecord } from '../foundation/service-stateful-wire-codec';
|
|
22
24
|
import { ApplicationJobQueue } from '../host/application-job-queue';
|
|
23
25
|
export interface ZLinkSpotNodeRuntimeManagerOptions {
|
|
26
|
+
readonly listenerRecords?: ZLinkListenerRecords;
|
|
24
27
|
readonly registration: ZLinkFrameworkRegistration;
|
|
25
28
|
readonly primaryMeshName?: string;
|
|
26
29
|
readonly backendAdapterFactory: ZLinkBackendAdapterFactory;
|
|
@@ -46,10 +49,8 @@ export interface ZLinkSpotNodeRuntimeManagerOptions {
|
|
|
46
49
|
readonly peerAdmissionSealed?: (meshName: string) => boolean;
|
|
47
50
|
readonly meshRecordDispatcher?: (meshName: string, owner: ReadyRecord, record: ReceiveRecord) => void | Promise<void>;
|
|
48
51
|
readonly messageFollowReceiver?: (record: ServiceMessageFollowRecord) => void;
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
readonly limit: number;
|
|
52
|
-
};
|
|
52
|
+
/** MeshNode §5.1 activation admission record; the descriptor projects it for placement. */
|
|
53
|
+
readonly activationConcurrency?: (meshName: string) => ZLinkActivationConcurrency;
|
|
53
54
|
}
|
|
54
55
|
export declare class ZLinkSpotNodeRuntimeManager {
|
|
55
56
|
private readonly options;
|
|
@@ -72,7 +73,6 @@ export declare class ZLinkSpotNodeRuntimeManager {
|
|
|
72
73
|
private locationAutoConnect?;
|
|
73
74
|
private readonly applicationJobQueue;
|
|
74
75
|
constructor(options: ZLinkSpotNodeRuntimeManagerOptions);
|
|
75
|
-
createReceived(): import("../backend/runtime-values").ZLinkBackendReceived;
|
|
76
76
|
createTopicMessage(): import("../backend/runtime-values").ZLinkBackendTopicMessage;
|
|
77
77
|
configureLocationAutoConnect(runtime: ZLinkLocationRuntime, stores: ZLinkLocationRuntimeStores, options: ZLinkLocationOptionOverrides, events?: ZLinkLocationEventSink): void;
|
|
78
78
|
startLocationAutoConnect(signal?: AbortSignal): Promise<void>;
|
|
@@ -55,9 +55,6 @@ class ZLinkSpotNodeRuntimeManager {
|
|
|
55
55
|
options.applicationJobQueue ??
|
|
56
56
|
new application_job_queue_1.ApplicationJobQueue((0, application_job_queue_1.resolveApplicationJobQueueConfiguration)());
|
|
57
57
|
}
|
|
58
|
-
createReceived() {
|
|
59
|
-
return this.options.backendAdapterFactory.createReceived();
|
|
60
|
-
}
|
|
61
58
|
createTopicMessage() {
|
|
62
59
|
return this.options.backendAdapterFactory.createTopicMessage();
|
|
63
60
|
}
|
|
@@ -236,6 +233,10 @@ class ZLinkSpotNodeRuntimeManager {
|
|
|
236
233
|
this.meshNodes.set(spotNodeName, node);
|
|
237
234
|
this.meshPumps.set(spotNodeName, pump);
|
|
238
235
|
this.meshCompletions.set(spotNodeName, completions);
|
|
236
|
+
const listenerEndpoint = node.status().localEndpoint;
|
|
237
|
+
if (listenerEndpoint.length > 0) {
|
|
238
|
+
this.options.listenerRecords?.record('routeMesh', spotNodeName, listenerEndpoint);
|
|
239
|
+
}
|
|
239
240
|
}
|
|
240
241
|
catch (error) {
|
|
241
242
|
this.entryActivations.delete(spotNodeName);
|
|
@@ -333,13 +334,9 @@ class ZLinkSpotNodeRuntimeManager {
|
|
|
333
334
|
};
|
|
334
335
|
})
|
|
335
336
|
},
|
|
336
|
-
activationConcurrency: {
|
|
337
|
-
active:
|
|
338
|
-
|
|
339
|
-
0,
|
|
340
|
-
limit: this.options.instanceActivationConcurrencyProvider?.(meshName).limit ??
|
|
341
|
-
registration.activationConcurrencyLimit ??
|
|
342
|
-
128
|
|
337
|
+
activationConcurrency: this.options.activationConcurrency?.(meshName) ?? {
|
|
338
|
+
active: 0,
|
|
339
|
+
limit: registration.activationConcurrencyLimit ?? 128
|
|
343
340
|
},
|
|
344
341
|
channelWeights: Object.fromEntries(this.serverChannels(meshName).map(([channelName, channel]) => [
|
|
345
342
|
channelName,
|
|
@@ -693,7 +690,6 @@ class ZLinkSpotNodeRuntimeManager {
|
|
|
693
690
|
entrySpotType: spotNode.entrySpotType,
|
|
694
691
|
nativeSpot: node.entrySpot(),
|
|
695
692
|
nativeNode: node,
|
|
696
|
-
createReceived: () => this.options.backendAdapterFactory.createReceived(),
|
|
697
693
|
createTopicMessage: () => this.options.backendAdapterFactory.createTopicMessage(),
|
|
698
694
|
nodeRid: String(node.status().routingId),
|
|
699
695
|
spotNodeName,
|
|
@@ -5,7 +5,6 @@ exports.sendToSpotHandle = sendToSpotHandle;
|
|
|
5
5
|
exports.requestToSpotHandle = requestToSpotHandle;
|
|
6
6
|
const framework_errors_internal_1 = require("../framework-errors-internal");
|
|
7
7
|
const contracts_1 = require("../../contracts");
|
|
8
|
-
const Errors_1 = require("../../contracts/Errors");
|
|
9
8
|
const submission_result_1 = require("../messaging/submission-result");
|
|
10
9
|
const routing_id_1 = require("../routing-id");
|
|
11
10
|
const configuration_1 = require("../configuration");
|
|
@@ -405,26 +404,7 @@ async function requestToSpotHandle(transport, spot, request, options = {}) {
|
|
|
405
404
|
}
|
|
406
405
|
return transport.requestToSpot(target, request, transportOptions);
|
|
407
406
|
};
|
|
408
|
-
|
|
409
|
-
try {
|
|
410
|
-
return await requestResolved(resolved);
|
|
411
|
-
}
|
|
412
|
-
catch (error) {
|
|
413
|
-
if (!shouldRefreshAfterRouteDisconnect(resolved, error)) {
|
|
414
|
-
throw error;
|
|
415
|
-
}
|
|
416
|
-
let refreshed;
|
|
417
|
-
try {
|
|
418
|
-
refreshed = await (0, spot_handle_1.refreshSpotHandle)(spot, options.signal);
|
|
419
|
-
}
|
|
420
|
-
catch {
|
|
421
|
-
throw error;
|
|
422
|
-
}
|
|
423
|
-
if (isShutdownTargetState(refreshed?.targetNodeState)) {
|
|
424
|
-
throw (0, framework_errors_internal_1.createInternalFrameworkException)(framework_errors_internal_1.ZLinkFrameworkInternalErrorKind.RuntimeShutdown, `Spot '${String(spot.spotId)}' target host is shutting down.`, false, error);
|
|
425
|
-
}
|
|
426
|
-
throw error;
|
|
427
|
-
}
|
|
407
|
+
return requestResolved(await requireSpotRef(spot, options.signal));
|
|
428
408
|
}
|
|
429
409
|
async function requireSpotRef(handle, signal) {
|
|
430
410
|
const resolved = await (0, spot_handle_1.resolveSpotHandle)(handle, signal);
|
|
@@ -443,14 +423,6 @@ function spotRefToSpotRouteTarget(spot, spotRouterChannelIdForMesh = (meshName)
|
|
|
443
423
|
targetNodeState: spot.targetNodeState
|
|
444
424
|
};
|
|
445
425
|
}
|
|
446
|
-
function shouldRefreshAfterRouteDisconnect(target, error) {
|
|
447
|
-
return (target.targetNodeState === contracts_1.ZLinkFrameworkRuntimeState.Serving &&
|
|
448
|
-
error instanceof Errors_1.ZLinkFrameworkException &&
|
|
449
|
-
(0, framework_errors_internal_1.internalFrameworkErrorKind)(error) === framework_errors_internal_1.ZLinkFrameworkInternalErrorKind.RouteNotConnected);
|
|
450
|
-
}
|
|
451
|
-
function isShutdownTargetState(state) {
|
|
452
|
-
return (state === contracts_1.ZLinkFrameworkRuntimeState.Draining || state === contracts_1.ZLinkFrameworkRuntimeState.Stopped);
|
|
453
|
-
}
|
|
454
426
|
function normalizeSpotRefRoutingId(routingId) {
|
|
455
427
|
return (0, routing_id_1.normalizeOpaqueRoutingId)(routingId);
|
|
456
428
|
}
|
|
@@ -8,6 +8,7 @@ interface ZLinkRoutedActorAdmissionTarget {
|
|
|
8
8
|
}
|
|
9
9
|
interface ZLinkSpotRoutedActorAdmissionOptions {
|
|
10
10
|
readonly serial: ZLinkSpotSerialTurnExecutor;
|
|
11
|
+
readonly isSpotClosing?: () => boolean;
|
|
11
12
|
readonly getTarget: () => ZLinkRoutedActorAdmissionTarget;
|
|
12
13
|
readonly defaultAccept: boolean;
|
|
13
14
|
readonly routedActorTransferProvider?: ZLinkRoutedActorTransferProvider;
|
|
@@ -7,6 +7,7 @@ const payload_codec_1 = require("../messaging/payload-codec");
|
|
|
7
7
|
const routing_id_1 = require("../routing-id");
|
|
8
8
|
const spot_remote_codec_1 = require("./spot-remote-codec");
|
|
9
9
|
const spot_route_replies_1 = require("./spot-route-replies");
|
|
10
|
+
const framework_errors_internal_1 = require("../framework-errors-internal");
|
|
10
11
|
class ZLinkSpotRoutedActorAdmission {
|
|
11
12
|
options;
|
|
12
13
|
pending = new Map();
|
|
@@ -21,6 +22,15 @@ class ZLinkSpotRoutedActorAdmission {
|
|
|
21
22
|
if (decoded === undefined) {
|
|
22
23
|
return false;
|
|
23
24
|
}
|
|
25
|
+
if (this.options.isSpotClosing?.() === true) {
|
|
26
|
+
try {
|
|
27
|
+
(0, spot_route_replies_1.submitRoutedActorJoinError)(received, decoded, (0, framework_errors_internal_1.createInternalFrameworkException)(framework_errors_internal_1.ZLinkFrameworkInternalErrorKind.RequestRejected, `Actor '${decoded.actorId}' target Spot is closing.`));
|
|
28
|
+
}
|
|
29
|
+
finally {
|
|
30
|
+
this.closeDecoded(decoded);
|
|
31
|
+
}
|
|
32
|
+
return true;
|
|
33
|
+
}
|
|
24
34
|
if (decoded.phase === 'admission') {
|
|
25
35
|
await this.admitTransfer(decoded, received);
|
|
26
36
|
return true;
|
|
@@ -3,7 +3,7 @@ import type { ZLinkProviderResolver } from '../../contracts/Common/ZLinkProvider
|
|
|
3
3
|
import type { RoutingId } from '../../contracts';
|
|
4
4
|
import type { ActorRef } from '../../contracts/Common/ActorRef';
|
|
5
5
|
import type { ZLinkRemoteActorPacketTarget, ZLinkRemoteBoundSessionTarget } from '../actors';
|
|
6
|
-
import type { ZLinkBackendReceived
|
|
6
|
+
import type { ZLinkBackendReceived } from '../backend/contracts';
|
|
7
7
|
import type { ZLinkDispatchErrorReporter } from '../channels';
|
|
8
8
|
import type { ZLinkActorPacketDelivery, ZLinkActorResponseOptions } from './spot-actor-packet-dispatch';
|
|
9
9
|
import type { ZLinkSpotHandlerRegistration } from './spot-handler-registry';
|
|
@@ -15,10 +15,9 @@ interface ZLinkRoutedFrameAdmissionTarget {
|
|
|
15
15
|
onActorJoin?(actorId: string, request: ZLinkMessage): Promise<ZLinkSpotActorJoinResult>;
|
|
16
16
|
}
|
|
17
17
|
interface ZLinkSpotRoutedFrameDispatchOptions {
|
|
18
|
-
readonly nativeSpot: ZLinkBackendSpot;
|
|
19
|
-
readonly createReceived: () => ZLinkBackendReceived;
|
|
20
18
|
readonly nativeSpotId: string;
|
|
21
19
|
readonly serial: ZLinkSpotSerialTurnExecutor;
|
|
20
|
+
readonly isSpotClosing?: () => boolean;
|
|
22
21
|
readonly resolveActor: (actorId: string) => ZLinkActor | undefined;
|
|
23
22
|
readonly getTarget: () => ZLinkRoutedFrameAdmissionTarget & ZLinkSpot;
|
|
24
23
|
readonly defaultAccept: boolean;
|
|
@@ -34,11 +33,9 @@ interface ZLinkSpotRoutedFrameDispatchOptions {
|
|
|
34
33
|
readonly providerResolver?: ZLinkProviderResolver;
|
|
35
34
|
readonly dispatchErrors?: ZLinkDispatchErrorReporter;
|
|
36
35
|
readonly claimApplicationWork?: () => ZLinkApplicationWorkClaim;
|
|
37
|
-
readonly waitIdle: () => Promise<void>;
|
|
38
36
|
}
|
|
39
37
|
export declare class ZLinkSpotRoutedFrameDispatch {
|
|
40
38
|
private readonly options;
|
|
41
|
-
private routeDraining;
|
|
42
39
|
private readonly packetHandlers;
|
|
43
40
|
private readonly routedBoundSessionDispatch;
|
|
44
41
|
private readonly actorPacketRelayDispatch;
|
|
@@ -46,7 +43,6 @@ export declare class ZLinkSpotRoutedFrameDispatch {
|
|
|
46
43
|
private readonly routedActorAdmission;
|
|
47
44
|
constructor(options: ZLinkSpotRoutedFrameDispatchOptions);
|
|
48
45
|
configurePacketHandlers(registrations: readonly ZLinkSpotHandlerRegistration[]): void;
|
|
49
|
-
drain(received?: ZLinkBackendReceived | undefined, retryDeadlineMs?: number): Promise<void>;
|
|
50
46
|
dispatchFromEvent(received: ZLinkBackendReceived): Promise<void>;
|
|
51
47
|
private channelCodecs;
|
|
52
48
|
private dispatch;
|
|
@@ -2,14 +2,12 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ZLinkSpotRoutedFrameDispatch = void 0;
|
|
4
4
|
const spot_remote_route_codec_1 = require("./spot-remote-route-codec");
|
|
5
|
-
const spot_native_flags_1 = require("./spot-native-flags");
|
|
6
5
|
const spot_actor_packet_relay_dispatch_1 = require("./spot-actor-packet-relay-dispatch");
|
|
7
6
|
const spot_route_packet_dispatch_1 = require("./spot-route-packet-dispatch");
|
|
8
7
|
const spot_routed_actor_admission_1 = require("./spot-routed-actor-admission");
|
|
9
8
|
const spot_routed_bound_session_dispatch_1 = require("./spot-routed-bound-session-dispatch");
|
|
10
9
|
class ZLinkSpotRoutedFrameDispatch {
|
|
11
10
|
options;
|
|
12
|
-
routeDraining = false;
|
|
13
11
|
packetHandlers = new Map();
|
|
14
12
|
routedBoundSessionDispatch;
|
|
15
13
|
actorPacketRelayDispatch;
|
|
@@ -42,6 +40,7 @@ class ZLinkSpotRoutedFrameDispatch {
|
|
|
42
40
|
});
|
|
43
41
|
this.routedActorAdmission = new spot_routed_actor_admission_1.ZLinkSpotRoutedActorAdmission({
|
|
44
42
|
serial: options.serial,
|
|
43
|
+
isSpotClosing: options.isSpotClosing,
|
|
45
44
|
getTarget: options.getTarget,
|
|
46
45
|
defaultAccept: options.defaultAccept,
|
|
47
46
|
routedActorTransferProvider: options.routedActorTransferProvider,
|
|
@@ -61,62 +60,6 @@ class ZLinkSpotRoutedFrameDispatch {
|
|
|
61
60
|
this.packetHandlers.set(packetName, existing);
|
|
62
61
|
}
|
|
63
62
|
}
|
|
64
|
-
async drain(received = undefined, retryDeadlineMs = performance.now()) {
|
|
65
|
-
if (this.routeDraining) {
|
|
66
|
-
if (received !== undefined) {
|
|
67
|
-
try {
|
|
68
|
-
await this.dispatch(received);
|
|
69
|
-
}
|
|
70
|
-
finally {
|
|
71
|
-
received.close();
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
return;
|
|
75
|
-
}
|
|
76
|
-
this.routeDraining = true;
|
|
77
|
-
try {
|
|
78
|
-
if (received !== undefined) {
|
|
79
|
-
try {
|
|
80
|
-
await this.dispatch(received);
|
|
81
|
-
}
|
|
82
|
-
finally {
|
|
83
|
-
received.close();
|
|
84
|
-
}
|
|
85
|
-
received = undefined;
|
|
86
|
-
}
|
|
87
|
-
for (;;) {
|
|
88
|
-
received ??= this.options.createReceived();
|
|
89
|
-
try {
|
|
90
|
-
if (!this.options.nativeSpot.recvRoute(received, spot_native_flags_1.ZLINK_RECV_DONT_WAIT)) {
|
|
91
|
-
received.close();
|
|
92
|
-
await this.options.waitIdle();
|
|
93
|
-
return;
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
catch (error) {
|
|
97
|
-
if (isRouteRecvRetryable(error)) {
|
|
98
|
-
closeReceivedQuietly(received);
|
|
99
|
-
if (performance.now() < retryDeadlineMs) {
|
|
100
|
-
setTimeout(() => void this.drain(undefined, retryDeadlineMs), 10);
|
|
101
|
-
}
|
|
102
|
-
return;
|
|
103
|
-
}
|
|
104
|
-
received.close();
|
|
105
|
-
throw error;
|
|
106
|
-
}
|
|
107
|
-
try {
|
|
108
|
-
await this.dispatch(received);
|
|
109
|
-
}
|
|
110
|
-
finally {
|
|
111
|
-
received.close();
|
|
112
|
-
}
|
|
113
|
-
received = this.options.createReceived();
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
finally {
|
|
117
|
-
this.routeDraining = false;
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
63
|
async dispatchFromEvent(received) {
|
|
121
64
|
try {
|
|
122
65
|
await this.dispatch(received);
|
|
@@ -145,18 +88,7 @@ class ZLinkSpotRoutedFrameDispatch {
|
|
|
145
88
|
if (await this.routePacketDispatch.dispatch(received)) {
|
|
146
89
|
return;
|
|
147
90
|
}
|
|
148
|
-
await this.routedActorAdmission.admit(received);
|
|
91
|
+
await this.options.serial.executeLifecycleOperation(() => this.routedActorAdmission.admit(received));
|
|
149
92
|
}
|
|
150
93
|
}
|
|
151
94
|
exports.ZLinkSpotRoutedFrameDispatch = ZLinkSpotRoutedFrameDispatch;
|
|
152
|
-
function isRouteRecvRetryable(error) {
|
|
153
|
-
return (typeof error === 'object' &&
|
|
154
|
-
error !== null &&
|
|
155
|
-
[201, 202, 204].includes(Number(error.result)));
|
|
156
|
-
}
|
|
157
|
-
function closeReceivedQuietly(received) {
|
|
158
|
-
try {
|
|
159
|
-
received.close();
|
|
160
|
-
}
|
|
161
|
-
catch { }
|
|
162
|
-
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { ActorRef, RoutingId, ZLinkActor, ZLinkActorJoinOperationId, ZLinkSpot } from '../../contracts';
|
|
2
2
|
import type { Message } from '../../contracts/Common/Message';
|
|
3
3
|
import type { ZLinkMessageFollowOrigin } from '../foundation/service-runtime-contracts';
|
|
4
|
-
import type { ZLinkRemoteActorPacketTarget, ZLinkRemoteBoundSessionTarget,
|
|
4
|
+
import type { ZLinkRemoteActorPacketTarget, ZLinkRemoteBoundSessionTarget, ZLinkDeferredJoinCompletion } from '../actors';
|
|
5
5
|
import type { ZLinkActorHandoffDispatch } from '../actors/actor-handoff';
|
|
6
6
|
import type { ZLinkActorResponseOptions } from './spot-actor-packet-dispatch';
|
|
7
7
|
import type { ZLinkRemoteActorJoinActor, ZLinkRoutedActorTransferProvider } from './spot-remote-codec';
|
|
@@ -16,10 +16,8 @@ export interface ZLinkEntryActorRuntime {
|
|
|
16
16
|
}>;
|
|
17
17
|
}
|
|
18
18
|
export interface ZLinkSpotActorTransferRuntime {
|
|
19
|
-
prepareDeferredJoinAccepted(actorId: string, operationId: ZLinkActorJoinOperationId, actorRef: ActorRef, rawReply: Uint8Array, replyContentType?: string
|
|
20
|
-
|
|
21
|
-
markDeferredJoinAcceptedCommitted(root: ZLinkDeferredJoinAcceptedRoot, actorRef: ActorRef, signal?: AbortSignal): Promise<ZLinkDeferredJoinAcceptedRoot>;
|
|
22
|
-
commitAndDeliverDeferredJoinAccepted(root: ZLinkDeferredJoinAcceptedRoot, actor: ZLinkActor, actorRef: ActorRef, submitMailbox: <T>(operation: () => Promise<T>) => Promise<T>, signal?: AbortSignal): Promise<ZLinkDeferredJoinAcceptedRoot>;
|
|
19
|
+
prepareDeferredJoinAccepted(actorId: string, operationId: ZLinkActorJoinOperationId, actorRef: ActorRef, rawReply: Uint8Array, replyContentType?: string): ZLinkDeferredJoinCompletion;
|
|
20
|
+
deliverDeferredJoinAccepted(completion: ZLinkDeferredJoinCompletion, actor: ZLinkActor, actorRef: ActorRef, submitMailbox: <T>(operation: () => Promise<T>) => Promise<T>, signal?: AbortSignal): Promise<void>;
|
|
23
21
|
getOrCreateRoutedActor(actorId: string, actorType: string, actorRef?: ActorRef, remoteBoundSessionTarget?: ZLinkRemoteBoundSessionTarget, actorCreateRequest?: Message, signal?: AbortSignal): Promise<ZLinkRemoteActorJoinActor>;
|
|
24
22
|
materializeRoutedActor: ZLinkRoutedActorTransferProvider;
|
|
25
23
|
commitRoutedActorAuthority(actor: ZLinkActor, sourceActorRef: ActorRef, transferId: string, spotId: RoutingId, spotGeneration: bigint, membershipEpoch: bigint, deadlineAtMs: number, signal?: AbortSignal): Promise<import('../locations/internal-location-contracts').ZLinkAuthoritySnapshot>;
|
|
@@ -31,6 +31,11 @@ export declare class ZLinkSpotSerialExecutor {
|
|
|
31
31
|
* ownership turn. Already accepted work remains drainable.
|
|
32
32
|
*/
|
|
33
33
|
close(): Promise<void>;
|
|
34
|
+
/**
|
|
35
|
+
* Closes the Actor and timer queues. The Spot queue stays open for the Spot
|
|
36
|
+
* Close lifecycle item that owns it; that Close closes it when it finishes.
|
|
37
|
+
*/
|
|
38
|
+
closeChildren(): Promise<void>;
|
|
34
39
|
private actorExecutor;
|
|
35
40
|
private actorSerial;
|
|
36
41
|
private timerSerial;
|
|
@@ -70,6 +70,14 @@ class ZLinkSpotSerialExecutor {
|
|
|
70
70
|
* ownership turn. Already accepted work remains drainable.
|
|
71
71
|
*/
|
|
72
72
|
close() {
|
|
73
|
+
const children = this.closeChildren();
|
|
74
|
+
return Promise.all([children, this.spotSerial.close()]).then(() => undefined);
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Closes the Actor and timer queues. The Spot queue stays open for the Spot
|
|
78
|
+
* Close lifecycle item that owns it; that Close closes it when it finishes.
|
|
79
|
+
*/
|
|
80
|
+
closeChildren() {
|
|
73
81
|
if (this.closePromise !== undefined)
|
|
74
82
|
return this.closePromise;
|
|
75
83
|
this.closing = true;
|
|
@@ -79,7 +87,6 @@ class ZLinkSpotSerialExecutor {
|
|
|
79
87
|
this.timerSerials.clear();
|
|
80
88
|
this.actorExecutors.clear();
|
|
81
89
|
this.closePromise = Promise.all([
|
|
82
|
-
this.spotSerial.close(),
|
|
83
90
|
...childSerials.map((serial) => serial.close()),
|
|
84
91
|
...actorExecutors.map((executor) => executor.close())
|
|
85
92
|
]).then(() => undefined);
|
|
@@ -19,6 +19,7 @@ export declare class ZLinkSpotSerialTurnExecutor {
|
|
|
19
19
|
get currentTurn(): ZLinkSpotSerialTurn | undefined;
|
|
20
20
|
/** Stops new turns while allowing turns accepted before close to complete. */
|
|
21
21
|
close(): Promise<void>;
|
|
22
|
+
closeAdmission(): void;
|
|
22
23
|
/** Distinguishes a gate-owning turn from a suspended AsyncLocalStorage tail. */
|
|
23
24
|
isActiveTurn(turn: ZLinkSpotSerialTurn, turnId: number): boolean;
|
|
24
25
|
setExecutionBarrier(barrier: ZLinkExecutionBarrier): void;
|
|
@@ -43,6 +44,8 @@ export declare class ZLinkSpotSerialTurnExecutor {
|
|
|
43
44
|
* barrier seal after this turn finishes.
|
|
44
45
|
*/
|
|
45
46
|
postBarrierTurn<T>(operation: () => Promise<T> | T, workOptions?: ZLinkSerialWorkOptions): Promise<T>;
|
|
47
|
+
/** Holds this Spot's lifecycle FIFO until the full operation result settles. */
|
|
48
|
+
executeLifecycleOperation<T>(operation: () => Promise<T> | T): Promise<T>;
|
|
46
49
|
private enqueueApplicationTurn;
|
|
47
50
|
private enqueueFrameworkTurn;
|
|
48
51
|
private enqueueContinuationTurn;
|
|
@@ -39,6 +39,9 @@ class ZLinkSpotSerialTurnExecutor {
|
|
|
39
39
|
close() {
|
|
40
40
|
return this.scheduler.close();
|
|
41
41
|
}
|
|
42
|
+
closeAdmission() {
|
|
43
|
+
this.scheduler.closeAdmission();
|
|
44
|
+
}
|
|
42
45
|
/** Distinguishes a gate-owning turn from a suspended AsyncLocalStorage tail. */
|
|
43
46
|
isActiveTurn(turn, turnId) {
|
|
44
47
|
return (this.depth > 0 &&
|
|
@@ -109,6 +112,10 @@ class ZLinkSpotSerialTurnExecutor {
|
|
|
109
112
|
postBarrierTurn(operation, workOptions) {
|
|
110
113
|
return this.enqueueFrameworkTurn(operation, workOptions);
|
|
111
114
|
}
|
|
115
|
+
/** Holds this Spot's lifecycle FIFO until the full operation result settles. */
|
|
116
|
+
executeLifecycleOperation(operation) {
|
|
117
|
+
return this.scheduler.submitLifecycleOperation(operation);
|
|
118
|
+
}
|
|
112
119
|
async enqueueApplicationTurn(operation, workOptions = {}) {
|
|
113
120
|
this.lastActivityAtMs = performance.now();
|
|
114
121
|
let barrierClaim;
|
|
@@ -186,13 +193,10 @@ class ZLinkSpotSerialTurnExecutor {
|
|
|
186
193
|
]);
|
|
187
194
|
}
|
|
188
195
|
postResume(turn, resume, reject) {
|
|
189
|
-
|
|
190
|
-
const resumeClaim = barrier?.tryEnter();
|
|
191
|
-
if (barrier !== undefined && resumeClaim === undefined) {
|
|
196
|
+
if (!turn.resumeExecutionClaim()) {
|
|
192
197
|
reject((0, framework_errors_internal_1.createInternalFrameworkException)(framework_errors_internal_1.ZLinkFrameworkInternalErrorKind.SpotMoving, 'The yielded Spot turn cannot resume after its execution unit was sealed.'));
|
|
193
198
|
return true;
|
|
194
199
|
}
|
|
195
|
-
turn.bindExecutionClaim(resumeClaim);
|
|
196
200
|
void this.enqueueContinuationTurn(async () => {
|
|
197
201
|
this.resumedOwnerTurn = turn;
|
|
198
202
|
try {
|