@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
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.readFrameworkPacketJsonContract = void 0;
|
|
3
4
|
exports.resolveFrameworkPacketName = resolveFrameworkPacketName;
|
|
4
5
|
exports.resolveFrameworkPacketJsonContract = resolveFrameworkPacketJsonContract;
|
|
5
|
-
|
|
6
|
+
const json_1 = require("@zlink-systems/stream-wire/internal/json");
|
|
6
7
|
const Attributes_1 = require("../../contracts/Handlers/Attributes");
|
|
7
8
|
const configuration_1 = require("../configuration");
|
|
8
9
|
const STRUCTURAL_PAYLOAD_NAMES = new Set([
|
|
@@ -18,7 +19,7 @@ const STRUCTURAL_PAYLOAD_NAMES = new Set([
|
|
|
18
19
|
'Date'
|
|
19
20
|
]);
|
|
20
21
|
function resolveFrameworkPacketName(payload, explicitPacketName, surface) {
|
|
21
|
-
const packetName = normalizePacketName(explicitPacketName) ??
|
|
22
|
+
const packetName = (0, json_1.normalizePacketName)(explicitPacketName) ??
|
|
22
23
|
tryDecoratorPacketName(payload) ??
|
|
23
24
|
tryConstructorPacketName(payload);
|
|
24
25
|
if (packetName === undefined) {
|
|
@@ -32,20 +33,10 @@ function resolveFrameworkPacketJsonContract(payload, explicitPacketName) {
|
|
|
32
33
|
const constructor = payload.constructor;
|
|
33
34
|
if (constructor === undefined || constructor === Object)
|
|
34
35
|
return undefined;
|
|
35
|
-
return readFrameworkPacketJsonContract(constructor, explicitPacketName);
|
|
36
|
-
}
|
|
37
|
-
function readFrameworkPacketJsonContract(type, explicitPacketName) {
|
|
38
|
-
const expectedPacketName = normalizePacketName(explicitPacketName);
|
|
39
|
-
for (const metadata of (0, Attributes_1.readZLinkDecoratorMetadata)(type)) {
|
|
40
|
-
if (metadata.kind === 'packet' &&
|
|
41
|
-
metadata.jsonContract !== undefined &&
|
|
42
|
-
(expectedPacketName === undefined ||
|
|
43
|
-
normalizePacketName(metadata.packetName) === expectedPacketName)) {
|
|
44
|
-
return metadata.jsonContract;
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
return undefined;
|
|
36
|
+
return (0, json_1.readFrameworkPacketJsonContract)(constructor, explicitPacketName);
|
|
48
37
|
}
|
|
38
|
+
var json_2 = require("@zlink-systems/stream-wire/internal/json");
|
|
39
|
+
Object.defineProperty(exports, "readFrameworkPacketJsonContract", { enumerable: true, get: function () { return json_2.readFrameworkPacketJsonContract; } });
|
|
49
40
|
function tryDecoratorPacketName(payload) {
|
|
50
41
|
if (typeof payload !== 'object' || payload === null) {
|
|
51
42
|
return undefined;
|
|
@@ -56,7 +47,7 @@ function tryDecoratorPacketName(payload) {
|
|
|
56
47
|
}
|
|
57
48
|
for (const metadata of (0, Attributes_1.readZLinkDecoratorMetadata)(constructor)) {
|
|
58
49
|
if (metadata.kind === 'packet') {
|
|
59
|
-
return normalizePacketName(metadata.packetName);
|
|
50
|
+
return (0, json_1.normalizePacketName)(metadata.packetName);
|
|
60
51
|
}
|
|
61
52
|
}
|
|
62
53
|
return undefined;
|
|
@@ -69,12 +60,5 @@ function tryConstructorPacketName(payload) {
|
|
|
69
60
|
if (typeof name !== 'string' || STRUCTURAL_PAYLOAD_NAMES.has(name)) {
|
|
70
61
|
return undefined;
|
|
71
62
|
}
|
|
72
|
-
return normalizePacketName(name);
|
|
73
|
-
}
|
|
74
|
-
function normalizePacketName(value) {
|
|
75
|
-
if (typeof value !== 'string') {
|
|
76
|
-
return undefined;
|
|
77
|
-
}
|
|
78
|
-
const trimmed = value.trim();
|
|
79
|
-
return trimmed.length > 0 ? trimmed : undefined;
|
|
63
|
+
return (0, json_1.normalizePacketName)(name);
|
|
80
64
|
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createZLinkRequest = createZLinkRequest;
|
|
4
|
+
const completedAdmission = Promise.resolve();
|
|
5
|
+
const ignoreAdmissionFailure = () => { };
|
|
6
|
+
function createZLinkRequest(start, deliverReply) {
|
|
7
|
+
let admitted;
|
|
8
|
+
let resolveAdmission;
|
|
9
|
+
let rejectAdmission;
|
|
10
|
+
const confirmAdmission = () => {
|
|
11
|
+
admitted ??= completedAdmission;
|
|
12
|
+
resolveAdmission?.();
|
|
13
|
+
};
|
|
14
|
+
const failAdmission = (error) => {
|
|
15
|
+
if (admitted === undefined) {
|
|
16
|
+
admitted = Promise.reject(error);
|
|
17
|
+
// Existing callers may observe only the reply Promise. Observing the
|
|
18
|
+
// rejection here leaves the public admission Promise rejected.
|
|
19
|
+
void admitted.catch(ignoreAdmissionFailure);
|
|
20
|
+
}
|
|
21
|
+
else {
|
|
22
|
+
rejectAdmission?.(error);
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
const observeAdmission = () => {
|
|
26
|
+
if (admitted === undefined) {
|
|
27
|
+
admitted = new Promise((resolve, reject) => {
|
|
28
|
+
resolveAdmission = resolve;
|
|
29
|
+
rejectAdmission = reject;
|
|
30
|
+
});
|
|
31
|
+
void admitted.catch(ignoreAdmissionFailure);
|
|
32
|
+
}
|
|
33
|
+
return admitted;
|
|
34
|
+
};
|
|
35
|
+
let pending;
|
|
36
|
+
try {
|
|
37
|
+
pending = start(confirmAdmission);
|
|
38
|
+
}
|
|
39
|
+
catch (error) {
|
|
40
|
+
pending = Promise.reject(error);
|
|
41
|
+
}
|
|
42
|
+
const observed = pending.then((value) => {
|
|
43
|
+
// A successful reply proves admission even without an observation callback.
|
|
44
|
+
confirmAdmission();
|
|
45
|
+
return value;
|
|
46
|
+
}, (error) => {
|
|
47
|
+
failAdmission(error);
|
|
48
|
+
throw error;
|
|
49
|
+
});
|
|
50
|
+
const reply = deliverReply?.(observed) ?? observed;
|
|
51
|
+
return Object.defineProperty(reply, 'admitted', {
|
|
52
|
+
get: observeAdmission
|
|
53
|
+
});
|
|
54
|
+
}
|
|
@@ -10,6 +10,7 @@ export declare enum ZLinkSubmitStatus {
|
|
|
10
10
|
export interface ZLinkSubmitResult {
|
|
11
11
|
readonly status: ZLinkSubmitStatus;
|
|
12
12
|
}
|
|
13
|
+
export declare const submittedResult: ZLinkSubmitResult;
|
|
13
14
|
/** Projects typed submit failure; capacity refusal has no admission wait token. */
|
|
14
15
|
export declare function submitToRequestResult(result: number, phase: 'submit' | 'completion'): number;
|
|
15
16
|
export declare function classifySubmitResult(result: number, operation: string, phase?: 'submit' | 'completion'): ZLinkSubmitResult;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ZLinkSubmitStatus = void 0;
|
|
3
|
+
exports.submittedResult = exports.ZLinkSubmitStatus = void 0;
|
|
4
4
|
exports.submitToRequestResult = submitToRequestResult;
|
|
5
5
|
exports.classifySubmitResult = classifySubmitResult;
|
|
6
6
|
exports.requireOneWayCompletion = requireOneWayCompletion;
|
|
@@ -19,6 +19,9 @@ var ZLinkSubmitStatus;
|
|
|
19
19
|
ZLinkSubmitStatus["RouteNotConnected"] = "routeNotConnected";
|
|
20
20
|
ZLinkSubmitStatus["Shutdown"] = "shutdown";
|
|
21
21
|
})(ZLinkSubmitStatus || (exports.ZLinkSubmitStatus = ZLinkSubmitStatus = {}));
|
|
22
|
+
exports.submittedResult = Object.freeze({
|
|
23
|
+
status: ZLinkSubmitStatus.Submitted
|
|
24
|
+
});
|
|
22
25
|
/** Projects typed submit failure; capacity refusal has no admission wait token. */
|
|
23
26
|
function submitToRequestResult(result, phase) {
|
|
24
27
|
switch (result) {
|
|
@@ -50,7 +53,7 @@ function classifySubmitResult(result, operation, phase = 'submit') {
|
|
|
50
53
|
const terminal = submitToRequestResult(result, phase);
|
|
51
54
|
switch (terminal) {
|
|
52
55
|
case runtime_values_1.RequestResult.Ok:
|
|
53
|
-
return
|
|
56
|
+
return exports.submittedResult;
|
|
54
57
|
case runtime_values_1.RequestResult.TimedOut:
|
|
55
58
|
return { status: ZLinkSubmitStatus.TimedOut };
|
|
56
59
|
case runtime_values_1.RequestResult.NotFound:
|
|
@@ -1169,6 +1169,20 @@ export declare function encodeRelocationPendingTimerTick(value: RelocationPendin
|
|
|
1169
1169
|
export type RelocationPendingTimerTickVector = readonly RelocationPendingTimerTick[];
|
|
1170
1170
|
export declare function decodeRelocationPendingTimerTickVector(bytes: Uint8Array, context: ServiceWireDecoderContext): RelocationPendingTimerTickVector;
|
|
1171
1171
|
export declare function encodeRelocationPendingTimerTickVector(value: RelocationPendingTimerTickVector, context: ServiceWireDecoderContext): Uint8Array;
|
|
1172
|
+
export type RelocationSessionBinding = {
|
|
1173
|
+
readonly participantId: NonzeroU64;
|
|
1174
|
+
readonly sessionOwnerNodeRid: Rid;
|
|
1175
|
+
readonly sessionOwnerNodeGeneration: NonzeroU64;
|
|
1176
|
+
readonly sessionOwnerId: Text8;
|
|
1177
|
+
readonly sessionOwnerLeaseGeneration: NonzeroU64;
|
|
1178
|
+
readonly sessionRid: Rid;
|
|
1179
|
+
readonly bindingGeneration: NonzeroU64;
|
|
1180
|
+
};
|
|
1181
|
+
export declare function decodeRelocationSessionBinding(bytes: Uint8Array, context: ServiceWireDecoderContext): RelocationSessionBinding;
|
|
1182
|
+
export declare function encodeRelocationSessionBinding(value: RelocationSessionBinding, context: ServiceWireDecoderContext): Uint8Array;
|
|
1183
|
+
export type RelocationSessionBindingVector = readonly RelocationSessionBinding[];
|
|
1184
|
+
export declare function decodeRelocationSessionBindingVector(bytes: Uint8Array, context: ServiceWireDecoderContext): RelocationSessionBindingVector;
|
|
1185
|
+
export declare function encodeRelocationSessionBindingVector(value: RelocationSessionBindingVector, context: ServiceWireDecoderContext): Uint8Array;
|
|
1172
1186
|
export type RelocationEnvelopeV1 = {
|
|
1173
1187
|
readonly relocation: RelocationId;
|
|
1174
1188
|
readonly object: RelocationObjectIdentity;
|
|
@@ -1177,6 +1191,7 @@ export type RelocationEnvelopeV1 = {
|
|
|
1177
1191
|
readonly savedWork: SavedWorkVector;
|
|
1178
1192
|
readonly timerRegistrations: RelocationTimerRegistrationVector;
|
|
1179
1193
|
readonly pendingTimerTicks: RelocationPendingTimerTickVector;
|
|
1194
|
+
readonly sessionBindings: RelocationSessionBindingVector;
|
|
1180
1195
|
};
|
|
1181
1196
|
export declare function decodeRelocationEnvelopeV1(bytes: Uint8Array, context: ServiceWireDecoderContext): RelocationEnvelopeV1;
|
|
1182
1197
|
export declare function encodeRelocationEnvelopeV1(value: RelocationEnvelopeV1, context: ServiceWireDecoderContext): Uint8Array;
|
|
@@ -351,6 +351,10 @@ exports.decodeRelocationPendingTimerTick = decodeRelocationPendingTimerTick;
|
|
|
351
351
|
exports.encodeRelocationPendingTimerTick = encodeRelocationPendingTimerTick;
|
|
352
352
|
exports.decodeRelocationPendingTimerTickVector = decodeRelocationPendingTimerTickVector;
|
|
353
353
|
exports.encodeRelocationPendingTimerTickVector = encodeRelocationPendingTimerTickVector;
|
|
354
|
+
exports.decodeRelocationSessionBinding = decodeRelocationSessionBinding;
|
|
355
|
+
exports.encodeRelocationSessionBinding = encodeRelocationSessionBinding;
|
|
356
|
+
exports.decodeRelocationSessionBindingVector = decodeRelocationSessionBindingVector;
|
|
357
|
+
exports.encodeRelocationSessionBindingVector = encodeRelocationSessionBindingVector;
|
|
354
358
|
exports.decodeRelocationEnvelopeV1 = decodeRelocationEnvelopeV1;
|
|
355
359
|
exports.encodeRelocationEnvelopeV1 = encodeRelocationEnvelopeV1;
|
|
356
360
|
exports.decodeHelloCommand = decodeHelloCommand;
|
|
@@ -8487,6 +8491,141 @@ function writeRelocationPendingTimerTickVector(input, writer, context, enclosing
|
|
|
8487
8491
|
}
|
|
8488
8492
|
function decodeRelocationPendingTimerTickVector(bytes, context) { const reader = new Reader(bytes); const value = readRelocationPendingTimerTickVector(reader, context, {}, 0); reader.done("relocation-pending-timer-tick-vector"); return value; }
|
|
8489
8493
|
function encodeRelocationPendingTimerTickVector(value, context) { const writer = new Writer(); writeRelocationPendingTimerTickVector(value, writer, context, {}, 0); return writer.result(); }
|
|
8494
|
+
function readRelocationSessionBinding(reader, context, enclosing, flags) {
|
|
8495
|
+
void context;
|
|
8496
|
+
void enclosing;
|
|
8497
|
+
void flags;
|
|
8498
|
+
const value = {};
|
|
8499
|
+
value["participantId"] = readNonzeroU64(reader, context, value, flags);
|
|
8500
|
+
value["sessionOwnerNodeRid"] = readRid(reader, context, value, flags);
|
|
8501
|
+
value["sessionOwnerNodeGeneration"] = readNonzeroU64(reader, context, value, flags);
|
|
8502
|
+
value["sessionOwnerId"] = readText8(reader, context, value, flags);
|
|
8503
|
+
value["sessionOwnerLeaseGeneration"] = readNonzeroU64(reader, context, value, flags);
|
|
8504
|
+
value["sessionRid"] = readRid(reader, context, value, flags);
|
|
8505
|
+
value["bindingGeneration"] = readNonzeroU64(reader, context, value, flags);
|
|
8506
|
+
return value;
|
|
8507
|
+
}
|
|
8508
|
+
function* readIncrementalRelocationSessionBinding(reader, context, enclosing, flags) {
|
|
8509
|
+
void context;
|
|
8510
|
+
void enclosing;
|
|
8511
|
+
void flags;
|
|
8512
|
+
const value = {};
|
|
8513
|
+
value["participantId"] = yield* readIncrementalNonzeroU64(reader, context, value, flags);
|
|
8514
|
+
value["sessionOwnerNodeRid"] = yield* readIncrementalRid(reader, context, value, flags);
|
|
8515
|
+
value["sessionOwnerNodeGeneration"] = yield* readIncrementalNonzeroU64(reader, context, value, flags);
|
|
8516
|
+
value["sessionOwnerId"] = yield* readIncrementalText8(reader, context, value, flags);
|
|
8517
|
+
value["sessionOwnerLeaseGeneration"] = yield* readIncrementalNonzeroU64(reader, context, value, flags);
|
|
8518
|
+
value["sessionRid"] = yield* readIncrementalRid(reader, context, value, flags);
|
|
8519
|
+
value["bindingGeneration"] = yield* readIncrementalNonzeroU64(reader, context, value, flags);
|
|
8520
|
+
return value;
|
|
8521
|
+
}
|
|
8522
|
+
function writeRelocationSessionBinding(input, writer, context, enclosing, flags) {
|
|
8523
|
+
void context;
|
|
8524
|
+
void enclosing;
|
|
8525
|
+
void flags;
|
|
8526
|
+
const value = input;
|
|
8527
|
+
if (value["participantId"] === undefined)
|
|
8528
|
+
fail("participantId required");
|
|
8529
|
+
writeNonzeroU64(numeric(value["participantId"]), writer, context, value, flags);
|
|
8530
|
+
if (value["sessionOwnerNodeRid"] === undefined)
|
|
8531
|
+
fail("sessionOwnerNodeRid required");
|
|
8532
|
+
writeRid(value["sessionOwnerNodeRid"], writer, context, value, flags);
|
|
8533
|
+
if (value["sessionOwnerNodeGeneration"] === undefined)
|
|
8534
|
+
fail("sessionOwnerNodeGeneration required");
|
|
8535
|
+
writeNonzeroU64(numeric(value["sessionOwnerNodeGeneration"]), writer, context, value, flags);
|
|
8536
|
+
if (value["sessionOwnerId"] === undefined)
|
|
8537
|
+
fail("sessionOwnerId required");
|
|
8538
|
+
writeText8(value["sessionOwnerId"], writer, context, value, flags);
|
|
8539
|
+
if (value["sessionOwnerLeaseGeneration"] === undefined)
|
|
8540
|
+
fail("sessionOwnerLeaseGeneration required");
|
|
8541
|
+
writeNonzeroU64(numeric(value["sessionOwnerLeaseGeneration"]), writer, context, value, flags);
|
|
8542
|
+
if (value["sessionRid"] === undefined)
|
|
8543
|
+
fail("sessionRid required");
|
|
8544
|
+
writeRid(value["sessionRid"], writer, context, value, flags);
|
|
8545
|
+
if (value["bindingGeneration"] === undefined)
|
|
8546
|
+
fail("bindingGeneration required");
|
|
8547
|
+
writeNonzeroU64(numeric(value["bindingGeneration"]), writer, context, value, flags);
|
|
8548
|
+
}
|
|
8549
|
+
function decodeRelocationSessionBinding(bytes, context) { const reader = new Reader(bytes); const value = readRelocationSessionBinding(reader, context, {}, 0); reader.done("relocation-session-binding"); return value; }
|
|
8550
|
+
function encodeRelocationSessionBinding(value, context) { const writer = new Writer(); writeRelocationSessionBinding(value, writer, context, {}, 0); return writer.result(); }
|
|
8551
|
+
function readRelocationSessionBindingVector(reader, context, enclosing, flags) {
|
|
8552
|
+
void context;
|
|
8553
|
+
void enclosing;
|
|
8554
|
+
void flags;
|
|
8555
|
+
const count = Number(readU32(reader, context, enclosing, flags));
|
|
8556
|
+
if (count > 1024)
|
|
8557
|
+
fail("relocation-session-binding-vector count");
|
|
8558
|
+
const value = Array.from({ length: count }, () => readRelocationSessionBinding(reader, context, enclosing, flags));
|
|
8559
|
+
try {
|
|
8560
|
+
for (let index = 1; index < value.length; ++index)
|
|
8561
|
+
if (compareResults([compareBigint(numeric(value[index - 1]["participantId"]), numeric(value[index]["participantId"]))]) >= 0)
|
|
8562
|
+
fail("relocation-session-binding-vector sorted");
|
|
8563
|
+
}
|
|
8564
|
+
catch (error) {
|
|
8565
|
+
if (error instanceof ServiceWireProtocolError || error instanceof ServiceWireCapacityError)
|
|
8566
|
+
throw error;
|
|
8567
|
+
if (error instanceof RangeError)
|
|
8568
|
+
capacityFail("relocation-session-binding-vector constraint capacity");
|
|
8569
|
+
throw error;
|
|
8570
|
+
}
|
|
8571
|
+
return value;
|
|
8572
|
+
}
|
|
8573
|
+
function* readIncrementalRelocationSessionBindingVector(reader, context, enclosing, flags) {
|
|
8574
|
+
void context;
|
|
8575
|
+
void enclosing;
|
|
8576
|
+
void flags;
|
|
8577
|
+
const count = Number(yield* readIncrementalU32(reader, context, enclosing, flags));
|
|
8578
|
+
if (count > 1024)
|
|
8579
|
+
fail("relocation-session-binding-vector count");
|
|
8580
|
+
const value = [];
|
|
8581
|
+
for (let index = 0; index < count; ++index) {
|
|
8582
|
+
const item = yield* readIncrementalRelocationSessionBinding(reader, context, enclosing, flags);
|
|
8583
|
+
try {
|
|
8584
|
+
value.push(item);
|
|
8585
|
+
}
|
|
8586
|
+
catch {
|
|
8587
|
+
capacityFail("relocation-session-binding-vector capacity");
|
|
8588
|
+
}
|
|
8589
|
+
}
|
|
8590
|
+
try {
|
|
8591
|
+
for (let index = 1; index < value.length; ++index)
|
|
8592
|
+
if (compareResults([compareBigint(numeric(value[index - 1]["participantId"]), numeric(value[index]["participantId"]))]) >= 0)
|
|
8593
|
+
fail("relocation-session-binding-vector sorted");
|
|
8594
|
+
}
|
|
8595
|
+
catch (error) {
|
|
8596
|
+
if (error instanceof ServiceWireProtocolError || error instanceof ServiceWireCapacityError)
|
|
8597
|
+
throw error;
|
|
8598
|
+
if (error instanceof RangeError)
|
|
8599
|
+
capacityFail("relocation-session-binding-vector constraint capacity");
|
|
8600
|
+
throw error;
|
|
8601
|
+
}
|
|
8602
|
+
return value;
|
|
8603
|
+
}
|
|
8604
|
+
function writeRelocationSessionBindingVector(input, writer, context, enclosing, flags) {
|
|
8605
|
+
void context;
|
|
8606
|
+
void enclosing;
|
|
8607
|
+
void flags;
|
|
8608
|
+
const value = input;
|
|
8609
|
+
if (!Array.isArray(value) || value.length > 1024)
|
|
8610
|
+
fail("relocation-session-binding-vector count");
|
|
8611
|
+
try {
|
|
8612
|
+
for (let index = 1; index < value.length; ++index)
|
|
8613
|
+
if (compareResults([compareBigint(numeric(value[index - 1]["participantId"]), numeric(value[index]["participantId"]))]) >= 0)
|
|
8614
|
+
fail("relocation-session-binding-vector sorted");
|
|
8615
|
+
}
|
|
8616
|
+
catch (error) {
|
|
8617
|
+
if (error instanceof ServiceWireProtocolError || error instanceof ServiceWireCapacityError)
|
|
8618
|
+
throw error;
|
|
8619
|
+
if (error instanceof RangeError)
|
|
8620
|
+
capacityFail("relocation-session-binding-vector constraint capacity");
|
|
8621
|
+
throw error;
|
|
8622
|
+
}
|
|
8623
|
+
writeU32(value.length, writer, context, enclosing, flags);
|
|
8624
|
+
for (const item of value)
|
|
8625
|
+
writeRelocationSessionBinding(item, writer, context, enclosing, flags);
|
|
8626
|
+
}
|
|
8627
|
+
function decodeRelocationSessionBindingVector(bytes, context) { const reader = new Reader(bytes); const value = readRelocationSessionBindingVector(reader, context, {}, 0); reader.done("relocation-session-binding-vector"); return value; }
|
|
8628
|
+
function encodeRelocationSessionBindingVector(value, context) { const writer = new Writer(); writeRelocationSessionBindingVector(value, writer, context, {}, 0); return writer.result(); }
|
|
8490
8629
|
function readRelocationEnvelopeV1(reader, context, enclosing, flags) {
|
|
8491
8630
|
void context;
|
|
8492
8631
|
void enclosing;
|
|
@@ -8499,6 +8638,7 @@ function readRelocationEnvelopeV1(reader, context, enclosing, flags) {
|
|
|
8499
8638
|
value["savedWork"] = readSavedWorkVector(reader, context, value, flags);
|
|
8500
8639
|
value["timerRegistrations"] = readRelocationTimerRegistrationVector(reader, context, value, flags);
|
|
8501
8640
|
value["pendingTimerTicks"] = readRelocationPendingTimerTickVector(reader, context, value, flags);
|
|
8641
|
+
value["sessionBindings"] = readRelocationSessionBindingVector(reader, context, value, flags);
|
|
8502
8642
|
return value;
|
|
8503
8643
|
}
|
|
8504
8644
|
function* readIncrementalRelocationEnvelopeV1(reader, context, enclosing, flags) {
|
|
@@ -8513,6 +8653,7 @@ function* readIncrementalRelocationEnvelopeV1(reader, context, enclosing, flags)
|
|
|
8513
8653
|
value["savedWork"] = yield* readIncrementalSavedWorkVector(reader, context, value, flags);
|
|
8514
8654
|
value["timerRegistrations"] = yield* readIncrementalRelocationTimerRegistrationVector(reader, context, value, flags);
|
|
8515
8655
|
value["pendingTimerTicks"] = yield* readIncrementalRelocationPendingTimerTickVector(reader, context, value, flags);
|
|
8656
|
+
value["sessionBindings"] = yield* readIncrementalRelocationSessionBindingVector(reader, context, value, flags);
|
|
8516
8657
|
return value;
|
|
8517
8658
|
}
|
|
8518
8659
|
function writeRelocationEnvelopeV1(input, writer, context, enclosing, flags) {
|
|
@@ -8541,6 +8682,9 @@ function writeRelocationEnvelopeV1(input, writer, context, enclosing, flags) {
|
|
|
8541
8682
|
if (value["pendingTimerTicks"] === undefined)
|
|
8542
8683
|
fail("pendingTimerTicks required");
|
|
8543
8684
|
writeRelocationPendingTimerTickVector(value["pendingTimerTicks"], writer, context, value, flags);
|
|
8685
|
+
if (value["sessionBindings"] === undefined)
|
|
8686
|
+
fail("sessionBindings required");
|
|
8687
|
+
writeRelocationSessionBindingVector(value["sessionBindings"], writer, context, value, flags);
|
|
8544
8688
|
}
|
|
8545
8689
|
function decodeRelocationEnvelopeV1(bytes, context) { const reader = new Reader(bytes); const value = readRelocationEnvelopeV1(reader, context, {}, 0); reader.done("relocation-envelope-v1"); return value; }
|
|
8546
8690
|
function encodeRelocationEnvelopeV1(value, context) { const writer = new Writer(); writeRelocationEnvelopeV1(value, writer, context, {}, 0); return writer.result(); }
|
|
@@ -72,6 +72,15 @@ export interface RelocationEnvelopeV1 {
|
|
|
72
72
|
readonly scheduledAtUnixMilliseconds: bigint;
|
|
73
73
|
readonly skippedTicks: bigint;
|
|
74
74
|
}[];
|
|
75
|
+
readonly sessionBindings: readonly {
|
|
76
|
+
readonly participantId: bigint;
|
|
77
|
+
readonly sessionOwnerNodeRid: Uint8Array;
|
|
78
|
+
readonly sessionOwnerNodeGeneration: bigint;
|
|
79
|
+
readonly sessionOwnerId: string;
|
|
80
|
+
readonly sessionOwnerLeaseGeneration: bigint;
|
|
81
|
+
readonly sessionRid: Uint8Array;
|
|
82
|
+
readonly bindingGeneration: bigint;
|
|
83
|
+
}[];
|
|
75
84
|
}
|
|
76
85
|
export interface RelocationDataChunkV1 {
|
|
77
86
|
readonly order: number;
|
|
@@ -331,6 +331,17 @@ function encodeRelocationEnvelopeV1(value) { const out = []; if (value.relocatio
|
|
|
331
331
|
u64(out, p.scheduledIndex);
|
|
332
332
|
u64(out, p.scheduledAtUnixMilliseconds);
|
|
333
333
|
u64(out, p.skippedTicks);
|
|
334
|
+
} sorted(value.sessionBindings, (a, b) => a.participantId < b.participantId ? -1 : a.participantId > b.participantId ? 1 : 0, "sessionBindings"); if (value.sessionBindings.length > 1024)
|
|
335
|
+
throw new RangeError("bindings count"); u32(out, value.sessionBindings.length); for (const b of value.sessionBindings) {
|
|
336
|
+
if (b.participantId === 0n || b.sessionOwnerNodeGeneration === 0n || b.sessionOwnerLeaseGeneration === 0n || b.bindingGeneration === 0n)
|
|
337
|
+
throw new RangeError("binding");
|
|
338
|
+
u64(out, b.participantId);
|
|
339
|
+
rid(out, b.sessionOwnerNodeRid);
|
|
340
|
+
u64(out, b.sessionOwnerNodeGeneration);
|
|
341
|
+
text8(out, b.sessionOwnerId);
|
|
342
|
+
u64(out, b.sessionOwnerLeaseGeneration);
|
|
343
|
+
rid(out, b.sessionRid);
|
|
344
|
+
u64(out, b.bindingGeneration);
|
|
334
345
|
} if (out.length > 274877906944)
|
|
335
346
|
throw new RangeError("relocation logical bytes"); return Uint8Array.from(out); }
|
|
336
347
|
function decodeRelocationEnvelopeV1(chunks) { const n = chunks.reduce((s, c) => s + c.length, 0); if (n > 274877906944)
|
|
@@ -381,7 +392,9 @@ function decodeRelocationEnvelopeV1(chunks) { const n = chunks.reduce((s, c) =>
|
|
|
381
392
|
if (registeredTimerNames.get(participantId)?.has(timerName) !== true)
|
|
382
393
|
throw new RangeError("pending timer registration");
|
|
383
394
|
pendingTimerTicks.push({ participantId, order, timerName, deliveryIndex: nonzero64(bytes, at, "delivery"), scheduledIndex: nonzero64(bytes, at, "scheduled"), scheduledAtUnixMilliseconds: read64(bytes, at), skippedTicks: read64(bytes, at) });
|
|
384
|
-
}
|
|
395
|
+
} const sessionBindings = []; const bindingCount = read32(bytes, at); if (bindingCount > 1024)
|
|
396
|
+
throw new RangeError("bindings count"); for (let n = 0; n < bindingCount; n++)
|
|
397
|
+
sessionBindings.push({ participantId: nonzero64(bytes, at, "participant"), sessionOwnerNodeRid: readRid(bytes, at), sessionOwnerNodeGeneration: nonzero64(bytes, at, "session node"), sessionOwnerId: readText8(bytes, at), sessionOwnerLeaseGeneration: nonzero64(bytes, at, "session lease"), sessionRid: readRid(bytes, at), bindingGeneration: nonzero64(bytes, at, "binding") }); sorted(sessionBindings, (a, b) => a.participantId < b.participantId ? -1 : a.participantId > b.participantId ? 1 : 0, "sessionBindings"); exactEnd(at, bytes.length, "relocation envelope"); sorted(applicationStates, (a, b) => a.participantId < b.participantId ? -1 : a.participantId > b.participantId ? 1 : 0, "applicationStates"); sorted(savedWork, (a, b) => a.participantId === b.participantId ? (a.order < b.order ? -1 : a.order > b.order ? 1 : 0) : (a.participantId < b.participantId ? -1 : 1), "savedWork"); sorted(timerRegistrations, (a, b) => a.participantId === b.participantId ? compareUtf8(a.name, b.name) : a.participantId < b.participantId ? -1 : 1, "timerRegistrations"); sorted(pendingTimerTicks, (a, b) => a.participantId === b.participantId ? (a.order < b.order ? -1 : a.order > b.order ? 1 : 0) : (a.participantId < b.participantId ? -1 : 1), "pendingTimerTicks"); return { relocationHigh, relocationLow, object, applicationVersion, applicationStates, savedWork, timerRegistrations, pendingTimerTicks, sessionBindings }; }
|
|
385
398
|
function crc32c(bytes) { let crc = 0xffffffff; for (const octet of bytes) {
|
|
386
399
|
crc ^= octet;
|
|
387
400
|
for (let bit = 0; bit < 8; bit++)
|
|
@@ -22,7 +22,7 @@ export interface ZLinkParkedActorArrival {
|
|
|
22
22
|
readonly reject: (reason: unknown) => void;
|
|
23
23
|
}
|
|
24
24
|
export type ZLinkActorJoinIngressRoute = 'parked' | 'not-found';
|
|
25
|
-
export type ZLinkFormalRemoteActorAdmissionState = 'provisional' | 'admitting' | 'admitted' | 'rejected' | 'committed' | 'aborted' | 'failed';
|
|
25
|
+
export type ZLinkFormalRemoteActorAdmissionState = 'provisional' | 'admitting' | 'admitted' | 'restoring' | 'rejected' | 'committed' | 'aborted' | 'failed';
|
|
26
26
|
export interface ZLinkFormalRemoteActorAdmission {
|
|
27
27
|
readonly actorId: string;
|
|
28
28
|
readonly actorType: string;
|
|
@@ -56,7 +56,7 @@ export interface ZLinkFormalRemoteActorAdmissionRecord {
|
|
|
56
56
|
readonly resultTask: Promise<ZLinkFormalRemoteActorAdmissionResult>;
|
|
57
57
|
}
|
|
58
58
|
interface ZLinkFormalRemoteActorAdmissionEntry extends ZLinkFormalRemoteActorAdmissionRecord {
|
|
59
|
-
|
|
59
|
+
timer: ReturnType<typeof setTimeout>;
|
|
60
60
|
readonly resolveResult: (result: ZLinkFormalRemoteActorAdmissionResult) => void;
|
|
61
61
|
admission: ZLinkFormalRemoteActorAdmission;
|
|
62
62
|
state: ZLinkFormalRemoteActorAdmissionState;
|
|
@@ -70,6 +70,11 @@ export declare class ZLinkFormalRemoteActorAdmissionRegistry {
|
|
|
70
70
|
private readonly admissions;
|
|
71
71
|
private readonly byObject;
|
|
72
72
|
get(transferId: string): ZLinkFormalRemoteActorAdmissionEntry | undefined;
|
|
73
|
+
/** PREPARE transfers prepared resources to the target attempt until its terminal. */
|
|
74
|
+
beginRestore(transferId: string): void;
|
|
75
|
+
/** Retains successful commit replay; unsuccessful attempts release their resources now. */
|
|
76
|
+
finishRestore(transferId: string): void;
|
|
77
|
+
private scheduleExpiry;
|
|
73
78
|
begin(input: ZLinkFormalRemoteActorAdmission): {
|
|
74
79
|
readonly record: ZLinkFormalRemoteActorAdmissionEntry;
|
|
75
80
|
readonly created: boolean;
|
|
@@ -17,6 +17,34 @@ class ZLinkFormalRemoteActorAdmissionRegistry {
|
|
|
17
17
|
get(transferId) {
|
|
18
18
|
return this.admissions.get(transferId);
|
|
19
19
|
}
|
|
20
|
+
/** PREPARE transfers prepared resources to the target attempt until its terminal. */
|
|
21
|
+
beginRestore(transferId) {
|
|
22
|
+
const entry = this.admissions.get(transferId);
|
|
23
|
+
if (entry === undefined || (entry.state !== 'admitted' && entry.state !== 'restoring')) {
|
|
24
|
+
throw new Error(`Remote actor admission '${transferId}' is not ready to restore.`);
|
|
25
|
+
}
|
|
26
|
+
clearTimeout(entry.timer);
|
|
27
|
+
entry.state = 'restoring';
|
|
28
|
+
}
|
|
29
|
+
/** Retains successful commit replay; unsuccessful attempts release their resources now. */
|
|
30
|
+
finishRestore(transferId) {
|
|
31
|
+
const entry = this.admissions.get(transferId);
|
|
32
|
+
if (entry === undefined)
|
|
33
|
+
return;
|
|
34
|
+
if (entry.state === 'committed') {
|
|
35
|
+
clearTimeout(entry.timer);
|
|
36
|
+
entry.timer = this.scheduleExpiry(transferId);
|
|
37
|
+
}
|
|
38
|
+
else {
|
|
39
|
+
this.abort(transferId);
|
|
40
|
+
this.delete(transferId);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
scheduleExpiry(transferId) {
|
|
44
|
+
const timer = setTimeout(() => this.delete(transferId), ADMISSION_RETENTION_MS);
|
|
45
|
+
timer.unref();
|
|
46
|
+
return timer;
|
|
47
|
+
}
|
|
20
48
|
begin(input) {
|
|
21
49
|
const existing = this.admissions.get(input.transferId);
|
|
22
50
|
if (existing !== undefined) {
|
|
@@ -71,10 +99,7 @@ class ZLinkFormalRemoteActorAdmissionRegistry {
|
|
|
71
99
|
const resultTask = new Promise((resolve) => {
|
|
72
100
|
resolveResult = resolve;
|
|
73
101
|
});
|
|
74
|
-
const timer =
|
|
75
|
-
this.delete(input.transferId);
|
|
76
|
-
}, ADMISSION_RETENTION_MS);
|
|
77
|
-
timer.unref();
|
|
102
|
+
const timer = this.scheduleExpiry(input.transferId);
|
|
78
103
|
const entry = {
|
|
79
104
|
admission: input,
|
|
80
105
|
state,
|
|
@@ -186,7 +211,7 @@ class ZLinkFormalRemoteActorAdmissionRegistry {
|
|
|
186
211
|
const entry = this.admissions.get(transferId);
|
|
187
212
|
if (entry === undefined)
|
|
188
213
|
return;
|
|
189
|
-
if (entry.state !== 'admitted' && entry.state !== 'committed') {
|
|
214
|
+
if (entry.state !== 'admitted' && entry.state !== 'restoring' && entry.state !== 'committed') {
|
|
190
215
|
throw new Error(`Remote actor admission '${transferId}' is not ready to commit.`);
|
|
191
216
|
}
|
|
192
217
|
entry.state = 'committed';
|
|
@@ -195,7 +220,7 @@ class ZLinkFormalRemoteActorAdmissionRegistry {
|
|
|
195
220
|
attachDeferredJoinCompletion(transferId, root) {
|
|
196
221
|
const entry = this.admissions.get(transferId);
|
|
197
222
|
if (entry === undefined ||
|
|
198
|
-
entry.state !== 'admitted' ||
|
|
223
|
+
(entry.state !== 'admitted' && entry.state !== 'restoring') ||
|
|
199
224
|
entry.result === undefined ||
|
|
200
225
|
'error' in entry.result ||
|
|
201
226
|
!entry.result.accepted) {
|
|
@@ -227,7 +252,7 @@ class ZLinkFormalRemoteActorAdmissionRegistry {
|
|
|
227
252
|
*/
|
|
228
253
|
delete(transferId) {
|
|
229
254
|
const pending = this.admissions.get(transferId);
|
|
230
|
-
if (pending === undefined)
|
|
255
|
+
if (pending === undefined || pending.state === 'restoring')
|
|
231
256
|
return;
|
|
232
257
|
clearTimeout(pending.timer);
|
|
233
258
|
this.admissions.delete(transferId);
|
|
@@ -240,18 +265,7 @@ class ZLinkFormalRemoteActorAdmissionRegistry {
|
|
|
240
265
|
}
|
|
241
266
|
exports.ZLinkFormalRemoteActorAdmissionRegistry = ZLinkFormalRemoteActorAdmissionRegistry;
|
|
242
267
|
function sameAdmission(left, right) {
|
|
243
|
-
return
|
|
244
|
-
left.actorType === right.actorType &&
|
|
245
|
-
String(left.spotId) === String(right.spotId) &&
|
|
246
|
-
left.targetSpotGeneration === right.targetSpotGeneration &&
|
|
247
|
-
left.expectedMembershipEpoch === right.expectedMembershipEpoch &&
|
|
248
|
-
left.requestFingerprint === right.requestFingerprint &&
|
|
249
|
-
sameOperationId(left.completionOperationId, right.completionOperationId) &&
|
|
250
|
-
String(left.sourceSpotId ?? '') === String(right.sourceSpotId ?? '') &&
|
|
251
|
-
String(left.sourceActorNodeRid ?? '') === String(right.sourceActorNodeRid ?? '') &&
|
|
252
|
-
left.actorRef.actorId === right.actorRef.actorId &&
|
|
253
|
-
String(left.actorRef.nodeRid) === String(right.actorRef.nodeRid) &&
|
|
254
|
-
left.actorRef.objectGeneration === right.actorRef.objectGeneration);
|
|
268
|
+
return left.actorType === right.actorType && sameProvisionalAdmission(left, right);
|
|
255
269
|
}
|
|
256
270
|
function sameProvisionalAdmission(left, right) {
|
|
257
271
|
return (left.actorId === right.actorId &&
|
|
@@ -64,6 +64,7 @@ export interface ZLinkSpotManagerOptions {
|
|
|
64
64
|
readonly dispatchEntryActorJoin?: (meshName: string, actor: ZLinkActor, handoffBacklog?: readonly ZLinkActorHandoffPacket[]) => Promise<void>;
|
|
65
65
|
readonly executeEntryActor?: <T>(meshName: string, actorId: string, operation: () => Promise<T>) => Promise<T>;
|
|
66
66
|
readonly actorCountProvider?: (spotId: RoutingId) => number;
|
|
67
|
+
readonly releaseActorMembers?: (meshName: string, spotId: RoutingId) => Promise<void>;
|
|
67
68
|
readonly userSpotExecutionMode?: (meshName: string, spotType: Type<ZLinkSpot>) => import('../../contracts').ZLinkUserSpotExecutionMode;
|
|
68
69
|
readonly userSpotRelocationCoordinationMode?: (meshName: string, spotType: Type<ZLinkSpot>) => import('../../contracts').ZLinkSpotRelocationCoordinationMode;
|
|
69
70
|
readonly actorDispatchOwnerResolver?: (actorId: string) => {
|
|
@@ -215,6 +216,7 @@ export declare class DefaultZLinkSpotManager {
|
|
|
215
216
|
readonly workOptions?: import('../execution/serial-execution-queue').ZLinkSerialWorkOptions;
|
|
216
217
|
readonly admissionTimeoutMs?: number;
|
|
217
218
|
readonly signal?: AbortSignal;
|
|
219
|
+
readonly onAdmitted?: () => void;
|
|
218
220
|
}): Promise<TReply>;
|
|
219
221
|
dispatchMeshSpot(meshName: string, owner: ReadyRecord, record: ReceiveRecord): Promise<void>;
|
|
220
222
|
private ensureInstanceApplicationActivation;
|
|
@@ -228,6 +230,7 @@ export declare class DefaultZLinkSpotManager {
|
|
|
228
230
|
private dispatchMeshSpotControlCore;
|
|
229
231
|
completeFormalSourceLeaveTerminal(actorId: string, transferId: string, succeeded: boolean): Promise<boolean>;
|
|
230
232
|
finalizeActorJoinRelocation(meshName: string, relocationId: string, actor: ZLinkActor, actorRef: ActorRef, submitSourceLeave: (sourceNodeRid: RoutingId) => Promise<void>, signal?: AbortSignal): Promise<boolean>;
|
|
233
|
+
beginActorJoinRelocation(relocationId: string): () => void;
|
|
231
234
|
restoreCanonicalActorJoinRecovery(recovery: CanonicalActorJoinRecovery, signal?: AbortSignal): Promise<void>;
|
|
232
235
|
private encodeMeshActorReply;
|
|
233
236
|
private createActivation;
|
|
@@ -130,6 +130,7 @@ class DefaultZLinkSpotManager {
|
|
|
130
130
|
nodeRid: options.nodeRid,
|
|
131
131
|
nodeRidProvider: options.nodeRidProvider,
|
|
132
132
|
actorCountProvider: options.actorCountProvider,
|
|
133
|
+
releaseActorMembers: options.releaseActorMembers,
|
|
133
134
|
userSpotExecutionMode: options.userSpotExecutionMode,
|
|
134
135
|
userSpotRelocationCoordinationMode: options.userSpotRelocationCoordinationMode,
|
|
135
136
|
channelClient: options.channelClient,
|
|
@@ -1894,7 +1895,7 @@ class DefaultZLinkSpotManager {
|
|
|
1894
1895
|
const outcome = admission.result ?? (await admission.resultTask);
|
|
1895
1896
|
if ('error' in outcome)
|
|
1896
1897
|
throw outcome.error;
|
|
1897
|
-
if (!outcome.accepted || admission.state !== 'admitted') {
|
|
1898
|
+
if (!outcome.accepted || (admission.state !== 'admitted' && admission.state !== 'restoring')) {
|
|
1898
1899
|
throw new Error(`Actor Join relocation '${relocationId}' has no accepted admission.`);
|
|
1899
1900
|
}
|
|
1900
1901
|
const entrySpotId = this.options.entryNodeRidProvider?.() ?? this.options.entryNodeRid;
|
|
@@ -1944,6 +1945,10 @@ class DefaultZLinkSpotManager {
|
|
|
1944
1945
|
this.formalRemoteActorAdmissions.markCommitted(relocationId, actor);
|
|
1945
1946
|
return true;
|
|
1946
1947
|
}
|
|
1948
|
+
beginActorJoinRelocation(relocationId) {
|
|
1949
|
+
this.formalRemoteActorAdmissions.beginRestore(relocationId);
|
|
1950
|
+
return () => this.formalRemoteActorAdmissions.finishRestore(relocationId);
|
|
1951
|
+
}
|
|
1947
1952
|
async restoreCanonicalActorJoinRecovery(recovery, signal) {
|
|
1948
1953
|
(0, abort_1.throwIfAborted)(signal);
|
|
1949
1954
|
const admission = this.formalRemoteActorAdmissions.get(recovery.request.handoffId);
|
|
@@ -1951,7 +1956,9 @@ class DefaultZLinkSpotManager {
|
|
|
1951
1956
|
throw new Error(`Actor Join recovery '${recovery.request.handoffId}' has no canonical command-28 admission.`);
|
|
1952
1957
|
}
|
|
1953
1958
|
const outcome = admission.result ?? (await admission.resultTask);
|
|
1954
|
-
if ('error' in outcome ||
|
|
1959
|
+
if ('error' in outcome ||
|
|
1960
|
+
!outcome.accepted ||
|
|
1961
|
+
(admission.state !== 'admitted' && admission.state !== 'restoring')) {
|
|
1955
1962
|
throw new Error(`Actor Join recovery '${recovery.request.handoffId}' has no accepted admission.`);
|
|
1956
1963
|
}
|
|
1957
1964
|
const admitted = admission.admission;
|
|
@@ -29,6 +29,7 @@ export interface ZLinkSpotActivationLifecycleOptions {
|
|
|
29
29
|
readonly nodeRid?: RoutingId;
|
|
30
30
|
readonly nodeRidProvider?: (meshName: string) => RoutingId | undefined;
|
|
31
31
|
readonly actorCountProvider?: (spotId: RoutingId) => number;
|
|
32
|
+
readonly releaseActorMembers?: (meshName: string, spotId: RoutingId) => Promise<void>;
|
|
32
33
|
readonly userSpotExecutionMode?: (meshName: string, spotType: Type<ZLinkSpot>) => ZLinkUserSpotExecutionMode;
|
|
33
34
|
readonly userSpotRelocationCoordinationMode?: (meshName: string, spotType: Type<ZLinkSpot>) => ZLinkSpotRelocationCoordinationMode;
|
|
34
35
|
readonly channelClient?: ZLinkChannelClient;
|