@zlink-systems/framework 0.27.0 → 0.28.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/Actors/ZLinkActorClient.d.ts +1 -1
- package/dist/contracts/Channels/Calls.d.ts +1 -1
- package/dist/contracts/Configuration/Builders.d.ts +0 -1
- package/dist/contracts/Configuration/Configs.d.ts +0 -1
- package/dist/contracts/Configuration/RegistrationTypes.d.ts +0 -5
- package/dist/contracts/Configuration/RegistrationValidators.js +0 -2
- package/dist/contracts/Spots/Contracts.d.ts +1 -1
- package/dist/contracts/Streams/BoundSessionContracts.d.ts +1 -1
- package/dist/contracts/Streams/IZLinkSession.d.ts +2 -3
- package/dist/contracts/Streams/IZLinkSessionActor.d.ts +2 -2
- package/dist/runtime/actors/actor-client.js +7 -10
- package/dist/runtime/actors/actor-request-deadline.d.ts +1 -3
- package/dist/runtime/actors/actor-request-deadline.js +4 -29
- package/dist/runtime/actors/actor-routed-join-transport.d.ts +2 -3
- package/dist/runtime/backend/contracts/index.d.ts +1 -4
- package/dist/runtime/backend/node/node-backend-adapter-support.d.ts +2 -0
- package/dist/runtime/backend/node/node-backend-adapter-support.js +35 -4
- 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 +1 -2
- package/dist/runtime/backend/node/node-raw-binding-port.js +10 -27
- package/dist/runtime/backend/node/node-socket-backend-adapter.js +1 -1
- package/dist/runtime/channels/channel-clients.js +8 -10
- package/dist/runtime/channels/channel-envelope.d.ts +1 -1
- package/dist/runtime/channels/channel-envelope.js +4 -10
- package/dist/runtime/channels/channel-outbound-operations.d.ts +2 -2
- package/dist/runtime/channels/channel-outbound-operations.js +20 -36
- package/dist/runtime/channels/channel-runtime-manager.d.ts +4 -4
- package/dist/runtime/channels/channel-runtime-manager.js +8 -8
- package/dist/runtime/channels/channel-socket-options.js +0 -10
- package/dist/runtime/channels/channel-socket-registry.d.ts +1 -1
- package/dist/runtime/channels/channel-socket-registry.js +3 -14
- package/dist/runtime/channels/channel-transports.d.ts +10 -14
- package/dist/runtime/channels/channel-transports.js +11 -14
- package/dist/runtime/channels/local-spot-route-transport.d.ts +1 -1
- package/dist/runtime/channels/local-spot-route-transport.js +1 -3
- package/dist/runtime/channels/router-socket-spot-route-transport.d.ts +1 -1
- package/dist/runtime/channels/router-socket-spot-route-transport.js +2 -2
- package/dist/runtime/channels/source-spot-router.d.ts +1 -1
- package/dist/runtime/channels/source-spot-router.js +2 -4
- package/dist/runtime/channels/spot-node-route-transport.d.ts +1 -1
- package/dist/runtime/channels/spot-node-route-transport.js +2 -3
- package/dist/runtime/channels/spot-route-bridge-transport.d.ts +1 -1
- package/dist/runtime/channels/spot-route-bridge-transport.js +2 -2
- package/dist/runtime/channels/spot-route-dispatch-strategy.d.ts +2 -4
- package/dist/runtime/channels/spot-route-dispatch-strategy.js +11 -12
- package/dist/runtime/foundation/raw-service-mesh-runtime.js +17 -11
- package/dist/runtime/host/actor-packet-relay.d.ts +2 -2
- package/dist/runtime/host/actor-packet-relay.js +8 -10
- package/dist/runtime/host/index.js +1 -15
- package/dist/runtime/host/remote-bound-session-relay.js +8 -8
- package/dist/runtime/host/spot-address-transport.d.ts +1 -9
- package/dist/runtime/host/spot-address-transport.js +46 -86
- package/dist/runtime/locations/location-store-repository.js +6 -4
- package/dist/runtime/messaging/request-deadline.d.ts +3 -0
- package/dist/runtime/messaging/request-deadline.js +39 -0
- package/dist/runtime/messaging/submission-result.d.ts +2 -1
- package/dist/runtime/messaging/submission-result.js +11 -4
- package/dist/runtime/spots/spot-outbound.d.ts +3 -5
- package/dist/runtime/spots/spot-outbound.js +12 -15
- package/dist/runtime/streams/bound-actor-relay-sender.d.ts +2 -2
- package/dist/runtime/streams/bound-actor-relay-sender.js +14 -14
- package/dist/runtime/streams/bound-session-service.js +1 -1
- package/dist/runtime/streams/index.d.ts +2 -2
- package/dist/runtime/streams/index.js +2 -2
- package/dist/runtime/streams/managed-stream.d.ts +2 -2
- package/dist/runtime/streams/managed-stream.js +3 -5
- package/dist/runtime/streams/native-fallback-bound-session.js +13 -16
- package/dist/runtime/streams/session-calls.d.ts +5 -7
- package/dist/runtime/streams/session-calls.js +6 -23
- package/dist/runtime/streams/session-context.d.ts +4 -4
- package/dist/runtime/streams/session-context.js +3 -6
- package/package.json +3 -3
- package/src/contracts/Actors/ZLinkActorClient.ts +1 -1
- package/src/contracts/Channels/Calls.ts +1 -1
- package/src/contracts/Configuration/Builders.ts +0 -1
- package/src/contracts/Configuration/Configs.ts +0 -1
- package/src/contracts/Configuration/RegistrationBuilders.ts +0 -3
- package/src/contracts/Configuration/RegistrationTypes.ts +0 -5
- package/src/contracts/Configuration/RegistrationValidators.ts +0 -4
- package/src/contracts/Spots/Contracts.ts +1 -1
- package/src/contracts/Streams/BoundSessionContracts.ts +1 -1
- package/src/contracts/Streams/IZLinkSession.ts +2 -3
- package/src/contracts/Streams/IZLinkSessionActor.ts +2 -6
- package/src/runtime/actors/actor-client.ts +9 -15
- package/src/runtime/actors/actor-request-deadline.ts +4 -49
- package/src/runtime/actors/actor-routed-join-transport.ts +3 -5
- package/src/runtime/backend/contracts/index.ts +1 -8
- package/src/runtime/backend/node/node-backend-adapter-support.ts +45 -5
- package/src/runtime/backend/node/node-dealer-channel-client-transport.ts +0 -2
- package/src/runtime/backend/node/node-raw-binding-port.ts +15 -41
- package/src/runtime/backend/node/node-socket-backend-adapter.ts +1 -1
- package/src/runtime/channels/channel-clients.ts +9 -19
- package/src/runtime/channels/channel-envelope.ts +16 -28
- package/src/runtime/channels/channel-outbound-operations.ts +36 -38
- package/src/runtime/channels/channel-runtime-manager.ts +6 -28
- package/src/runtime/channels/channel-socket-options.ts +0 -13
- package/src/runtime/channels/channel-socket-registry.ts +3 -17
- package/src/runtime/channels/channel-transports.ts +7 -33
- package/src/runtime/channels/local-spot-route-transport.ts +1 -5
- package/src/runtime/channels/router-socket-spot-route-transport.ts +2 -6
- package/src/runtime/channels/source-spot-router.ts +2 -9
- package/src/runtime/channels/spot-node-route-transport.ts +2 -7
- package/src/runtime/channels/spot-route-bridge-transport.ts +5 -12
- package/src/runtime/channels/spot-route-dispatch-strategy.ts +11 -30
- package/src/runtime/foundation/raw-service-mesh-runtime.ts +17 -14
- package/src/runtime/host/actor-packet-relay.ts +8 -15
- package/src/runtime/host/index.ts +2 -26
- package/src/runtime/host/remote-bound-session-relay.ts +8 -16
- package/src/runtime/host/spot-address-transport.ts +106 -165
- package/src/runtime/locations/location-store-repository.ts +7 -4
- package/src/runtime/messaging/request-deadline.ts +58 -0
- package/src/runtime/messaging/submission-result.ts +18 -4
- package/src/runtime/spots/spot-outbound.ts +14 -24
- package/src/runtime/streams/bound-actor-relay-sender.ts +12 -26
- package/src/runtime/streams/bound-session-service.ts +1 -1
- package/src/runtime/streams/index.ts +2 -4
- package/src/runtime/streams/managed-stream.ts +3 -13
- package/src/runtime/streams/native-fallback-bound-session.ts +13 -25
- package/src/runtime/streams/session-calls.ts +8 -34
- package/src/runtime/streams/session-context.ts +6 -15
|
@@ -13,9 +13,7 @@ export class ZLinkLocalSpotRouteTransport {
|
|
|
13
13
|
spotId: RoutingId,
|
|
14
14
|
packetName: string | undefined,
|
|
15
15
|
message: unknown,
|
|
16
|
-
|
|
17
|
-
metadata?: ReadonlyMap<string, string>,
|
|
18
|
-
timeoutMs?: number
|
|
16
|
+
metadata?: ReadonlyMap<string, string>
|
|
19
17
|
): Promise<void> {
|
|
20
18
|
if (this.dispatcher === undefined) {
|
|
21
19
|
throw new ZLinkConfigurationException(
|
|
@@ -24,8 +22,6 @@ export class ZLinkLocalSpotRouteTransport {
|
|
|
24
22
|
}
|
|
25
23
|
await this.dispatcher.send(spotId, packetName, message, {
|
|
26
24
|
channelName: routerChannelId,
|
|
27
|
-
admissionTimeoutMs: timeoutMs ?? this.defaultRequestTimeoutMs,
|
|
28
|
-
signal,
|
|
29
25
|
metadata
|
|
30
26
|
});
|
|
31
27
|
}
|
|
@@ -15,15 +15,11 @@ export class ZLinkRouterSocketSpotRouteTransport {
|
|
|
15
15
|
async send(
|
|
16
16
|
target: ZLinkSpotRouteTarget,
|
|
17
17
|
parts: readonly Message[],
|
|
18
|
-
flags: ZLinkBackendSendFlags
|
|
19
|
-
signal?: AbortSignal
|
|
18
|
+
flags: ZLinkBackendSendFlags
|
|
20
19
|
): Promise<void> {
|
|
21
20
|
const router = this.sockets.routeRouter(target.routerChannelId);
|
|
22
21
|
try {
|
|
23
|
-
await
|
|
24
|
-
router.sendToSpot(target.targetNodeRid, target.spotId, parts, flags),
|
|
25
|
-
signal
|
|
26
|
-
);
|
|
22
|
+
await router.sendToSpot(target.targetNodeRid, target.spotId, parts, flags);
|
|
27
23
|
} finally {
|
|
28
24
|
closeMessages(parts);
|
|
29
25
|
}
|
|
@@ -47,11 +47,8 @@ export class ZLinkSourceSpotRouter {
|
|
|
47
47
|
target: ZLinkSpotRouteTarget,
|
|
48
48
|
packetName: string | undefined,
|
|
49
49
|
message: unknown,
|
|
50
|
-
|
|
51
|
-
metadata?: ReadonlyMap<string, string>,
|
|
52
|
-
timeoutMs?: number
|
|
50
|
+
metadata?: ReadonlyMap<string, string>
|
|
53
51
|
): Promise<void> {
|
|
54
|
-
throwIfAborted(signal);
|
|
55
52
|
const parts = [
|
|
56
53
|
encodeSpotDirectEnvelope(
|
|
57
54
|
ZLinkChannelMessageKind.Command,
|
|
@@ -62,11 +59,7 @@ export class ZLinkSourceSpotRouter {
|
|
|
62
59
|
)
|
|
63
60
|
] as readonly Message[];
|
|
64
61
|
try {
|
|
65
|
-
|
|
66
|
-
await awaitWithAbort(
|
|
67
|
-
sourceSpot.sendToSpot(target.targetNodeRid, target.spotId, parts),
|
|
68
|
-
signal
|
|
69
|
-
);
|
|
62
|
+
await sourceSpot.sendToSpot(target.targetNodeRid, target.spotId, parts);
|
|
70
63
|
} finally {
|
|
71
64
|
closeMessages(parts);
|
|
72
65
|
}
|
|
@@ -16,18 +16,13 @@ export class ZLinkSpotNodeRouteTransport {
|
|
|
16
16
|
private readonly targets: ZLinkSpotRouteTargetResolver
|
|
17
17
|
) {}
|
|
18
18
|
|
|
19
|
-
async send(
|
|
20
|
-
target: ZLinkSpotRouteTarget,
|
|
21
|
-
parts: readonly Message[],
|
|
22
|
-
signal?: AbortSignal
|
|
23
|
-
): Promise<boolean> {
|
|
19
|
+
async send(target: ZLinkSpotRouteTarget, parts: readonly Message[]): Promise<boolean> {
|
|
24
20
|
const router = this.targets.spotNodeRouter(target.routerChannelId);
|
|
25
21
|
if (router === undefined) {
|
|
26
22
|
return false;
|
|
27
23
|
}
|
|
28
24
|
try {
|
|
29
|
-
|
|
30
|
-
await awaitWithAbort(router.sendToSpot(target.targetNodeRid, target.spotId, parts), signal);
|
|
25
|
+
await router.sendToSpot(target.targetNodeRid, target.spotId, parts);
|
|
31
26
|
return true;
|
|
32
27
|
} finally {
|
|
33
28
|
closeMessages(parts);
|
|
@@ -20,20 +20,13 @@ export class ZLinkSpotRouteBridgeTransport {
|
|
|
20
20
|
return this.bridges.has(routerChannelId);
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
-
async send(
|
|
24
|
-
target: ZLinkSpotRouteTarget,
|
|
25
|
-
parts: readonly Message[],
|
|
26
|
-
signal?: AbortSignal
|
|
27
|
-
): Promise<void> {
|
|
23
|
+
async send(target: ZLinkSpotRouteTarget, parts: readonly Message[]): Promise<void> {
|
|
28
24
|
const bridge = this.requireBridge(target.routerChannelId);
|
|
29
25
|
try {
|
|
30
|
-
await
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
).submit(),
|
|
35
|
-
signal
|
|
36
|
-
);
|
|
26
|
+
await appendParts(
|
|
27
|
+
bridge.send(target.routerChannelId, target.targetNodeRid, target.spotId),
|
|
28
|
+
parts
|
|
29
|
+
).submit();
|
|
37
30
|
} finally {
|
|
38
31
|
closeMessages(parts);
|
|
39
32
|
}
|
|
@@ -32,8 +32,6 @@ export interface ZLinkLocalSpotRouteDispatcher {
|
|
|
32
32
|
message: unknown,
|
|
33
33
|
context: {
|
|
34
34
|
readonly channelName: string;
|
|
35
|
-
readonly admissionTimeoutMs?: number;
|
|
36
|
-
readonly signal?: AbortSignal;
|
|
37
35
|
readonly metadata?: ReadonlyMap<string, string>;
|
|
38
36
|
}
|
|
39
37
|
): Promise<void>;
|
|
@@ -101,14 +99,12 @@ export class ZLinkSpotRouteDispatchStrategy {
|
|
|
101
99
|
spotRouteTarget: ZLinkSpotRouteTarget,
|
|
102
100
|
packetName: string | undefined,
|
|
103
101
|
message: unknown,
|
|
104
|
-
|
|
105
|
-
metadata?: ReadonlyMap<string, string>,
|
|
106
|
-
timeoutMs?: number
|
|
102
|
+
metadata?: ReadonlyMap<string, string>
|
|
107
103
|
): Promise<void> {
|
|
108
104
|
// Call-scoped flow (spec 27 §4): the envelope flow pair lives only for
|
|
109
105
|
// the duration of this outbound call, never in the caller's context.
|
|
110
106
|
return runWithOutboundFlow(this.options.flowCreationEnabled?.() ?? true, () =>
|
|
111
|
-
this.routeSendToSpotScoped(spotRouteTarget, packetName, message,
|
|
107
|
+
this.routeSendToSpotScoped(spotRouteTarget, packetName, message, metadata)
|
|
112
108
|
);
|
|
113
109
|
}
|
|
114
110
|
|
|
@@ -116,11 +112,8 @@ export class ZLinkSpotRouteDispatchStrategy {
|
|
|
116
112
|
spotRouteTarget: ZLinkSpotRouteTarget,
|
|
117
113
|
packetName: string | undefined,
|
|
118
114
|
message: unknown,
|
|
119
|
-
|
|
120
|
-
metadata?: ReadonlyMap<string, string>,
|
|
121
|
-
timeoutMs?: number
|
|
115
|
+
metadata?: ReadonlyMap<string, string>
|
|
122
116
|
): Promise<void> {
|
|
123
|
-
throwIfAborted(signal);
|
|
124
117
|
const localSpotRouteNode = this.targets.localRouteNode(spotRouteTarget);
|
|
125
118
|
if (localSpotRouteNode !== undefined) {
|
|
126
119
|
await this.localTransport.send(
|
|
@@ -128,9 +121,7 @@ export class ZLinkSpotRouteDispatchStrategy {
|
|
|
128
121
|
spotRouteTarget.spotId,
|
|
129
122
|
packetName,
|
|
130
123
|
message,
|
|
131
|
-
|
|
132
|
-
metadata,
|
|
133
|
-
timeoutMs
|
|
124
|
+
metadata
|
|
134
125
|
);
|
|
135
126
|
return;
|
|
136
127
|
}
|
|
@@ -148,22 +139,22 @@ export class ZLinkSpotRouteDispatchStrategy {
|
|
|
148
139
|
) as readonly Message[];
|
|
149
140
|
if (
|
|
150
141
|
this.targets.hasNamedSpotNode(spotRouteTarget.routerChannelId) &&
|
|
151
|
-
(await this.spotNodeTransport.send(spotRouteTarget, parts
|
|
142
|
+
(await this.spotNodeTransport.send(spotRouteTarget, parts))
|
|
152
143
|
) {
|
|
153
144
|
return;
|
|
154
145
|
}
|
|
155
146
|
if (this.bridgeTransport.has(spotRouteTarget.routerChannelId)) {
|
|
156
|
-
await this.bridgeTransport.send(spotRouteTarget, parts
|
|
147
|
+
await this.bridgeTransport.send(spotRouteTarget, parts);
|
|
157
148
|
return;
|
|
158
149
|
}
|
|
159
150
|
if (this.targets.hasBoundRouteRouter(spotRouteTarget.routerChannelId)) {
|
|
160
|
-
await this.routerSocketTransport.send(spotRouteTarget, parts, ZLINK_SEND_DONT_WAIT
|
|
151
|
+
await this.routerSocketTransport.send(spotRouteTarget, parts, ZLINK_SEND_DONT_WAIT);
|
|
161
152
|
return;
|
|
162
153
|
}
|
|
163
|
-
if (await this.spotNodeTransport.send(spotRouteTarget, parts
|
|
154
|
+
if (await this.spotNodeTransport.send(spotRouteTarget, parts)) {
|
|
164
155
|
return;
|
|
165
156
|
}
|
|
166
|
-
await this.routerSocketTransport.send(spotRouteTarget, parts, ZLINK_SEND_DONT_WAIT
|
|
157
|
+
await this.routerSocketTransport.send(spotRouteTarget, parts, ZLINK_SEND_DONT_WAIT);
|
|
167
158
|
}
|
|
168
159
|
|
|
169
160
|
routeRequestToSpot<TReply>(
|
|
@@ -291,19 +282,9 @@ export class ZLinkSpotRouteDispatchStrategy {
|
|
|
291
282
|
spotRouteTarget: ZLinkSpotRouteTarget,
|
|
292
283
|
packetName: string | undefined,
|
|
293
284
|
message: unknown,
|
|
294
|
-
|
|
295
|
-
metadata?: ReadonlyMap<string, string>,
|
|
296
|
-
timeoutMs?: number
|
|
285
|
+
metadata?: ReadonlyMap<string, string>
|
|
297
286
|
): Promise<void> {
|
|
298
|
-
await this.sourceSpotRouter.send(
|
|
299
|
-
sourceSpot,
|
|
300
|
-
spotRouteTarget,
|
|
301
|
-
packetName,
|
|
302
|
-
message,
|
|
303
|
-
signal,
|
|
304
|
-
metadata,
|
|
305
|
-
timeoutMs
|
|
306
|
-
);
|
|
287
|
+
await this.sourceSpotRouter.send(sourceSpot, spotRouteTarget, packetName, message, metadata);
|
|
307
288
|
}
|
|
308
289
|
|
|
309
290
|
routeRequestRawFromSpotToSpot(
|
|
@@ -10,7 +10,8 @@ import type {
|
|
|
10
10
|
ZLinkRawReceivedRecord,
|
|
11
11
|
ZLinkRawRouterPort
|
|
12
12
|
} from '../backend/raw-binding-port';
|
|
13
|
-
import {
|
|
13
|
+
import { submitToRequestResult } from '../messaging/submission-result';
|
|
14
|
+
import { RequestResult, SubmitResult, isZLinkBackendResultError } from '../backend/runtime-values';
|
|
14
15
|
import { enumWireRejectReason } from '../protocol/service_wire_codec.generated';
|
|
15
16
|
import { OperationRegistry, type PendingOperation } from './operation-registry';
|
|
16
17
|
import { ServiceLivenessRegistry, type ServiceLivenessTick } from './service-liveness-registry';
|
|
@@ -830,17 +831,14 @@ export class RawServiceMeshRuntime {
|
|
|
830
831
|
peer.connectionId,
|
|
831
832
|
record.probeId
|
|
832
833
|
);
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
if (!sent) {
|
|
842
|
-
return 'protocolError';
|
|
843
|
-
}
|
|
834
|
+
if (ack === undefined) return 'protocolError';
|
|
835
|
+
const sent = await this.send(received.sourceRid, [
|
|
836
|
+
livenessCodec.encodeLivenessRecord({
|
|
837
|
+
command: M6aServiceWireCommand.livenessAck,
|
|
838
|
+
probeId: record.probeId
|
|
839
|
+
})
|
|
840
|
+
]);
|
|
841
|
+
if (!sent) return 'dropped';
|
|
844
842
|
} else {
|
|
845
843
|
this.liveness.acknowledge(received.sourceRid, peer.connectionId, record.probeId, nowMs);
|
|
846
844
|
}
|
|
@@ -1263,8 +1261,13 @@ export class RawServiceMeshRuntime {
|
|
|
1263
1261
|
try {
|
|
1264
1262
|
await this.requireStarted().send(targetNodeRoutingId, parts);
|
|
1265
1263
|
return true;
|
|
1266
|
-
} catch {
|
|
1267
|
-
|
|
1264
|
+
} catch (error) {
|
|
1265
|
+
if (isZLinkBackendResultError(error) && error.operation === 'submit') {
|
|
1266
|
+
const terminal = submitToRequestResult(error.result, error.phase);
|
|
1267
|
+
if (terminal === RequestResult.NotConnected || terminal === RequestResult.NotFound)
|
|
1268
|
+
return false;
|
|
1269
|
+
}
|
|
1270
|
+
throw error;
|
|
1268
1271
|
}
|
|
1269
1272
|
}
|
|
1270
1273
|
}
|
|
@@ -464,13 +464,12 @@ export class ZLinkActorPacketRelay {
|
|
|
464
464
|
async relayActorPacket(
|
|
465
465
|
actor: ZLinkSessionActor,
|
|
466
466
|
frameHeader: ZLinkStreamFrameHeader,
|
|
467
|
-
payload: Message
|
|
468
|
-
signal?: AbortSignal
|
|
467
|
+
payload: Message
|
|
469
468
|
): Promise<boolean> {
|
|
470
|
-
if (await this.relayRemoteActorPacket(actor, frameHeader, payload
|
|
469
|
+
if (await this.relayRemoteActorPacket(actor, frameHeader, payload)) {
|
|
471
470
|
return true;
|
|
472
471
|
}
|
|
473
|
-
return this.relayLocalActorPacket(actor, frameHeader, payload
|
|
472
|
+
return this.relayLocalActorPacket(actor, frameHeader, payload);
|
|
474
473
|
}
|
|
475
474
|
|
|
476
475
|
async confirmRemoteSessionBinding(
|
|
@@ -581,8 +580,7 @@ export class ZLinkActorPacketRelay {
|
|
|
581
580
|
async relayRemoteActorPacket(
|
|
582
581
|
actor: ZLinkSessionActor,
|
|
583
582
|
frameHeader: ZLinkStreamFrameHeader,
|
|
584
|
-
payload: Message
|
|
585
|
-
signal?: AbortSignal
|
|
583
|
+
payload: Message
|
|
586
584
|
): Promise<boolean> {
|
|
587
585
|
const streamRuntime = this.options.streamBindingRuntime();
|
|
588
586
|
const responseTarget = await streamRuntime.captureBoundSessionResponseTarget(actor);
|
|
@@ -671,8 +669,7 @@ export class ZLinkActorPacketRelay {
|
|
|
671
669
|
remoteAddress.routerChannelId,
|
|
672
670
|
String(remoteAddress.targetNodeRid),
|
|
673
671
|
ZLINK_REMOTE_ACTOR_PACKET_RELAY_PACKET,
|
|
674
|
-
request
|
|
675
|
-
signal
|
|
672
|
+
request
|
|
676
673
|
);
|
|
677
674
|
if (result.status !== ZLinkSubmitStatus.Submitted) {
|
|
678
675
|
throw new Error(`Actor '${actor.actorId}' remote node relay was not admitted.`);
|
|
@@ -681,8 +678,7 @@ export class ZLinkActorPacketRelay {
|
|
|
681
678
|
}
|
|
682
679
|
if (frameHeader.kind === ZLinkStreamMessageKind.Send || frameHeader.requestSeq === undefined) {
|
|
683
680
|
await this.options.routeTransport.sendToSpot(remoteAddress, request, {
|
|
684
|
-
packetName: ZLINK_REMOTE_ACTOR_PACKET_RELAY_PACKET
|
|
685
|
-
signal
|
|
681
|
+
packetName: ZLINK_REMOTE_ACTOR_PACKET_RELAY_PACKET
|
|
686
682
|
});
|
|
687
683
|
return true;
|
|
688
684
|
}
|
|
@@ -702,8 +698,7 @@ export class ZLinkActorPacketRelay {
|
|
|
702
698
|
throw new Error(`Remote actor packet relay reply was empty for '${actor.actorId}'.`);
|
|
703
699
|
}
|
|
704
700
|
return JSON.parse(parts[0].getString('utf8')) as typeof reply;
|
|
705
|
-
}
|
|
706
|
-
signal
|
|
701
|
+
}
|
|
707
702
|
);
|
|
708
703
|
const actorPacketTarget = this.targets.decodeFromWire(reply.actorPacketTarget);
|
|
709
704
|
const currentStoredRoute = await streamRuntime.sessionRouteFence(actor.actorId);
|
|
@@ -863,10 +858,8 @@ export class ZLinkActorPacketRelay {
|
|
|
863
858
|
private async relayLocalActorPacket(
|
|
864
859
|
actor: ZLinkSessionActor,
|
|
865
860
|
frameHeader: ZLinkStreamFrameHeader,
|
|
866
|
-
payload: Message
|
|
867
|
-
signal?: AbortSignal
|
|
861
|
+
payload: Message
|
|
868
862
|
): Promise<boolean> {
|
|
869
|
-
void signal;
|
|
870
863
|
const state = this.options.actorManager()?.getState(actor.actorId);
|
|
871
864
|
const spotId = state?.spotId as RoutingId | undefined;
|
|
872
865
|
const hasActiveSpot =
|
|
@@ -221,8 +221,6 @@ const HOST_SHUTDOWN_POLL_INTERVAL_MS = 100;
|
|
|
221
221
|
const HANDOFF_ACCEPTANCE_POLL_INTERVAL_MS = 10;
|
|
222
222
|
const DEFAULT_HOST_CONTROL_TIMEOUT_MS = 30_000;
|
|
223
223
|
|
|
224
|
-
const LEGACY_MESH_SEND_TIMEOUT_MS = 1000;
|
|
225
|
-
|
|
226
224
|
export interface ZLinkFrameworkRuntimeLifecycle {
|
|
227
225
|
readonly isStarted: boolean;
|
|
228
226
|
readonly locationRuntimeQuery?: ZLinkLocationRuntimeQuery;
|
|
@@ -367,25 +365,6 @@ export class ZLinkFrameworkRuntimeHost
|
|
|
367
365
|
);
|
|
368
366
|
this.meshRouters = new MeshRouterResolver(options.registration);
|
|
369
367
|
this.spotRouterChannelIdForMesh = this.meshRouters.spotRouterChannelIdByMesh();
|
|
370
|
-
const sendTimeoutMsForSpotMesh = (meshName: string): number =>
|
|
371
|
-
options.registration.spotNodes.get(meshName)?.router?.sendTimeoutMs ??
|
|
372
|
-
LEGACY_MESH_SEND_TIMEOUT_MS;
|
|
373
|
-
const sendTimeoutMsForSpotRouteChannel = (routeChannelId: string): number => {
|
|
374
|
-
const routeChannel = options.registration.routeChannelOptions.get(routeChannelId);
|
|
375
|
-
if (routeChannel !== undefined) {
|
|
376
|
-
return routeChannel.sendTimeoutMs ?? LEGACY_MESH_SEND_TIMEOUT_MS;
|
|
377
|
-
}
|
|
378
|
-
return sendTimeoutMsForSpotMesh(routeChannelId);
|
|
379
|
-
};
|
|
380
|
-
const defaultSpotSendTimeoutMs = Math.max(
|
|
381
|
-
LEGACY_MESH_SEND_TIMEOUT_MS,
|
|
382
|
-
...[...options.registration.spotNodes.values()].map(
|
|
383
|
-
(node) => node.router?.sendTimeoutMs ?? LEGACY_MESH_SEND_TIMEOUT_MS
|
|
384
|
-
),
|
|
385
|
-
...[...options.registration.routeChannelOptions.values()].map(
|
|
386
|
-
(route) => route.sendTimeoutMs ?? LEGACY_MESH_SEND_TIMEOUT_MS
|
|
387
|
-
)
|
|
388
|
-
);
|
|
389
368
|
this.routeTransport = new ZLinkRuntimeRouteTransport(
|
|
390
369
|
() => this.channelRuntime,
|
|
391
370
|
(routerChannelId) => this.meshRouters.canUseRouterChannel(routerChannelId),
|
|
@@ -410,9 +389,6 @@ export class ZLinkFrameworkRuntimeHost
|
|
|
410
389
|
completions: (meshName) => this.spotNodeRuntime?.meshCompletionTable(meshName),
|
|
411
390
|
codecs: { serializers: options.registration.messageSerializers },
|
|
412
391
|
defaultRequestTimeoutMs: options.registration.requestTimeoutMs ?? DEFAULT_REQUEST_TIMEOUT_MS,
|
|
413
|
-
defaultSendTimeoutMs: defaultSpotSendTimeoutMs,
|
|
414
|
-
sendTimeoutMsForMesh: sendTimeoutMsForSpotMesh,
|
|
415
|
-
sendTimeoutMsForRouteChannel: sendTimeoutMsForSpotRouteChannel,
|
|
416
392
|
dispatchErrors: this.createDispatchErrorReporter(this.runtimeOrPreStartErrorSink)
|
|
417
393
|
});
|
|
418
394
|
this.locationOwner = new ZLinkLocationRuntimeOwner({
|
|
@@ -463,8 +439,8 @@ export class ZLinkFrameworkRuntimeHost
|
|
|
463
439
|
options
|
|
464
440
|
);
|
|
465
441
|
},
|
|
466
|
-
relay: (actor, header, payload
|
|
467
|
-
this.boundSessionRelay.actorPackets.relayActorPacket(actor, header, payload
|
|
442
|
+
relay: (actor, header, payload) =>
|
|
443
|
+
this.boundSessionRelay.actorPackets.relayActorPacket(actor, header, payload),
|
|
468
444
|
notifyDisconnected: (actor, signal) =>
|
|
469
445
|
this.boundSessionRelay.actorPackets.notifyBoundActorDisconnected(actor, signal)
|
|
470
446
|
});
|
|
@@ -642,8 +642,7 @@ export class ZLinkRemoteBoundSessionRelay {
|
|
|
642
642
|
packetName,
|
|
643
643
|
requestSeq,
|
|
644
644
|
response,
|
|
645
|
-
replyOptions
|
|
646
|
-
signal
|
|
645
|
+
replyOptions
|
|
647
646
|
);
|
|
648
647
|
return;
|
|
649
648
|
}
|
|
@@ -698,8 +697,7 @@ export class ZLinkRemoteBoundSessionRelay {
|
|
|
698
697
|
packetName,
|
|
699
698
|
requestSeq,
|
|
700
699
|
error,
|
|
701
|
-
metadata
|
|
702
|
-
signal
|
|
700
|
+
metadata
|
|
703
701
|
);
|
|
704
702
|
return;
|
|
705
703
|
}
|
|
@@ -731,8 +729,7 @@ export class ZLinkRemoteBoundSessionRelay {
|
|
|
731
729
|
packetName: string,
|
|
732
730
|
requestSeq: bigint,
|
|
733
731
|
message: unknown,
|
|
734
|
-
replyOptions: ZLinkActorResponseOptions
|
|
735
|
-
signal?: AbortSignal
|
|
732
|
+
replyOptions: ZLinkActorResponseOptions
|
|
736
733
|
): Promise<void> {
|
|
737
734
|
const actorPacketTarget = encodeRemoteActorPacketTarget(
|
|
738
735
|
this.options.actorPacketTargetForState(actorId)
|
|
@@ -747,8 +744,7 @@ export class ZLinkRemoteBoundSessionRelay {
|
|
|
747
744
|
metadata: replyOptions.metadata,
|
|
748
745
|
compressPayload: replyOptions.compressPayload,
|
|
749
746
|
actorPacketTarget
|
|
750
|
-
})
|
|
751
|
-
signal
|
|
747
|
+
})
|
|
752
748
|
);
|
|
753
749
|
}
|
|
754
750
|
|
|
@@ -758,8 +754,7 @@ export class ZLinkRemoteBoundSessionRelay {
|
|
|
758
754
|
packetName: string,
|
|
759
755
|
requestSeq: bigint,
|
|
760
756
|
error: unknown,
|
|
761
|
-
metadata: ReadonlyMap<string, string
|
|
762
|
-
signal?: AbortSignal
|
|
757
|
+
metadata: ReadonlyMap<string, string>
|
|
763
758
|
): Promise<void> {
|
|
764
759
|
await this.sendRemoteBoundSessionControl(
|
|
765
760
|
target,
|
|
@@ -772,15 +767,13 @@ export class ZLinkRemoteBoundSessionRelay {
|
|
|
772
767
|
actorPacketTarget: encodeRemoteActorPacketTarget(
|
|
773
768
|
this.options.actorPacketTargetForState(actorId)
|
|
774
769
|
)
|
|
775
|
-
})
|
|
776
|
-
signal
|
|
770
|
+
})
|
|
777
771
|
);
|
|
778
772
|
}
|
|
779
773
|
|
|
780
774
|
private async sendRemoteBoundSessionControl(
|
|
781
775
|
target: ZLinkRemoteBoundSessionTarget,
|
|
782
|
-
payload: Record<string, unknown
|
|
783
|
-
signal?: AbortSignal
|
|
776
|
+
payload: Record<string, unknown>
|
|
784
777
|
): Promise<void> {
|
|
785
778
|
const packetName = payload.packetName;
|
|
786
779
|
if (typeof packetName !== 'string') {
|
|
@@ -796,8 +789,7 @@ export class ZLinkRemoteBoundSessionRelay {
|
|
|
796
789
|
target.routerChannelId,
|
|
797
790
|
String(target.targetNodeRid),
|
|
798
791
|
packetName,
|
|
799
|
-
payload
|
|
800
|
-
signal
|
|
792
|
+
payload
|
|
801
793
|
);
|
|
802
794
|
if (result.status !== ZLinkSubmitStatus.Submitted) {
|
|
803
795
|
throw new Error(
|