@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.keepChannelRequestAlive = keepChannelRequestAlive;
|
|
|
5
5
|
exports.requestTerminalResult = requestTerminalResult;
|
|
6
6
|
exports.isRemoteChannelErrorReply = isRemoteChannelErrorReply;
|
|
7
7
|
const framework_errors_internal_1 = require("../framework-errors-internal");
|
|
8
|
+
const request_deadline_1 = require("../messaging/request-deadline");
|
|
8
9
|
const runtime_values_1 = require("../backend/runtime-values");
|
|
9
10
|
const submission_result_1 = require("../messaging/submission-result");
|
|
10
11
|
const ZLinkDispatchOptions_1 = require("../../contracts/Dispatch/ZLinkDispatchOptions");
|
|
@@ -32,16 +33,15 @@ class ZLinkChannelOutboundOperations {
|
|
|
32
33
|
pendingRequestCount(channelName) {
|
|
33
34
|
return this.pendingRequests.get(channelName) ?? 0;
|
|
34
35
|
}
|
|
35
|
-
send(channelName, packetName, message,
|
|
36
|
+
send(channelName, packetName, message, metadata = EMPTY_OUTBOUND_METADATA) {
|
|
36
37
|
// Call-scoped flow (spec 27 §4): the envelope encoder and the trace
|
|
37
38
|
// points below share one ambient flow that does not outlive this call.
|
|
38
|
-
return (0, flow_context_1.runWithOutboundFlow)(this.dispatchServices.flowCreationEnabled(), () => this.sendScoped(channelName, packetName, message,
|
|
39
|
+
return (0, flow_context_1.runWithOutboundFlow)(this.dispatchServices.flowCreationEnabled(), () => this.sendScoped(channelName, packetName, message, metadata));
|
|
39
40
|
}
|
|
40
|
-
async sendScoped(channelName, packetName, message,
|
|
41
|
-
|
|
42
|
-
const dealer = await this.sockets.awaitClientDealerForOutbound(channelName, signal);
|
|
41
|
+
async sendScoped(channelName, packetName, message, metadata = EMPTY_OUTBOUND_METADATA) {
|
|
42
|
+
const dealer = await this.sockets.awaitClientDealerForOutbound(channelName);
|
|
43
43
|
if (dealer === undefined) {
|
|
44
|
-
return { status: submission_result_1.ZLinkSubmitStatus.
|
|
44
|
+
return { status: submission_result_1.ZLinkSubmitStatus.Shutdown };
|
|
45
45
|
}
|
|
46
46
|
const parts = (0, channel_envelope_1.encodeChannelEnvelopeParts)(3 /* ZLinkChannelMessageKind.Command */, channelName, packetName, message, undefined, undefined, this.codecs, undefined, this.dispatchServices.flowCreationEnabled(), metadata);
|
|
47
47
|
try {
|
|
@@ -49,17 +49,8 @@ class ZLinkChannelOutboundOperations {
|
|
|
49
49
|
}
|
|
50
50
|
catch (error) {
|
|
51
51
|
(0, channel_envelope_1.closeMessages)(parts);
|
|
52
|
-
if (
|
|
53
|
-
|
|
54
|
-
surface: ZLinkDispatchOptions_1.ZLinkDispatchErrorSurface.Channel,
|
|
55
|
-
messageKind: ZLinkDispatchOptions_1.ZLinkDispatchMessageKind.Send,
|
|
56
|
-
channelName,
|
|
57
|
-
channelRouteKind: 'client_server',
|
|
58
|
-
packetName,
|
|
59
|
-
correlationId: undefined,
|
|
60
|
-
result: 'backpressured'
|
|
61
|
-
});
|
|
62
|
-
return { status: submission_result_1.ZLinkSubmitStatus.TimedOut };
|
|
52
|
+
if ((0, runtime_values_1.isZLinkBackendResultError)(error) && error.operation === 'submit') {
|
|
53
|
+
return (0, submission_result_1.classifySubmitResult)(error.result, 'One-way send', error.phase);
|
|
63
54
|
}
|
|
64
55
|
throw error;
|
|
65
56
|
}
|
|
@@ -81,6 +72,8 @@ class ZLinkChannelOutboundOperations {
|
|
|
81
72
|
return keepChannelRequestAlive((0, flow_context_1.runWithOutboundFlow)(this.dispatchServices.flowCreationEnabled(), () => this.requestScoped(channelName, packetName, request, timeoutMs, signal, metadata)));
|
|
82
73
|
}
|
|
83
74
|
async requestScoped(channelName, packetName, request, timeoutMs, signal, metadata) {
|
|
75
|
+
const deadlineMs = timeoutMs === undefined ? undefined : performance.now() + timeoutMs;
|
|
76
|
+
const deadlineUnixMs = timeoutMs === undefined ? undefined : Date.now() + timeoutMs;
|
|
84
77
|
let correlationId;
|
|
85
78
|
let selectedServerRid;
|
|
86
79
|
let terminalRecorded = false;
|
|
@@ -101,14 +94,16 @@ class ZLinkChannelOutboundOperations {
|
|
|
101
94
|
};
|
|
102
95
|
try {
|
|
103
96
|
(0, abort_1.throwIfAborted)(signal);
|
|
104
|
-
const
|
|
97
|
+
const readyWait = new AbortController();
|
|
98
|
+
const readySignal = signal === undefined ? readyWait.signal : AbortSignal.any([signal, readyWait.signal]);
|
|
99
|
+
const dealer = await (0, request_deadline_1.waitRequestReply)(this.sockets.awaitClientDealerForOutbound(channelName, readySignal), `Channel request '${channelName}'`, deadlineMs, signal, () => readyWait.abort());
|
|
105
100
|
if (dealer === undefined) {
|
|
106
101
|
throw (0, framework_errors_internal_1.createInternalFrameworkException)(framework_errors_internal_1.ZLinkFrameworkInternalErrorKind.DeadlineExceeded, `Channel '${channelName}' has no ready ClientServer server before its admission deadline.`);
|
|
107
102
|
}
|
|
108
103
|
const serverRid = this.sockets.selectedClientServerRid(channelName, dealer);
|
|
109
104
|
selectedServerRid = serverRid;
|
|
110
105
|
correlationId = (0, channel_envelope_1.newChannelCorrelationId)();
|
|
111
|
-
const parts = (0, channel_envelope_1.
|
|
106
|
+
const parts = (0, channel_envelope_1.encodeChannelEnvelopePartsAtDeadline)(1 /* ZLinkChannelMessageKind.Request */, channelName, packetName, request, deadlineUnixMs, undefined, this.codecs, correlationId, this.dispatchServices.flowCreationEnabled(), metadata);
|
|
112
107
|
this.dispatchServices.beginOutbound(ZLinkDispatchOptions_1.ZLinkRuntimeMessageFlowOutcome.Sent)?.trace({
|
|
113
108
|
surface: ZLinkDispatchOptions_1.ZLinkDispatchErrorSurface.Channel,
|
|
114
109
|
messageKind: ZLinkDispatchOptions_1.ZLinkDispatchMessageKind.Request,
|
|
@@ -122,7 +117,7 @@ class ZLinkChannelOutboundOperations {
|
|
|
122
117
|
let replyParts = [];
|
|
123
118
|
try {
|
|
124
119
|
try {
|
|
125
|
-
replyParts = await (0, abort_1.awaitWithAbort)(dealer.request(parts,
|
|
120
|
+
replyParts = await (0, abort_1.awaitWithAbort)(dealer.request(parts, (0, request_deadline_1.remainingRequestTimeout)(`Channel request '${channelName}'`, deadlineMs)), signal);
|
|
126
121
|
}
|
|
127
122
|
catch (error) {
|
|
128
123
|
if (signal?.aborted === true)
|
|
@@ -182,29 +177,18 @@ class ZLinkChannelOutboundOperations {
|
|
|
182
177
|
publisher.publish(topic, parts);
|
|
183
178
|
return publishResult(submission_result_1.ZLinkSubmitStatus.Submitted);
|
|
184
179
|
}
|
|
185
|
-
routeSubmit(routerChannelId, targetNodeRid, packetName, message,
|
|
186
|
-
return (0, flow_context_1.runWithOutboundFlow)(this.dispatchServices.flowCreationEnabled(), () => this.routeSubmitScoped(routerChannelId, targetNodeRid, packetName, message,
|
|
180
|
+
routeSubmit(routerChannelId, targetNodeRid, packetName, message, metadata = EMPTY_OUTBOUND_METADATA) {
|
|
181
|
+
return (0, flow_context_1.runWithOutboundFlow)(this.dispatchServices.flowCreationEnabled(), () => this.routeSubmitScoped(routerChannelId, targetNodeRid, packetName, message, metadata));
|
|
187
182
|
}
|
|
188
|
-
async routeSubmitScoped(routerChannelId, targetNodeRid, packetName, message,
|
|
189
|
-
(0, abort_1.throwIfAborted)(signal);
|
|
183
|
+
async routeSubmitScoped(routerChannelId, targetNodeRid, packetName, message, metadata = EMPTY_OUTBOUND_METADATA) {
|
|
190
184
|
const router = this.sockets.routeRouter(routerChannelId);
|
|
191
185
|
const parts = (0, channel_envelope_1.encodeChannelEnvelopeParts)(3 /* ZLinkChannelMessageKind.Command */, routerChannelId, packetName, message, undefined, undefined, (0, channel_framework_packets_1.codecsForFrameworkPacket)(packetName, this.codecs), undefined, this.dispatchServices.flowCreationEnabled(), metadata);
|
|
192
186
|
try {
|
|
193
187
|
await router.send(targetNodeRid, parts);
|
|
194
188
|
}
|
|
195
189
|
catch (error) {
|
|
196
|
-
if (
|
|
197
|
-
|
|
198
|
-
surface: ZLinkDispatchOptions_1.ZLinkDispatchErrorSurface.RouteMeshChannel,
|
|
199
|
-
messageKind: ZLinkDispatchOptions_1.ZLinkDispatchMessageKind.Send,
|
|
200
|
-
channelName: routerChannelId,
|
|
201
|
-
channelRouteKind: 'route_mesh',
|
|
202
|
-
packetName,
|
|
203
|
-
correlationId: undefined,
|
|
204
|
-
targetRid: targetNodeRid,
|
|
205
|
-
result: 'backpressured'
|
|
206
|
-
});
|
|
207
|
-
return { status: submission_result_1.ZLinkSubmitStatus.TimedOut };
|
|
190
|
+
if ((0, runtime_values_1.isZLinkBackendResultError)(error) && error.operation === 'submit') {
|
|
191
|
+
return (0, submission_result_1.classifySubmitResult)(error.result, 'One-way send', error.phase);
|
|
208
192
|
}
|
|
209
193
|
throw error;
|
|
210
194
|
}
|
|
@@ -44,16 +44,16 @@ export declare class ZLinkChannelRuntimeManager {
|
|
|
44
44
|
dispatchMeshRoute(meshName: string, record: ReceiveRecord, signal?: AbortSignal): Promise<void>;
|
|
45
45
|
dispatchLocalMeshRoute(meshName: string, sourceNodeRid: RoutingId, parts: readonly Message[], signal?: AbortSignal): Promise<void>;
|
|
46
46
|
canDispatchLocalMeshRoute(meshName: string): boolean;
|
|
47
|
-
send(channelName: string, packetName: string | undefined, message: unknown,
|
|
47
|
+
send(channelName: string, packetName: string | undefined, message: unknown, metadata?: ReadonlyMap<string, string>): Promise<ZLinkSubmitResult>;
|
|
48
48
|
request<TReply>(channelName: string, packetName: string | undefined, request: unknown, timeoutMs: number | undefined, signal?: AbortSignal, metadata?: ReadonlyMap<string, string>): Promise<TReply>;
|
|
49
49
|
tryPublish(channelName: string, topic: string, packetName: string | undefined, event: unknown, metadata?: ReadonlyMap<string, string>): ZLinkSubmitResult;
|
|
50
50
|
publish(channelName: string, topic: string, packetName: string | undefined, event: unknown, signal?: AbortSignal, metadata?: ReadonlyMap<string, string>): Promise<ZLinkSubmitResult>;
|
|
51
|
-
routeSubmit(routerChannelId: string, targetNodeRid: string, packetName: string | undefined, message: unknown,
|
|
51
|
+
routeSubmit(routerChannelId: string, targetNodeRid: string, packetName: string | undefined, message: unknown, metadata?: ReadonlyMap<string, string>): Promise<ZLinkSubmitResult>;
|
|
52
52
|
routeRequest<TReply>(routerChannelId: string, targetNodeRid: string, packetName: string | undefined, request: unknown, timeoutMs: number | undefined, signal?: AbortSignal, metadata?: ReadonlyMap<string, string>): Promise<TReply>;
|
|
53
|
-
routeSendToSpot(spotRouteTarget: ZLinkSpotRouteTarget, packetName: string | undefined, message: unknown,
|
|
53
|
+
routeSendToSpot(spotRouteTarget: ZLinkSpotRouteTarget, packetName: string | undefined, message: unknown, metadata?: ReadonlyMap<string, string>): Promise<void>;
|
|
54
54
|
routeRequestToSpot<TReply>(spotRouteTarget: ZLinkSpotRouteTarget, packetName: string | undefined, request: unknown, timeoutMs: number | undefined, signal?: AbortSignal, metadata?: ReadonlyMap<string, string>): Promise<TReply>;
|
|
55
55
|
routeRequestFromSpotToSpot<TReply>(sourceSpot: ZLinkBackendSpot, spotRouteTarget: ZLinkSpotRouteTarget, packetName: string | undefined, request: unknown, timeoutMs: number | undefined, signal?: AbortSignal): Promise<TReply>;
|
|
56
|
-
routeSendFromSpotToSpot(sourceSpot: ZLinkBackendSpot, spotRouteTarget: ZLinkSpotRouteTarget, packetName: string | undefined, message: unknown,
|
|
56
|
+
routeSendFromSpotToSpot(sourceSpot: ZLinkBackendSpot, spotRouteTarget: ZLinkSpotRouteTarget, packetName: string | undefined, message: unknown, metadata?: ReadonlyMap<string, string>): Promise<void>;
|
|
57
57
|
routeRequestRawFromSpotToSpot(sourceSpot: ZLinkBackendSpot, spotRouteTarget: ZLinkSpotRouteTarget, request: Message, timeoutMs: number | undefined, signal?: AbortSignal): Promise<readonly Message[]>;
|
|
58
58
|
routeRequestRawToSpot(spotRouteTarget: ZLinkSpotRouteTarget, request: Message, timeoutMs: number | undefined, signal?: AbortSignal): Promise<readonly Message[]>;
|
|
59
59
|
canRouteChannel(routerChannelId: string): boolean;
|
|
@@ -138,8 +138,8 @@ class ZLinkChannelRuntimeManager {
|
|
|
138
138
|
canDispatchLocalMeshRoute(meshName) {
|
|
139
139
|
return this.lifecycle.canDispatchLocalMeshRoute(meshName);
|
|
140
140
|
}
|
|
141
|
-
send(channelName, packetName, message,
|
|
142
|
-
return this.outbound.send(channelName, packetName, message,
|
|
141
|
+
send(channelName, packetName, message, metadata) {
|
|
142
|
+
return this.outbound.send(channelName, packetName, message, metadata);
|
|
143
143
|
}
|
|
144
144
|
async request(channelName, packetName, request, timeoutMs, signal, metadata) {
|
|
145
145
|
return this.outbound.request(channelName, packetName, request, timeoutMs, signal, metadata);
|
|
@@ -150,14 +150,14 @@ class ZLinkChannelRuntimeManager {
|
|
|
150
150
|
publish(channelName, topic, packetName, event, signal, metadata) {
|
|
151
151
|
return this.outbound.publish(channelName, topic, packetName, event, signal, metadata);
|
|
152
152
|
}
|
|
153
|
-
routeSubmit(routerChannelId, targetNodeRid, packetName, message,
|
|
154
|
-
return this.outbound.routeSubmit(routerChannelId, targetNodeRid, packetName, message,
|
|
153
|
+
routeSubmit(routerChannelId, targetNodeRid, packetName, message, metadata) {
|
|
154
|
+
return this.outbound.routeSubmit(routerChannelId, targetNodeRid, packetName, message, metadata);
|
|
155
155
|
}
|
|
156
156
|
async routeRequest(routerChannelId, targetNodeRid, packetName, request, timeoutMs, signal, metadata) {
|
|
157
157
|
return this.outbound.routeRequest(routerChannelId, targetNodeRid, packetName, request, timeoutMs, signal, metadata);
|
|
158
158
|
}
|
|
159
|
-
async routeSendToSpot(spotRouteTarget, packetName, message,
|
|
160
|
-
return this.spotRoutes.routeSendToSpot(spotRouteTarget, packetName, message,
|
|
159
|
+
async routeSendToSpot(spotRouteTarget, packetName, message, metadata) {
|
|
160
|
+
return this.spotRoutes.routeSendToSpot(spotRouteTarget, packetName, message, metadata);
|
|
161
161
|
}
|
|
162
162
|
async routeRequestToSpot(spotRouteTarget, packetName, request, timeoutMs, signal, metadata) {
|
|
163
163
|
return this.spotRoutes.routeRequestToSpot(spotRouteTarget, packetName, request, timeoutMs, signal, metadata);
|
|
@@ -165,8 +165,8 @@ class ZLinkChannelRuntimeManager {
|
|
|
165
165
|
async routeRequestFromSpotToSpot(sourceSpot, spotRouteTarget, packetName, request, timeoutMs, signal) {
|
|
166
166
|
return this.spotRoutes.routeRequestFromSpotToSpot(sourceSpot, spotRouteTarget, packetName, request, timeoutMs, signal);
|
|
167
167
|
}
|
|
168
|
-
async routeSendFromSpotToSpot(sourceSpot, spotRouteTarget, packetName, message,
|
|
169
|
-
return this.spotRoutes.routeSendFromSpotToSpot(sourceSpot, spotRouteTarget, packetName, message,
|
|
168
|
+
async routeSendFromSpotToSpot(sourceSpot, spotRouteTarget, packetName, message, metadata) {
|
|
169
|
+
return this.spotRoutes.routeSendFromSpotToSpot(sourceSpot, spotRouteTarget, packetName, message, metadata);
|
|
170
170
|
}
|
|
171
171
|
async routeRequestRawFromSpotToSpot(sourceSpot, spotRouteTarget, request, timeoutMs, signal) {
|
|
172
172
|
return this.spotRoutes.routeRequestRawFromSpotToSpot(sourceSpot, spotRouteTarget, request, timeoutMs, signal);
|
|
@@ -41,13 +41,6 @@ class ZLinkLiveSocketConfig {
|
|
|
41
41
|
(0, SendTimeoutValidation_1.requireValidSendTimeoutMs)('receiveTimeoutMs', value);
|
|
42
42
|
this.socket.receiveTimeoutMs = value;
|
|
43
43
|
}
|
|
44
|
-
get sendTimeoutMs() {
|
|
45
|
-
return this.socket.sendTimeoutMs;
|
|
46
|
-
}
|
|
47
|
-
set sendTimeoutMs(value) {
|
|
48
|
-
validateSendTimeout(value);
|
|
49
|
-
this.socket.sendTimeoutMs = value;
|
|
50
|
-
}
|
|
51
44
|
}
|
|
52
45
|
class ZLinkServerRuntimeOptions {
|
|
53
46
|
serverSocket;
|
|
@@ -122,6 +115,3 @@ function validateHighWaterMark(value, label) {
|
|
|
122
115
|
throw new configuration_1.ZLinkConfigurationException(`${label} must be a non-negative integer.`);
|
|
123
116
|
}
|
|
124
117
|
}
|
|
125
|
-
function validateSendTimeout(value) {
|
|
126
|
-
(0, SendTimeoutValidation_1.requireValidSendTimeoutMs)('sendTimeoutMs', value);
|
|
127
|
-
}
|
|
@@ -70,7 +70,7 @@ export declare class ZLinkChannelSocketRegistry {
|
|
|
70
70
|
selectClientServerDealer(channelName: string): ZLinkBackendDealerSocket | undefined;
|
|
71
71
|
clientDealerForOutbound(channelName: string): ZLinkBackendDealerSocket | undefined;
|
|
72
72
|
selectedClientServerRid(channelName: string, dealer: ZLinkBackendDealerSocket): string | undefined;
|
|
73
|
-
/** Observes discovery changes until
|
|
73
|
+
/** Observes discovery changes until a server is ready or the runtime closes. */
|
|
74
74
|
awaitClientDealerForOutbound(channelName: string, signal?: AbortSignal): Promise<ZLinkBackendDealerSocket | undefined>;
|
|
75
75
|
startManualClientServerConnections(): void;
|
|
76
76
|
startLocalClientServerConnections(): void;
|
|
@@ -158,8 +158,7 @@ class ZLinkChannelSocketRegistry {
|
|
|
158
158
|
dealer.setRoutingId(deriveRoutingId(channel.routingId, 'dealer'));
|
|
159
159
|
}
|
|
160
160
|
applySocketConfig(dealer, {
|
|
161
|
-
...client
|
|
162
|
-
sendTimeoutMs: configuredSendTimeoutMs(client.sendTimeoutMs)
|
|
161
|
+
...client
|
|
163
162
|
});
|
|
164
163
|
return dealer;
|
|
165
164
|
}
|
|
@@ -283,8 +282,7 @@ class ZLinkChannelSocketRegistry {
|
|
|
283
282
|
dealer.setChannelName(channelName);
|
|
284
283
|
dealer.setRoutingId(`cs-client-${(0, node_crypto_1.randomUUID)()}`);
|
|
285
284
|
applySocketConfig(dealer, {
|
|
286
|
-
...client
|
|
287
|
-
sendTimeoutMs: configuredSendTimeoutMs(client.sendTimeoutMs)
|
|
285
|
+
...client
|
|
288
286
|
});
|
|
289
287
|
connection.readablePoller = this.adapter.createReadablePoller(dealer);
|
|
290
288
|
created.push(connection.readablePoller);
|
|
@@ -482,7 +480,7 @@ class ZLinkChannelSocketRegistry {
|
|
|
482
480
|
}
|
|
483
481
|
return undefined;
|
|
484
482
|
}
|
|
485
|
-
/** Observes discovery changes until
|
|
483
|
+
/** Observes discovery changes until a server is ready or the runtime closes. */
|
|
486
484
|
async awaitClientDealerForOutbound(channelName, signal) {
|
|
487
485
|
(0, abort_1.throwIfAborted)(signal);
|
|
488
486
|
const select = () => {
|
|
@@ -497,10 +495,8 @@ class ZLinkChannelSocketRegistry {
|
|
|
497
495
|
const dealer = select();
|
|
498
496
|
if (dealer !== undefined)
|
|
499
497
|
return dealer;
|
|
500
|
-
const sendTimeoutMs = configuredSendTimeoutMs(this.registration.channels.get(channelName)?.client?.sendTimeoutMs);
|
|
501
498
|
return new Promise((resolve, reject) => {
|
|
502
499
|
const cleanup = () => {
|
|
503
|
-
clearTimeout(deadline);
|
|
504
500
|
unsubscribe();
|
|
505
501
|
signal?.removeEventListener('abort', abort);
|
|
506
502
|
};
|
|
@@ -524,10 +520,6 @@ class ZLinkChannelSocketRegistry {
|
|
|
524
520
|
}
|
|
525
521
|
};
|
|
526
522
|
const unsubscribe = this.clientServerDiscovery.onClientServerChanged(changed);
|
|
527
|
-
const deadline = setTimeout(() => {
|
|
528
|
-
cleanup();
|
|
529
|
-
resolve(undefined);
|
|
530
|
-
}, sendTimeoutMs);
|
|
531
523
|
signal?.addEventListener('abort', abort, { once: true });
|
|
532
524
|
// Registration and selection share one event-loop turn; recheck after subscribing.
|
|
533
525
|
changed();
|
|
@@ -1510,9 +1502,6 @@ function applySocketConfig(socket, config) {
|
|
|
1510
1502
|
if (config.receiveTimeoutMs !== undefined) {
|
|
1511
1503
|
socket.receiveTimeoutMs = config.receiveTimeoutMs;
|
|
1512
1504
|
}
|
|
1513
|
-
if (config.sendTimeoutMs !== undefined) {
|
|
1514
|
-
socket.sendTimeoutMs = config.sendTimeoutMs;
|
|
1515
|
-
}
|
|
1516
1505
|
if (config.maxMessageSize !== undefined) {
|
|
1517
1506
|
socket.maxMessageSize = config.maxMessageSize;
|
|
1518
1507
|
}
|
|
@@ -10,7 +10,7 @@ import type { ZLinkSpotRouteTarget } from '../spots/spot-routing-internal';
|
|
|
10
10
|
import type { ZLinkSpotRoutedSendOptions, ZLinkSpotRoutedRequestOptions } from '../spots/spot-outbound';
|
|
11
11
|
import { type ZLinkChannelEnvelopeCodecRegistry } from './channel-envelope';
|
|
12
12
|
export interface ZLinkChannelClientTransport {
|
|
13
|
-
send(channelName: string, packetName: string | undefined, message: unknown,
|
|
13
|
+
send(channelName: string, packetName: string | undefined, message: unknown, metadata?: ReadonlyMap<string, string>): void | ZLinkSubmitResult | Promise<void | ZLinkSubmitResult>;
|
|
14
14
|
request<TReply>(channelName: string, packetName: string | undefined, request: unknown, timeoutMs: number | undefined, signal?: AbortSignal, metadata?: ReadonlyMap<string, string>): Promise<TReply>;
|
|
15
15
|
tryPublish?(channelName: string, topic: string, packetName: string | undefined, event: unknown, metadata?: ReadonlyMap<string, string>): ZLinkSubmitResult;
|
|
16
16
|
publish(channelName: string, topic: string, packetName: string | undefined, event: unknown, signal?: AbortSignal, metadata?: ReadonlyMap<string, string>): ZLinkSubmitResult | Promise<ZLinkSubmitResult>;
|
|
@@ -21,14 +21,12 @@ export interface ZLinkSpotPublisherClientTransport {
|
|
|
21
21
|
publish(meshName: string, channelName: string, topic: string, packetName: string | undefined, event: unknown, signal?: AbortSignal, metadata?: ReadonlyMap<string, string>): ZLinkSubmitResult | Promise<ZLinkSubmitResult>;
|
|
22
22
|
}
|
|
23
23
|
export interface ZLinkRouteClientTransport {
|
|
24
|
-
submit(routerChannelId: string, targetNodeRid: string, packetName: string | undefined, message: unknown,
|
|
24
|
+
submit(routerChannelId: string, targetNodeRid: string, packetName: string | undefined, message: unknown, metadata?: ReadonlyMap<string, string>): void | ZLinkSubmitResult | Promise<void | ZLinkSubmitResult>;
|
|
25
25
|
request<TReply>(routerChannelId: string, targetNodeRid: string, packetName: string | undefined, request: unknown, timeoutMs: number | undefined, signal?: AbortSignal, metadata?: ReadonlyMap<string, string>): Promise<TReply>;
|
|
26
|
-
submitToChannel(meshName: string, channelName: string, packetName: string | undefined, message: unknown,
|
|
26
|
+
submitToChannel(meshName: string, channelName: string, packetName: string | undefined, message: unknown, metadata?: ReadonlyMap<string, string>): void | ZLinkSubmitResult | Promise<void | ZLinkSubmitResult>;
|
|
27
27
|
requestToChannel<TReply>(meshName: string, channelName: string, packetName: string | undefined, request: unknown, timeoutMs: number | undefined, signal?: AbortSignal, metadata?: ReadonlyMap<string, string>): Promise<TReply>;
|
|
28
28
|
sendToSpot?(spotRouteTarget: ZLinkSpotRouteTarget, message: unknown, options: {
|
|
29
29
|
readonly packetName?: string;
|
|
30
|
-
readonly timeoutMs?: number;
|
|
31
|
-
readonly signal?: AbortSignal;
|
|
32
30
|
readonly metadata?: ReadonlyMap<string, string>;
|
|
33
31
|
}): Promise<ZLinkSubmitResult>;
|
|
34
32
|
requestToSpot?<TReply = unknown>(spotRouteTarget: ZLinkSpotRouteTarget, request: unknown, options: {
|
|
@@ -39,16 +37,16 @@ export interface ZLinkRouteClientTransport {
|
|
|
39
37
|
}): Promise<TReply>;
|
|
40
38
|
}
|
|
41
39
|
interface ZLinkChannelTransportRuntime {
|
|
42
|
-
send(channelName: string, packetName: string | undefined, message: unknown,
|
|
40
|
+
send(channelName: string, packetName: string | undefined, message: unknown, metadata?: ReadonlyMap<string, string>): Promise<ZLinkSubmitResult>;
|
|
43
41
|
request<TReply>(channelName: string, packetName: string | undefined, request: unknown, timeoutMs: number | undefined, signal?: AbortSignal, metadata?: ReadonlyMap<string, string>): Promise<TReply>;
|
|
44
42
|
tryPublish(channelName: string, topic: string, packetName: string | undefined, event: unknown, metadata?: ReadonlyMap<string, string>): ZLinkSubmitResult;
|
|
45
43
|
publish(channelName: string, topic: string, packetName: string | undefined, event: unknown, signal?: AbortSignal, metadata?: ReadonlyMap<string, string>): Promise<ZLinkSubmitResult>;
|
|
46
44
|
canRouteChannel(routerChannelId: string): boolean;
|
|
47
45
|
canRoutePacketChannel(routerChannelId: string): boolean;
|
|
48
|
-
routeSubmit(routerChannelId: string, targetNodeRid: string, packetName: string | undefined, message: unknown,
|
|
46
|
+
routeSubmit(routerChannelId: string, targetNodeRid: string, packetName: string | undefined, message: unknown, metadata?: ReadonlyMap<string, string>): Promise<ZLinkSubmitResult>;
|
|
49
47
|
routeRequest<TReply>(routerChannelId: string, targetNodeRid: string, packetName: string | undefined, request: unknown, timeoutMs: number | undefined, signal?: AbortSignal, metadata?: ReadonlyMap<string, string>): Promise<TReply>;
|
|
50
|
-
routeSendToSpot(spotRouteTarget: ZLinkSpotRouteTarget, packetName: string | undefined, message: unknown,
|
|
51
|
-
routeSendFromSpotToSpot(sourceSpot: ZLinkBackendSpot, spotRouteTarget: ZLinkSpotRouteTarget, packetName: string | undefined, message: unknown,
|
|
48
|
+
routeSendToSpot(spotRouteTarget: ZLinkSpotRouteTarget, packetName: string | undefined, message: unknown, metadata?: ReadonlyMap<string, string>): Promise<void>;
|
|
49
|
+
routeSendFromSpotToSpot(sourceSpot: ZLinkBackendSpot, spotRouteTarget: ZLinkSpotRouteTarget, packetName: string | undefined, message: unknown, metadata?: ReadonlyMap<string, string>): Promise<void>;
|
|
52
50
|
routeRequestToSpot<TReply>(spotRouteTarget: ZLinkSpotRouteTarget, packetName: string | undefined, request: unknown, timeoutMs: number | undefined, signal?: AbortSignal, metadata?: ReadonlyMap<string, string>): Promise<TReply>;
|
|
53
51
|
routeRequestFromSpotToSpot<TReply>(sourceSpot: ZLinkBackendSpot, spotRouteTarget: ZLinkSpotRouteTarget, packetName: string | undefined, request: unknown, timeoutMs: number | undefined, signal?: AbortSignal): Promise<TReply>;
|
|
54
52
|
routeRequestRawFromSpotToSpot(sourceSpot: ZLinkBackendSpot, spotRouteTarget: ZLinkSpotRouteTarget, request: Message, timeoutMs: number | undefined, signal?: AbortSignal): Promise<readonly Message[]>;
|
|
@@ -70,13 +68,13 @@ export declare class ZLinkRuntimeRouteTransport implements ZLinkRouteClientTrans
|
|
|
70
68
|
} | undefined) | undefined, codecs?: ZLinkChannelEnvelopeCodecRegistry | undefined, manualNodeTarget?: ((meshName: string, targetNodeRid: string) => boolean | undefined) | undefined, localNodeSubmit?: ((meshName: string, sourceNodeRid: string, parts: readonly MessageLike[]) => ZLinkSubmitResult) | undefined, metrics?: ZLinkRuntimeMetrics | undefined, flowCreationEnabled?: () => boolean, outboundFlow?: () => ZLinkMessageFlowTracer | undefined);
|
|
71
69
|
canRouteChannel(routerChannelId: string): boolean;
|
|
72
70
|
canRoutePacketChannel(routerChannelId: string): boolean;
|
|
73
|
-
submit(meshName: string, targetNodeRid: string, packetName: string | undefined, message: unknown,
|
|
74
|
-
submitInfrastructure(meshName: string, targetNodeRid: string, packetName: string | undefined, message: unknown,
|
|
71
|
+
submit(meshName: string, targetNodeRid: string, packetName: string | undefined, message: unknown, metadata?: ReadonlyMap<string, string>): Promise<ZLinkSubmitResult>;
|
|
72
|
+
submitInfrastructure(meshName: string, targetNodeRid: string, packetName: string | undefined, message: unknown, metadata?: ReadonlyMap<string, string>): Promise<ZLinkSubmitResult>;
|
|
75
73
|
private submitNode;
|
|
76
74
|
request<TReply>(meshName: string, targetNodeRid: string, packetName: string | undefined, request: unknown, timeoutMs: number | undefined, signal?: AbortSignal, metadata?: ReadonlyMap<string, string>): Promise<TReply>;
|
|
77
75
|
private requestScoped;
|
|
78
76
|
private traceNodeRequest;
|
|
79
|
-
submitToChannel(meshName: string, channelName: string, packetName: string | undefined, message: unknown,
|
|
77
|
+
submitToChannel(meshName: string, channelName: string, packetName: string | undefined, message: unknown, metadata?: ReadonlyMap<string, string>): Promise<ZLinkSubmitResult>;
|
|
80
78
|
private submitToChannelScoped;
|
|
81
79
|
requestToChannel<TReply>(meshName: string, channelName: string, packetName: string | undefined, request: unknown, timeoutMs: number | undefined, signal?: AbortSignal, metadata?: ReadonlyMap<string, string>): Promise<TReply>;
|
|
82
80
|
private requestToChannelScoped;
|
|
@@ -85,8 +83,6 @@ export declare class ZLinkRuntimeRouteTransport implements ZLinkRouteClientTrans
|
|
|
85
83
|
private sendToSpotScoped;
|
|
86
84
|
sendFromSpotToSpot(sourceSpot: ZLinkBackendSpot, spotRouteTarget: ZLinkSpotRouteTarget, message: unknown, options: {
|
|
87
85
|
readonly packetName?: string;
|
|
88
|
-
readonly timeoutMs?: number;
|
|
89
|
-
readonly signal?: AbortSignal;
|
|
90
86
|
readonly metadata?: ReadonlyMap<string, string>;
|
|
91
87
|
}): Promise<ZLinkSubmitResult>;
|
|
92
88
|
requestToSpot<TReply = unknown>(spotRouteTarget: ZLinkSpotRouteTarget, request: unknown, options: ZLinkSpotRoutedRequestOptions): Promise<TReply>;
|
|
@@ -52,20 +52,19 @@ class ZLinkRuntimeRouteTransport {
|
|
|
52
52
|
this.routeChannelPredicate?.(routerChannelId) ??
|
|
53
53
|
false);
|
|
54
54
|
}
|
|
55
|
-
async submit(meshName, targetNodeRid, packetName, message,
|
|
55
|
+
async submit(meshName, targetNodeRid, packetName, message, metadata) {
|
|
56
56
|
// Call-scoped flow (spec 27 §4): the envelope flow pair lives only for
|
|
57
57
|
// the duration of this outbound call, never in the caller's context.
|
|
58
|
-
return (0, flow_context_1.runWithOutboundFlow)(this.flowCreationEnabled(), () => this.submitNode(meshName, targetNodeRid, packetName, message,
|
|
58
|
+
return (0, flow_context_1.runWithOutboundFlow)(this.flowCreationEnabled(), () => this.submitNode(meshName, targetNodeRid, packetName, message, metadata, false));
|
|
59
59
|
}
|
|
60
|
-
async submitInfrastructure(meshName, targetNodeRid, packetName, message,
|
|
61
|
-
return (0, flow_context_1.runWithOutboundFlow)(this.flowCreationEnabled(), () => this.submitNode(meshName, targetNodeRid, packetName, message,
|
|
60
|
+
async submitInfrastructure(meshName, targetNodeRid, packetName, message, metadata) {
|
|
61
|
+
return (0, flow_context_1.runWithOutboundFlow)(this.flowCreationEnabled(), () => this.submitNode(meshName, targetNodeRid, packetName, message, metadata, true));
|
|
62
62
|
}
|
|
63
|
-
async submitNode(meshName, targetNodeRid, packetName, message,
|
|
63
|
+
async submitNode(meshName, targetNodeRid, packetName, message, metadata, allowObjectClientTarget) {
|
|
64
64
|
const node = this.meshNode(meshName);
|
|
65
65
|
if (node === undefined) {
|
|
66
|
-
return this.requireManager().routeSubmit(meshName, targetNodeRid, packetName, message,
|
|
66
|
+
return this.requireManager().routeSubmit(meshName, targetNodeRid, packetName, message, metadata);
|
|
67
67
|
}
|
|
68
|
-
(0, abort_1.throwIfAborted)(signal);
|
|
69
68
|
if (!allowObjectClientTarget &&
|
|
70
69
|
node.isObjectClientNodeDirectTarget?.((0, routing_id_1.toBackendRoutingId)(targetNodeRid)) === true) {
|
|
71
70
|
return { status: submission_result_1.ZLinkSubmitStatus.TargetNotFound };
|
|
@@ -135,11 +134,10 @@ class ZLinkRuntimeRouteTransport {
|
|
|
135
134
|
...(error instanceof Error ? { errorType: error.name, errorMessage: error.message } : {})
|
|
136
135
|
});
|
|
137
136
|
}
|
|
138
|
-
submitToChannel(meshName, channelName, packetName, message,
|
|
139
|
-
return (0, flow_context_1.runWithOutboundFlow)(this.flowCreationEnabled(), () => this.submitToChannelScoped(meshName, channelName, packetName, message,
|
|
137
|
+
submitToChannel(meshName, channelName, packetName, message, metadata) {
|
|
138
|
+
return (0, flow_context_1.runWithOutboundFlow)(this.flowCreationEnabled(), () => this.submitToChannelScoped(meshName, channelName, packetName, message, metadata));
|
|
140
139
|
}
|
|
141
|
-
async submitToChannelScoped(meshName, channelName, packetName, message,
|
|
142
|
-
(0, abort_1.throwIfAborted)(signal);
|
|
140
|
+
async submitToChannelScoped(meshName, channelName, packetName, message, metadata) {
|
|
143
141
|
const node = this.requireMeshNode(meshName);
|
|
144
142
|
const parts = this.encodeMessage(3 /* ZLinkChannelMessageKind.Command */, channelName, packetName, message, undefined, metadata);
|
|
145
143
|
const operation = `MeshNode '${meshName}' send to channel '${channelName}'`;
|
|
@@ -199,10 +197,9 @@ class ZLinkRuntimeRouteTransport {
|
|
|
199
197
|
if (spotRouteTarget.spotKind === Spots_1.ZLinkSpotKind.Instance) {
|
|
200
198
|
throw new configuration_1.ZLinkConfigurationException('Instance Spot routes require the MeshNode command 39 transport.');
|
|
201
199
|
}
|
|
202
|
-
await this.requireManager().routeSendToSpot(spotRouteTarget, options.packetName, message, options.
|
|
200
|
+
await this.requireManager().routeSendToSpot(spotRouteTarget, options.packetName, message, options.metadata);
|
|
203
201
|
return { status: submission_result_1.ZLinkSubmitStatus.Submitted };
|
|
204
202
|
}
|
|
205
|
-
(0, abort_1.throwIfAborted)(options.signal);
|
|
206
203
|
const operation = `MeshNode '${spotRouteTarget.routerChannelId}' send to Spot '${spotRouteTarget.spotId}'`;
|
|
207
204
|
try {
|
|
208
205
|
const encoded = this.encodeMessage(3 /* ZLinkChannelMessageKind.Command */, spotRouteTarget.routerChannelId, options.packetName, message, undefined, options.metadata);
|
|
@@ -222,7 +219,7 @@ class ZLinkRuntimeRouteTransport {
|
|
|
222
219
|
}
|
|
223
220
|
}
|
|
224
221
|
async sendFromSpotToSpot(sourceSpot, spotRouteTarget, message, options) {
|
|
225
|
-
await this.requireManager().routeSendFromSpotToSpot(sourceSpot, spotRouteTarget, options.packetName, message, options.
|
|
222
|
+
await this.requireManager().routeSendFromSpotToSpot(sourceSpot, spotRouteTarget, options.packetName, message, options.metadata);
|
|
226
223
|
return { status: submission_result_1.ZLinkSubmitStatus.Submitted };
|
|
227
224
|
}
|
|
228
225
|
requestToSpot(spotRouteTarget, request, options) {
|
|
@@ -4,6 +4,6 @@ export declare class ZLinkLocalSpotRouteTransport {
|
|
|
4
4
|
private readonly dispatcher;
|
|
5
5
|
private readonly defaultRequestTimeoutMs;
|
|
6
6
|
constructor(dispatcher: ZLinkLocalSpotRouteDispatcher | undefined, defaultRequestTimeoutMs: number | undefined);
|
|
7
|
-
send(routerChannelId: string, spotId: RoutingId, packetName: string | undefined, message: unknown,
|
|
7
|
+
send(routerChannelId: string, spotId: RoutingId, packetName: string | undefined, message: unknown, metadata?: ReadonlyMap<string, string>): Promise<void>;
|
|
8
8
|
request<TReply>(routerChannelId: string, spotId: RoutingId, packetName: string | undefined, request: unknown, timeoutMs: number | undefined, signal?: AbortSignal): Promise<TReply>;
|
|
9
9
|
}
|
|
@@ -9,14 +9,12 @@ class ZLinkLocalSpotRouteTransport {
|
|
|
9
9
|
this.dispatcher = dispatcher;
|
|
10
10
|
this.defaultRequestTimeoutMs = defaultRequestTimeoutMs;
|
|
11
11
|
}
|
|
12
|
-
async send(routerChannelId, spotId, packetName, message,
|
|
12
|
+
async send(routerChannelId, spotId, packetName, message, metadata) {
|
|
13
13
|
if (this.dispatcher === undefined) {
|
|
14
14
|
throw new configuration_1.ZLinkConfigurationException(`Route channel '${routerChannelId}' could not dispatch local SPOT send.`);
|
|
15
15
|
}
|
|
16
16
|
await this.dispatcher.send(spotId, packetName, message, {
|
|
17
17
|
channelName: routerChannelId,
|
|
18
|
-
admissionTimeoutMs: timeoutMs ?? this.defaultRequestTimeoutMs,
|
|
19
|
-
signal,
|
|
20
18
|
metadata
|
|
21
19
|
});
|
|
22
20
|
}
|
|
@@ -6,7 +6,7 @@ import type { ZLinkChannelSocketRegistry } from './channel-socket-registry';
|
|
|
6
6
|
export declare class ZLinkRouterSocketSpotRouteTransport {
|
|
7
7
|
private readonly sockets;
|
|
8
8
|
constructor(sockets: ZLinkChannelSocketRegistry);
|
|
9
|
-
send(target: ZLinkSpotRouteTarget, parts: readonly Message[], flags: ZLinkBackendSendFlags
|
|
9
|
+
send(target: ZLinkSpotRouteTarget, parts: readonly Message[], flags: ZLinkBackendSendFlags): Promise<void>;
|
|
10
10
|
request<TReply>(target: ZLinkSpotRouteTarget, parts: readonly Message[], codecs: ZLinkChannelEnvelopeCodecRegistry | undefined, flags: ZLinkBackendSendFlags, timeoutMs: number | undefined, signal?: AbortSignal): Promise<TReply>;
|
|
11
11
|
requestRaw(target: ZLinkSpotRouteTarget, request: Message, timeoutMs: number | undefined, signal?: AbortSignal): Promise<readonly Message[]>;
|
|
12
12
|
}
|
|
@@ -8,10 +8,10 @@ class ZLinkRouterSocketSpotRouteTransport {
|
|
|
8
8
|
constructor(sockets) {
|
|
9
9
|
this.sockets = sockets;
|
|
10
10
|
}
|
|
11
|
-
async send(target, parts, flags
|
|
11
|
+
async send(target, parts, flags) {
|
|
12
12
|
const router = this.sockets.routeRouter(target.routerChannelId);
|
|
13
13
|
try {
|
|
14
|
-
await
|
|
14
|
+
await router.sendToSpot(target.targetNodeRid, target.spotId, parts, flags);
|
|
15
15
|
}
|
|
16
16
|
finally {
|
|
17
17
|
(0, channel_envelope_1.closeMessages)(parts);
|
|
@@ -5,6 +5,6 @@ export declare class ZLinkSourceSpotRouter {
|
|
|
5
5
|
private readonly defaultRequestTimeoutMs;
|
|
6
6
|
constructor(defaultRequestTimeoutMs: number | undefined);
|
|
7
7
|
request<TReply>(sourceSpot: ZLinkBackendSpot, target: ZLinkSpotRouteTarget, packetName: string | undefined, request: unknown, timeoutMs: number | undefined, signal?: AbortSignal): Promise<TReply>;
|
|
8
|
-
send(sourceSpot: ZLinkBackendSpot, target: ZLinkSpotRouteTarget, packetName: string | undefined, message: unknown,
|
|
8
|
+
send(sourceSpot: ZLinkBackendSpot, target: ZLinkSpotRouteTarget, packetName: string | undefined, message: unknown, metadata?: ReadonlyMap<string, string>): Promise<void>;
|
|
9
9
|
requestRaw(sourceSpot: ZLinkBackendSpot, target: ZLinkSpotRouteTarget, request: Message, timeoutMs: number | undefined, signal?: AbortSignal): Promise<readonly Message[]>;
|
|
10
10
|
}
|
|
@@ -26,14 +26,12 @@ class ZLinkSourceSpotRouter {
|
|
|
26
26
|
(0, channel_envelope_1.closeMessages)(parts);
|
|
27
27
|
}
|
|
28
28
|
}
|
|
29
|
-
async send(sourceSpot, target, packetName, message,
|
|
30
|
-
(0, abort_1.throwIfAborted)(signal);
|
|
29
|
+
async send(sourceSpot, target, packetName, message, metadata) {
|
|
31
30
|
const parts = [
|
|
32
31
|
(0, spot_direct_envelope_1.encodeSpotDirectEnvelope)(3 /* ZLinkChannelMessageKind.Command */, target.routerChannelId, packetName, message, metadata)
|
|
33
32
|
];
|
|
34
33
|
try {
|
|
35
|
-
|
|
36
|
-
await (0, abort_1.awaitWithAbort)(sourceSpot.sendToSpot(target.targetNodeRid, target.spotId, parts), signal);
|
|
34
|
+
await sourceSpot.sendToSpot(target.targetNodeRid, target.spotId, parts);
|
|
37
35
|
}
|
|
38
36
|
finally {
|
|
39
37
|
(0, channel_envelope_1.closeMessages)(parts);
|
|
@@ -7,7 +7,7 @@ export declare class ZLinkSpotNodeRouteTransport {
|
|
|
7
7
|
private readonly registration;
|
|
8
8
|
private readonly targets;
|
|
9
9
|
constructor(registration: ZLinkFrameworkRegistration, targets: ZLinkSpotRouteTargetResolver);
|
|
10
|
-
send(target: ZLinkSpotRouteTarget, parts: readonly Message[]
|
|
10
|
+
send(target: ZLinkSpotRouteTarget, parts: readonly Message[]): Promise<boolean>;
|
|
11
11
|
request<TReply>(target: ZLinkSpotRouteTarget, parts: readonly Message[], codecs: ZLinkChannelEnvelopeCodecRegistry | undefined, timeoutMs: number | undefined, signal?: AbortSignal): Promise<TReply> | undefined;
|
|
12
12
|
requestRaw(target: ZLinkSpotRouteTarget, request: Message, timeoutMs: number | undefined, signal?: AbortSignal): Promise<readonly Message[]> | undefined;
|
|
13
13
|
}
|
|
@@ -11,14 +11,13 @@ class ZLinkSpotNodeRouteTransport {
|
|
|
11
11
|
this.registration = registration;
|
|
12
12
|
this.targets = targets;
|
|
13
13
|
}
|
|
14
|
-
async send(target, parts
|
|
14
|
+
async send(target, parts) {
|
|
15
15
|
const router = this.targets.spotNodeRouter(target.routerChannelId);
|
|
16
16
|
if (router === undefined) {
|
|
17
17
|
return false;
|
|
18
18
|
}
|
|
19
19
|
try {
|
|
20
|
-
(
|
|
21
|
-
await (0, abort_1.awaitWithAbort)(router.sendToSpot(target.targetNodeRid, target.spotId, parts), signal);
|
|
20
|
+
await router.sendToSpot(target.targetNodeRid, target.spotId, parts);
|
|
22
21
|
return true;
|
|
23
22
|
}
|
|
24
23
|
finally {
|
|
@@ -7,7 +7,7 @@ export declare class ZLinkSpotRouteBridgeTransport {
|
|
|
7
7
|
private readonly defaultRequestTimeoutMs;
|
|
8
8
|
constructor(bridges: ReadonlyMap<string, ZLinkBackendSpotRouteBridge>, defaultRequestTimeoutMs: number | undefined);
|
|
9
9
|
has(routerChannelId: string): boolean;
|
|
10
|
-
send(target: ZLinkSpotRouteTarget, parts: readonly Message[]
|
|
10
|
+
send(target: ZLinkSpotRouteTarget, parts: readonly Message[]): Promise<void>;
|
|
11
11
|
request<TReply>(target: ZLinkSpotRouteTarget, parts: readonly Message[], codecs: ZLinkChannelEnvelopeCodecRegistry | undefined, timeoutMs: number | undefined, signal?: AbortSignal): Promise<TReply>;
|
|
12
12
|
requestRaw(target: ZLinkSpotRouteTarget, request: Message, timeoutMs: number | undefined, signal?: AbortSignal): Promise<readonly Message[]>;
|
|
13
13
|
private requireBridge;
|
|
@@ -15,10 +15,10 @@ class ZLinkSpotRouteBridgeTransport {
|
|
|
15
15
|
has(routerChannelId) {
|
|
16
16
|
return this.bridges.has(routerChannelId);
|
|
17
17
|
}
|
|
18
|
-
async send(target, parts
|
|
18
|
+
async send(target, parts) {
|
|
19
19
|
const bridge = this.requireBridge(target.routerChannelId);
|
|
20
20
|
try {
|
|
21
|
-
await (0,
|
|
21
|
+
await (0, channel_multipart_1.appendParts)(bridge.send(target.routerChannelId, target.targetNodeRid, target.spotId), parts).submit();
|
|
22
22
|
}
|
|
23
23
|
finally {
|
|
24
24
|
(0, channel_envelope_1.closeMessages)(parts);
|
|
@@ -8,8 +8,6 @@ import type { ZLinkChannelSocketRegistry } from './channel-socket-registry';
|
|
|
8
8
|
export interface ZLinkLocalSpotRouteDispatcher {
|
|
9
9
|
send(spotId: RoutingId, packetName: string | undefined, message: unknown, context: {
|
|
10
10
|
readonly channelName: string;
|
|
11
|
-
readonly admissionTimeoutMs?: number;
|
|
12
|
-
readonly signal?: AbortSignal;
|
|
13
11
|
readonly metadata?: ReadonlyMap<string, string>;
|
|
14
12
|
}): Promise<void>;
|
|
15
13
|
request<TReply>(spotId: RoutingId, packetName: string | undefined, request: unknown, context: {
|
|
@@ -39,12 +37,12 @@ export declare class ZLinkSpotRouteDispatchStrategy {
|
|
|
39
37
|
spotRouteNode(routerChannelId: string): ZLinkBackendSpotNode | undefined;
|
|
40
38
|
canRouteChannel(routerChannelId: string): boolean;
|
|
41
39
|
canRoutePacketChannel(routerChannelId: string): boolean;
|
|
42
|
-
routeSendToSpot(spotRouteTarget: ZLinkSpotRouteTarget, packetName: string | undefined, message: unknown,
|
|
40
|
+
routeSendToSpot(spotRouteTarget: ZLinkSpotRouteTarget, packetName: string | undefined, message: unknown, metadata?: ReadonlyMap<string, string>): Promise<void>;
|
|
43
41
|
private routeSendToSpotScoped;
|
|
44
42
|
routeRequestToSpot<TReply>(spotRouteTarget: ZLinkSpotRouteTarget, packetName: string | undefined, request: unknown, timeoutMs: number | undefined, signal?: AbortSignal, metadata?: ReadonlyMap<string, string>): Promise<TReply>;
|
|
45
43
|
private routeRequestToSpotScoped;
|
|
46
44
|
routeRequestFromSpotToSpot<TReply>(sourceSpot: ZLinkBackendSpot, spotRouteTarget: ZLinkSpotRouteTarget, packetName: string | undefined, request: unknown, timeoutMs: number | undefined, signal?: AbortSignal): Promise<TReply>;
|
|
47
|
-
routeSendFromSpotToSpot(sourceSpot: ZLinkBackendSpot, spotRouteTarget: ZLinkSpotRouteTarget, packetName: string | undefined, message: unknown,
|
|
45
|
+
routeSendFromSpotToSpot(sourceSpot: ZLinkBackendSpot, spotRouteTarget: ZLinkSpotRouteTarget, packetName: string | undefined, message: unknown, metadata?: ReadonlyMap<string, string>): Promise<void>;
|
|
48
46
|
routeRequestRawFromSpotToSpot(sourceSpot: ZLinkBackendSpot, spotRouteTarget: ZLinkSpotRouteTarget, request: Message, timeoutMs: number | undefined, signal?: AbortSignal): Promise<readonly Message[]>;
|
|
49
47
|
routeRequestRawToSpot(spotRouteTarget: ZLinkSpotRouteTarget, request: Message, timeoutMs: number | undefined, signal?: AbortSignal): Promise<readonly Message[]>;
|
|
50
48
|
}
|