@zlink-systems/framework 0.30.0 → 0.30.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +150 -68
- package/dist/.tsbuildinfo +1 -1
- package/dist/contracts/Actors/ZLinkActorClient.d.ts +2 -1
- package/dist/contracts/Channels/Calls.d.ts +2 -1
- package/dist/contracts/Common/ZLinkMessageMetadata.js +11 -5
- package/dist/contracts/Handlers/Attributes.d.ts +5 -13
- package/dist/contracts/Handlers/Attributes.js +7 -11
- package/dist/contracts/Handlers/JsonContract.d.ts +2 -46
- package/dist/contracts/Handlers/JsonContract.js +4 -153
- package/dist/contracts/Spots/Contracts.d.ts +2 -1
- package/dist/nest-integration.d.ts +1 -1
- package/dist/nest-integration.js +2 -1
- package/dist/runtime/actors/actor-client.d.ts +1 -1
- package/dist/runtime/actors/actor-client.js +14 -12
- package/dist/runtime/actors/actor-handoff.d.ts +1 -1
- package/dist/runtime/actors/actor-handoff.js +7 -4
- package/dist/runtime/actors/actor-join-relocation.d.ts +1 -0
- package/dist/runtime/actors/actor-local-native-join.js +9 -12
- package/dist/runtime/actors/actor-remote-wire.js +15 -0
- package/dist/runtime/actors/actor-routed-join-transport.d.ts +6 -2
- package/dist/runtime/actors/actor-routed-json-request.d.ts +2 -0
- package/dist/runtime/actors/index.d.ts +2 -1
- package/dist/runtime/actors/index.js +18 -6
- package/dist/runtime/actors/spot-actor-dispatch.js +2 -2
- package/dist/runtime/admission.d.ts +1 -1
- package/dist/runtime/admission.js +15 -5
- package/dist/runtime/application-jobs/application-ingress-record-owner.d.ts +6 -8
- package/dist/runtime/application-jobs/application-ingress-record-owner.js +39 -22
- package/dist/runtime/application-jobs/application-job-queue-scope.d.ts +2 -1
- package/dist/runtime/application-jobs/application-job-queue-scope.js +37 -22
- package/dist/runtime/application-jobs/contracts.d.ts +10 -1
- package/dist/runtime/backend/contracts/index.d.ts +18 -9
- package/dist/runtime/backend/mesh-completion-table.d.ts +9 -1
- package/dist/runtime/backend/mesh-completion-table.js +149 -49
- package/dist/runtime/backend/mesh-dispatch-pump.d.ts +3 -0
- package/dist/runtime/backend/mesh-dispatch-pump.js +32 -11
- package/dist/runtime/backend/node/node-backend-adapter-support.d.ts +2 -2
- package/dist/runtime/backend/node/node-backend-adapter-support.js +16 -9
- package/dist/runtime/backend/node/node-dealer-channel-client-transport.d.ts +1 -1
- package/dist/runtime/backend/node/node-dealer-channel-client-transport.js +5 -2
- package/dist/runtime/backend/node/node-raw-binding-port.js +42 -22
- package/dist/runtime/backend/node/node-raw-mesh-backend.d.ts +13 -5
- package/dist/runtime/backend/node/node-raw-mesh-backend.js +69 -51
- package/dist/runtime/backend/node/node-socket-backend-adapter.js +6 -6
- package/dist/runtime/backend/raw-binding-port.d.ts +2 -2
- package/dist/runtime/backend/runtime-message.d.ts +1 -0
- package/dist/runtime/backend/runtime-message.js +5 -0
- package/dist/runtime/backend/runtime-values.d.ts +1 -0
- package/dist/runtime/backend/runtime-values.js +2 -1
- package/dist/runtime/channels/channel-clients.d.ts +1 -0
- package/dist/runtime/channels/channel-clients.js +58 -21
- package/dist/runtime/channels/channel-dispatch-pipeline.d.ts +3 -2
- package/dist/runtime/channels/channel-dispatch-pipeline.js +20 -11
- package/dist/runtime/channels/channel-dispatch-services.d.ts +1 -0
- package/dist/runtime/channels/channel-dispatch-services.js +45 -0
- package/dist/runtime/channels/channel-dispatchers.d.ts +1 -1
- package/dist/runtime/channels/channel-dispatchers.js +27 -26
- package/dist/runtime/channels/channel-envelope-inspection.d.ts +1 -2
- package/dist/runtime/channels/channel-envelope-inspection.js +1 -16
- package/dist/runtime/channels/channel-envelope.d.ts +1 -0
- package/dist/runtime/channels/channel-envelope.js +83 -8
- package/dist/runtime/channels/channel-outbound-operations.d.ts +2 -2
- package/dist/runtime/channels/channel-outbound-operations.js +8 -8
- package/dist/runtime/channels/channel-runtime-manager.d.ts +6 -6
- package/dist/runtime/channels/channel-runtime-manager.js +12 -12
- package/dist/runtime/channels/channel-transports.d.ts +18 -15
- package/dist/runtime/channels/channel-transports.js +48 -31
- package/dist/runtime/channels/local-spot-route-transport.d.ts +1 -1
- package/dist/runtime/channels/local-spot-route-transport.js +2 -1
- package/dist/runtime/channels/router-socket-spot-route-transport.d.ts +2 -2
- package/dist/runtime/channels/router-socket-spot-route-transport.js +4 -4
- package/dist/runtime/channels/source-spot-router.d.ts +2 -2
- package/dist/runtime/channels/source-spot-router.js +4 -4
- package/dist/runtime/channels/spot-node-route-transport.d.ts +2 -2
- package/dist/runtime/channels/spot-node-route-transport.js +4 -4
- package/dist/runtime/channels/spot-route-bridge-transport.d.ts +2 -2
- package/dist/runtime/channels/spot-route-bridge-transport.js +4 -4
- package/dist/runtime/channels/spot-route-dispatch-strategy.d.ts +5 -4
- package/dist/runtime/channels/spot-route-dispatch-strategy.js +18 -18
- package/dist/runtime/execution/serial-execution-queue.d.ts +1 -0
- package/dist/runtime/execution/serial-execution-queue.js +1 -0
- package/dist/runtime/foundation/actor-join-recovery-codec.js +2 -2
- package/dist/runtime/foundation/durable-service-request.d.ts +14 -0
- package/dist/runtime/foundation/durable-service-request.js +98 -0
- package/dist/runtime/foundation/operation-identity.d.ts +1 -0
- package/dist/runtime/foundation/operation-identity.js +5 -1
- package/dist/runtime/foundation/raw-service-mesh-runtime.d.ts +22 -5
- package/dist/runtime/foundation/raw-service-mesh-runtime.js +356 -232
- package/dist/runtime/foundation/service-relocation-object-owner.d.ts +1 -0
- package/dist/runtime/foundation/service-relocation-object-owner.js +1 -0
- package/dist/runtime/foundation/service-relocation-runtime.d.ts +2 -0
- package/dist/runtime/foundation/service-relocation-runtime.js +13 -1
- package/dist/runtime/foundation/service-runtime-contracts.d.ts +2 -0
- package/dist/runtime/foundation/service-stateful-runtime.d.ts +4 -4
- package/dist/runtime/foundation/service-stateful-runtime.js +44 -103
- package/dist/runtime/foundation/service-stateful-wire-codec.d.ts +0 -5
- package/dist/runtime/foundation/service-topology-registry.d.ts +12 -2
- package/dist/runtime/foundation/service-topology-registry.js +61 -27
- package/dist/runtime/foundation/service-wire-m6a-codec.d.ts +3 -3
- package/dist/runtime/foundation/service-wire-m6a-codec.js +36 -38
- package/dist/runtime/handlers/handler-instance-scope.d.ts +8 -0
- package/dist/runtime/handlers/handler-instance-scope.js +54 -11
- package/dist/runtime/host/actor-runtime-options-factory.js +2 -2
- package/dist/runtime/host/application-job-queue.d.ts +19 -7
- package/dist/runtime/host/application-job-queue.js +150 -42
- package/dist/runtime/host/entry-actor-runtime.d.ts +1 -0
- package/dist/runtime/host/entry-actor-runtime.js +3 -0
- package/dist/runtime/host/index.d.ts +7 -1
- package/dist/runtime/host/index.js +142 -118
- package/dist/runtime/host/remote-bound-session-relay.js +2 -18
- package/dist/runtime/host/route-mesh-runtime.js +1 -1
- package/dist/runtime/host/service-relocation-control.d.ts +1 -0
- package/dist/runtime/host/service-relocation-control.js +10 -4
- package/dist/runtime/host/service-relocation-host-runtime.d.ts +6 -8
- package/dist/runtime/host/service-relocation-host-runtime.js +213 -241
- package/dist/runtime/host/spot-address-transport.js +3 -2
- package/dist/runtime/host/spot-runtime-options-factory.js +1 -0
- package/dist/runtime/locations/actor-location-claims.d.ts +2 -2
- package/dist/runtime/locations/actor-location-claims.js +34 -19
- package/dist/runtime/locations/lifecycle.d.ts +1 -2
- package/dist/runtime/locations/lifecycle.js +2 -5
- package/dist/runtime/locations/runtime.d.ts +1 -1
- package/dist/runtime/locations/runtime.js +24 -23
- package/dist/runtime/messaging/framework-json-v1.d.ts +4 -6
- package/dist/runtime/messaging/framework-json-v1.js +38 -294
- package/dist/runtime/messaging/packet-name.d.ts +1 -1
- package/dist/runtime/messaging/packet-name.js +8 -24
- package/dist/runtime/messaging/request-result.d.ts +2 -0
- package/dist/runtime/messaging/request-result.js +54 -0
- package/dist/runtime/messaging/submission-result.d.ts +1 -0
- package/dist/runtime/messaging/submission-result.js +5 -2
- package/dist/runtime/protocol/service_wire_codec.generated.d.ts +15 -0
- package/dist/runtime/protocol/service_wire_codec.generated.js +144 -0
- package/dist/runtime/protocol/service_wire_pilot_codec.generated.d.ts +9 -0
- package/dist/runtime/protocol/service_wire_pilot_codec.generated.js +14 -1
- package/dist/runtime/spots/formal-remote-actor-admission-registry.d.ts +7 -2
- package/dist/runtime/spots/formal-remote-actor-admission-registry.js +33 -19
- package/dist/runtime/spots/index.d.ts +3 -0
- package/dist/runtime/spots/index.js +9 -2
- package/dist/runtime/spots/spot-activation.d.ts +1 -0
- package/dist/runtime/spots/spot-activation.js +17 -8
- package/dist/runtime/spots/spot-entry-activation.js +6 -2
- package/dist/runtime/spots/spot-handler-registry.d.ts +3 -1
- package/dist/runtime/spots/spot-handler-registry.js +18 -8
- package/dist/runtime/spots/spot-node-autoconnect.js +4 -3
- package/dist/runtime/spots/spot-outbound.d.ts +3 -0
- package/dist/runtime/spots/spot-outbound.js +24 -15
- package/dist/runtime/spots/spot-routed-spot-packet-dispatch.d.ts +1 -0
- package/dist/runtime/spots/spot-routed-spot-packet-dispatch.js +1 -1
- package/dist/runtime/spots/spot-runtime-ports.d.ts +1 -0
- package/dist/runtime/spots/spot-subscription-dispatch.js +0 -3
- package/dist/runtime/spots/spot-timer.js +1 -0
- package/dist/runtime/streams/stream-session-runtime.d.ts +1 -1
- package/dist/runtime/streams/stream-session-runtime.js +13 -27
- package/package.json +2 -2
- package/src/contracts/Actors/ZLinkActorClient.ts +2 -1
- package/src/contracts/Channels/Calls.ts +2 -1
- package/src/contracts/Common/ZLinkMessageMetadata.ts +13 -8
- package/src/contracts/Handlers/Attributes.ts +14 -21
- package/src/contracts/Handlers/JsonContract.ts +8 -216
- package/src/contracts/Spots/Contracts.ts +2 -1
- package/src/nest-integration.ts +1 -0
- package/src/runtime/actors/actor-client.ts +40 -16
- package/src/runtime/actors/actor-handoff.ts +9 -4
- package/src/runtime/actors/actor-join-relocation.ts +1 -0
- package/src/runtime/actors/actor-local-native-join.ts +17 -26
- package/src/runtime/actors/actor-remote-wire.ts +17 -0
- package/src/runtime/actors/actor-routed-join-transport.ts +14 -4
- package/src/runtime/actors/actor-routed-json-request.ts +10 -2
- package/src/runtime/actors/index.ts +19 -5
- package/src/runtime/actors/spot-actor-dispatch.ts +4 -2
- package/src/runtime/admission.ts +18 -5
- package/src/runtime/application-jobs/application-ingress-record-owner.ts +41 -25
- package/src/runtime/application-jobs/application-job-queue-scope.ts +51 -22
- package/src/runtime/application-jobs/contracts.ts +14 -1
- package/src/runtime/backend/contracts/index.ts +53 -14
- package/src/runtime/backend/mesh-completion-table.ts +156 -57
- package/src/runtime/backend/mesh-dispatch-pump.ts +40 -10
- package/src/runtime/backend/node/node-backend-adapter-support.ts +17 -8
- package/src/runtime/backend/node/node-dealer-channel-client-transport.ts +12 -2
- package/src/runtime/backend/node/node-raw-binding-port.ts +57 -30
- package/src/runtime/backend/node/node-raw-mesh-backend.ts +128 -65
- package/src/runtime/backend/node/node-socket-backend-adapter.ts +21 -6
- package/src/runtime/backend/raw-binding-port.ts +7 -2
- package/src/runtime/backend/runtime-message.ts +6 -0
- package/src/runtime/backend/runtime-values.ts +1 -0
- package/src/runtime/channels/channel-clients.ts +90 -41
- package/src/runtime/channels/channel-dispatch-pipeline.ts +69 -34
- package/src/runtime/channels/channel-dispatch-services.ts +69 -1
- package/src/runtime/channels/channel-dispatchers.ts +29 -27
- package/src/runtime/channels/channel-envelope-inspection.ts +2 -16
- package/src/runtime/channels/channel-envelope.ts +133 -8
- package/src/runtime/channels/channel-outbound-operations.ts +22 -8
- package/src/runtime/channels/channel-runtime-manager.ts +29 -12
- package/src/runtime/channels/channel-transports.ts +128 -60
- package/src/runtime/channels/local-spot-route-transport.ts +3 -1
- package/src/runtime/channels/router-socket-spot-route-transport.ts +13 -4
- package/src/runtime/channels/source-spot-router.ts +8 -4
- package/src/runtime/channels/spot-node-route-transport.ts +8 -4
- package/src/runtime/channels/spot-route-bridge-transport.ts +6 -4
- package/src/runtime/channels/spot-route-dispatch-strategy.ts +47 -18
- package/src/runtime/execution/serial-execution-queue.ts +2 -0
- package/src/runtime/foundation/actor-join-recovery-codec.ts +2 -2
- package/src/runtime/foundation/durable-service-request.ts +137 -0
- package/src/runtime/foundation/operation-identity.ts +5 -1
- package/src/runtime/foundation/raw-service-mesh-runtime.ts +484 -293
- package/src/runtime/foundation/service-relocation-object-owner.ts +2 -0
- package/src/runtime/foundation/service-relocation-runtime.ts +18 -1
- package/src/runtime/foundation/service-runtime-contracts.ts +7 -1
- package/src/runtime/foundation/service-stateful-runtime.ts +67 -125
- package/src/runtime/foundation/service-stateful-wire-codec.ts +0 -5
- package/src/runtime/foundation/service-topology-registry.ts +91 -36
- package/src/runtime/foundation/service-wire-m6a-codec.ts +57 -38
- package/src/runtime/handlers/handler-instance-scope.ts +67 -16
- package/src/runtime/host/actor-runtime-options-factory.ts +13 -2
- package/src/runtime/host/application-job-queue.ts +175 -41
- package/src/runtime/host/entry-actor-runtime.ts +4 -0
- package/src/runtime/host/index.ts +201 -156
- package/src/runtime/host/remote-bound-session-relay.ts +2 -23
- package/src/runtime/host/route-mesh-runtime.ts +1 -1
- package/src/runtime/host/service-relocation-control.ts +11 -5
- package/src/runtime/host/service-relocation-host-runtime.ts +315 -291
- package/src/runtime/host/spot-address-transport.ts +4 -2
- package/src/runtime/host/spot-runtime-options-factory.ts +2 -0
- package/src/runtime/locations/actor-location-claims.ts +52 -30
- package/src/runtime/locations/lifecycle.ts +8 -26
- package/src/runtime/locations/runtime.ts +28 -24
- package/src/runtime/messaging/framework-json-v1.ts +5 -325
- package/src/runtime/messaging/packet-name.ts +5 -25
- package/src/runtime/messaging/request-result.ts +58 -0
- package/src/runtime/messaging/submission-result.ts +5 -1
- package/src/runtime/protocol/service_wire_codec.generated.ts +131 -1
- package/src/runtime/protocol/service_wire_pilot_codec.generated.ts +4 -4
- package/src/runtime/spots/formal-remote-actor-admission-registry.ts +43 -23
- package/src/runtime/spots/index.ts +14 -2
- package/src/runtime/spots/spot-activation.ts +28 -10
- package/src/runtime/spots/spot-entry-activation.ts +9 -2
- package/src/runtime/spots/spot-handler-registry.ts +41 -8
- package/src/runtime/spots/spot-node-autoconnect.ts +6 -2
- package/src/runtime/spots/spot-outbound.ts +36 -16
- package/src/runtime/spots/spot-routed-spot-packet-dispatch.ts +2 -1
- package/src/runtime/spots/spot-runtime-ports.ts +1 -0
- package/src/runtime/spots/spot-subscription-dispatch.ts +0 -3
- package/src/runtime/spots/spot-timer.ts +5 -1
- package/src/runtime/streams/stream-session-runtime.ts +12 -29
|
@@ -13,7 +13,7 @@ import {
|
|
|
13
13
|
} from '../../contracts/Dispatch/ZLinkDispatchOptions';
|
|
14
14
|
import type { Message } from '../../contracts/Common/Message';
|
|
15
15
|
import { SubmitResult } from '../backend/runtime-values';
|
|
16
|
-
import type
|
|
16
|
+
import { ReceiveKind, type ReceiveRecord } from '../foundation/service-runtime-contracts';
|
|
17
17
|
import { ZLinkConfigurationException, type ZLinkRouteChannelOptions } from '../configuration';
|
|
18
18
|
import type { ZLinkBackendSpotRouteBridge } from '../backend/contracts';
|
|
19
19
|
import type { ZLinkRuntimeMetrics } from '../diagnostics';
|
|
@@ -59,6 +59,8 @@ export interface ZLinkChannelRequestDispatcherOptions {
|
|
|
59
59
|
readonly unhandled?: ZLinkUnhandledDispatchOptions;
|
|
60
60
|
}
|
|
61
61
|
|
|
62
|
+
const completedChannelReply = Promise.resolve();
|
|
63
|
+
|
|
62
64
|
export interface ZLinkChannelRequestHandler {
|
|
63
65
|
handle(payload: unknown, context: ZLinkMessageContext): Promise<unknown> | unknown;
|
|
64
66
|
}
|
|
@@ -134,7 +136,7 @@ export class ZLinkChannelRequestDispatcher {
|
|
|
134
136
|
await this.pipeline.dispatchMalformed({
|
|
135
137
|
info,
|
|
136
138
|
error,
|
|
137
|
-
transportRequest: replyToken
|
|
139
|
+
transportRequest: replyToken != null,
|
|
138
140
|
writeProtocolError:
|
|
139
141
|
replyToken === null
|
|
140
142
|
? undefined
|
|
@@ -236,19 +238,19 @@ export class ZLinkChannelRequestDispatcher {
|
|
|
236
238
|
});
|
|
237
239
|
}
|
|
238
240
|
|
|
239
|
-
|
|
241
|
+
dispatchMesh(record: ReceiveRecord, signal?: AbortSignal): Promise<void> {
|
|
240
242
|
if (record.parts.length === 0 || record.parts[0].data().length === 0) {
|
|
241
|
-
return;
|
|
243
|
+
return completedChannelReply;
|
|
242
244
|
}
|
|
243
245
|
let envelope: ReturnType<typeof decodeChannelEnvelope>;
|
|
244
246
|
try {
|
|
245
247
|
envelope = decodeChannelEnvelope(record.parts, undefined, this.flowEnabled());
|
|
246
248
|
} catch (error) {
|
|
247
249
|
const info = inspectMalformedChannelHeader(record.parts, this.flowEnabled());
|
|
248
|
-
|
|
250
|
+
return this.pipeline.dispatchMalformed({
|
|
249
251
|
info,
|
|
250
252
|
error,
|
|
251
|
-
transportRequest:
|
|
253
|
+
transportRequest: isMeshRequest(record),
|
|
252
254
|
sourceRid: record.sourceNodeRid == null ? undefined : String(record.sourceNodeRid),
|
|
253
255
|
writeProtocolError: async (protocolError) => {
|
|
254
256
|
requireMeshReplyAccepted(
|
|
@@ -261,7 +263,6 @@ export class ZLinkChannelRequestDispatcher {
|
|
|
261
263
|
);
|
|
262
264
|
}
|
|
263
265
|
});
|
|
264
|
-
return;
|
|
265
266
|
}
|
|
266
267
|
const packetName = envelope.packetName;
|
|
267
268
|
if (packetName === undefined) {
|
|
@@ -269,7 +270,7 @@ export class ZLinkChannelRequestDispatcher {
|
|
|
269
270
|
}
|
|
270
271
|
const correlationId = envelope.header.correlationId ?? undefined;
|
|
271
272
|
if (envelope.header.kind === ZLinkChannelMessageKind.Command) {
|
|
272
|
-
|
|
273
|
+
return this.pipeline.dispatchOneWay({
|
|
273
274
|
fields: {
|
|
274
275
|
messageKind: ZLinkDispatchMessageKind.Send,
|
|
275
276
|
packetName,
|
|
@@ -283,10 +284,9 @@ export class ZLinkChannelRequestDispatcher {
|
|
|
283
284
|
context: this.createMeshContext(envelope, record.sourceNodeRid),
|
|
284
285
|
signal
|
|
285
286
|
});
|
|
286
|
-
return;
|
|
287
287
|
}
|
|
288
288
|
if (envelope.header.kind !== ZLinkChannelMessageKind.Request) {
|
|
289
|
-
return;
|
|
289
|
+
return completedChannelReply;
|
|
290
290
|
}
|
|
291
291
|
const fields: ZLinkChannelDispatchFields = {
|
|
292
292
|
messageKind: ZLinkDispatchMessageKind.Request,
|
|
@@ -295,7 +295,7 @@ export class ZLinkChannelRequestDispatcher {
|
|
|
295
295
|
flowId: envelope.header.flowId,
|
|
296
296
|
flowOrigin: envelope.header.flowOrigin
|
|
297
297
|
};
|
|
298
|
-
|
|
298
|
+
return this.pipeline.dispatchRequest({
|
|
299
299
|
fields,
|
|
300
300
|
envelope,
|
|
301
301
|
codecs: this.options.codecs,
|
|
@@ -303,12 +303,12 @@ export class ZLinkChannelRequestDispatcher {
|
|
|
303
303
|
context: this.createMeshContext(envelope, record.sourceNodeRid),
|
|
304
304
|
signal,
|
|
305
305
|
missingHandlerMessage: `No channel request handler is registered for '${this.options.channelName}:${packetName}'.`,
|
|
306
|
-
writeReply:
|
|
306
|
+
writeReply: (reply) => {
|
|
307
307
|
requireMeshReplyAccepted(
|
|
308
308
|
record.reply(encodeChannelReplyParts(envelope.header, reply, this.options.codecs))
|
|
309
309
|
);
|
|
310
310
|
},
|
|
311
|
-
writeError:
|
|
311
|
+
writeError: (error) => {
|
|
312
312
|
requireMeshReplyAccepted(
|
|
313
313
|
record.reply(encodeChannelErrorReplyParts(envelope.header, error))
|
|
314
314
|
);
|
|
@@ -324,7 +324,7 @@ export class ZLinkChannelRequestDispatcher {
|
|
|
324
324
|
if (operation.submit() === false) {
|
|
325
325
|
throw new ZLinkConfigurationException('Channel reply was not accepted by Core.');
|
|
326
326
|
}
|
|
327
|
-
return
|
|
327
|
+
return completedChannelReply;
|
|
328
328
|
}
|
|
329
329
|
|
|
330
330
|
private createMeshContext(
|
|
@@ -587,7 +587,7 @@ export class ZLinkRoutePacketDispatcher {
|
|
|
587
587
|
await this.pipeline.dispatchMalformed({
|
|
588
588
|
info,
|
|
589
589
|
error,
|
|
590
|
-
transportRequest: replyToken
|
|
590
|
+
transportRequest: replyToken != null,
|
|
591
591
|
sourceRid: String(received.routingId),
|
|
592
592
|
writeProtocolError:
|
|
593
593
|
replyToken === null
|
|
@@ -685,19 +685,19 @@ export class ZLinkRoutePacketDispatcher {
|
|
|
685
685
|
});
|
|
686
686
|
}
|
|
687
687
|
|
|
688
|
-
|
|
688
|
+
dispatchMesh(record: ReceiveRecord, signal?: AbortSignal): Promise<void> {
|
|
689
689
|
if (record.parts.length === 0 || record.parts[0].data().length === 0) {
|
|
690
|
-
return;
|
|
690
|
+
return completedChannelReply;
|
|
691
691
|
}
|
|
692
692
|
let envelope: ReturnType<typeof decodeChannelEnvelope>;
|
|
693
693
|
try {
|
|
694
694
|
envelope = decodeChannelEnvelope(record.parts, undefined, this.flowEnabled());
|
|
695
695
|
} catch (error) {
|
|
696
696
|
const info = inspectMalformedChannelHeader(record.parts, this.flowEnabled());
|
|
697
|
-
|
|
697
|
+
return this.pipeline.dispatchMalformed({
|
|
698
698
|
info,
|
|
699
699
|
error,
|
|
700
|
-
transportRequest:
|
|
700
|
+
transportRequest: isMeshRequest(record),
|
|
701
701
|
sourceRid: record.sourceNodeRid == null ? undefined : String(record.sourceNodeRid),
|
|
702
702
|
writeProtocolError: async (protocolError) => {
|
|
703
703
|
requireMeshReplyAccepted(
|
|
@@ -710,7 +710,6 @@ export class ZLinkRoutePacketDispatcher {
|
|
|
710
710
|
);
|
|
711
711
|
}
|
|
712
712
|
});
|
|
713
|
-
return;
|
|
714
713
|
}
|
|
715
714
|
const packetName = envelope.packetName;
|
|
716
715
|
if (packetName === undefined) {
|
|
@@ -719,17 +718,16 @@ export class ZLinkRoutePacketDispatcher {
|
|
|
719
718
|
const sourceNodeRid = String(record.sourceNodeRid ?? '');
|
|
720
719
|
const correlationId = envelope.header.correlationId ?? undefined;
|
|
721
720
|
if (envelope.header.kind === ZLinkChannelMessageKind.Command) {
|
|
722
|
-
|
|
721
|
+
return this.dispatchMeshCommand(
|
|
723
722
|
envelope,
|
|
724
723
|
packetName,
|
|
725
724
|
sourceNodeRid,
|
|
726
725
|
record.sourceNodeRid,
|
|
727
726
|
signal
|
|
728
727
|
);
|
|
729
|
-
return;
|
|
730
728
|
}
|
|
731
729
|
if (envelope.header.kind !== ZLinkChannelMessageKind.Request) {
|
|
732
|
-
return;
|
|
730
|
+
return completedChannelReply;
|
|
733
731
|
}
|
|
734
732
|
const fields: ZLinkChannelDispatchFields = {
|
|
735
733
|
messageKind: ZLinkDispatchMessageKind.Request,
|
|
@@ -740,7 +738,7 @@ export class ZLinkRoutePacketDispatcher {
|
|
|
740
738
|
flowOrigin: envelope.header.flowOrigin
|
|
741
739
|
};
|
|
742
740
|
const codecs = codecsForFrameworkPacket(packetName, this.codecs);
|
|
743
|
-
|
|
741
|
+
return this.pipeline.dispatchRequest({
|
|
744
742
|
fields,
|
|
745
743
|
envelope,
|
|
746
744
|
codecs,
|
|
@@ -748,12 +746,12 @@ export class ZLinkRoutePacketDispatcher {
|
|
|
748
746
|
context: this.createRouteContext(envelope, record.sourceNodeRid),
|
|
749
747
|
signal,
|
|
750
748
|
missingHandlerMessage: `No routed request handler is registered for '${this.routerChannelId}:${packetName}'.`,
|
|
751
|
-
writeReply:
|
|
749
|
+
writeReply: (reply) => {
|
|
752
750
|
requireMeshReplyAccepted(
|
|
753
751
|
record.reply(encodeChannelReplyParts(envelope.header, reply, codecs))
|
|
754
752
|
);
|
|
755
753
|
},
|
|
756
|
-
writeError:
|
|
754
|
+
writeError: (error) => {
|
|
757
755
|
requireMeshReplyAccepted(
|
|
758
756
|
record.reply(encodeChannelErrorReplyParts(envelope.header, error))
|
|
759
757
|
);
|
|
@@ -826,7 +824,7 @@ export class ZLinkRoutePacketDispatcher {
|
|
|
826
824
|
if (operation.submit() === false) {
|
|
827
825
|
throw new ZLinkConfigurationException('Route reply was not accepted by Core.');
|
|
828
826
|
}
|
|
829
|
-
return
|
|
827
|
+
return completedChannelReply;
|
|
830
828
|
}
|
|
831
829
|
|
|
832
830
|
private createRouteContext(
|
|
@@ -844,3 +842,7 @@ export class ZLinkRoutePacketDispatcher {
|
|
|
844
842
|
};
|
|
845
843
|
}
|
|
846
844
|
}
|
|
845
|
+
|
|
846
|
+
function isMeshRequest(record: ReceiveRecord): boolean {
|
|
847
|
+
return record.kind === ReceiveKind.NodeRequest || record.kind === ReceiveKind.ChannelRequest;
|
|
848
|
+
}
|
|
@@ -3,6 +3,7 @@ import type { Message } from '../../contracts/Common/Message';
|
|
|
3
3
|
import type { ZLinkFlowOrigin } from '../../contracts';
|
|
4
4
|
import {
|
|
5
5
|
decodeChannelHeader,
|
|
6
|
+
isValidChannelCorrelationId,
|
|
6
7
|
ZLINK_CHANNEL_FORMAT_MARKER,
|
|
7
8
|
ZLinkChannelMessageKind,
|
|
8
9
|
type ZLinkChannelEnvelopeHeader
|
|
@@ -29,7 +30,6 @@ export function tryDecodeChannelHeader(
|
|
|
29
30
|
* present only when it is individually well-formed.
|
|
30
31
|
*/
|
|
31
32
|
export interface ZLinkMalformedChannelHeaderInfo {
|
|
32
|
-
readonly kind?: ZLinkChannelMessageKind;
|
|
33
33
|
readonly channelName?: string;
|
|
34
34
|
readonly messageName?: string;
|
|
35
35
|
readonly correlationId?: string;
|
|
@@ -50,7 +50,6 @@ export function inspectMalformedChannelHeader(
|
|
|
50
50
|
} catch {
|
|
51
51
|
return {};
|
|
52
52
|
}
|
|
53
|
-
if (header.formatMarker !== ZLINK_CHANNEL_FORMAT_MARKER) return {};
|
|
54
53
|
const flowId =
|
|
55
54
|
typeof header.flowId === 'string' && CHANNEL_FLOW_ID_PATTERN.test(header.flowId)
|
|
56
55
|
? header.flowId
|
|
@@ -58,7 +57,6 @@ export function inspectMalformedChannelHeader(
|
|
|
58
57
|
const flowOrigin = salvageFlowOrigin(header.flowOrigin);
|
|
59
58
|
const flowPairValid = flowEnabled && flowId !== undefined && flowOrigin !== undefined;
|
|
60
59
|
return {
|
|
61
|
-
kind: salvageChannelKind(header.kind),
|
|
62
60
|
channelName: salvageString(header.channelName),
|
|
63
61
|
messageName: salvageString(header.messageName),
|
|
64
62
|
correlationId: salvageCorrelationId(header.correlationId),
|
|
@@ -94,24 +92,12 @@ export function malformedProtocolErrorRequestHeader(
|
|
|
94
92
|
const CHANNEL_FLOW_ID_PATTERN =
|
|
95
93
|
/^[0-9a-f]{8}-[0-9a-f]{4}-7[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/;
|
|
96
94
|
|
|
97
|
-
function salvageChannelKind(value: unknown): ZLinkChannelMessageKind | undefined {
|
|
98
|
-
return value === ZLinkChannelMessageKind.Request ||
|
|
99
|
-
value === ZLinkChannelMessageKind.Response ||
|
|
100
|
-
value === ZLinkChannelMessageKind.Command ||
|
|
101
|
-
value === ZLinkChannelMessageKind.Publish ||
|
|
102
|
-
value === ZLinkChannelMessageKind.Error
|
|
103
|
-
? value
|
|
104
|
-
: undefined;
|
|
105
|
-
}
|
|
106
|
-
|
|
107
95
|
function salvageString(value: unknown): string | undefined {
|
|
108
96
|
return typeof value === 'string' && value.length > 0 ? value : undefined;
|
|
109
97
|
}
|
|
110
98
|
|
|
111
99
|
function salvageCorrelationId(value: unknown): string | undefined {
|
|
112
|
-
|
|
113
|
-
const byteLength = Buffer.byteLength(value, 'utf8');
|
|
114
|
-
return byteLength >= 1 && byteLength <= 64 && /^[\x00-\x7f]*$/.test(value) ? value : undefined;
|
|
100
|
+
return typeof value === 'string' && isValidChannelCorrelationId(value) ? value : undefined;
|
|
115
101
|
}
|
|
116
102
|
|
|
117
103
|
function salvageFlowOrigin(value: unknown): ZLinkFlowOrigin | undefined {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { Message } from '../../contracts/Common/Message';
|
|
2
|
+
import { ZLinkBufferMessage } from '../backend/runtime-message';
|
|
2
3
|
import type { ZLinkBackendMessageLike as MessageLike } from '../backend/runtime-values';
|
|
3
4
|
import { randomUUID } from 'node:crypto';
|
|
4
5
|
import { isUtf8 } from 'node:buffer';
|
|
@@ -70,6 +71,24 @@ export interface ZLinkChannelEnvelopeCodecRegistry {
|
|
|
70
71
|
readonly serializers: ReadonlyMap<string, ZLinkMessageSerializer>;
|
|
71
72
|
}
|
|
72
73
|
|
|
74
|
+
interface PreparedChannelHeader {
|
|
75
|
+
readonly bytes: Buffer;
|
|
76
|
+
readonly correlationOffset: number;
|
|
77
|
+
readonly deadlineOffset: number;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
type PreparedHeaderVariants = Map<ZLinkChannelMessageKind, Map<boolean, PreparedChannelHeader>>;
|
|
81
|
+
const preparedChannelHeaders = new WeakMap<
|
|
82
|
+
ReadonlyMap<string, ZLinkMessageSerializer>,
|
|
83
|
+
Map<string, Map<string, Map<string, PreparedHeaderVariants>>>
|
|
84
|
+
>();
|
|
85
|
+
const CHANNEL_CORRELATION_FIELD = ',"correlationId":';
|
|
86
|
+
const CHANNEL_DEADLINE_FIELD = ',"deadline":';
|
|
87
|
+
const CHANNEL_CORRELATION_TEXT_LENGTH = 32;
|
|
88
|
+
const PREPARED_CHANNEL_CORRELATION = '0'.repeat(CHANNEL_CORRELATION_TEXT_LENGTH);
|
|
89
|
+
const PREPARED_CHANNEL_DEADLINE = '2000-01-01T00:00:00.000Z';
|
|
90
|
+
const CHANNEL_CORRELATION_TEXT = /^[0-9a-f]{32}$/;
|
|
91
|
+
|
|
73
92
|
export function newChannelCorrelationId(): string {
|
|
74
93
|
return randomUUID().replaceAll('-', '');
|
|
75
94
|
}
|
|
@@ -147,7 +166,8 @@ export function encodeChannelEnvelopePartsAtDeadline(
|
|
|
147
166
|
undefined,
|
|
148
167
|
applicationMetadataRecord(metadata),
|
|
149
168
|
flow?.flowId,
|
|
150
|
-
flow?.flowOrigin
|
|
169
|
+
flow?.flowOrigin,
|
|
170
|
+
codecs
|
|
151
171
|
),
|
|
152
172
|
encoded.message
|
|
153
173
|
];
|
|
@@ -215,7 +235,8 @@ export function encodeChannelReplyParts(
|
|
|
215
235
|
undefined,
|
|
216
236
|
EMPTY_APPLICATION_METADATA,
|
|
217
237
|
request.flowId,
|
|
218
|
-
request.flowOrigin
|
|
238
|
+
request.flowOrigin,
|
|
239
|
+
codecs
|
|
219
240
|
),
|
|
220
241
|
encoded.message
|
|
221
242
|
];
|
|
@@ -325,7 +346,7 @@ export function decodeChannelReply<TReply>(
|
|
|
325
346
|
return undefined as TReply;
|
|
326
347
|
}
|
|
327
348
|
if (header.contentType === BINARY_CONTENT_TYPE) {
|
|
328
|
-
return
|
|
349
|
+
return ZLinkBufferMessage.retainPayload(parts[1]) as TReply;
|
|
329
350
|
}
|
|
330
351
|
if (serializer !== undefined) {
|
|
331
352
|
return serializer.deserialize<TReply>(
|
|
@@ -517,8 +538,47 @@ function encodeChannelHeader(
|
|
|
517
538
|
source: string | null | undefined,
|
|
518
539
|
metadata: Readonly<Record<string, string>>,
|
|
519
540
|
flowId: string | undefined,
|
|
520
|
-
flowOrigin: ZLinkFlowOrigin | undefined
|
|
541
|
+
flowOrigin: ZLinkFlowOrigin | undefined,
|
|
542
|
+
codecs?: ZLinkChannelEnvelopeCodecRegistry
|
|
521
543
|
): Buffer {
|
|
544
|
+
if (
|
|
545
|
+
codecs !== undefined &&
|
|
546
|
+
metadata === EMPTY_APPLICATION_METADATA &&
|
|
547
|
+
flowId === undefined &&
|
|
548
|
+
flowOrigin === undefined &&
|
|
549
|
+
topic === null &&
|
|
550
|
+
source === undefined &&
|
|
551
|
+
((kind === ZLinkChannelMessageKind.Command &&
|
|
552
|
+
correlationId === null &&
|
|
553
|
+
deadline === null &&
|
|
554
|
+
errorCode === null &&
|
|
555
|
+
errorMessage === null) ||
|
|
556
|
+
(kind === ZLinkChannelMessageKind.Request &&
|
|
557
|
+
correlationId !== null &&
|
|
558
|
+
CHANNEL_CORRELATION_TEXT.test(correlationId) &&
|
|
559
|
+
deadline !== null &&
|
|
560
|
+
deadline.length === PREPARED_CHANNEL_DEADLINE.length &&
|
|
561
|
+
errorCode === null &&
|
|
562
|
+
errorMessage === null) ||
|
|
563
|
+
(kind === ZLinkChannelMessageKind.Response &&
|
|
564
|
+
correlationId !== null &&
|
|
565
|
+
CHANNEL_CORRELATION_TEXT.test(correlationId) &&
|
|
566
|
+
deadline === null &&
|
|
567
|
+
errorCode === undefined &&
|
|
568
|
+
errorMessage === undefined))
|
|
569
|
+
) {
|
|
570
|
+
return preparedChannelHeader(
|
|
571
|
+
codecs,
|
|
572
|
+
kind,
|
|
573
|
+
channelName,
|
|
574
|
+
messageName,
|
|
575
|
+
contentType,
|
|
576
|
+
correlationId,
|
|
577
|
+
deadline,
|
|
578
|
+
errorCode,
|
|
579
|
+
errorMessage
|
|
580
|
+
);
|
|
581
|
+
}
|
|
522
582
|
// The wire has a fixed field order. Measure escaped UTF-8 first, then write
|
|
523
583
|
// each field once into the only header Buffer: no header object, whole JSON
|
|
524
584
|
// string, or post-encode byte copy exists on the outbound path.
|
|
@@ -560,6 +620,63 @@ function encodeChannelHeader(
|
|
|
560
620
|
return result;
|
|
561
621
|
}
|
|
562
622
|
|
|
623
|
+
function preparedChannelHeader(
|
|
624
|
+
codecs: ZLinkChannelEnvelopeCodecRegistry,
|
|
625
|
+
kind: ZLinkChannelMessageKind,
|
|
626
|
+
channelName: string,
|
|
627
|
+
messageName: string,
|
|
628
|
+
contentType: string,
|
|
629
|
+
correlationId: string | null,
|
|
630
|
+
deadline: string | null,
|
|
631
|
+
errorCode: string | null | undefined,
|
|
632
|
+
errorMessage: string | null | undefined
|
|
633
|
+
): Buffer {
|
|
634
|
+
let channels = preparedChannelHeaders.get(codecs.serializers);
|
|
635
|
+
if (channels === undefined)
|
|
636
|
+
preparedChannelHeaders.set(codecs.serializers, (channels = new Map()));
|
|
637
|
+
let packets = channels.get(channelName);
|
|
638
|
+
if (packets === undefined) channels.set(channelName, (packets = new Map()));
|
|
639
|
+
let contentTypes = packets.get(messageName);
|
|
640
|
+
if (contentTypes === undefined) packets.set(messageName, (contentTypes = new Map()));
|
|
641
|
+
let kinds = contentTypes.get(contentType);
|
|
642
|
+
if (kinds === undefined) contentTypes.set(contentType, (kinds = new Map()));
|
|
643
|
+
let deadlines = kinds.get(kind);
|
|
644
|
+
if (deadlines === undefined) kinds.set(kind, (deadlines = new Map()));
|
|
645
|
+
const hasDeadline = deadline !== null;
|
|
646
|
+
let prepared = deadlines.get(hasDeadline);
|
|
647
|
+
if (prepared === undefined) {
|
|
648
|
+
const bytes = encodeChannelHeader(
|
|
649
|
+
kind,
|
|
650
|
+
channelName,
|
|
651
|
+
messageName,
|
|
652
|
+
contentType,
|
|
653
|
+
correlationId === null ? null : PREPARED_CHANNEL_CORRELATION,
|
|
654
|
+
hasDeadline ? PREPARED_CHANNEL_DEADLINE : null,
|
|
655
|
+
null,
|
|
656
|
+
errorCode,
|
|
657
|
+
errorMessage,
|
|
658
|
+
undefined,
|
|
659
|
+
EMPTY_APPLICATION_METADATA,
|
|
660
|
+
undefined,
|
|
661
|
+
undefined
|
|
662
|
+
);
|
|
663
|
+
prepared = {
|
|
664
|
+
bytes,
|
|
665
|
+
correlationOffset:
|
|
666
|
+
bytes.indexOf(CHANNEL_CORRELATION_FIELD) + CHANNEL_CORRELATION_FIELD.length + 1,
|
|
667
|
+
deadlineOffset: bytes.indexOf(CHANNEL_DEADLINE_FIELD) + CHANNEL_DEADLINE_FIELD.length + 1
|
|
668
|
+
};
|
|
669
|
+
deadlines.set(hasDeadline, prepared);
|
|
670
|
+
}
|
|
671
|
+
if (correlationId === null) return prepared.bytes;
|
|
672
|
+
const bytes = Buffer.alloc(prepared.bytes.byteLength);
|
|
673
|
+
prepared.bytes.copy(bytes);
|
|
674
|
+
bytes.write(correlationId, prepared.correlationOffset, CHANNEL_CORRELATION_TEXT_LENGTH, 'ascii');
|
|
675
|
+
if (deadline !== null)
|
|
676
|
+
bytes.write(deadline, prepared.deadlineOffset, PREPARED_CHANNEL_DEADLINE.length, 'ascii');
|
|
677
|
+
return bytes;
|
|
678
|
+
}
|
|
679
|
+
|
|
563
680
|
function writeChannelHeader(
|
|
564
681
|
writer: ChannelHeaderWriter,
|
|
565
682
|
kind: ZLinkChannelMessageKind,
|
|
@@ -586,9 +703,9 @@ function writeChannelHeader(
|
|
|
586
703
|
writer.string(messageName);
|
|
587
704
|
writer.append(',"contentType":');
|
|
588
705
|
writer.string(contentType);
|
|
589
|
-
writer.append(
|
|
706
|
+
writer.append(CHANNEL_CORRELATION_FIELD);
|
|
590
707
|
writer.nullableString(correlationId);
|
|
591
|
-
writer.append(
|
|
708
|
+
writer.append(CHANNEL_DEADLINE_FIELD);
|
|
592
709
|
writer.nullableString(deadline);
|
|
593
710
|
writer.append(',"topic":');
|
|
594
711
|
writer.nullableString(topic);
|
|
@@ -994,9 +1111,17 @@ function validateCorrelationForKind(
|
|
|
994
1111
|
}
|
|
995
1112
|
}
|
|
996
1113
|
|
|
1114
|
+
const MAXIMUM_CORRELATION_ID_BYTES = 64;
|
|
1115
|
+
|
|
1116
|
+
export function isValidChannelCorrelationId(value: string): boolean {
|
|
1117
|
+
const byteLength = Buffer.byteLength(value, 'utf8');
|
|
1118
|
+
return (
|
|
1119
|
+
byteLength >= 1 && byteLength <= MAXIMUM_CORRELATION_ID_BYTES && /^[\x00-\x7f]*$/.test(value)
|
|
1120
|
+
);
|
|
1121
|
+
}
|
|
1122
|
+
|
|
997
1123
|
function validateCorrelationValue(correlationId: string): void {
|
|
998
|
-
|
|
999
|
-
if (byteLength < 1 || byteLength > 64 || !/^[\x00-\x7f]*$/.test(correlationId)) {
|
|
1124
|
+
if (!isValidChannelCorrelationId(correlationId)) {
|
|
1000
1125
|
throw new ZLinkConfigurationException(
|
|
1001
1126
|
'Channel envelope correlationId must be a non-empty ASCII value of at most 64 bytes.'
|
|
1002
1127
|
);
|
|
@@ -128,11 +128,20 @@ export class ZLinkChannelOutboundOperations {
|
|
|
128
128
|
request: unknown,
|
|
129
129
|
timeoutMs: number | undefined,
|
|
130
130
|
signal?: AbortSignal,
|
|
131
|
-
metadata?: ReadonlyMap<string, string
|
|
131
|
+
metadata?: ReadonlyMap<string, string>,
|
|
132
|
+
onAdmitted?: () => void
|
|
132
133
|
): Promise<TReply> {
|
|
133
134
|
return keepChannelRequestAlive(
|
|
134
135
|
runWithOutboundFlow(this.dispatchServices.flowCreationEnabled(), () =>
|
|
135
|
-
this.requestScoped<TReply>(
|
|
136
|
+
this.requestScoped<TReply>(
|
|
137
|
+
channelName,
|
|
138
|
+
packetName,
|
|
139
|
+
request,
|
|
140
|
+
timeoutMs,
|
|
141
|
+
signal,
|
|
142
|
+
metadata,
|
|
143
|
+
onAdmitted
|
|
144
|
+
)
|
|
136
145
|
)
|
|
137
146
|
);
|
|
138
147
|
}
|
|
@@ -143,7 +152,8 @@ export class ZLinkChannelOutboundOperations {
|
|
|
143
152
|
request: unknown,
|
|
144
153
|
timeoutMs: number | undefined,
|
|
145
154
|
signal?: AbortSignal,
|
|
146
|
-
metadata?: ReadonlyMap<string, string
|
|
155
|
+
metadata?: ReadonlyMap<string, string>,
|
|
156
|
+
onAdmitted?: () => void
|
|
147
157
|
): Promise<TReply> {
|
|
148
158
|
const deadlineMs = timeoutMs === undefined ? undefined : performance.now() + timeoutMs;
|
|
149
159
|
const deadlineUnixMs = timeoutMs === undefined ? undefined : Date.now() + timeoutMs;
|
|
@@ -213,7 +223,8 @@ export class ZLinkChannelOutboundOperations {
|
|
|
213
223
|
replyParts = await awaitWithAbort(
|
|
214
224
|
dealer.request(
|
|
215
225
|
parts,
|
|
216
|
-
remainingRequestTimeout(`Channel request '${channelName}'`, deadlineMs)
|
|
226
|
+
remainingRequestTimeout(`Channel request '${channelName}'`, deadlineMs),
|
|
227
|
+
onAdmitted
|
|
217
228
|
),
|
|
218
229
|
signal
|
|
219
230
|
);
|
|
@@ -397,7 +408,8 @@ export class ZLinkChannelOutboundOperations {
|
|
|
397
408
|
request: unknown,
|
|
398
409
|
timeoutMs: number | undefined,
|
|
399
410
|
signal?: AbortSignal,
|
|
400
|
-
metadata?: ReadonlyMap<string, string
|
|
411
|
+
metadata?: ReadonlyMap<string, string>,
|
|
412
|
+
onAdmitted?: () => void
|
|
401
413
|
): Promise<TReply> {
|
|
402
414
|
return runWithOutboundFlow(this.dispatchServices.flowCreationEnabled(), () =>
|
|
403
415
|
this.routeRequestScoped<TReply>(
|
|
@@ -407,7 +419,8 @@ export class ZLinkChannelOutboundOperations {
|
|
|
407
419
|
request,
|
|
408
420
|
timeoutMs,
|
|
409
421
|
signal,
|
|
410
|
-
metadata
|
|
422
|
+
metadata,
|
|
423
|
+
onAdmitted
|
|
411
424
|
)
|
|
412
425
|
);
|
|
413
426
|
}
|
|
@@ -419,7 +432,8 @@ export class ZLinkChannelOutboundOperations {
|
|
|
419
432
|
request: unknown,
|
|
420
433
|
timeoutMs: number | undefined,
|
|
421
434
|
signal?: AbortSignal,
|
|
422
|
-
metadata?: ReadonlyMap<string, string
|
|
435
|
+
metadata?: ReadonlyMap<string, string>,
|
|
436
|
+
onAdmitted?: () => void
|
|
423
437
|
): Promise<TReply> {
|
|
424
438
|
let correlationId: string | undefined;
|
|
425
439
|
let router: ReturnType<ZLinkChannelSocketRegistry['routeRouter']> | undefined;
|
|
@@ -471,7 +485,7 @@ export class ZLinkChannelOutboundOperations {
|
|
|
471
485
|
});
|
|
472
486
|
const reply = await this.measureRequest(routerChannelId, async () => {
|
|
473
487
|
const replyParts = await awaitWithAbort(
|
|
474
|
-
router!.request(targetNodeRid, parts, timeoutMs),
|
|
488
|
+
router!.request(targetNodeRid, parts, timeoutMs, onAdmitted),
|
|
475
489
|
signal
|
|
476
490
|
);
|
|
477
491
|
try {
|
|
@@ -244,7 +244,8 @@ export class ZLinkChannelRuntimeManager {
|
|
|
244
244
|
request: unknown,
|
|
245
245
|
timeoutMs: number | undefined,
|
|
246
246
|
signal?: AbortSignal,
|
|
247
|
-
metadata?: ReadonlyMap<string, string
|
|
247
|
+
metadata?: ReadonlyMap<string, string>,
|
|
248
|
+
onAdmitted?: () => void
|
|
248
249
|
): Promise<TReply> {
|
|
249
250
|
return this.outbound.request<TReply>(
|
|
250
251
|
channelName,
|
|
@@ -252,7 +253,8 @@ export class ZLinkChannelRuntimeManager {
|
|
|
252
253
|
request,
|
|
253
254
|
timeoutMs,
|
|
254
255
|
signal,
|
|
255
|
-
metadata
|
|
256
|
+
metadata,
|
|
257
|
+
onAdmitted
|
|
256
258
|
);
|
|
257
259
|
}
|
|
258
260
|
|
|
@@ -294,7 +296,8 @@ export class ZLinkChannelRuntimeManager {
|
|
|
294
296
|
request: unknown,
|
|
295
297
|
timeoutMs: number | undefined,
|
|
296
298
|
signal?: AbortSignal,
|
|
297
|
-
metadata?: ReadonlyMap<string, string
|
|
299
|
+
metadata?: ReadonlyMap<string, string>,
|
|
300
|
+
onAdmitted?: () => void
|
|
298
301
|
): Promise<TReply> {
|
|
299
302
|
return this.outbound.routeRequest<TReply>(
|
|
300
303
|
routerChannelId,
|
|
@@ -303,7 +306,8 @@ export class ZLinkChannelRuntimeManager {
|
|
|
303
306
|
request,
|
|
304
307
|
timeoutMs,
|
|
305
308
|
signal,
|
|
306
|
-
metadata
|
|
309
|
+
metadata,
|
|
310
|
+
onAdmitted
|
|
307
311
|
);
|
|
308
312
|
}
|
|
309
313
|
|
|
@@ -322,7 +326,8 @@ export class ZLinkChannelRuntimeManager {
|
|
|
322
326
|
request: unknown,
|
|
323
327
|
timeoutMs: number | undefined,
|
|
324
328
|
signal?: AbortSignal,
|
|
325
|
-
metadata?: ReadonlyMap<string, string
|
|
329
|
+
metadata?: ReadonlyMap<string, string>,
|
|
330
|
+
onAdmitted?: () => void
|
|
326
331
|
): Promise<TReply> {
|
|
327
332
|
return this.spotRoutes.routeRequestToSpot<TReply>(
|
|
328
333
|
spotRouteTarget,
|
|
@@ -330,7 +335,8 @@ export class ZLinkChannelRuntimeManager {
|
|
|
330
335
|
request,
|
|
331
336
|
timeoutMs,
|
|
332
337
|
signal,
|
|
333
|
-
metadata
|
|
338
|
+
metadata,
|
|
339
|
+
onAdmitted
|
|
334
340
|
);
|
|
335
341
|
}
|
|
336
342
|
|
|
@@ -340,7 +346,8 @@ export class ZLinkChannelRuntimeManager {
|
|
|
340
346
|
packetName: string | undefined,
|
|
341
347
|
request: unknown,
|
|
342
348
|
timeoutMs: number | undefined,
|
|
343
|
-
signal?: AbortSignal
|
|
349
|
+
signal?: AbortSignal,
|
|
350
|
+
onAdmitted?: () => void
|
|
344
351
|
): Promise<TReply> {
|
|
345
352
|
return this.spotRoutes.routeRequestFromSpotToSpot<TReply>(
|
|
346
353
|
sourceSpot,
|
|
@@ -348,7 +355,8 @@ export class ZLinkChannelRuntimeManager {
|
|
|
348
355
|
packetName,
|
|
349
356
|
request,
|
|
350
357
|
timeoutMs,
|
|
351
|
-
signal
|
|
358
|
+
signal,
|
|
359
|
+
onAdmitted
|
|
352
360
|
);
|
|
353
361
|
}
|
|
354
362
|
|
|
@@ -373,14 +381,16 @@ export class ZLinkChannelRuntimeManager {
|
|
|
373
381
|
spotRouteTarget: ZLinkSpotRouteTarget,
|
|
374
382
|
request: Message,
|
|
375
383
|
timeoutMs: number | undefined,
|
|
376
|
-
signal?: AbortSignal
|
|
384
|
+
signal?: AbortSignal,
|
|
385
|
+
onAdmitted?: () => void
|
|
377
386
|
): Promise<readonly Message[]> {
|
|
378
387
|
return this.spotRoutes.routeRequestRawFromSpotToSpot(
|
|
379
388
|
sourceSpot,
|
|
380
389
|
spotRouteTarget,
|
|
381
390
|
request,
|
|
382
391
|
timeoutMs,
|
|
383
|
-
signal
|
|
392
|
+
signal,
|
|
393
|
+
onAdmitted
|
|
384
394
|
);
|
|
385
395
|
}
|
|
386
396
|
|
|
@@ -388,9 +398,16 @@ export class ZLinkChannelRuntimeManager {
|
|
|
388
398
|
spotRouteTarget: ZLinkSpotRouteTarget,
|
|
389
399
|
request: Message,
|
|
390
400
|
timeoutMs: number | undefined,
|
|
391
|
-
signal?: AbortSignal
|
|
401
|
+
signal?: AbortSignal,
|
|
402
|
+
onAdmitted?: () => void
|
|
392
403
|
): Promise<readonly Message[]> {
|
|
393
|
-
return this.spotRoutes.routeRequestRawToSpot(
|
|
404
|
+
return this.spotRoutes.routeRequestRawToSpot(
|
|
405
|
+
spotRouteTarget,
|
|
406
|
+
request,
|
|
407
|
+
timeoutMs,
|
|
408
|
+
signal,
|
|
409
|
+
onAdmitted
|
|
410
|
+
);
|
|
394
411
|
}
|
|
395
412
|
|
|
396
413
|
canRouteChannel(routerChannelId: string): boolean {
|