@zlink-systems/framework 0.27.0 → 0.29.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 +2 -1
- package/dist/contracts/Configuration/Configs.d.ts +0 -1
- package/dist/contracts/Configuration/InternalDefaults.d.ts +3 -0
- package/dist/contracts/Configuration/InternalDefaults.js +4 -1
- package/dist/contracts/Configuration/RegistrationBuilders.js +9 -0
- package/dist/contracts/Configuration/RegistrationNormalizers.d.ts +1 -0
- package/dist/contracts/Configuration/RegistrationNormalizers.js +16 -0
- package/dist/contracts/Configuration/RegistrationTypes.d.ts +3 -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-mailbox.d.ts +2 -2
- package/dist/runtime/actors/actor-mailbox.js +2 -2
- 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-raw-mesh-backend.js +1 -3
- 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/execution/serial-execution-queue.d.ts +12 -3
- package/dist/runtime/execution/serial-execution-queue.js +116 -28
- package/dist/runtime/foundation/operation-registry.d.ts +3 -2
- package/dist/runtime/foundation/operation-registry.js +5 -1
- package/dist/runtime/foundation/raw-service-mesh-runtime.js +17 -11
- package/dist/runtime/foundation/service-authority-payload-codec.d.ts +0 -2
- package/dist/runtime/foundation/service-authority-payload-codec.js +0 -43
- package/dist/runtime/foundation/service-stateful-registry.d.ts +4 -3
- package/dist/runtime/foundation/service-stateful-registry.js +5 -2
- package/dist/runtime/foundation/service-stateful-runtime.d.ts +1 -8
- package/dist/runtime/foundation/service-stateful-runtime.js +78 -126
- package/dist/runtime/foundation/service-stateful-wire-codec.d.ts +0 -11
- package/dist/runtime/foundation/service-stateful-wire-codec.js +1 -23
- package/dist/runtime/foundation/service-topology-registry.d.ts +5 -0
- package/dist/runtime/foundation/service-topology-registry.js +16 -17
- 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/instance-activation-authority.d.ts +0 -1
- package/dist/runtime/host/instance-activation-authority.js +46 -97
- 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 +47 -87
- package/dist/runtime/host/stateful-authority-route-runtime.d.ts +1 -0
- package/dist/runtime/host/stateful-authority-route-runtime.js +17 -9
- package/dist/runtime/locations/domain-store-contract.d.ts +1 -0
- package/dist/runtime/locations/in-memory-authority-store.d.ts +2 -0
- package/dist/runtime/locations/in-memory-authority-store.js +22 -8
- package/dist/runtime/locations/in-memory-location-store.d.ts +1 -0
- package/dist/runtime/locations/in-memory-location-store.js +3 -0
- package/dist/runtime/locations/internal-store-contracts.d.ts +1 -1
- package/dist/runtime/locations/location-store-repository.d.ts +1 -0
- package/dist/runtime/locations/location-store-repository.js +98 -53
- 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/spots/spot-serial-executor.js +4 -1
- package/dist/runtime/spots/spot-serial-turn-executor.d.ts +3 -0
- package/dist/runtime/spots/spot-serial-turn-executor.js +5 -0
- 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 -3
- package/dist/runtime/streams/index.js +6 -5
- 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/protocol.js +0 -9
- 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 -8
- package/dist/runtime/streams/session-context.js +3 -32
- package/dist/runtime/streams/session-serial-executor.d.ts +0 -1
- package/dist/runtime/streams/session-serial-executor.js +0 -3
- package/dist/runtime/streams/stream-message-utils.d.ts +0 -1
- package/dist/runtime/streams/stream-message-utils.js +0 -20
- package/dist/runtime/streams/stream-session-runtime.d.ts +6 -3
- package/dist/runtime/streams/stream-session-runtime.js +40 -85
- 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 +2 -1
- package/src/contracts/Configuration/Configs.ts +0 -1
- package/src/contracts/Configuration/InternalDefaults.ts +4 -0
- package/src/contracts/Configuration/RegistrationBuilders.ts +13 -3
- package/src/contracts/Configuration/RegistrationNormalizers.ts +25 -0
- package/src/contracts/Configuration/RegistrationTypes.ts +3 -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-mailbox.ts +7 -2
- 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-raw-mesh-backend.ts +1 -7
- 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/execution/serial-execution-queue.ts +117 -29
- package/src/runtime/foundation/operation-registry.ts +16 -9
- package/src/runtime/foundation/raw-service-mesh-runtime.ts +17 -14
- package/src/runtime/foundation/service-authority-payload-codec.ts +0 -46
- package/src/runtime/foundation/service-stateful-registry.ts +10 -5
- package/src/runtime/foundation/service-stateful-runtime.ts +103 -181
- package/src/runtime/foundation/service-stateful-wire-codec.ts +0 -25
- package/src/runtime/foundation/service-topology-registry.ts +30 -20
- package/src/runtime/host/actor-packet-relay.ts +8 -15
- package/src/runtime/host/index.ts +2 -26
- package/src/runtime/host/instance-activation-authority.ts +58 -125
- package/src/runtime/host/remote-bound-session-relay.ts +8 -16
- package/src/runtime/host/spot-address-transport.ts +107 -166
- package/src/runtime/host/stateful-authority-route-runtime.ts +22 -9
- package/src/runtime/locations/domain-store-contract.ts +5 -0
- package/src/runtime/locations/in-memory-authority-store.ts +42 -8
- package/src/runtime/locations/in-memory-location-store.ts +8 -0
- package/src/runtime/locations/internal-store-contracts.ts +1 -0
- package/src/runtime/locations/location-store-repository.ts +130 -68
- package/src/runtime/messaging/request-deadline.ts +58 -0
- package/src/runtime/messaging/submission-result.ts +18 -4
- package/src/runtime/protocol/service_wire_pilot_codec.generated.ts +1 -1
- package/src/runtime/spots/spot-outbound.ts +14 -24
- package/src/runtime/spots/spot-serial-executor.ts +4 -1
- package/src/runtime/spots/spot-serial-turn-executor.ts +10 -0
- 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 +5 -5
- package/src/runtime/streams/managed-stream.ts +3 -13
- package/src/runtime/streams/native-fallback-bound-session.ts +13 -25
- package/src/runtime/streams/protocol.ts +0 -13
- package/src/runtime/streams/session-calls.ts +8 -34
- package/src/runtime/streams/session-context.ts +6 -47
- package/src/runtime/streams/session-serial-executor.ts +0 -8
- package/src/runtime/streams/stream-message-utils.ts +1 -27
- package/src/runtime/streams/stream-session-runtime.ts +54 -97
- package/dist/runtime/streams/session-requests.d.ts +0 -25
- package/dist/runtime/streams/session-requests.js +0 -101
- package/src/runtime/streams/session-requests.ts +0 -110
|
@@ -5,7 +5,6 @@ import {
|
|
|
5
5
|
ZLinkDispatchMessageKind,
|
|
6
6
|
ZLinkRuntimeMessageFlowOutcome
|
|
7
7
|
} from '../../contracts/Dispatch/ZLinkDispatchOptions';
|
|
8
|
-
import { throwIfAborted } from '../abort';
|
|
9
8
|
import type { ZLinkDispatchErrorReporter } from '../channels';
|
|
10
9
|
import { flowIfEnabled } from '../diagnostics';
|
|
11
10
|
import { encodeFrameworkPayloadMessage } from '../messaging/payload-codec';
|
|
@@ -33,8 +32,7 @@ export interface ZLinkBoundActorRelaySenderOptions {
|
|
|
33
32
|
readonly relay?: (
|
|
34
33
|
actor: ZLinkSessionActor,
|
|
35
34
|
header: ZLinkStreamFrameHeader,
|
|
36
|
-
payload: Message
|
|
37
|
-
signal?: AbortSignal
|
|
35
|
+
payload: Message
|
|
38
36
|
) => Promise<boolean>;
|
|
39
37
|
readonly notifyDisconnected?: (actor: ZLinkSessionActor, signal?: AbortSignal) => Promise<void>;
|
|
40
38
|
}
|
|
@@ -53,7 +51,6 @@ export class ZLinkBoundActorRelaySender {
|
|
|
53
51
|
async relay(
|
|
54
52
|
actor: DefaultZLinkSessionActor,
|
|
55
53
|
payload: ZLinkMessage,
|
|
56
|
-
signal?: AbortSignal,
|
|
57
54
|
dispatchHeader?: ZLinkStreamFrameHeader
|
|
58
55
|
): Promise<ZLinkSubmitResult> {
|
|
59
56
|
const header =
|
|
@@ -64,18 +61,16 @@ export class ZLinkBoundActorRelaySender {
|
|
|
64
61
|
const operation = async (): Promise<ZLinkSubmitResult> => {
|
|
65
62
|
const admission = await this.routes.beginAcceptedRequestFrameWhenReady(
|
|
66
63
|
actor.actorId,
|
|
67
|
-
actor.bindingToken
|
|
68
|
-
signal
|
|
64
|
+
actor.bindingToken
|
|
69
65
|
);
|
|
70
66
|
try {
|
|
71
|
-
return await this.relayAcceptedFrame(actor, payload,
|
|
67
|
+
return await this.relayAcceptedFrame(actor, payload, header, admission);
|
|
72
68
|
} finally {
|
|
73
69
|
await admission.complete();
|
|
74
70
|
}
|
|
75
71
|
};
|
|
76
72
|
return await operation();
|
|
77
73
|
}
|
|
78
|
-
throwIfAborted(signal);
|
|
79
74
|
const held = await this.routes.acceptOneWay(actor.actorId, actor.bindingToken, () => {
|
|
80
75
|
let heldMessage: Message | undefined = encodeFrameworkPayloadMessage(
|
|
81
76
|
payload,
|
|
@@ -87,8 +82,7 @@ export class ZLinkBoundActorRelaySender {
|
|
|
87
82
|
const result = await this.routes.runAcceptedFrameWhenReady(
|
|
88
83
|
actor.actorId,
|
|
89
84
|
actor.bindingToken,
|
|
90
|
-
() =>
|
|
91
|
-
this.relayAcceptedFrame(actor, payload, undefined, header, undefined, heldMessage)
|
|
85
|
+
() => this.relayAcceptedFrame(actor, payload, header, undefined, heldMessage)
|
|
92
86
|
);
|
|
93
87
|
if (result.status !== ZLinkSubmitStatus.Submitted) {
|
|
94
88
|
this.traceHeldDrop(
|
|
@@ -116,11 +110,8 @@ export class ZLinkBoundActorRelaySender {
|
|
|
116
110
|
if (held) {
|
|
117
111
|
return { status: ZLinkSubmitStatus.Submitted };
|
|
118
112
|
}
|
|
119
|
-
return this.routes.runAcceptedFrameWhenReady(
|
|
120
|
-
actor
|
|
121
|
-
actor.bindingToken,
|
|
122
|
-
() => this.relayAcceptedFrame(actor, payload, signal),
|
|
123
|
-
signal
|
|
113
|
+
return this.routes.runAcceptedFrameWhenReady(actor.actorId, actor.bindingToken, () =>
|
|
114
|
+
this.relayAcceptedFrame(actor, payload)
|
|
124
115
|
);
|
|
125
116
|
}
|
|
126
117
|
|
|
@@ -150,7 +141,6 @@ export class ZLinkBoundActorRelaySender {
|
|
|
150
141
|
private async relayAcceptedFrame(
|
|
151
142
|
actor: DefaultZLinkSessionActor,
|
|
152
143
|
payload: ZLinkMessage,
|
|
153
|
-
signal?: AbortSignal,
|
|
154
144
|
header?: ZLinkStreamFrameHeader,
|
|
155
145
|
requestAdmission?: { beginSubmission(signal?: AbortSignal): Promise<void> | undefined },
|
|
156
146
|
acceptedPayload?: Message
|
|
@@ -160,7 +150,6 @@ export class ZLinkBoundActorRelaySender {
|
|
|
160
150
|
const completion = this.relayInsideLifecycle(
|
|
161
151
|
actor,
|
|
162
152
|
payload,
|
|
163
|
-
signal,
|
|
164
153
|
activeHeader,
|
|
165
154
|
requestAdmission,
|
|
166
155
|
acceptedPayload
|
|
@@ -207,20 +196,18 @@ export class ZLinkBoundActorRelaySender {
|
|
|
207
196
|
private async relayInsideLifecycle(
|
|
208
197
|
actor: DefaultZLinkSessionActor,
|
|
209
198
|
payload: ZLinkMessage,
|
|
210
|
-
signal: AbortSignal | undefined,
|
|
211
199
|
currentHeader?: ZLinkStreamFrameHeader,
|
|
212
200
|
requestAdmission?: { beginSubmission(signal?: AbortSignal): Promise<void> | undefined },
|
|
213
201
|
acceptedPayload?: Message
|
|
214
202
|
): Promise<ZLinkSubmitResult> {
|
|
215
203
|
const header = currentHeader ?? (await this.currentHeader(actor));
|
|
216
|
-
const held = requestAdmission?.beginSubmission(
|
|
204
|
+
const held = requestAdmission?.beginSubmission();
|
|
217
205
|
if (held !== undefined) await held;
|
|
218
|
-
throwIfAborted(signal);
|
|
219
206
|
const payloadMessage =
|
|
220
207
|
acceptedPayload ?? encodeFrameworkPayloadMessage(payload, this.options.messageSerializers);
|
|
221
208
|
try {
|
|
222
209
|
if (this.options.relay !== undefined) {
|
|
223
|
-
const handled = await this.options.relay(actor, header, payloadMessage
|
|
210
|
+
const handled = await this.options.relay(actor, header, payloadMessage);
|
|
224
211
|
if (handled) {
|
|
225
212
|
return { status: ZLinkSubmitStatus.Submitted };
|
|
226
213
|
}
|
|
@@ -234,11 +221,10 @@ export class ZLinkBoundActorRelaySender {
|
|
|
234
221
|
messageToBytes(payloadMessage)
|
|
235
222
|
);
|
|
236
223
|
try {
|
|
237
|
-
return await route.context.stream.submitBoundActor(
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
);
|
|
224
|
+
return await route.context.stream.submitBoundActor(actor.actorId, [
|
|
225
|
+
headerMessage,
|
|
226
|
+
framePayloadMessage
|
|
227
|
+
]);
|
|
242
228
|
} finally {
|
|
243
229
|
headerMessage.close();
|
|
244
230
|
framePayloadMessage.close();
|
|
@@ -129,7 +129,7 @@ export class ZLinkBoundSessionService {
|
|
|
129
129
|
if ((await this.routes.route(actorId))?.bindingToken !== route.bindingToken) {
|
|
130
130
|
return { status: ZLinkSubmitStatus.TargetNotFound };
|
|
131
131
|
}
|
|
132
|
-
return await route.context.stream.submitRaw(frame
|
|
132
|
+
return await route.context.stream.submitRaw(frame);
|
|
133
133
|
} finally {
|
|
134
134
|
frame.close();
|
|
135
135
|
}
|
|
@@ -87,7 +87,6 @@ import {
|
|
|
87
87
|
type ZLinkStreamSessionRuntimeOptions as ZLinkStreamSessionRuntimeCoreOptions
|
|
88
88
|
} from './stream-session-runtime';
|
|
89
89
|
const DEFAULT_STREAM_SERVICE_SHUTDOWN_TIMEOUT_MS = 1000;
|
|
90
|
-
export { ZLinkPendingSessionRequest } from './session-requests';
|
|
91
90
|
export { ZLinkActorSessionLifecycleCoordinator } from './actor-session-lifecycle-coordinator';
|
|
92
91
|
export { ZLinkActorSessionBindingRegistry } from './actor-session-binding-registry';
|
|
93
92
|
export { zlinkStreamLz4CompressionCodec } from './stream-frame-factory';
|
|
@@ -139,8 +138,7 @@ export interface ZLinkStreamBindingRuntimeOptions {
|
|
|
139
138
|
readonly relay?: (
|
|
140
139
|
actor: ZLinkSessionActor,
|
|
141
140
|
header: ZLinkStreamFrameHeader,
|
|
142
|
-
payload: Message
|
|
143
|
-
signal?: AbortSignal
|
|
141
|
+
payload: Message
|
|
144
142
|
) => Promise<boolean>;
|
|
145
143
|
readonly notifyDisconnected?: (actor: ZLinkSessionActor, signal?: AbortSignal) => Promise<void>;
|
|
146
144
|
readonly flowCreationEnabled?: () => boolean;
|
|
@@ -306,6 +304,9 @@ export class ZLinkStreamRuntimeManager {
|
|
|
306
304
|
const readablePoller = streamAdapter.createReadablePoller(socket);
|
|
307
305
|
const runtime = new ZLinkStreamSessionNodeRuntimeCore({
|
|
308
306
|
nodeName,
|
|
307
|
+
heartbeatIntervalMs: streamNode.heartbeatIntervalMs,
|
|
308
|
+
heartbeatTimeoutMs: streamNode.heartbeatTimeoutMs,
|
|
309
|
+
idleTimeoutMs: streamNode.idleTimeoutMs,
|
|
309
310
|
socket,
|
|
310
311
|
createPacket: () => streamAdapter.createStreamPacket(),
|
|
311
312
|
readablePoller,
|
|
@@ -758,10 +759,9 @@ export class ZLinkStreamBindingRuntime {
|
|
|
758
759
|
async relay(
|
|
759
760
|
actor: DefaultZLinkSessionActor,
|
|
760
761
|
payload: ZLinkMessage,
|
|
761
|
-
signal?: AbortSignal,
|
|
762
762
|
dispatchHeader?: ZLinkStreamFrameHeader
|
|
763
763
|
): Promise<ZLinkSubmitResult> {
|
|
764
|
-
return await this.boundActorRelay.relay(actor, payload,
|
|
764
|
+
return await this.boundActorRelay.relay(actor, payload, dispatchHeader);
|
|
765
765
|
}
|
|
766
766
|
|
|
767
767
|
async notifyDisconnected(actor: DefaultZLinkSessionActor, signal?: AbortSignal): Promise<void> {
|
|
@@ -130,14 +130,9 @@ export class ZLinkManagedStream implements ZLinkStream {
|
|
|
130
130
|
return this.socket.send(this.backendRoutingId(), payload, flags ?? 0);
|
|
131
131
|
}
|
|
132
132
|
|
|
133
|
-
async submitRaw(
|
|
134
|
-
payload: Message,
|
|
135
|
-
signal?: AbortSignal,
|
|
136
|
-
timeoutMs?: number
|
|
137
|
-
): Promise<ZLinkSubmitResult> {
|
|
133
|
+
async submitRaw(payload: Message): Promise<ZLinkSubmitResult> {
|
|
138
134
|
try {
|
|
139
|
-
|
|
140
|
-
await this.socket.submit(this.backendRoutingId(), payload, timeoutMs);
|
|
135
|
+
await this.socket.submit(this.backendRoutingId(), payload);
|
|
141
136
|
return { status: ZLinkSubmitStatus.Submitted };
|
|
142
137
|
} catch (error) {
|
|
143
138
|
if (isZLinkBackendResultError(error) && error.operation === 'submit') {
|
|
@@ -147,12 +142,7 @@ export class ZLinkManagedStream implements ZLinkStream {
|
|
|
147
142
|
}
|
|
148
143
|
}
|
|
149
144
|
|
|
150
|
-
async submitBoundActor(
|
|
151
|
-
actorId: string,
|
|
152
|
-
parts: readonly Message[],
|
|
153
|
-
signal?: AbortSignal
|
|
154
|
-
): Promise<ZLinkSubmitResult> {
|
|
155
|
-
throwIfAborted(signal);
|
|
145
|
+
async submitBoundActor(actorId: string, parts: readonly Message[]): Promise<ZLinkSubmitResult> {
|
|
156
146
|
return (await this.sendBoundActor(actorId, parts, ZLINK_SEND_DONT_WAIT))
|
|
157
147
|
? { status: ZLinkSubmitStatus.Submitted }
|
|
158
148
|
: { status: ZLinkSubmitStatus.Backpressured };
|
|
@@ -32,7 +32,6 @@ import {
|
|
|
32
32
|
type ZLinkStreamFrameHeader
|
|
33
33
|
} from './protocol';
|
|
34
34
|
import type { ZLinkNativeFallbackBoundSessionPort } from './stream-binding-runtime-ports';
|
|
35
|
-
import { throwIfAborted } from '../abort';
|
|
36
35
|
import type { ZLinkBackendActorSessionNode } from '../backend';
|
|
37
36
|
import { resolveFrameworkPacketName } from '../messaging/packet-name';
|
|
38
37
|
import { currentOrCreateFlow, runWithOutboundFlow } from '../diagnostics/flow-context';
|
|
@@ -87,8 +86,7 @@ export class ZLinkNativeFallbackBoundSession implements ZLinkBoundSession {
|
|
|
87
86
|
return;
|
|
88
87
|
}
|
|
89
88
|
await this.options.routedTransport.sendToSpot(target, payload, {
|
|
90
|
-
packetName: ZLINK_REMOTE_ACTOR_PACKET_RELAY_PACKET
|
|
91
|
-
signal
|
|
89
|
+
packetName: ZLINK_REMOTE_ACTOR_PACKET_RELAY_PACKET
|
|
92
90
|
});
|
|
93
91
|
return;
|
|
94
92
|
}
|
|
@@ -126,7 +124,7 @@ class ZLinkNativeFallbackBoundSessionSendCall implements ZLinkBoundSessionSendCa
|
|
|
126
124
|
return this;
|
|
127
125
|
}
|
|
128
126
|
|
|
129
|
-
async submit(
|
|
127
|
+
async submit(): Promise<void> {
|
|
130
128
|
if (this.executed) {
|
|
131
129
|
throwAlreadySubmitted('Bound session send call');
|
|
132
130
|
}
|
|
@@ -136,8 +134,7 @@ class ZLinkNativeFallbackBoundSessionSendCall implements ZLinkBoundSessionSendCa
|
|
|
136
134
|
'Bound session'
|
|
137
135
|
);
|
|
138
136
|
this.executed = true;
|
|
139
|
-
|
|
140
|
-
const result = await this.execute(packetName, signal);
|
|
137
|
+
const result = await this.execute(packetName);
|
|
141
138
|
requireOneWayCompletion(
|
|
142
139
|
result,
|
|
143
140
|
'Bound session send',
|
|
@@ -145,19 +142,16 @@ class ZLinkNativeFallbackBoundSessionSendCall implements ZLinkBoundSessionSendCa
|
|
|
145
142
|
);
|
|
146
143
|
}
|
|
147
144
|
|
|
148
|
-
private execute(packetName: string
|
|
145
|
+
private execute(packetName: string): Promise<ZLinkSubmitResult> {
|
|
149
146
|
// Call-scoped flow (spec 27 §4): the relay JSON flow pair and any nested
|
|
150
147
|
// routed-transport envelope share one ambient flow that does not outlive
|
|
151
148
|
// this submit call.
|
|
152
149
|
return runWithOutboundFlow(this.options.flowCreationEnabled?.() ?? true, () =>
|
|
153
|
-
this.executeScoped(packetName
|
|
150
|
+
this.executeScoped(packetName)
|
|
154
151
|
);
|
|
155
152
|
}
|
|
156
153
|
|
|
157
|
-
private async executeScoped(
|
|
158
|
-
packetName: string,
|
|
159
|
-
signal?: AbortSignal
|
|
160
|
-
): Promise<ZLinkSubmitResult> {
|
|
154
|
+
private async executeScoped(packetName: string): Promise<ZLinkSubmitResult> {
|
|
161
155
|
const localActor = this.options.localActorProvider?.() === true;
|
|
162
156
|
const remoteTarget = this.options.remoteBoundSessionTargetProvider();
|
|
163
157
|
let nativeAttempted = false;
|
|
@@ -166,8 +160,7 @@ class ZLinkNativeFallbackBoundSessionSendCall implements ZLinkBoundSessionSendCa
|
|
|
166
160
|
this.options.actorId,
|
|
167
161
|
this.message,
|
|
168
162
|
packetName,
|
|
169
|
-
this.selectedMetadata
|
|
170
|
-
signal
|
|
163
|
+
this.selectedMetadata
|
|
171
164
|
);
|
|
172
165
|
if (result.status !== ZLinkSubmitStatus.TargetNotFound) {
|
|
173
166
|
this.traceSubmitted(result, packetName);
|
|
@@ -188,8 +181,7 @@ class ZLinkNativeFallbackBoundSessionSendCall implements ZLinkBoundSessionSendCa
|
|
|
188
181
|
actorRef,
|
|
189
182
|
this.message,
|
|
190
183
|
packetName,
|
|
191
|
-
this.selectedMetadata
|
|
192
|
-
signal
|
|
184
|
+
this.selectedMetadata
|
|
193
185
|
);
|
|
194
186
|
if (result.status !== ZLinkSubmitStatus.TargetNotFound) {
|
|
195
187
|
this.traceSubmitted(result, packetName);
|
|
@@ -234,15 +226,14 @@ class ZLinkNativeFallbackBoundSessionSendCall implements ZLinkBoundSessionSendCa
|
|
|
234
226
|
spotKind: ZLinkSpotKind.Entry
|
|
235
227
|
},
|
|
236
228
|
payload,
|
|
237
|
-
{ packetName: ZLINK_REMOTE_BOUND_SESSION_SEND_PACKET
|
|
229
|
+
{ packetName: ZLINK_REMOTE_BOUND_SESSION_SEND_PACKET }
|
|
238
230
|
)
|
|
239
231
|
: await submit.call(
|
|
240
232
|
this.options.routedTransport,
|
|
241
233
|
remoteTarget.routerChannelId,
|
|
242
234
|
String(remoteTarget.targetNodeRid),
|
|
243
235
|
ZLINK_REMOTE_BOUND_SESSION_SEND_PACKET,
|
|
244
|
-
payload
|
|
245
|
-
signal
|
|
236
|
+
payload
|
|
246
237
|
);
|
|
247
238
|
this.traceSubmitted(result, packetName);
|
|
248
239
|
return result;
|
|
@@ -251,8 +242,7 @@ class ZLinkNativeFallbackBoundSessionSendCall implements ZLinkBoundSessionSendCa
|
|
|
251
242
|
this.options.actorId,
|
|
252
243
|
this.message,
|
|
253
244
|
packetName,
|
|
254
|
-
this.selectedMetadata
|
|
255
|
-
signal
|
|
245
|
+
this.selectedMetadata
|
|
256
246
|
);
|
|
257
247
|
if (localResult.status !== ZLinkSubmitStatus.TargetNotFound) {
|
|
258
248
|
this.traceSubmitted(localResult, packetName);
|
|
@@ -272,8 +262,7 @@ class ZLinkNativeFallbackBoundSessionSendCall implements ZLinkBoundSessionSendCa
|
|
|
272
262
|
actorRef,
|
|
273
263
|
this.message,
|
|
274
264
|
packetName,
|
|
275
|
-
this.selectedMetadata
|
|
276
|
-
signal
|
|
265
|
+
this.selectedMetadata
|
|
277
266
|
);
|
|
278
267
|
this.traceSubmitted(result, packetName);
|
|
279
268
|
return result;
|
|
@@ -289,8 +278,7 @@ class ZLinkNativeFallbackBoundSessionSendCall implements ZLinkBoundSessionSendCa
|
|
|
289
278
|
this.options.actorId,
|
|
290
279
|
this.message,
|
|
291
280
|
packetName,
|
|
292
|
-
this.selectedMetadata
|
|
293
|
-
signal
|
|
281
|
+
this.selectedMetadata
|
|
294
282
|
);
|
|
295
283
|
this.traceSubmitted(result, packetName);
|
|
296
284
|
return result;
|
|
@@ -175,19 +175,6 @@ export function decodeStreamHeader(header: Uint8Array, flowEnabled = true): ZLin
|
|
|
175
175
|
const decoded = decodeStreamWireHeader(header, undefined, flowEnabled);
|
|
176
176
|
const kind = decoded.kind as ZLinkStreamMessageKind;
|
|
177
177
|
const flags = decoded.flags as ZLinkStreamHeaderFlags;
|
|
178
|
-
const hasRequestSeq = (flags & ZLinkStreamHeaderFlags.HasRequestSeq) !== 0;
|
|
179
|
-
const hasMetadata = (flags & ZLinkStreamHeaderFlags.HasMetadata) !== 0;
|
|
180
|
-
const hasCorrelation = (flags & ZLinkStreamHeaderFlags.HasCorrelationId) !== 0;
|
|
181
|
-
const hasFlow = (flags & ZLinkStreamHeaderFlags.HasFlowId) !== 0;
|
|
182
|
-
const hasActorSlot = (flags & ZLinkStreamHeaderFlags.HasActorSlot) !== 0;
|
|
183
|
-
if (
|
|
184
|
-
kind === ZLinkStreamMessageKind.Control &&
|
|
185
|
-
(hasCorrelation || hasRequestSeq || hasMetadata || hasFlow || hasActorSlot)
|
|
186
|
-
) {
|
|
187
|
-
throw new Error(
|
|
188
|
-
'Control packet must not contain a request sequence, metadata, correlation id, or flow id.'
|
|
189
|
-
);
|
|
190
|
-
}
|
|
191
178
|
const metadata = publicStreamMetadata(decoded.metadata);
|
|
192
179
|
return {
|
|
193
180
|
kind,
|
|
@@ -4,9 +4,6 @@ import type {
|
|
|
4
4
|
ZLinkSessionSendCall
|
|
5
5
|
} from '../../contracts';
|
|
6
6
|
import type { Message } from '../../contracts/Common/Message';
|
|
7
|
-
import { ZLINK_MAX_SEND_TIMEOUT_MS } from '../../contracts/Configuration/SendTimeoutValidation';
|
|
8
|
-
import { throwIfAborted } from '../abort';
|
|
9
|
-
import { ZLinkConfigurationException } from '../configuration';
|
|
10
7
|
import { ZLinkFrameworkInternalErrorKind } from '../framework-errors-internal';
|
|
11
8
|
import { type ZLinkSubmitResult, requireOneWayCompletion } from '../messaging/submission-result';
|
|
12
9
|
|
|
@@ -23,19 +20,14 @@ export interface ZLinkBoundSessionSendRuntime {
|
|
|
23
20
|
actorId: string,
|
|
24
21
|
message: unknown,
|
|
25
22
|
packetName: string | undefined,
|
|
26
|
-
metadata: ReadonlyMap<string, string
|
|
27
|
-
signal?: AbortSignal
|
|
23
|
+
metadata: ReadonlyMap<string, string>
|
|
28
24
|
): Promise<ZLinkSubmitResult>;
|
|
29
25
|
}
|
|
30
26
|
|
|
31
27
|
export interface ZLinkSessionCallContext {
|
|
32
28
|
readonly stream: {
|
|
33
29
|
writeRaw(payload: Message): boolean;
|
|
34
|
-
submitRaw(
|
|
35
|
-
payload: Message,
|
|
36
|
-
signal?: AbortSignal,
|
|
37
|
-
timeoutMs?: number
|
|
38
|
-
): Promise<ZLinkSubmitResult>;
|
|
30
|
+
submitRaw(payload: Message): Promise<ZLinkSubmitResult>;
|
|
39
31
|
};
|
|
40
32
|
readonly dispatchHeader: ZLinkStreamFrameHeader | undefined;
|
|
41
33
|
createJsonFrameMessage(
|
|
@@ -88,17 +80,15 @@ export class DefaultZLinkBoundSessionSendCall implements ZLinkBoundSessionSendCa
|
|
|
88
80
|
return this;
|
|
89
81
|
}
|
|
90
82
|
|
|
91
|
-
async submit(
|
|
83
|
+
async submit(): Promise<void> {
|
|
92
84
|
ensureSingleSubmit(this.executed);
|
|
93
85
|
const packetName = resolvePacketName(this.message, this.selectedPacketName);
|
|
94
86
|
this.executed = true;
|
|
95
|
-
throwIfAborted(signal);
|
|
96
87
|
const result = await this.runtime.sendBoundSession(
|
|
97
88
|
this.actorId,
|
|
98
89
|
this.message,
|
|
99
90
|
packetName,
|
|
100
|
-
this.selectedMetadata
|
|
101
|
-
signal
|
|
91
|
+
this.selectedMetadata
|
|
102
92
|
);
|
|
103
93
|
requireOneWayCompletion(
|
|
104
94
|
result,
|
|
@@ -112,7 +102,6 @@ export class DefaultZLinkSessionSendCall implements ZLinkSessionSendCall {
|
|
|
112
102
|
private selectedPacketName: string | undefined;
|
|
113
103
|
private readonly selectedMetadata = new Map<string, string>();
|
|
114
104
|
private compressionEnabled = false;
|
|
115
|
-
private selectedTimeoutMs: number | undefined;
|
|
116
105
|
private executed = false;
|
|
117
106
|
|
|
118
107
|
constructor(
|
|
@@ -135,21 +124,10 @@ export class DefaultZLinkSessionSendCall implements ZLinkSessionSendCall {
|
|
|
135
124
|
return this;
|
|
136
125
|
}
|
|
137
126
|
|
|
138
|
-
|
|
139
|
-
if (!Number.isInteger(timeoutMs) || timeoutMs < 1 || timeoutMs > ZLINK_MAX_SEND_TIMEOUT_MS) {
|
|
140
|
-
throw new ZLinkConfigurationException(
|
|
141
|
-
`STREAM session send timeout must be an integer from 1 through ${ZLINK_MAX_SEND_TIMEOUT_MS} milliseconds.`
|
|
142
|
-
);
|
|
143
|
-
}
|
|
144
|
-
this.selectedTimeoutMs = timeoutMs;
|
|
145
|
-
return this;
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
async submit(signal?: AbortSignal): Promise<void> {
|
|
127
|
+
async submit(): Promise<void> {
|
|
149
128
|
ensureSingleSubmit(this.executed);
|
|
150
129
|
const packetName = resolvePacketName(this.message, this.selectedPacketName);
|
|
151
130
|
this.executed = true;
|
|
152
|
-
throwIfAborted(signal);
|
|
153
131
|
const message = this.context.createJsonFrameMessage(
|
|
154
132
|
ZLinkStreamMessageKind.Send,
|
|
155
133
|
packetName,
|
|
@@ -159,7 +137,7 @@ export class DefaultZLinkSessionSendCall implements ZLinkSessionSendCall {
|
|
|
159
137
|
this.message
|
|
160
138
|
);
|
|
161
139
|
try {
|
|
162
|
-
const result = await this.context.stream.submitRaw(message
|
|
140
|
+
const result = await this.context.stream.submitRaw(message);
|
|
163
141
|
requireOneWayCompletion(result, 'STREAM session send');
|
|
164
142
|
this.context.traceFrameWritten?.(ZLinkStreamMessageKind.Send, packetName, undefined);
|
|
165
143
|
} finally {
|
|
@@ -182,7 +160,7 @@ export class DefaultZLinkSessionReplyCall implements ZLinkSessionReplyCall {
|
|
|
182
160
|
return this;
|
|
183
161
|
}
|
|
184
162
|
|
|
185
|
-
async submit(
|
|
163
|
+
async submit(): Promise<void> {
|
|
186
164
|
ensureSingleSubmit(this.executed);
|
|
187
165
|
this.executed = true;
|
|
188
166
|
const requestHeader = this.context.dispatchHeader;
|
|
@@ -190,10 +168,6 @@ export class DefaultZLinkSessionReplyCall implements ZLinkSessionReplyCall {
|
|
|
190
168
|
throw new Error('Reply is only available while handling a request packet.');
|
|
191
169
|
}
|
|
192
170
|
this.context.claimReply(requestHeader);
|
|
193
|
-
// Reply-token validity wins over caller cancellation. Claiming before the
|
|
194
|
-
// pre-cancel check keeps duplicate calls deterministic while still making
|
|
195
|
-
// a pre-cancelled first call perform no transport admission.
|
|
196
|
-
throwIfAborted(signal);
|
|
197
171
|
const message = this.context.createJsonReplyFrameMessage(
|
|
198
172
|
requestHeader,
|
|
199
173
|
ZLinkStreamMessageKind.Response,
|
|
@@ -202,7 +176,7 @@ export class DefaultZLinkSessionReplyCall implements ZLinkSessionReplyCall {
|
|
|
202
176
|
this.message
|
|
203
177
|
);
|
|
204
178
|
try {
|
|
205
|
-
const result = await this.context.stream.submitRaw(message
|
|
179
|
+
const result = await this.context.stream.submitRaw(message);
|
|
206
180
|
requireOneWayCompletion(result, 'STREAM session reply');
|
|
207
181
|
this.context.traceFrameWritten?.(
|
|
208
182
|
ZLinkStreamMessageKind.Response,
|
|
@@ -33,7 +33,6 @@ import { ZLinkFrameworkInternalErrorKind } from '../framework-errors-internal';
|
|
|
33
33
|
import { type ZLinkSubmitResult, requireOneWayCompletion } from '../messaging/submission-result';
|
|
34
34
|
|
|
35
35
|
import {
|
|
36
|
-
messageToBytes,
|
|
37
36
|
ZLinkStreamHeaderFlags,
|
|
38
37
|
ZLinkStreamMessageKind,
|
|
39
38
|
type ZLinkStreamFrameHeader,
|
|
@@ -45,11 +44,10 @@ import {
|
|
|
45
44
|
DefaultZLinkSessionSendCall
|
|
46
45
|
} from './session-calls';
|
|
47
46
|
import { ZLinkSessionLocalActorBindings } from './session-local-actors';
|
|
48
|
-
import { ZLinkSessionRequestTracker, type ZLinkPendingSessionRequest } from './session-requests';
|
|
49
47
|
|
|
50
48
|
export interface ZLinkSessionContextStream extends ZLinkStream {
|
|
51
49
|
writeRaw(payload: Message, flags?: number): boolean;
|
|
52
|
-
submitRaw(payload: Message
|
|
50
|
+
submitRaw(payload: Message): Promise<ZLinkSubmitResult>;
|
|
53
51
|
enqueueActorBound?(actorSlot: number, actorId: string): Promise<void>;
|
|
54
52
|
enqueueActorUnbound?(actorSlot: number): Promise<void>;
|
|
55
53
|
}
|
|
@@ -88,7 +86,6 @@ interface ZLinkSessionContextRuntime {
|
|
|
88
86
|
relay(
|
|
89
87
|
actor: DefaultZLinkSessionActor,
|
|
90
88
|
payload: ZLinkMessage,
|
|
91
|
-
signal?: AbortSignal,
|
|
92
89
|
dispatchHeader?: ZLinkStreamFrameHeader
|
|
93
90
|
): Promise<ZLinkSubmitResult>;
|
|
94
91
|
notifyDisconnected(actor: DefaultZLinkSessionActor, signal?: AbortSignal): Promise<void>;
|
|
@@ -120,7 +117,6 @@ export class DefaultZLinkSessionContext implements ZLinkSessionContext {
|
|
|
120
117
|
private readonly handlerRegistry: DefaultZLinkSessionHandlerRegistry;
|
|
121
118
|
readonly handlers: ZLinkSessionHandlerRegistry;
|
|
122
119
|
private readonly localActors = new ZLinkSessionLocalActorBindings<DefaultZLinkSessionActor>();
|
|
123
|
-
private readonly requests = new ZLinkSessionRequestTracker();
|
|
124
120
|
private currentDispatchHeader: ZLinkStreamFrameHeader | undefined;
|
|
125
121
|
private currentReplyClaimed = false;
|
|
126
122
|
private actorBindingReplacementHandler?: ZLinkActorBindingReplacementHandler;
|
|
@@ -319,23 +315,6 @@ export class DefaultZLinkSessionContext implements ZLinkSessionContext {
|
|
|
319
315
|
this.currentReplyClaimed = true;
|
|
320
316
|
}
|
|
321
317
|
|
|
322
|
-
startRequest(timeoutMs?: number): ZLinkPendingSessionRequest {
|
|
323
|
-
return this.requests.start(timeoutMs);
|
|
324
|
-
}
|
|
325
|
-
|
|
326
|
-
tryCompleteResponse(header: ZLinkStreamFrameHeader, payload: Message): boolean {
|
|
327
|
-
if (header.requestSeq === undefined) {
|
|
328
|
-
return false;
|
|
329
|
-
}
|
|
330
|
-
if (header.kind === ZLinkStreamMessageKind.Response) {
|
|
331
|
-
return this.requests.complete(header.requestSeq, payload);
|
|
332
|
-
}
|
|
333
|
-
if (header.kind === ZLinkStreamMessageKind.Error) {
|
|
334
|
-
return this.requests.fail(header.requestSeq, decodeStreamErrorPayload(payload));
|
|
335
|
-
}
|
|
336
|
-
return false;
|
|
337
|
-
}
|
|
338
|
-
|
|
339
318
|
payloadForHeader(header: ZLinkStreamFrameHeader, payload: Message): Message {
|
|
340
319
|
if ((header.flags & ZLinkStreamHeaderFlags.PayloadCompressed) === 0) {
|
|
341
320
|
return payload;
|
|
@@ -538,30 +517,22 @@ export class DefaultZLinkSessionActor implements ZLinkSessionActor {
|
|
|
538
517
|
this.currentRef = ref;
|
|
539
518
|
}
|
|
540
519
|
|
|
541
|
-
async relay(payload: ZLinkMessage
|
|
542
|
-
async relay(
|
|
543
|
-
dispatch: ZLinkSessionDispatchContext,
|
|
544
|
-
payload: ZLinkMessage,
|
|
545
|
-
signal?: AbortSignal
|
|
546
|
-
): Promise<void>;
|
|
520
|
+
async relay(payload: ZLinkMessage): Promise<void>;
|
|
521
|
+
async relay(dispatch: ZLinkSessionDispatchContext, payload: ZLinkMessage): Promise<void>;
|
|
547
522
|
async relay(
|
|
548
523
|
dispatchOrPayload: ZLinkSessionDispatchContext | ZLinkMessage,
|
|
549
|
-
|
|
550
|
-
signal?: AbortSignal
|
|
524
|
+
selectedPayload?: ZLinkMessage
|
|
551
525
|
): Promise<void> {
|
|
552
526
|
const dispatch = isSessionDispatchContext(dispatchOrPayload) ? dispatchOrPayload : undefined;
|
|
553
527
|
let payload: ZLinkMessage;
|
|
554
|
-
let relaySignal: AbortSignal | undefined;
|
|
555
528
|
let header: ZLinkStreamFrameHeader | undefined;
|
|
556
529
|
if (dispatch === undefined) {
|
|
557
530
|
payload = dispatchOrPayload as ZLinkMessage;
|
|
558
|
-
relaySignal = payloadOrSignal as AbortSignal | undefined;
|
|
559
531
|
} else {
|
|
560
|
-
payload =
|
|
561
|
-
relaySignal = signal;
|
|
532
|
+
payload = selectedPayload as ZLinkMessage;
|
|
562
533
|
header = sessionDispatchHeader(dispatch);
|
|
563
534
|
}
|
|
564
|
-
const result = await this.runtime.relay(this, payload,
|
|
535
|
+
const result = await this.runtime.relay(this, payload, header);
|
|
565
536
|
requireOneWayCompletion(
|
|
566
537
|
result,
|
|
567
538
|
'Session Actor relay',
|
|
@@ -632,18 +603,6 @@ export class DefaultZLinkBoundSessionFactory implements ZLinkBoundSessionFactory
|
|
|
632
603
|
}
|
|
633
604
|
}
|
|
634
605
|
|
|
635
|
-
function decodeStreamErrorPayload(payload: Message): Error {
|
|
636
|
-
try {
|
|
637
|
-
const value = JSON.parse(Buffer.from(messageToBytes(payload)).toString()) as {
|
|
638
|
-
readonly code?: unknown;
|
|
639
|
-
readonly message?: unknown;
|
|
640
|
-
};
|
|
641
|
-
return new Error(typeof value.message === 'string' ? value.message : 'Stream request failed.');
|
|
642
|
-
} catch {
|
|
643
|
-
return new Error('Stream request failed.');
|
|
644
|
-
}
|
|
645
|
-
}
|
|
646
|
-
|
|
647
606
|
function sameRetiredSession(
|
|
648
607
|
left: ServiceRetiredBoundSessionRouteFence,
|
|
649
608
|
right: ServiceRetiredBoundSessionRouteFence
|
|
@@ -36,14 +36,6 @@ export class ZLinkSessionSerialExecutor {
|
|
|
36
36
|
return this.submit(work, 'lifecycle', options, onRejected);
|
|
37
37
|
}
|
|
38
38
|
|
|
39
|
-
executeInfrastructure(
|
|
40
|
-
work: () => Promise<void>,
|
|
41
|
-
options: Omit<ZLinkSerialWorkOptions, 'lane'> = {},
|
|
42
|
-
onRejected?: (error?: unknown) => void
|
|
43
|
-
): boolean {
|
|
44
|
-
return this.submit(work, 'lifecycle', options, onRejected);
|
|
45
|
-
}
|
|
46
|
-
|
|
47
39
|
executeFinal(work: () => Promise<void>): Promise<void> {
|
|
48
40
|
if (this.closed) {
|
|
49
41
|
return Promise.reject(
|
|
@@ -1,35 +1,9 @@
|
|
|
1
1
|
import type { Message } from '../../contracts/Common/Message';
|
|
2
2
|
import { parseFrameworkJsonV1 } from '../messaging/framework-json-v1';
|
|
3
|
-
import { utf8Decode
|
|
3
|
+
import { utf8Decode } from './protocol';
|
|
4
4
|
|
|
5
5
|
const EMPTY_MESSAGE_BYTES = new Uint8Array(0);
|
|
6
6
|
|
|
7
|
-
export function copyMessage(message: Message): Message {
|
|
8
|
-
const value = message as unknown as {
|
|
9
|
-
copy?: () => Message;
|
|
10
|
-
toBytes?: () => Uint8Array;
|
|
11
|
-
data?: () => Uint8Array;
|
|
12
|
-
bytes?: Uint8Array;
|
|
13
|
-
getString?: () => string;
|
|
14
|
-
};
|
|
15
|
-
if (value.copy !== undefined) {
|
|
16
|
-
return value.copy();
|
|
17
|
-
}
|
|
18
|
-
if (value.toBytes !== undefined) {
|
|
19
|
-
return simpleMessage(value.toBytes()) as Message;
|
|
20
|
-
}
|
|
21
|
-
if (value.data !== undefined) {
|
|
22
|
-
return simpleMessage(value.data()) as Message;
|
|
23
|
-
}
|
|
24
|
-
if (value.bytes !== undefined) {
|
|
25
|
-
return simpleMessage(value.bytes) as Message;
|
|
26
|
-
}
|
|
27
|
-
if (value.getString !== undefined) {
|
|
28
|
-
return simpleMessage(utf8Encode(value.getString())) as Message;
|
|
29
|
-
}
|
|
30
|
-
throw new Error('Stream response payload cannot be copied.');
|
|
31
|
-
}
|
|
32
|
-
|
|
33
7
|
export function simpleMessage(bytes: Uint8Array): unknown {
|
|
34
8
|
return createSimpleMessage(new Uint8Array(bytes), false);
|
|
35
9
|
}
|