@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
|
@@ -5,6 +5,7 @@ exports.submitToRequestResult = submitToRequestResult;
|
|
|
5
5
|
exports.classifySubmitResult = classifySubmitResult;
|
|
6
6
|
exports.requireOneWayCompletion = requireOneWayCompletion;
|
|
7
7
|
exports.requirePublishCompletion = requirePublishCompletion;
|
|
8
|
+
exports.requireClassicFanoutCompletion = requireClassicFanoutCompletion;
|
|
8
9
|
exports.throwAlreadySubmitted = throwAlreadySubmitted;
|
|
9
10
|
const framework_errors_internal_1 = require("../framework-errors-internal");
|
|
10
11
|
const contracts_1 = require("../../contracts");
|
|
@@ -18,7 +19,7 @@ var ZLinkSubmitStatus;
|
|
|
18
19
|
ZLinkSubmitStatus["RouteNotConnected"] = "routeNotConnected";
|
|
19
20
|
ZLinkSubmitStatus["Shutdown"] = "shutdown";
|
|
20
21
|
})(ZLinkSubmitStatus || (exports.ZLinkSubmitStatus = ZLinkSubmitStatus = {}));
|
|
21
|
-
/** Projects
|
|
22
|
+
/** Projects immediate refusal and pending admission failure from their Core phase. */
|
|
22
23
|
function submitToRequestResult(result, phase) {
|
|
23
24
|
switch (result) {
|
|
24
25
|
case runtime_values_1.SubmitResult.Ok:
|
|
@@ -28,7 +29,7 @@ function submitToRequestResult(result, phase) {
|
|
|
28
29
|
case runtime_values_1.SubmitResult.NotConnected:
|
|
29
30
|
return runtime_values_1.RequestResult.NotConnected;
|
|
30
31
|
case runtime_values_1.SubmitResult.NotFound:
|
|
31
|
-
return runtime_values_1.RequestResult.NotFound;
|
|
32
|
+
return phase === 'submit' ? runtime_values_1.RequestResult.NotFound : runtime_values_1.RequestResult.NotConnected;
|
|
32
33
|
case runtime_values_1.SubmitResult.NotAdmitted:
|
|
33
34
|
return runtime_values_1.RequestResult.Rejected;
|
|
34
35
|
case runtime_values_1.SubmitResult.InvalidHandle:
|
|
@@ -45,7 +46,7 @@ function submitToRequestResult(result, phase) {
|
|
|
45
46
|
return runtime_values_1.RequestResult.InternalError;
|
|
46
47
|
}
|
|
47
48
|
}
|
|
48
|
-
function classifySubmitResult(result, operation, phase = '
|
|
49
|
+
function classifySubmitResult(result, operation, phase = 'submit') {
|
|
49
50
|
const terminal = submitToRequestResult(result, phase);
|
|
50
51
|
switch (terminal) {
|
|
51
52
|
case runtime_values_1.RequestResult.Ok:
|
|
@@ -67,8 +68,9 @@ function requireOneWayCompletion(result, operation, notFoundKind = framework_err
|
|
|
67
68
|
case ZLinkSubmitStatus.Submitted:
|
|
68
69
|
return;
|
|
69
70
|
case ZLinkSubmitStatus.TimedOut:
|
|
70
|
-
case ZLinkSubmitStatus.Backpressured:
|
|
71
71
|
throw (0, framework_errors_internal_1.createInternalFrameworkException)(framework_errors_internal_1.ZLinkFrameworkInternalErrorKind.DeadlineExceeded, `${operation} did not obtain admission before its deadline.`, true);
|
|
72
|
+
case ZLinkSubmitStatus.Backpressured:
|
|
73
|
+
throw (0, framework_errors_internal_1.createInternalFrameworkException)(framework_errors_internal_1.ZLinkFrameworkInternalErrorKind.RouteNotConnected, `${operation} has no admission wait token.`, true);
|
|
72
74
|
case ZLinkSubmitStatus.TargetNotFound:
|
|
73
75
|
throw (0, framework_errors_internal_1.createInternalFrameworkException)(notFoundKind, `${operation} target was not found.`);
|
|
74
76
|
case ZLinkSubmitStatus.RouteNotConnected:
|
|
@@ -80,6 +82,11 @@ function requireOneWayCompletion(result, operation, notFoundKind = framework_err
|
|
|
80
82
|
function requirePublishCompletion(result, operation) {
|
|
81
83
|
requireOneWayCompletion(result, operation);
|
|
82
84
|
}
|
|
85
|
+
function requireClassicFanoutCompletion(result, operation) {
|
|
86
|
+
requireOneWayCompletion(result.status === ZLinkSubmitStatus.Backpressured
|
|
87
|
+
? { status: ZLinkSubmitStatus.TimedOut }
|
|
88
|
+
: result, operation);
|
|
89
|
+
}
|
|
83
90
|
function throwAlreadySubmitted(operation) {
|
|
84
91
|
throw (0, framework_errors_internal_1.createInternalFrameworkException)(framework_errors_internal_1.ZLinkFrameworkInternalErrorKind.AlreadySubmitted, `${operation} has already been submitted.`);
|
|
85
92
|
}
|
|
@@ -48,7 +48,7 @@ export interface ZLinkSpotAddressCallOptions {
|
|
|
48
48
|
* activation. Public callers never handle an owner or generation fence.
|
|
49
49
|
*/
|
|
50
50
|
export interface ZLinkSpotAddressTransport {
|
|
51
|
-
sendToSpotAddress(spotId: RoutingId, message: unknown, options: ZLinkSpotAddressCallOptions): Promise<ZLinkSubmitResult>;
|
|
51
|
+
sendToSpotAddress(spotId: RoutingId, message: unknown, options: Omit<ZLinkSpotAddressCallOptions, 'timeoutMs' | 'signal'>): Promise<ZLinkSubmitResult>;
|
|
52
52
|
requestToSpotAddress<TReply = unknown>(spotId: RoutingId, request: unknown, options: ZLinkSpotAddressCallOptions): Promise<TReply>;
|
|
53
53
|
}
|
|
54
54
|
export interface ZLinkSpotRoutedTransport {
|
|
@@ -60,13 +60,11 @@ export interface ZLinkSpotRoutedTransport {
|
|
|
60
60
|
export interface ZLinkSpotRoutedSendOptions {
|
|
61
61
|
readonly instanceSpot?: boolean;
|
|
62
62
|
readonly packetName?: string;
|
|
63
|
-
/** Internal end-to-end budget remaining for route admission. */
|
|
64
|
-
readonly timeoutMs?: number;
|
|
65
|
-
readonly signal?: AbortSignal;
|
|
66
63
|
readonly metadata?: ReadonlyMap<string, string>;
|
|
67
64
|
}
|
|
68
65
|
export interface ZLinkSpotRoutedRequestOptions extends ZLinkSpotRoutedSendOptions {
|
|
69
66
|
readonly timeoutMs?: number;
|
|
67
|
+
readonly signal?: AbortSignal;
|
|
70
68
|
}
|
|
71
69
|
export interface ZLinkSpotHandleCallOptions {
|
|
72
70
|
readonly metadata?: ReadonlyMap<string, string>;
|
|
@@ -75,5 +73,5 @@ export interface ZLinkSpotHandleCallOptions {
|
|
|
75
73
|
readonly spotRouterChannelIdForMesh?: (meshName: string) => string;
|
|
76
74
|
readonly sourceSpot?: ZLinkBackendSpot;
|
|
77
75
|
}
|
|
78
|
-
export declare function sendToSpotHandle(transport: ZLinkSpotRoutedTransport, spot: SpotHandle, message: unknown, options?: ZLinkSpotHandleCallOptions): Promise<ZLinkSubmitResult>;
|
|
76
|
+
export declare function sendToSpotHandle(transport: ZLinkSpotRoutedTransport, spot: SpotHandle, message: unknown, options?: Omit<ZLinkSpotHandleCallOptions, 'timeoutMs' | 'signal'>): Promise<ZLinkSubmitResult>;
|
|
79
77
|
export declare function requestToSpotHandle<TReply = unknown>(transport: ZLinkSpotRoutedTransport, spot: SpotHandle, request: unknown, options?: ZLinkSpotHandleCallOptions): Promise<TReply>;
|
|
@@ -103,10 +103,10 @@ function createAddressedSpotSendCall(serial, transport, spotId, message, sourceS
|
|
|
103
103
|
options.initialMeshName = requireAddressValue(meshName, 'Mesh name', CoreTypes_1.ZLINK_MAX_MESH_NAME_BYTES);
|
|
104
104
|
return this;
|
|
105
105
|
},
|
|
106
|
-
async submit(
|
|
106
|
+
async submit() {
|
|
107
107
|
markSubmitted(options);
|
|
108
108
|
const pending = startRequestOnSerial(serial, () => ({
|
|
109
|
-
pending: transport.sendToSpotAddress(spotId, message, freezeAddressCallOptions(options,
|
|
109
|
+
pending: transport.sendToSpotAddress(spotId, message, freezeAddressCallOptions(options, sourceSpotProvider?.()))
|
|
110
110
|
}));
|
|
111
111
|
const result = await (serial.isCurrentTurn ? pending : (0, workers_1.deliverOnSerial)(serial, pending));
|
|
112
112
|
(0, submission_result_1.requireOneWayCompletion)(result, 'Spot send', framework_errors_internal_1.ZLinkFrameworkInternalErrorKind.SpotRouteNotFound);
|
|
@@ -119,7 +119,11 @@ function createAddressedSpotRequestCall(serial, transport, spotId, request, sour
|
|
|
119
119
|
markSubmitted(options);
|
|
120
120
|
rejectSameSpotAsyncRequest(serial, spotId, waitPolicy);
|
|
121
121
|
return startRequestOnSerial(serial, () => ({
|
|
122
|
-
pending: transport.requestToSpotAddress(spotId, request,
|
|
122
|
+
pending: transport.requestToSpotAddress(spotId, request, {
|
|
123
|
+
...freezeAddressCallOptions(options, sourceSpotProvider?.()),
|
|
124
|
+
timeoutMs: options.timeoutMs,
|
|
125
|
+
signal
|
|
126
|
+
})
|
|
123
127
|
}));
|
|
124
128
|
};
|
|
125
129
|
return {
|
|
@@ -200,14 +204,12 @@ function markSubmitted(options) {
|
|
|
200
204
|
}
|
|
201
205
|
options.submitted = true;
|
|
202
206
|
}
|
|
203
|
-
function freezeAddressCallOptions(options,
|
|
207
|
+
function freezeAddressCallOptions(options, sourceSpot) {
|
|
204
208
|
return {
|
|
205
209
|
...(options.metadataPresent ? { metadata: new Map(options.metadata) } : {}),
|
|
206
210
|
instanceSpot: options.instanceSpot,
|
|
207
211
|
instanceSpotType: options.instanceSpotType,
|
|
208
212
|
initialMeshName: options.initialMeshName,
|
|
209
|
-
timeoutMs: options.timeoutMs,
|
|
210
|
-
signal,
|
|
211
213
|
sourceSpot
|
|
212
214
|
};
|
|
213
215
|
}
|
|
@@ -227,8 +229,8 @@ function wrapSendCall(serial, inner) {
|
|
|
227
229
|
inner.metadata(key);
|
|
228
230
|
return this;
|
|
229
231
|
},
|
|
230
|
-
async submit(
|
|
231
|
-
const result = await runInternalTransportStart(serial, () => inner.submit(
|
|
232
|
+
async submit() {
|
|
233
|
+
const result = await runInternalTransportStart(serial, () => inner.submit());
|
|
232
234
|
return result;
|
|
233
235
|
}
|
|
234
236
|
};
|
|
@@ -302,11 +304,10 @@ function wrapRoutedSpotSendCall(serial, transport, spot, message, spotRouterChan
|
|
|
302
304
|
}
|
|
303
305
|
return this;
|
|
304
306
|
},
|
|
305
|
-
async submit(
|
|
307
|
+
async submit() {
|
|
306
308
|
const pending = startRequestOnSerial(serial, () => ({
|
|
307
309
|
pending: sendToSpotHandle(transport, spot, message, {
|
|
308
310
|
metadata,
|
|
309
|
-
signal,
|
|
310
311
|
spotRouterChannelIdForMesh,
|
|
311
312
|
sourceSpot: sourceSpotProvider?.()
|
|
312
313
|
})
|
|
@@ -376,19 +377,15 @@ async function sendToSpotHandle(transport, spot, message, options = {}) {
|
|
|
376
377
|
if (options.sourceSpot !== undefined && transport.sendFromSpotToSpot !== undefined) {
|
|
377
378
|
return transport.sendFromSpotToSpot(options.sourceSpot, target, message, {
|
|
378
379
|
packetName,
|
|
379
|
-
timeoutMs: options.timeoutMs,
|
|
380
|
-
signal: options.signal,
|
|
381
380
|
metadata: options.metadata
|
|
382
381
|
});
|
|
383
382
|
}
|
|
384
383
|
return transport.sendToSpot(target, message, {
|
|
385
384
|
packetName,
|
|
386
|
-
timeoutMs: options.timeoutMs,
|
|
387
|
-
signal: options.signal,
|
|
388
385
|
metadata: options.metadata
|
|
389
386
|
});
|
|
390
387
|
};
|
|
391
|
-
return sendResolved(await requireSpotRef(spot
|
|
388
|
+
return sendResolved(await requireSpotRef(spot));
|
|
392
389
|
}
|
|
393
390
|
async function requestToSpotHandle(transport, spot, request, options = {}) {
|
|
394
391
|
const packetName = (0, packet_name_1.resolveFrameworkPacketName)(request, undefined, 'SPOT');
|
|
@@ -12,7 +12,7 @@ export interface ZLinkBoundActorRelaySenderOptions {
|
|
|
12
12
|
readonly dispatchErrors?: ZLinkDispatchErrorReporter;
|
|
13
13
|
readonly actorBindTimeoutMs?: number;
|
|
14
14
|
readonly messageSerializers?: ReadonlyMap<string, ZLinkMessageSerializer>;
|
|
15
|
-
readonly relay?: (actor: ZLinkSessionActor, header: ZLinkStreamFrameHeader, payload: Message
|
|
15
|
+
readonly relay?: (actor: ZLinkSessionActor, header: ZLinkStreamFrameHeader, payload: Message) => Promise<boolean>;
|
|
16
16
|
readonly notifyDisconnected?: (actor: ZLinkSessionActor, signal?: AbortSignal) => Promise<void>;
|
|
17
17
|
}
|
|
18
18
|
export declare class ZLinkBoundActorRelaySender {
|
|
@@ -21,7 +21,7 @@ export declare class ZLinkBoundActorRelaySender {
|
|
|
21
21
|
private readonly options;
|
|
22
22
|
private readonly lifecycle;
|
|
23
23
|
constructor(routes: ZLinkActorSessionBindingRegistry<DefaultZLinkSessionContext, DefaultZLinkSessionActor>, frameMessages: ZLinkStreamFrameMessageFactory, options?: ZLinkBoundActorRelaySenderOptions, lifecycle?: ZLinkActorSessionLifecycleCoordinator);
|
|
24
|
-
relay(actor: DefaultZLinkSessionActor, payload: ZLinkMessage,
|
|
24
|
+
relay(actor: DefaultZLinkSessionActor, payload: ZLinkMessage, dispatchHeader?: ZLinkStreamFrameHeader): Promise<ZLinkSubmitResult>;
|
|
25
25
|
private traceHeldDrop;
|
|
26
26
|
private relayAcceptedFrame;
|
|
27
27
|
private currentHeader;
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ZLinkBoundActorRelaySender = exports.DEFAULT_RELAY_ACTOR_BIND_TIMEOUT_MS = void 0;
|
|
4
4
|
const ZLinkDispatchOptions_1 = require("../../contracts/Dispatch/ZLinkDispatchOptions");
|
|
5
|
-
const abort_1 = require("../abort");
|
|
6
5
|
const diagnostics_1 = require("../diagnostics");
|
|
7
6
|
const payload_codec_1 = require("../messaging/payload-codec");
|
|
8
7
|
const submission_result_1 = require("../messaging/submission-result");
|
|
@@ -22,15 +21,15 @@ class ZLinkBoundActorRelaySender {
|
|
|
22
21
|
this.options = options;
|
|
23
22
|
this.lifecycle = lifecycle;
|
|
24
23
|
}
|
|
25
|
-
async relay(actor, payload,
|
|
24
|
+
async relay(actor, payload, dispatchHeader) {
|
|
26
25
|
const header = dispatchHeader === undefined
|
|
27
26
|
? await this.currentHeader(actor)
|
|
28
27
|
: await this.requireDispatchHeader(actor, dispatchHeader);
|
|
29
28
|
if (header.kind === protocol_1.ZLinkStreamMessageKind.Request && header.requestSeq !== undefined) {
|
|
30
29
|
const operation = async () => {
|
|
31
|
-
const admission = await this.routes.beginAcceptedRequestFrameWhenReady(actor.actorId, actor.bindingToken
|
|
30
|
+
const admission = await this.routes.beginAcceptedRequestFrameWhenReady(actor.actorId, actor.bindingToken);
|
|
32
31
|
try {
|
|
33
|
-
return await this.relayAcceptedFrame(actor, payload,
|
|
32
|
+
return await this.relayAcceptedFrame(actor, payload, header, admission);
|
|
34
33
|
}
|
|
35
34
|
finally {
|
|
36
35
|
await admission.complete();
|
|
@@ -38,13 +37,12 @@ class ZLinkBoundActorRelaySender {
|
|
|
38
37
|
};
|
|
39
38
|
return await operation();
|
|
40
39
|
}
|
|
41
|
-
(0, abort_1.throwIfAborted)(signal);
|
|
42
40
|
const held = await this.routes.acceptOneWay(actor.actorId, actor.bindingToken, () => {
|
|
43
41
|
let heldMessage = (0, payload_codec_1.encodeFrameworkPayloadMessage)(payload, this.options.messageSerializers);
|
|
44
42
|
return {
|
|
45
43
|
deliver: async () => {
|
|
46
44
|
try {
|
|
47
|
-
const result = await this.routes.runAcceptedFrameWhenReady(actor.actorId, actor.bindingToken, () => this.relayAcceptedFrame(actor, payload,
|
|
45
|
+
const result = await this.routes.runAcceptedFrameWhenReady(actor.actorId, actor.bindingToken, () => this.relayAcceptedFrame(actor, payload, header, undefined, heldMessage));
|
|
48
46
|
if (result.status !== submission_result_1.ZLinkSubmitStatus.Submitted) {
|
|
49
47
|
this.traceHeldDrop(header, result.status === submission_result_1.ZLinkSubmitStatus.Backpressured ||
|
|
50
48
|
result.status === submission_result_1.ZLinkSubmitStatus.TimedOut
|
|
@@ -69,7 +67,7 @@ class ZLinkBoundActorRelaySender {
|
|
|
69
67
|
if (held) {
|
|
70
68
|
return { status: submission_result_1.ZLinkSubmitStatus.Submitted };
|
|
71
69
|
}
|
|
72
|
-
return this.routes.runAcceptedFrameWhenReady(actor.actorId, actor.bindingToken, () => this.relayAcceptedFrame(actor, payload
|
|
70
|
+
return this.routes.runAcceptedFrameWhenReady(actor.actorId, actor.bindingToken, () => this.relayAcceptedFrame(actor, payload));
|
|
73
71
|
}
|
|
74
72
|
traceHeldDrop(header, reason, error) {
|
|
75
73
|
(0, diagnostics_1.flowIfEnabled)(this.options.dispatchErrors?.flow, ZLinkDispatchOptions_1.ZLinkRuntimeMessageFlowOutcome.Dropped, undefined, header.flowId)?.trace({
|
|
@@ -84,10 +82,10 @@ class ZLinkBoundActorRelaySender {
|
|
|
84
82
|
...(error instanceof Error ? { errorType: error.name, errorMessage: error.message } : {})
|
|
85
83
|
});
|
|
86
84
|
}
|
|
87
|
-
async relayAcceptedFrame(actor, payload,
|
|
85
|
+
async relayAcceptedFrame(actor, payload, header, requestAdmission, acceptedPayload) {
|
|
88
86
|
const activeHeader = header ?? (await this.currentHeader(actor));
|
|
89
87
|
const started = await this.lifecycle.run(actor.actorId, async () => {
|
|
90
|
-
const completion = this.relayInsideLifecycle(actor, payload,
|
|
88
|
+
const completion = this.relayInsideLifecycle(actor, payload, activeHeader, requestAdmission, acceptedPayload);
|
|
91
89
|
if (activeHeader.kind === protocol_1.ZLinkStreamMessageKind.Request &&
|
|
92
90
|
activeHeader.requestSeq !== undefined) {
|
|
93
91
|
// A routed REQUEST only needs this lane while its ordered submission
|
|
@@ -119,16 +117,15 @@ class ZLinkBoundActorRelaySender {
|
|
|
119
117
|
}
|
|
120
118
|
return header;
|
|
121
119
|
}
|
|
122
|
-
async relayInsideLifecycle(actor, payload,
|
|
120
|
+
async relayInsideLifecycle(actor, payload, currentHeader, requestAdmission, acceptedPayload) {
|
|
123
121
|
const header = currentHeader ?? (await this.currentHeader(actor));
|
|
124
|
-
const held = requestAdmission?.beginSubmission(
|
|
122
|
+
const held = requestAdmission?.beginSubmission();
|
|
125
123
|
if (held !== undefined)
|
|
126
124
|
await held;
|
|
127
|
-
(0, abort_1.throwIfAborted)(signal);
|
|
128
125
|
const payloadMessage = acceptedPayload ?? (0, payload_codec_1.encodeFrameworkPayloadMessage)(payload, this.options.messageSerializers);
|
|
129
126
|
try {
|
|
130
127
|
if (this.options.relay !== undefined) {
|
|
131
|
-
const handled = await this.options.relay(actor, header, payloadMessage
|
|
128
|
+
const handled = await this.options.relay(actor, header, payloadMessage);
|
|
132
129
|
if (handled) {
|
|
133
130
|
return { status: submission_result_1.ZLinkSubmitStatus.Submitted };
|
|
134
131
|
}
|
|
@@ -140,7 +137,10 @@ class ZLinkBoundActorRelaySender {
|
|
|
140
137
|
const headerMessage = this.frameMessages.createBinaryMessage((0, protocol_1.encodeStreamHeader)(header));
|
|
141
138
|
const framePayloadMessage = this.frameMessages.createBinaryMessage((0, protocol_1.messageToBytes)(payloadMessage));
|
|
142
139
|
try {
|
|
143
|
-
return await route.context.stream.submitBoundActor(actor.actorId, [
|
|
140
|
+
return await route.context.stream.submitBoundActor(actor.actorId, [
|
|
141
|
+
headerMessage,
|
|
142
|
+
framePayloadMessage
|
|
143
|
+
]);
|
|
144
144
|
}
|
|
145
145
|
finally {
|
|
146
146
|
headerMessage.close();
|
|
@@ -47,7 +47,7 @@ class ZLinkBoundSessionService {
|
|
|
47
47
|
if ((await this.routes.route(actorId))?.bindingToken !== route.bindingToken) {
|
|
48
48
|
return { status: submission_result_1.ZLinkSubmitStatus.TargetNotFound };
|
|
49
49
|
}
|
|
50
|
-
return await route.context.stream.submitRaw(frame
|
|
50
|
+
return await route.context.stream.submitRaw(frame);
|
|
51
51
|
}
|
|
52
52
|
finally {
|
|
53
53
|
frame.close();
|
|
@@ -45,7 +45,7 @@ export interface ZLinkStreamBindingRuntimeOptions {
|
|
|
45
45
|
readonly errorSink?: () => {
|
|
46
46
|
reportRuntimeTaskException(taskName: string, error: unknown): void;
|
|
47
47
|
} | undefined;
|
|
48
|
-
readonly relay?: (actor: ZLinkSessionActor, header: ZLinkStreamFrameHeader, payload: Message
|
|
48
|
+
readonly relay?: (actor: ZLinkSessionActor, header: ZLinkStreamFrameHeader, payload: Message) => Promise<boolean>;
|
|
49
49
|
readonly notifyDisconnected?: (actor: ZLinkSessionActor, signal?: AbortSignal) => Promise<void>;
|
|
50
50
|
readonly flowCreationEnabled?: () => boolean;
|
|
51
51
|
readonly metrics?: import('../diagnostics').ZLinkRuntimeMetrics;
|
|
@@ -143,7 +143,7 @@ export declare class ZLinkStreamBindingRuntime {
|
|
|
143
143
|
disconnectNativeBoundSession(node: ZLinkBackendActorSessionNode, actorRef: ActorRef, signal?: AbortSignal): Promise<void>;
|
|
144
144
|
disconnectBoundSession(actorId: string, signal?: AbortSignal): Promise<void>;
|
|
145
145
|
closeSessionBinding(actorId: string, expected: ZLinkSessionBindingIdentity, signal?: AbortSignal): Promise<void>;
|
|
146
|
-
relay(actor: DefaultZLinkSessionActor, payload: ZLinkMessage,
|
|
146
|
+
relay(actor: DefaultZLinkSessionActor, payload: ZLinkMessage, dispatchHeader?: ZLinkStreamFrameHeader): Promise<ZLinkSubmitResult>;
|
|
147
147
|
notifyDisconnected(actor: DefaultZLinkSessionActor, signal?: AbortSignal): Promise<void>;
|
|
148
148
|
createTextMessage(payload: string): Message;
|
|
149
149
|
createBinaryMessage(payload: Uint8Array): Message;
|
|
@@ -327,8 +327,8 @@ class ZLinkStreamBindingRuntime {
|
|
|
327
327
|
async closeSessionBinding(actorId, expected, signal) {
|
|
328
328
|
await this.boundSessions.closeSessionBinding(actorId, expected, signal);
|
|
329
329
|
}
|
|
330
|
-
async relay(actor, payload,
|
|
331
|
-
return await this.boundActorRelay.relay(actor, payload,
|
|
330
|
+
async relay(actor, payload, dispatchHeader) {
|
|
331
|
+
return await this.boundActorRelay.relay(actor, payload, dispatchHeader);
|
|
332
332
|
}
|
|
333
333
|
async notifyDisconnected(actor, signal) {
|
|
334
334
|
await this.boundActorRelay.notifyDisconnected(actor, signal);
|
|
@@ -37,8 +37,8 @@ export declare class ZLinkManagedStream implements ZLinkStream {
|
|
|
37
37
|
get remoteAddr(): string | undefined;
|
|
38
38
|
write(payload: ZLinkMessage, flags?: ZLinkBackendSendFlags): boolean;
|
|
39
39
|
writeRaw(payload: Message, flags?: ZLinkBackendSendFlags): boolean;
|
|
40
|
-
submitRaw(payload: Message
|
|
41
|
-
submitBoundActor(actorId: string, parts: readonly Message[]
|
|
40
|
+
submitRaw(payload: Message): Promise<ZLinkSubmitResult>;
|
|
41
|
+
submitBoundActor(actorId: string, parts: readonly Message[]): Promise<ZLinkSubmitResult>;
|
|
42
42
|
close(signal?: AbortSignal): Promise<void>;
|
|
43
43
|
closeForDrain(signal?: AbortSignal): Promise<void>;
|
|
44
44
|
writeControl(name: string): Promise<void>;
|
|
@@ -75,10 +75,9 @@ class ZLinkManagedStream {
|
|
|
75
75
|
writeRaw(payload, flags) {
|
|
76
76
|
return this.socket.send(this.backendRoutingId(), payload, flags ?? 0);
|
|
77
77
|
}
|
|
78
|
-
async submitRaw(payload
|
|
78
|
+
async submitRaw(payload) {
|
|
79
79
|
try {
|
|
80
|
-
(
|
|
81
|
-
await this.socket.submit(this.backendRoutingId(), payload, timeoutMs);
|
|
80
|
+
await this.socket.submit(this.backendRoutingId(), payload);
|
|
82
81
|
return { status: submission_result_1.ZLinkSubmitStatus.Submitted };
|
|
83
82
|
}
|
|
84
83
|
catch (error) {
|
|
@@ -88,8 +87,7 @@ class ZLinkManagedStream {
|
|
|
88
87
|
throw error;
|
|
89
88
|
}
|
|
90
89
|
}
|
|
91
|
-
async submitBoundActor(actorId, parts
|
|
92
|
-
(0, abort_1.throwIfAborted)(signal);
|
|
90
|
+
async submitBoundActor(actorId, parts) {
|
|
93
91
|
return (await this.sendBoundActor(actorId, parts, ZLINK_SEND_DONT_WAIT))
|
|
94
92
|
? { status: submission_result_1.ZLinkSubmitStatus.Submitted }
|
|
95
93
|
: { status: submission_result_1.ZLinkSubmitStatus.Backpressured };
|
|
@@ -9,7 +9,6 @@ const actor_packet_relay_wire_1 = require("../actors/actor-packet-relay-wire");
|
|
|
9
9
|
const bound_session_wire_1 = require("../actors/bound-session-wire");
|
|
10
10
|
const actor_routed_json_request_1 = require("../actors/actor-routed-json-request");
|
|
11
11
|
const protocol_1 = require("./protocol");
|
|
12
|
-
const abort_1 = require("../abort");
|
|
13
12
|
const packet_name_1 = require("../messaging/packet-name");
|
|
14
13
|
const flow_context_1 = require("../diagnostics/flow-context");
|
|
15
14
|
class ZLinkNativeFallbackBoundSession {
|
|
@@ -45,8 +44,7 @@ class ZLinkNativeFallbackBoundSession {
|
|
|
45
44
|
return;
|
|
46
45
|
}
|
|
47
46
|
await this.options.routedTransport.sendToSpot(target, payload, {
|
|
48
|
-
packetName: actors_1.ZLINK_REMOTE_ACTOR_PACKET_RELAY_PACKET
|
|
49
|
-
signal
|
|
47
|
+
packetName: actors_1.ZLINK_REMOTE_ACTOR_PACKET_RELAY_PACKET
|
|
50
48
|
});
|
|
51
49
|
return;
|
|
52
50
|
}
|
|
@@ -80,28 +78,27 @@ class ZLinkNativeFallbackBoundSessionSendCall {
|
|
|
80
78
|
this.selectedPacketName = packetName;
|
|
81
79
|
return this;
|
|
82
80
|
}
|
|
83
|
-
async submit(
|
|
81
|
+
async submit() {
|
|
84
82
|
if (this.executed) {
|
|
85
83
|
(0, submission_result_1.throwAlreadySubmitted)('Bound session send call');
|
|
86
84
|
}
|
|
87
85
|
const packetName = (0, packet_name_1.resolveFrameworkPacketName)(this.message, this.selectedPacketName, 'Bound session');
|
|
88
86
|
this.executed = true;
|
|
89
|
-
|
|
90
|
-
const result = await this.execute(packetName, signal);
|
|
87
|
+
const result = await this.execute(packetName);
|
|
91
88
|
(0, submission_result_1.requireOneWayCompletion)(result, 'Bound session send', framework_errors_internal_1.ZLinkFrameworkInternalErrorKind.ActorSessionNotBound);
|
|
92
89
|
}
|
|
93
|
-
execute(packetName
|
|
90
|
+
execute(packetName) {
|
|
94
91
|
// Call-scoped flow (spec 27 §4): the relay JSON flow pair and any nested
|
|
95
92
|
// routed-transport envelope share one ambient flow that does not outlive
|
|
96
93
|
// this submit call.
|
|
97
|
-
return (0, flow_context_1.runWithOutboundFlow)(this.options.flowCreationEnabled?.() ?? true, () => this.executeScoped(packetName
|
|
94
|
+
return (0, flow_context_1.runWithOutboundFlow)(this.options.flowCreationEnabled?.() ?? true, () => this.executeScoped(packetName));
|
|
98
95
|
}
|
|
99
|
-
async executeScoped(packetName
|
|
96
|
+
async executeScoped(packetName) {
|
|
100
97
|
const localActor = this.options.localActorProvider?.() === true;
|
|
101
98
|
const remoteTarget = this.options.remoteBoundSessionTargetProvider();
|
|
102
99
|
let nativeAttempted = false;
|
|
103
100
|
if (localActor) {
|
|
104
|
-
const result = await this.options.runtime.submitLocalBoundSession(this.options.actorId, this.message, packetName, this.selectedMetadata
|
|
101
|
+
const result = await this.options.runtime.submitLocalBoundSession(this.options.actorId, this.message, packetName, this.selectedMetadata);
|
|
105
102
|
if (result.status !== submission_result_1.ZLinkSubmitStatus.TargetNotFound) {
|
|
106
103
|
this.traceSubmitted(result, packetName);
|
|
107
104
|
return result;
|
|
@@ -115,7 +112,7 @@ class ZLinkNativeFallbackBoundSessionSendCall {
|
|
|
115
112
|
const bindingGeneration = currentBindingGeneration(actorRef);
|
|
116
113
|
if (actorRef !== undefined && node !== undefined && bindingGeneration !== undefined) {
|
|
117
114
|
nativeAttempted = true;
|
|
118
|
-
const result = await this.options.runtime.sendNativeBoundSession(node, actorRef, this.message, packetName, this.selectedMetadata
|
|
115
|
+
const result = await this.options.runtime.sendNativeBoundSession(node, actorRef, this.message, packetName, this.selectedMetadata);
|
|
119
116
|
if (result.status !== submission_result_1.ZLinkSubmitStatus.TargetNotFound) {
|
|
120
117
|
this.traceSubmitted(result, packetName);
|
|
121
118
|
return result;
|
|
@@ -150,12 +147,12 @@ class ZLinkNativeFallbackBoundSessionSendCall {
|
|
|
150
147
|
targetNodeRid: remoteTarget.targetNodeRid,
|
|
151
148
|
spotId: remoteTarget.spotId,
|
|
152
149
|
spotKind: contracts_1.ZLinkSpotKind.Entry
|
|
153
|
-
}, payload, { packetName: actors_1.ZLINK_REMOTE_BOUND_SESSION_SEND_PACKET
|
|
154
|
-
: await submit.call(this.options.routedTransport, remoteTarget.routerChannelId, String(remoteTarget.targetNodeRid), actors_1.ZLINK_REMOTE_BOUND_SESSION_SEND_PACKET, payload
|
|
150
|
+
}, payload, { packetName: actors_1.ZLINK_REMOTE_BOUND_SESSION_SEND_PACKET })
|
|
151
|
+
: await submit.call(this.options.routedTransport, remoteTarget.routerChannelId, String(remoteTarget.targetNodeRid), actors_1.ZLINK_REMOTE_BOUND_SESSION_SEND_PACKET, payload);
|
|
155
152
|
this.traceSubmitted(result, packetName);
|
|
156
153
|
return result;
|
|
157
154
|
}
|
|
158
|
-
const localResult = await this.options.runtime.submitLocalBoundSession(this.options.actorId, this.message, packetName, this.selectedMetadata
|
|
155
|
+
const localResult = await this.options.runtime.submitLocalBoundSession(this.options.actorId, this.message, packetName, this.selectedMetadata);
|
|
159
156
|
if (localResult.status !== submission_result_1.ZLinkSubmitStatus.TargetNotFound) {
|
|
160
157
|
this.traceSubmitted(localResult, packetName);
|
|
161
158
|
return localResult;
|
|
@@ -167,14 +164,14 @@ class ZLinkNativeFallbackBoundSessionSendCall {
|
|
|
167
164
|
actorRef !== undefined &&
|
|
168
165
|
node !== undefined &&
|
|
169
166
|
bindingGeneration !== undefined) {
|
|
170
|
-
const result = await this.options.runtime.sendNativeBoundSession(node, actorRef, this.message, packetName, this.selectedMetadata
|
|
167
|
+
const result = await this.options.runtime.sendNativeBoundSession(node, actorRef, this.message, packetName, this.selectedMetadata);
|
|
171
168
|
this.traceSubmitted(result, packetName);
|
|
172
169
|
return result;
|
|
173
170
|
}
|
|
174
171
|
if (localActor) {
|
|
175
172
|
throw (0, framework_errors_internal_1.createInternalFrameworkException)(framework_errors_internal_1.ZLinkFrameworkInternalErrorKind.ActorSessionNotBound, `No current session binding exists for actor '${this.options.actorId}'.`, true);
|
|
176
173
|
}
|
|
177
|
-
const result = await this.options.runtime.sendBoundSession(this.options.actorId, this.message, packetName, this.selectedMetadata
|
|
174
|
+
const result = await this.options.runtime.sendBoundSession(this.options.actorId, this.message, packetName, this.selectedMetadata);
|
|
178
175
|
this.traceSubmitted(result, packetName);
|
|
179
176
|
return result;
|
|
180
177
|
}
|
|
@@ -3,12 +3,12 @@ import type { Message } from '../../contracts/Common/Message';
|
|
|
3
3
|
import { type ZLinkSubmitResult } from '../messaging/submission-result';
|
|
4
4
|
import { type ZLinkStreamFrameHeader, ZLinkStreamMessageKind, type ZLinkStreamReplyMessageKind } from './protocol';
|
|
5
5
|
export interface ZLinkBoundSessionSendRuntime {
|
|
6
|
-
sendBoundSession(actorId: string, message: unknown, packetName: string | undefined, metadata: ReadonlyMap<string, string
|
|
6
|
+
sendBoundSession(actorId: string, message: unknown, packetName: string | undefined, metadata: ReadonlyMap<string, string>): Promise<ZLinkSubmitResult>;
|
|
7
7
|
}
|
|
8
8
|
export interface ZLinkSessionCallContext {
|
|
9
9
|
readonly stream: {
|
|
10
10
|
writeRaw(payload: Message): boolean;
|
|
11
|
-
submitRaw(payload: Message
|
|
11
|
+
submitRaw(payload: Message): Promise<ZLinkSubmitResult>;
|
|
12
12
|
};
|
|
13
13
|
readonly dispatchHeader: ZLinkStreamFrameHeader | undefined;
|
|
14
14
|
createJsonFrameMessage(kind: ZLinkStreamMessageKind, packetName: string, metadata: ReadonlyMap<string, string>, compressed: boolean, requestSeq: bigint | undefined, payload: unknown, correlationId?: string): Message;
|
|
@@ -31,7 +31,7 @@ export declare class DefaultZLinkBoundSessionSendCall implements ZLinkBoundSessi
|
|
|
31
31
|
constructor(runtime: ZLinkBoundSessionSendRuntime, actorId: string, message: unknown);
|
|
32
32
|
metadata(key: string, value: string): this;
|
|
33
33
|
packetName(packetName: string): this;
|
|
34
|
-
submit(
|
|
34
|
+
submit(): Promise<void>;
|
|
35
35
|
}
|
|
36
36
|
export declare class DefaultZLinkSessionSendCall implements ZLinkSessionSendCall {
|
|
37
37
|
private readonly context;
|
|
@@ -39,14 +39,12 @@ export declare class DefaultZLinkSessionSendCall implements ZLinkSessionSendCall
|
|
|
39
39
|
private selectedPacketName;
|
|
40
40
|
private readonly selectedMetadata;
|
|
41
41
|
private compressionEnabled;
|
|
42
|
-
private selectedTimeoutMs;
|
|
43
42
|
private executed;
|
|
44
43
|
constructor(context: ZLinkSessionCallContext, message: unknown);
|
|
45
44
|
metadata(key: string, value: string): this;
|
|
46
45
|
packetName(packetName: string): this;
|
|
47
46
|
compress(enabled?: boolean): this;
|
|
48
|
-
|
|
49
|
-
submit(signal?: AbortSignal): Promise<void>;
|
|
47
|
+
submit(): Promise<void>;
|
|
50
48
|
}
|
|
51
49
|
export declare class DefaultZLinkSessionReplyCall implements ZLinkSessionReplyCall {
|
|
52
50
|
private readonly context;
|
|
@@ -55,5 +53,5 @@ export declare class DefaultZLinkSessionReplyCall implements ZLinkSessionReplyCa
|
|
|
55
53
|
private executed;
|
|
56
54
|
constructor(context: ZLinkSessionCallContext, message: unknown);
|
|
57
55
|
compress(enabled?: boolean): this;
|
|
58
|
-
submit(
|
|
56
|
+
submit(): Promise<void>;
|
|
59
57
|
}
|
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.DefaultZLinkSessionReplyCall = exports.DefaultZLinkSessionSendCall = exports.DefaultZLinkBoundSessionSendCall = void 0;
|
|
4
|
-
const SendTimeoutValidation_1 = require("../../contracts/Configuration/SendTimeoutValidation");
|
|
5
|
-
const abort_1 = require("../abort");
|
|
6
|
-
const configuration_1 = require("../configuration");
|
|
7
4
|
const framework_errors_internal_1 = require("../framework-errors-internal");
|
|
8
5
|
const submission_result_1 = require("../messaging/submission-result");
|
|
9
6
|
const protocol_1 = require("./protocol");
|
|
@@ -27,12 +24,11 @@ class DefaultZLinkBoundSessionSendCall {
|
|
|
27
24
|
this.selectedPacketName = packetName;
|
|
28
25
|
return this;
|
|
29
26
|
}
|
|
30
|
-
async submit(
|
|
27
|
+
async submit() {
|
|
31
28
|
(0, protocol_1.ensureSingleSubmit)(this.executed);
|
|
32
29
|
const packetName = (0, protocol_1.resolvePacketName)(this.message, this.selectedPacketName);
|
|
33
30
|
this.executed = true;
|
|
34
|
-
(
|
|
35
|
-
const result = await this.runtime.sendBoundSession(this.actorId, this.message, packetName, this.selectedMetadata, signal);
|
|
31
|
+
const result = await this.runtime.sendBoundSession(this.actorId, this.message, packetName, this.selectedMetadata);
|
|
36
32
|
(0, submission_result_1.requireOneWayCompletion)(result, 'Bound session send', framework_errors_internal_1.ZLinkFrameworkInternalErrorKind.ActorSessionNotBound);
|
|
37
33
|
}
|
|
38
34
|
}
|
|
@@ -43,7 +39,6 @@ class DefaultZLinkSessionSendCall {
|
|
|
43
39
|
selectedPacketName;
|
|
44
40
|
selectedMetadata = new Map();
|
|
45
41
|
compressionEnabled = false;
|
|
46
|
-
selectedTimeoutMs;
|
|
47
42
|
executed = false;
|
|
48
43
|
constructor(context, message) {
|
|
49
44
|
this.context = context;
|
|
@@ -61,21 +56,13 @@ class DefaultZLinkSessionSendCall {
|
|
|
61
56
|
this.compressionEnabled = enabled;
|
|
62
57
|
return this;
|
|
63
58
|
}
|
|
64
|
-
|
|
65
|
-
if (!Number.isInteger(timeoutMs) || timeoutMs < 1 || timeoutMs > SendTimeoutValidation_1.ZLINK_MAX_SEND_TIMEOUT_MS) {
|
|
66
|
-
throw new configuration_1.ZLinkConfigurationException(`STREAM session send timeout must be an integer from 1 through ${SendTimeoutValidation_1.ZLINK_MAX_SEND_TIMEOUT_MS} milliseconds.`);
|
|
67
|
-
}
|
|
68
|
-
this.selectedTimeoutMs = timeoutMs;
|
|
69
|
-
return this;
|
|
70
|
-
}
|
|
71
|
-
async submit(signal) {
|
|
59
|
+
async submit() {
|
|
72
60
|
(0, protocol_1.ensureSingleSubmit)(this.executed);
|
|
73
61
|
const packetName = (0, protocol_1.resolvePacketName)(this.message, this.selectedPacketName);
|
|
74
62
|
this.executed = true;
|
|
75
|
-
(0, abort_1.throwIfAborted)(signal);
|
|
76
63
|
const message = this.context.createJsonFrameMessage(protocol_1.ZLinkStreamMessageKind.Send, packetName, this.selectedMetadata, this.compressionEnabled, undefined, this.message);
|
|
77
64
|
try {
|
|
78
|
-
const result = await this.context.stream.submitRaw(message
|
|
65
|
+
const result = await this.context.stream.submitRaw(message);
|
|
79
66
|
(0, submission_result_1.requireOneWayCompletion)(result, 'STREAM session send');
|
|
80
67
|
this.context.traceFrameWritten?.(protocol_1.ZLinkStreamMessageKind.Send, packetName, undefined);
|
|
81
68
|
}
|
|
@@ -98,7 +85,7 @@ class DefaultZLinkSessionReplyCall {
|
|
|
98
85
|
this.compressionEnabled = enabled;
|
|
99
86
|
return this;
|
|
100
87
|
}
|
|
101
|
-
async submit(
|
|
88
|
+
async submit() {
|
|
102
89
|
(0, protocol_1.ensureSingleSubmit)(this.executed);
|
|
103
90
|
this.executed = true;
|
|
104
91
|
const requestHeader = this.context.dispatchHeader;
|
|
@@ -106,13 +93,9 @@ class DefaultZLinkSessionReplyCall {
|
|
|
106
93
|
throw new Error('Reply is only available while handling a request packet.');
|
|
107
94
|
}
|
|
108
95
|
this.context.claimReply(requestHeader);
|
|
109
|
-
// Reply-token validity wins over caller cancellation. Claiming before the
|
|
110
|
-
// pre-cancel check keeps duplicate calls deterministic while still making
|
|
111
|
-
// a pre-cancelled first call perform no transport admission.
|
|
112
|
-
(0, abort_1.throwIfAborted)(signal);
|
|
113
96
|
const message = this.context.createJsonReplyFrameMessage(requestHeader, protocol_1.ZLinkStreamMessageKind.Response, new Map(), this.compressionEnabled, this.message);
|
|
114
97
|
try {
|
|
115
|
-
const result = await this.context.stream.submitRaw(message
|
|
98
|
+
const result = await this.context.stream.submitRaw(message);
|
|
116
99
|
(0, submission_result_1.requireOneWayCompletion)(result, 'STREAM session reply');
|
|
117
100
|
this.context.traceFrameWritten?.(protocol_1.ZLinkStreamMessageKind.Response, requestHeader.name, requestHeader.correlationId);
|
|
118
101
|
}
|
|
@@ -9,7 +9,7 @@ import { DefaultZLinkBoundSessionSendCall } from './session-calls';
|
|
|
9
9
|
import { type ZLinkPendingSessionRequest } from './session-requests';
|
|
10
10
|
export interface ZLinkSessionContextStream extends ZLinkStream {
|
|
11
11
|
writeRaw(payload: Message, flags?: number): boolean;
|
|
12
|
-
submitRaw(payload: Message
|
|
12
|
+
submitRaw(payload: Message): Promise<ZLinkSubmitResult>;
|
|
13
13
|
enqueueActorBound?(actorSlot: number, actorId: string): Promise<void>;
|
|
14
14
|
enqueueActorUnbound?(actorSlot: number): Promise<void>;
|
|
15
15
|
}
|
|
@@ -22,7 +22,7 @@ interface ZLinkSessionContextRuntime {
|
|
|
22
22
|
decompressPayload(payload: Message): Message;
|
|
23
23
|
bind(context: DefaultZLinkSessionContext, actor: ZLinkActor | ActorRef, signal?: AbortSignal): Promise<DefaultZLinkSessionActor>;
|
|
24
24
|
bindOrGet(context: DefaultZLinkSessionContext, actorRef: ActorRef, signal?: AbortSignal): Promise<DefaultZLinkSessionActor>;
|
|
25
|
-
relay(actor: DefaultZLinkSessionActor, payload: ZLinkMessage,
|
|
25
|
+
relay(actor: DefaultZLinkSessionActor, payload: ZLinkMessage, dispatchHeader?: ZLinkStreamFrameHeader): Promise<ZLinkSubmitResult>;
|
|
26
26
|
notifyDisconnected(actor: DefaultZLinkSessionActor, signal?: AbortSignal): Promise<void>;
|
|
27
27
|
}
|
|
28
28
|
export type ZLinkActorBindingReplacementHandler = (actor: ServiceActorRef, retiredSession: ServiceRetiredBoundSessionRouteFence) => void;
|
|
@@ -95,8 +95,8 @@ export declare class DefaultZLinkSessionActor implements ZLinkSessionActor {
|
|
|
95
95
|
constructor(runtime: ZLinkSessionContextRuntime, ref: ActorRef, bindingToken: string);
|
|
96
96
|
get ref(): ActorRef;
|
|
97
97
|
updateRef(ref: ActorRef): void;
|
|
98
|
-
relay(payload: ZLinkMessage
|
|
99
|
-
relay(dispatch: ZLinkSessionDispatchContext, payload: ZLinkMessage
|
|
98
|
+
relay(payload: ZLinkMessage): Promise<void>;
|
|
99
|
+
relay(dispatch: ZLinkSessionDispatchContext, payload: ZLinkMessage): Promise<void>;
|
|
100
100
|
notifyDisconnected(signal?: AbortSignal): Promise<void>;
|
|
101
101
|
}
|
|
102
102
|
export declare function createSessionDispatchContext(header: ZLinkStreamFrameHeader, actor?: DefaultZLinkSessionActor): ZLinkSessionDispatchContext;
|