@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,7 +5,7 @@ export interface ZLinkActorClient {
|
|
|
5
5
|
}
|
|
6
6
|
export interface ZLinkActorSendCall {
|
|
7
7
|
metadata(key: string, value: string): this;
|
|
8
|
-
submit(
|
|
8
|
+
submit(): Promise<void>;
|
|
9
9
|
}
|
|
10
10
|
export interface ZLinkActorRequestCall {
|
|
11
11
|
metadata(key: string, value: string): this;
|
|
@@ -2,7 +2,7 @@ import type { ZLinkMessageMetadata } from '../Common';
|
|
|
2
2
|
export interface ZLinkSendCall {
|
|
3
3
|
metadata(key: string, value: string): this;
|
|
4
4
|
metadata(metadata: ZLinkMessageMetadata): this;
|
|
5
|
-
submit(
|
|
5
|
+
submit(): Promise<void>;
|
|
6
6
|
}
|
|
7
7
|
export interface ZLinkRequestCall {
|
|
8
8
|
metadata(key: string, value: string): this;
|
|
@@ -156,7 +156,6 @@ export interface ZLinkChannelOptions {
|
|
|
156
156
|
readonly weight?: number;
|
|
157
157
|
readonly sendHighWaterMark?: number;
|
|
158
158
|
readonly receiveHighWaterMark?: number;
|
|
159
|
-
readonly sendTimeoutMs?: number;
|
|
160
159
|
readonly maxMessageSize?: number;
|
|
161
160
|
};
|
|
162
161
|
readonly subscriber?: ZLinkClientCapabilityOptions;
|
|
@@ -165,7 +164,6 @@ export interface ZLinkClientCapabilityOptions {
|
|
|
165
164
|
readonly manualConnections?: readonly string[];
|
|
166
165
|
readonly sendHighWaterMark?: number;
|
|
167
166
|
readonly receiveHighWaterMark?: number;
|
|
168
|
-
readonly sendTimeoutMs?: number;
|
|
169
167
|
readonly maxMessageSize?: number;
|
|
170
168
|
}
|
|
171
169
|
export interface ZLinkPublisherCapabilityOptions {
|
|
@@ -184,7 +182,6 @@ export interface ZLinkRouteMeshChannelOptions {
|
|
|
184
182
|
readonly weight?: number;
|
|
185
183
|
readonly sendHighWaterMark?: number;
|
|
186
184
|
readonly receiveHighWaterMark?: number;
|
|
187
|
-
readonly sendTimeoutMs?: number;
|
|
188
185
|
readonly sendHandlers?: readonly ZLinkRouteChannelSendHandlerRegistration[];
|
|
189
186
|
readonly requestHandlers?: readonly ZLinkRouteChannelRequestHandlerRegistration[];
|
|
190
187
|
readonly handlers?: readonly ZLinkRouteChannelHandlerOptions[];
|
|
@@ -199,7 +196,6 @@ export interface ZLinkRouteChannelOptions {
|
|
|
199
196
|
readonly weight?: number;
|
|
200
197
|
readonly sendHighWaterMark?: number;
|
|
201
198
|
readonly receiveHighWaterMark?: number;
|
|
202
|
-
readonly sendTimeoutMs?: number;
|
|
203
199
|
readonly sendHandlers?: readonly ZLinkRouteChannelSendHandlerRegistration[];
|
|
204
200
|
readonly requestHandlers?: readonly ZLinkRouteChannelRequestHandlerRegistration[];
|
|
205
201
|
readonly handlers?: readonly ZLinkRouteChannelHandlerOptions[];
|
|
@@ -359,7 +355,6 @@ export interface ZLinkSpotRouterCapabilityOptions {
|
|
|
359
355
|
readonly sendHighWaterMark?: number;
|
|
360
356
|
readonly receiveHighWaterMark?: number;
|
|
361
357
|
readonly receiveTimeoutMs?: number;
|
|
362
|
-
readonly sendTimeoutMs?: number;
|
|
363
358
|
}
|
|
364
359
|
export interface ZLinkSpotRouterPeerConnectionOptions {
|
|
365
360
|
readonly peerRid: RoutingId;
|
|
@@ -457,10 +457,8 @@ function requireSocketOptions(label, options) {
|
|
|
457
457
|
requireNonNegativeInteger(`${label} sendHighWaterMark`, options.sendHighWaterMark);
|
|
458
458
|
requireNonNegativeInteger(`${label} receiveHighWaterMark`, options.receiveHighWaterMark);
|
|
459
459
|
requireNonNegativeInteger(`${label} maxMessageSize`, options.maxMessageSize);
|
|
460
|
-
(0, SendTimeoutValidation_1.requireValidSendTimeoutMs)(`${label} sendTimeoutMs`, options.sendTimeoutMs);
|
|
461
460
|
}
|
|
462
461
|
function requireRouteMeshSocketOptions(label, options) {
|
|
463
462
|
requireNonNegativeInteger(`${label} sendHighWaterMark`, options.sendHighWaterMark);
|
|
464
463
|
requireNonNegativeInteger(`${label} receiveHighWaterMark`, options.receiveHighWaterMark);
|
|
465
|
-
(0, SendTimeoutValidation_1.requireValidSendTimeoutMs)(`${label} sendTimeoutMs`, options.sendTimeoutMs);
|
|
466
464
|
}
|
|
@@ -68,7 +68,7 @@ export interface ZLinkSpotSendCall {
|
|
|
68
68
|
instanceSpot(): this;
|
|
69
69
|
instanceSpot(instanceSpotType: string): this;
|
|
70
70
|
inMesh(meshName: string): this;
|
|
71
|
-
submit(
|
|
71
|
+
submit(): Promise<void>;
|
|
72
72
|
}
|
|
73
73
|
export interface ZLinkSpotRequestCall {
|
|
74
74
|
metadata(key: string, value: string): this;
|
|
@@ -36,10 +36,9 @@ export interface ZLinkSessionClient {
|
|
|
36
36
|
export interface ZLinkSessionSendCall {
|
|
37
37
|
metadata(key: string, value: string): this;
|
|
38
38
|
compress(enabled?: boolean): this;
|
|
39
|
-
|
|
40
|
-
submit(signal?: AbortSignal): Promise<void>;
|
|
39
|
+
submit(): Promise<void>;
|
|
41
40
|
}
|
|
42
41
|
export interface ZLinkSessionReplyCall {
|
|
43
42
|
compress(enabled?: boolean): this;
|
|
44
|
-
submit(
|
|
43
|
+
submit(): Promise<void>;
|
|
45
44
|
}
|
|
@@ -9,7 +9,7 @@ export interface ZLinkSessionActors {
|
|
|
9
9
|
export interface ZLinkSessionActor {
|
|
10
10
|
readonly actorId: string;
|
|
11
11
|
readonly ref: ActorRef;
|
|
12
|
-
relay(payload: ZLinkMessage
|
|
13
|
-
relay(dispatch: ZLinkSessionDispatchContext, payload: ZLinkMessage
|
|
12
|
+
relay(payload: ZLinkMessage): Promise<void>;
|
|
13
|
+
relay(dispatch: ZLinkSessionDispatchContext, payload: ZLinkMessage): Promise<void>;
|
|
14
14
|
notifyDisconnected(signal?: AbortSignal): Promise<void>;
|
|
15
15
|
}
|
|
@@ -28,24 +28,21 @@ class DefaultZLinkActorClient {
|
|
|
28
28
|
}
|
|
29
29
|
sendToActor(actorId, message) {
|
|
30
30
|
requireActorId(actorId);
|
|
31
|
-
return new DefaultZLinkActorSendCall((packetName, metadata
|
|
31
|
+
return new DefaultZLinkActorSendCall((packetName, metadata) => this.send(actorId, packetName, message, metadata), message);
|
|
32
32
|
}
|
|
33
33
|
requestToActor(actorId, request) {
|
|
34
34
|
requireActorId(actorId);
|
|
35
35
|
return new DefaultZLinkActorRequestCall((packetName, timeoutMs, metadata, signal) => this.request(actorId, packetName, request, timeoutMs, metadata, signal, 'async'), (packetName, timeoutMs, metadata, signal) => this.request(actorId, packetName, request, timeoutMs, metadata, signal, 'yield'), actorId, request, this.options.defaultRequestTimeoutMs);
|
|
36
36
|
}
|
|
37
|
-
async send(actorId, explicitPacketName, message, metadata
|
|
38
|
-
|
|
39
|
-
const route = await this.resolveActorRoute(actorId, signal);
|
|
37
|
+
async send(actorId, explicitPacketName, message, metadata) {
|
|
38
|
+
const route = await this.resolveActorRoute(actorId);
|
|
40
39
|
const { meshName, actorRef: actor } = route;
|
|
41
40
|
this.throwIfKnownStale(meshName, actor);
|
|
42
41
|
const parts = this.createPacketParts(protocol_1.ZLinkStreamMessageKind.Send, undefined, explicitPacketName, message, metadata);
|
|
43
42
|
const messageFollow = createActorMessageFollowContext(route, parts, false);
|
|
44
43
|
const routedActor = (0, actor_message_follow_context_1.attachActorMessageFollowContext)(actor, messageFollow);
|
|
45
44
|
try {
|
|
46
|
-
const submissionCopies = (await this.options
|
|
47
|
-
.transportDeliveryGate?.()
|
|
48
|
-
?.waitBeforeSubmit(actorId, 'oneWay', signal)) ?? 1;
|
|
45
|
+
const submissionCopies = (await this.options.transportDeliveryGate?.()?.waitBeforeSubmit(actorId, 'oneWay')) ?? 1;
|
|
49
46
|
const handoff = this.options.handoffCapture?.(meshName, actor.actorId, parts, false, routedActor);
|
|
50
47
|
if (handoff !== undefined) {
|
|
51
48
|
const submissions = [handoff];
|
|
@@ -54,7 +51,7 @@ class DefaultZLinkActorClient {
|
|
|
54
51
|
if (duplicate !== undefined)
|
|
55
52
|
submissions.push(duplicate);
|
|
56
53
|
}
|
|
57
|
-
await
|
|
54
|
+
await Promise.all(submissions);
|
|
58
55
|
return { status: submission_result_1.ZLinkSubmitStatus.Submitted };
|
|
59
56
|
}
|
|
60
57
|
const node = this.requireNode(meshName);
|
|
@@ -370,10 +367,10 @@ class DefaultZLinkActorSendCall {
|
|
|
370
367
|
this.selectedMetadata.set(key, value);
|
|
371
368
|
return this;
|
|
372
369
|
}
|
|
373
|
-
async submit(
|
|
370
|
+
async submit() {
|
|
374
371
|
ensureSingleSubmit(this.executed);
|
|
375
372
|
this.executed = true;
|
|
376
|
-
const result = await this.submitter(this.packet ?? (0, packet_name_1.resolveFrameworkPacketName)(this.message, undefined, 'Actor'), this.selectedMetadata
|
|
373
|
+
const result = await this.submitter(this.packet ?? (0, packet_name_1.resolveFrameworkPacketName)(this.message, undefined, 'Actor'), this.selectedMetadata);
|
|
377
374
|
(0, submission_result_1.requireOneWayCompletion)(result, 'Actor send', framework_errors_internal_1.ZLinkFrameworkInternalErrorKind.ActorRouteNotFound);
|
|
378
375
|
}
|
|
379
376
|
}
|
|
@@ -1,3 +1 @@
|
|
|
1
|
-
export
|
|
2
|
-
/** Only actual Store, delivery-gate, and handoff waits acquire a deadline handle. */
|
|
3
|
-
export declare function waitActorReply<T>(reply: Promise<T>, actorId: string, deadlineMs: number | undefined, signal?: AbortSignal): Promise<T>;
|
|
1
|
+
export { remainingRequestTimeout as remainingActorRequestTimeout, waitRequestReply as waitActorReply } from '../messaging/request-deadline';
|
|
@@ -1,31 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.remainingActorRequestTimeout =
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
function remainingActorRequestTimeout(actorId, deadlineMs) {
|
|
8
|
-
if (deadlineMs === undefined)
|
|
9
|
-
return undefined;
|
|
10
|
-
const remaining = deadlineMs - performance.now();
|
|
11
|
-
if (remaining <= 0) {
|
|
12
|
-
throw (0, framework_errors_internal_1.createInternalFrameworkException)(framework_errors_internal_1.ZLinkFrameworkInternalErrorKind.DeadlineExceeded, `Actor request '${actorId}' exceeded its deadline.`);
|
|
13
|
-
}
|
|
14
|
-
return Math.max(1, Math.ceil(remaining));
|
|
15
|
-
}
|
|
16
|
-
/** Only actual Store, delivery-gate, and handoff waits acquire a deadline handle. */
|
|
17
|
-
async function waitActorReply(reply, actorId, deadlineMs, signal) {
|
|
18
|
-
if (deadlineMs === undefined)
|
|
19
|
-
return await (0, abort_1.awaitWithAbort)(reply, signal);
|
|
20
|
-
let timer;
|
|
21
|
-
const timeout = new Promise((_resolve, reject) => {
|
|
22
|
-
const remaining = remainingActorRequestTimeout(actorId, deadlineMs);
|
|
23
|
-
timer = setTimeout(() => reject((0, framework_errors_internal_1.createInternalFrameworkException)(framework_errors_internal_1.ZLinkFrameworkInternalErrorKind.DeadlineExceeded, `Actor request '${actorId}' exceeded its deadline.`)), remaining);
|
|
24
|
-
});
|
|
25
|
-
try {
|
|
26
|
-
return await (0, abort_1.awaitWithAbort)(Promise.race([reply, timeout]), signal);
|
|
27
|
-
}
|
|
28
|
-
finally {
|
|
29
|
-
clearTimeout(timer);
|
|
30
|
-
}
|
|
31
|
-
}
|
|
3
|
+
exports.waitActorReply = exports.remainingActorRequestTimeout = void 0;
|
|
4
|
+
var request_deadline_1 = require("../messaging/request-deadline");
|
|
5
|
+
Object.defineProperty(exports, "remainingActorRequestTimeout", { enumerable: true, get: function () { return request_deadline_1.remainingRequestTimeout; } });
|
|
6
|
+
Object.defineProperty(exports, "waitActorReply", { enumerable: true, get: function () { return request_deadline_1.waitRequestReply; } });
|
|
@@ -6,11 +6,10 @@ export interface ZLinkActorRoutedJoinTransport {
|
|
|
6
6
|
canRouteChannel?(routerChannelId: string): boolean;
|
|
7
7
|
canRoutePacketChannel?(routerChannelId: string): boolean;
|
|
8
8
|
request<TReply>(routerChannelId: string, targetNodeRid: string, packetName: string | undefined, request: unknown, timeoutMs: number | undefined, signal?: AbortSignal): Promise<TReply>;
|
|
9
|
-
submit?(routerChannelId: string, targetNodeRid: string, packetName: string | undefined, message: unknown
|
|
10
|
-
submitInfrastructure?(routerChannelId: string, targetNodeRid: string, packetName: string | undefined, message: unknown
|
|
9
|
+
submit?(routerChannelId: string, targetNodeRid: string, packetName: string | undefined, message: unknown): Promise<ZLinkSubmitResult>;
|
|
10
|
+
submitInfrastructure?(routerChannelId: string, targetNodeRid: string, packetName: string | undefined, message: unknown): Promise<ZLinkSubmitResult>;
|
|
11
11
|
sendToSpot(spotRouteTarget: ZLinkSpotRouteTarget, message: unknown, options: {
|
|
12
12
|
readonly packetName?: string;
|
|
13
|
-
readonly signal?: AbortSignal;
|
|
14
13
|
}): Promise<ZLinkSubmitResult>;
|
|
15
14
|
requestRawToSpot?(spotRouteTarget: ZLinkSpotRouteTarget, request: Message, options: {
|
|
16
15
|
readonly timeoutMs?: number;
|
|
@@ -292,7 +292,6 @@ export interface ZLinkBackendDealerSocket extends ZLinkBackendConnectableSocket
|
|
|
292
292
|
sendHighWaterMark: number;
|
|
293
293
|
receiveHighWaterMark: number;
|
|
294
294
|
receiveTimeoutMs: number;
|
|
295
|
-
sendTimeoutMs: number;
|
|
296
295
|
maxMessageSize: number;
|
|
297
296
|
send(message: Message | readonly Message[]): Promise<void>;
|
|
298
297
|
request(message: Message | readonly Message[], timeoutMs?: number): Promise<readonly Message[]>;
|
|
@@ -319,7 +318,6 @@ export interface ZLinkBackendRouterSocket extends ZLinkBackendConnectableSocket
|
|
|
319
318
|
sendHighWaterMark: number;
|
|
320
319
|
receiveHighWaterMark: number;
|
|
321
320
|
receiveTimeoutMs: number;
|
|
322
|
-
sendTimeoutMs: number;
|
|
323
321
|
maxMessageSize: number;
|
|
324
322
|
setRoutingId(routingId: RoutingId): void;
|
|
325
323
|
recv(flags?: ZLinkBackendRecvFlags): Received | undefined;
|
|
@@ -354,14 +352,13 @@ export interface ZLinkBackendStreamPacket {
|
|
|
354
352
|
close(): void;
|
|
355
353
|
}
|
|
356
354
|
export interface ZLinkBackendStreamSocket extends ZLinkBackendSocket {
|
|
357
|
-
readonly sendTimeoutMs: number;
|
|
358
355
|
readonly sendHighWaterMark: number;
|
|
359
356
|
/** Framework stream ingress uses this bound for packet payload validation. */
|
|
360
357
|
maxMessageSize: number;
|
|
361
358
|
setTlsServer(cert: string, key: string, requireClientCert?: boolean): void;
|
|
362
359
|
recvPacket(packet: ZLinkBackendStreamPacket, flags?: ZLinkBackendRecvFlags): boolean;
|
|
363
360
|
send(routingId: RoutingId, payload: Message | readonly Message[], flags: ZLinkBackendSendFlags): boolean;
|
|
364
|
-
submit(routingId: RoutingId, payload: Message | readonly Message[]
|
|
361
|
+
submit(routingId: RoutingId, payload: Message | readonly Message[]): Promise<void>;
|
|
365
362
|
disconnectPeer(routingId: RoutingId): void;
|
|
366
363
|
bindActor(sessionRid: RoutingId, actor: ZLinkBackendActorRef, timeoutMs: number, signal?: AbortSignal): Promise<void>;
|
|
367
364
|
unbindActor(sessionRid: RoutingId, actorId: string, timeoutMs: number, signal?: AbortSignal): Promise<void>;
|
|
@@ -40,6 +40,8 @@ export declare function submitBindingReply(operation: ZLinkBindingReplyOperation
|
|
|
40
40
|
export declare function submitBindingAsyncSend(operation: ZLinkBindingAsyncSendOperation, payload: unknown): Promise<void>;
|
|
41
41
|
export declare function submitBindingSyncSend(operation: ZLinkBindingAsyncSendOperation, payload: unknown): void;
|
|
42
42
|
export declare function submitBindingRequest(operation: ZLinkBindingRequestOperation, payload: unknown, timeoutMs: number | undefined): Promise<readonly unknown[]>;
|
|
43
|
+
export declare function bindingRequestReply(submission: import('@zlink-systems/zlink').RequestSubmission, deadlineMs: number | undefined): Promise<import('@zlink-systems/zlink').Message[]>;
|
|
44
|
+
export declare function closeBindingReply(replies: readonly import('@zlink-systems/zlink').Message[]): void;
|
|
43
45
|
/**
|
|
44
46
|
* Closes a binding handle once. An already closed or terminated handle counts as
|
|
45
47
|
* closed. A busy close propagates to the caller.
|
|
@@ -8,6 +8,8 @@ exports.submitBindingReply = submitBindingReply;
|
|
|
8
8
|
exports.submitBindingAsyncSend = submitBindingAsyncSend;
|
|
9
9
|
exports.submitBindingSyncSend = submitBindingSyncSend;
|
|
10
10
|
exports.submitBindingRequest = submitBindingRequest;
|
|
11
|
+
exports.bindingRequestReply = bindingRequestReply;
|
|
12
|
+
exports.closeBindingReply = closeBindingReply;
|
|
11
13
|
exports.closeBindingHandle = closeBindingHandle;
|
|
12
14
|
exports.isContextTerminatedError = isContextTerminatedError;
|
|
13
15
|
exports.disableSocketLinger = disableSocketLinger;
|
|
@@ -15,6 +17,7 @@ exports.toNativeRoutingId = toNativeRoutingId;
|
|
|
15
17
|
exports.translateBindingResultError = translateBindingResultError;
|
|
16
18
|
exports.toNativeActorRef = toNativeActorRef;
|
|
17
19
|
const node_os_1 = require("node:os");
|
|
20
|
+
const request_deadline_1 = require("../../messaging/request-deadline");
|
|
18
21
|
const submission_result_1 = require("../../messaging/submission-result");
|
|
19
22
|
const node_backend_adapter_1 = require("../node-backend-adapter");
|
|
20
23
|
const runtime_values_1 = require("../runtime-values");
|
|
@@ -53,7 +56,7 @@ function submitBindingPublish(operation, payload) {
|
|
|
53
56
|
translated.operation === 'submit' &&
|
|
54
57
|
(translated.result === runtime_values_1.SubmitResult.Backpressured ||
|
|
55
58
|
translated.result === runtime_values_1.SubmitResult.NotAdmitted)) {
|
|
56
|
-
(0, submission_result_1.
|
|
59
|
+
(0, submission_result_1.requireClassicFanoutCompletion)({ status: submission_result_1.ZLinkSubmitStatus.Backpressured }, 'Classic fanout publish');
|
|
57
60
|
}
|
|
58
61
|
throw translated;
|
|
59
62
|
}
|
|
@@ -73,6 +76,7 @@ function submitBindingReply(operation, payload) {
|
|
|
73
76
|
}
|
|
74
77
|
}
|
|
75
78
|
async function submitBindingAsyncSend(operation, payload) {
|
|
79
|
+
let submission;
|
|
76
80
|
try {
|
|
77
81
|
let current;
|
|
78
82
|
const parts = Array.isArray(payload) ? payload : [payload];
|
|
@@ -81,10 +85,18 @@ async function submitBindingAsyncSend(operation, payload) {
|
|
|
81
85
|
current = current === undefined ? operation.message(nativePart) : current.message(nativePart);
|
|
82
86
|
}
|
|
83
87
|
current ??= operation.message(Buffer.alloc(0));
|
|
84
|
-
|
|
88
|
+
submission = current.submit();
|
|
85
89
|
}
|
|
86
90
|
catch (error) {
|
|
87
|
-
throw translateBindingResultError(error);
|
|
91
|
+
throw translateBindingResultError(error, 'submit');
|
|
92
|
+
}
|
|
93
|
+
if (submission.result === runtime_values_1.SubmitResult.Backpressured) {
|
|
94
|
+
try {
|
|
95
|
+
await submission.admitted;
|
|
96
|
+
}
|
|
97
|
+
catch (error) {
|
|
98
|
+
throw translateBindingResultError(error, 'completion');
|
|
99
|
+
}
|
|
88
100
|
}
|
|
89
101
|
}
|
|
90
102
|
function submitBindingSyncSend(operation, payload) {
|
|
@@ -103,6 +115,7 @@ function submitBindingSyncSend(operation, payload) {
|
|
|
103
115
|
}
|
|
104
116
|
}
|
|
105
117
|
async function submitBindingRequest(operation, payload, timeoutMs) {
|
|
118
|
+
const deadlineMs = timeoutMs === undefined ? undefined : performance.now() + timeoutMs;
|
|
106
119
|
try {
|
|
107
120
|
let current;
|
|
108
121
|
if (Array.isArray(payload)) {
|
|
@@ -119,12 +132,30 @@ async function submitBindingRequest(operation, payload, timeoutMs) {
|
|
|
119
132
|
if (timeoutMs !== undefined) {
|
|
120
133
|
current = current.timeout(timeoutMs);
|
|
121
134
|
}
|
|
122
|
-
return await current.submit()
|
|
135
|
+
return await bindingRequestReply(current.submit(), deadlineMs);
|
|
123
136
|
}
|
|
124
137
|
catch (error) {
|
|
125
138
|
throw translateBindingResultError(error);
|
|
126
139
|
}
|
|
127
140
|
}
|
|
141
|
+
async function bindingRequestReply(submission, deadlineMs) {
|
|
142
|
+
const reply = submission.reply;
|
|
143
|
+
if (submission.result === runtime_values_1.SubmitResult.Backpressured) {
|
|
144
|
+
try {
|
|
145
|
+
const [, replies] = await (0, request_deadline_1.waitRequestReply)(Promise.all([submission.admitted, reply]), 'Request', deadlineMs);
|
|
146
|
+
return replies;
|
|
147
|
+
}
|
|
148
|
+
catch (error) {
|
|
149
|
+
void reply.then(closeBindingReply, () => undefined);
|
|
150
|
+
throw error;
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
return reply;
|
|
154
|
+
}
|
|
155
|
+
function closeBindingReply(replies) {
|
|
156
|
+
for (const reply of replies)
|
|
157
|
+
reply.close();
|
|
158
|
+
}
|
|
128
159
|
/**
|
|
129
160
|
* Closes a binding handle once. An already closed or terminated handle counts as
|
|
130
161
|
* closed. A busy close propagates to the caller.
|
|
@@ -6,7 +6,7 @@ export declare class ZLinkDealerChannelClientTransport implements ZLinkChannelCl
|
|
|
6
6
|
private readonly dealer;
|
|
7
7
|
private readonly publisher?;
|
|
8
8
|
constructor(dealer: DealerSocket, publisher?: PubSocket | undefined);
|
|
9
|
-
send(channelName: string, packetName: string | undefined, message: Message,
|
|
9
|
+
send(channelName: string, packetName: string | undefined, message: Message, metadata?: ReadonlyMap<string, string>): Promise<ZLinkSubmitResult>;
|
|
10
10
|
request<TReply>(channelName: string, packetName: string | undefined, request: Message, timeoutMs: number | undefined, signal?: AbortSignal, metadata?: ReadonlyMap<string, string>): Promise<TReply>;
|
|
11
11
|
tryPublish(channelName: string, topic: string, packetName: string | undefined, event: Message, metadata?: ReadonlyMap<string, string>): ZLinkSubmitResult;
|
|
12
12
|
publish(channelName: string, topic: string, packetName: string | undefined, event: Message, signal?: AbortSignal, metadata?: ReadonlyMap<string, string>): Promise<ZLinkSubmitResult>;
|
|
@@ -16,8 +16,7 @@ class ZLinkDealerChannelClientTransport {
|
|
|
16
16
|
this.dealer = dealer;
|
|
17
17
|
this.publisher = publisher;
|
|
18
18
|
}
|
|
19
|
-
async send(channelName, packetName, message,
|
|
20
|
-
(0, abort_1.throwIfAborted)(signal);
|
|
19
|
+
async send(channelName, packetName, message, metadata = EMPTY_METADATA) {
|
|
21
20
|
// Call-scoped flow (spec 27 §4): the envelope flow pair does not outlive
|
|
22
21
|
// this outbound call.
|
|
23
22
|
await (0, flow_context_1.runWithOutboundFlow)(true, () => (0, channel_multipart_1.appendParts)(this.dealer.send(), (0, channel_envelope_1.encodeChannelEnvelopeParts)(3 /* ZLinkChannelMessageKind.Command */, channelName, packetName, message, undefined, undefined, undefined, undefined, true, metadata)).submit().admitted);
|
|
@@ -204,15 +204,14 @@ class NodeRawRouterPort extends NodeRawSocketPort {
|
|
|
204
204
|
this.socket.options.setConnectRoutingId(bindingRoutingId(routingId));
|
|
205
205
|
this.connect(endpoint);
|
|
206
206
|
}
|
|
207
|
-
|
|
207
|
+
send(targetRid, parts) {
|
|
208
208
|
this.requireOpen();
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
await submission.admitted;
|
|
212
|
-
}
|
|
209
|
+
requireParts(parts);
|
|
210
|
+
return (0, node_backend_adapter_support_1.submitBindingAsyncSend)(this.socket.send(bindingRoutingId(targetRid)), parts);
|
|
213
211
|
}
|
|
214
212
|
async request(targetRid, parts, timeoutMs) {
|
|
215
213
|
this.requireOpen();
|
|
214
|
+
const deadlineMs = performance.now() + timeoutMs;
|
|
216
215
|
let submission;
|
|
217
216
|
try {
|
|
218
217
|
submission = appendRequestParts(this.socket.request(bindingRoutingId(targetRid)), parts)
|
|
@@ -223,7 +222,7 @@ class NodeRawRouterPort extends NodeRawSocketPort {
|
|
|
223
222
|
throw (0, node_backend_adapter_support_1.translateBindingResultError)(error, 'submit');
|
|
224
223
|
}
|
|
225
224
|
try {
|
|
226
|
-
const replies = await
|
|
225
|
+
const replies = await (0, node_backend_adapter_support_1.bindingRequestReply)(submission, deadlineMs);
|
|
227
226
|
return copyAndClose(replies);
|
|
228
227
|
}
|
|
229
228
|
catch (error) {
|
|
@@ -257,15 +256,14 @@ class NodeRawDealerPort extends NodeRawSocketPort {
|
|
|
257
256
|
this.requireOpen();
|
|
258
257
|
this.socket.setRoutingId(bindingRoutingId(routingId));
|
|
259
258
|
}
|
|
260
|
-
|
|
259
|
+
send(parts) {
|
|
261
260
|
this.requireOpen();
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
await submission.admitted;
|
|
265
|
-
}
|
|
261
|
+
requireParts(parts);
|
|
262
|
+
return (0, node_backend_adapter_support_1.submitBindingAsyncSend)(this.socket.send(), parts);
|
|
266
263
|
}
|
|
267
264
|
async request(parts, timeoutMs) {
|
|
268
265
|
this.requireOpen();
|
|
266
|
+
const deadlineMs = performance.now() + timeoutMs;
|
|
269
267
|
let submission;
|
|
270
268
|
try {
|
|
271
269
|
submission = appendRequestParts(this.socket.request(), parts).timeout(timeoutMs).submit();
|
|
@@ -274,7 +272,7 @@ class NodeRawDealerPort extends NodeRawSocketPort {
|
|
|
274
272
|
throw (0, node_backend_adapter_support_1.translateBindingResultError)(error, 'submit');
|
|
275
273
|
}
|
|
276
274
|
try {
|
|
277
|
-
const replies = await
|
|
275
|
+
const replies = await (0, node_backend_adapter_support_1.bindingRequestReply)(submission, deadlineMs);
|
|
278
276
|
return copyAndClose(replies);
|
|
279
277
|
}
|
|
280
278
|
catch (error) {
|
|
@@ -286,13 +284,6 @@ class NodeRawDealerPort extends NodeRawSocketPort {
|
|
|
286
284
|
return receiveRecord(this.socket, dontWait);
|
|
287
285
|
}
|
|
288
286
|
}
|
|
289
|
-
async function requestReply(submission) {
|
|
290
|
-
if (submission.result === zlink_1.SubmitResult.Backpressured) {
|
|
291
|
-
const [, replies] = await Promise.all([submission.admitted, submission.reply]);
|
|
292
|
-
return replies;
|
|
293
|
-
}
|
|
294
|
-
return submission.reply;
|
|
295
|
-
}
|
|
296
287
|
class NodeRawMonitorPort {
|
|
297
288
|
monitor;
|
|
298
289
|
release;
|
|
@@ -326,14 +317,6 @@ class NodeRawMonitorPort {
|
|
|
326
317
|
this.release();
|
|
327
318
|
}
|
|
328
319
|
}
|
|
329
|
-
function appendSendParts(operation, parts) {
|
|
330
|
-
requireParts(parts);
|
|
331
|
-
let next = operation.message(parts[0]);
|
|
332
|
-
for (let index = 1; index < parts.length; index += 1) {
|
|
333
|
-
next = next.message(parts[index]);
|
|
334
|
-
}
|
|
335
|
-
return next;
|
|
336
|
-
}
|
|
337
320
|
function appendRequestParts(operation, parts) {
|
|
338
321
|
requireParts(parts);
|
|
339
322
|
let next = operation.message(parts[0]);
|
|
@@ -132,7 +132,7 @@ function wrapSocket(nativeInstance, pollCompletion) {
|
|
|
132
132
|
}
|
|
133
133
|
return (0, node_backend_adapter_support_1.submitBindingAsyncSend)(operation, payload);
|
|
134
134
|
},
|
|
135
|
-
submit(routingId, payload
|
|
135
|
+
submit(routingId, payload) {
|
|
136
136
|
if (!hasStream)
|
|
137
137
|
throw new TypeError('Async stream send requires a STREAM socket.');
|
|
138
138
|
return (0, node_backend_adapter_support_1.submitBindingAsyncSend)(nativeInstance.send((0, node_backend_adapter_support_1.toNativeRoutingId)(routingId)), payload);
|
|
@@ -86,18 +86,18 @@ class DefaultZLinkRouteClient {
|
|
|
86
86
|
this.channelTransport = channelTransport;
|
|
87
87
|
}
|
|
88
88
|
sendToNode(meshName, targetNodeRid, message) {
|
|
89
|
-
return new DefaultZLinkSendCall(() => this.requireMesh(meshName), async (packetName, metadata
|
|
89
|
+
return new DefaultZLinkSendCall(() => this.requireMesh(meshName), async (packetName, metadata) => normalizeSubmitResult(await this.requireTransport().submit(meshName, targetNodeRid, packetName, message, metadata)));
|
|
90
90
|
}
|
|
91
91
|
requestToNode(meshName, targetNodeRid, request) {
|
|
92
92
|
return new DefaultZLinkRequestCall(() => this.requireMesh(meshName), (packetName, timeoutMs, metadata, signal) => this.requireTransport().request(meshName, targetNodeRid, packetName, request, timeoutMs, signal, metadata), this.defaultRequestTimeout(meshName));
|
|
93
93
|
}
|
|
94
94
|
sendToChannel(channelName, message) {
|
|
95
|
-
return new DefaultZLinkSendCall(() => this.requireChannelRoute(channelName), async (packetName, metadata
|
|
95
|
+
return new DefaultZLinkSendCall(() => this.requireChannelRoute(channelName), async (packetName, metadata) => {
|
|
96
96
|
const route = this.requireChannelRoute(channelName);
|
|
97
97
|
if (route.kind === 'route-mesh') {
|
|
98
|
-
return normalizeSubmitResult(await this.requireTransport().submitToChannel(route.meshName, channelName, packetName, message,
|
|
98
|
+
return normalizeSubmitResult(await this.requireTransport().submitToChannel(route.meshName, channelName, packetName, message, metadata));
|
|
99
99
|
}
|
|
100
|
-
return normalizeSubmitResult(await this.requireChannelTransport().send(channelName, packetName, message,
|
|
100
|
+
return normalizeSubmitResult(await this.requireChannelTransport().send(channelName, packetName, message, metadata));
|
|
101
101
|
});
|
|
102
102
|
}
|
|
103
103
|
requestToChannel(channelName, request) {
|
|
@@ -112,9 +112,8 @@ class DefaultZLinkRouteClient {
|
|
|
112
112
|
sendToSpot(spot, message) {
|
|
113
113
|
return new DefaultZLinkSendCall(() => {
|
|
114
114
|
this.requireSpotTransport();
|
|
115
|
-
}, async (_packetName, metadata
|
|
115
|
+
}, async (_packetName, metadata) => {
|
|
116
116
|
await (0, spot_outbound_1.sendToSpotHandle)(this.requireSpotTransport(), spot, message, {
|
|
117
|
-
signal,
|
|
118
117
|
metadata,
|
|
119
118
|
spotRouterChannelIdForMesh: this.spotRouterChannelIdForMesh
|
|
120
119
|
});
|
|
@@ -236,12 +235,11 @@ class DefaultZLinkSendCall {
|
|
|
236
235
|
}
|
|
237
236
|
return this;
|
|
238
237
|
}
|
|
239
|
-
async submit(
|
|
238
|
+
async submit() {
|
|
240
239
|
ensureNotExecuted(this.executed);
|
|
241
240
|
this.validate();
|
|
242
241
|
this.executed = true;
|
|
243
|
-
(
|
|
244
|
-
const result = await this.submitter(undefined, new Map(this.selectedMetadata), signal);
|
|
242
|
+
const result = await this.submitter(undefined, new Map(this.selectedMetadata));
|
|
245
243
|
(0, submission_result_1.requireOneWayCompletion)(result, 'One-way send');
|
|
246
244
|
}
|
|
247
245
|
}
|
|
@@ -337,6 +335,6 @@ class DefaultZLinkFanoutPublishCall {
|
|
|
337
335
|
this.executed = true;
|
|
338
336
|
(0, abort_1.throwIfAborted)(signal);
|
|
339
337
|
const result = await this.submitter(signal);
|
|
340
|
-
(0, submission_result_1.
|
|
338
|
+
(0, submission_result_1.requireClassicFanoutCompletion)(result, 'Classic fanout publish');
|
|
341
339
|
}
|
|
342
340
|
}
|
|
@@ -43,7 +43,7 @@ export declare function encodeChannelEnvelopeParts(kind: ZLinkChannelMessageKind
|
|
|
43
43
|
* entry point for operations that must not extend their original deadline
|
|
44
44
|
* while the message is being serialized.
|
|
45
45
|
*/
|
|
46
|
-
export declare function encodeChannelEnvelopePartsAtDeadline(kind: ZLinkChannelMessageKind, channelName: string, packetName: string | undefined, payload: unknown, deadlineUnixMs: number, topic?: string, codecs?: ZLinkChannelEnvelopeCodecRegistry, correlationId?: string, createFlow?: boolean, metadata?: ReadonlyMap<string, string>): readonly MessageLike[];
|
|
46
|
+
export declare function encodeChannelEnvelopePartsAtDeadline(kind: ZLinkChannelMessageKind, channelName: string, packetName: string | undefined, payload: unknown, deadlineUnixMs: number | undefined, topic?: string, codecs?: ZLinkChannelEnvelopeCodecRegistry, correlationId?: string, createFlow?: boolean, metadata?: ReadonlyMap<string, string>): readonly MessageLike[];
|
|
47
47
|
export declare function encodeChannelPublishEnvelopeParts(channelName: string, topic: string, packetName: string | undefined, payload: unknown, codecs?: ZLinkChannelEnvelopeCodecRegistry, createFlow?: boolean, metadata?: ReadonlyMap<string, string>): readonly MessageLike[];
|
|
48
48
|
export declare function encodeChannelReplyParts(request: ZLinkChannelEnvelopeHeader, payload: unknown, codecs?: ZLinkChannelEnvelopeCodecRegistry): readonly MessageLike[];
|
|
49
49
|
/**
|
|
@@ -38,14 +38,7 @@ function newChannelCorrelationId() {
|
|
|
38
38
|
return (0, node_crypto_1.randomUUID)().replaceAll('-', '');
|
|
39
39
|
}
|
|
40
40
|
function encodeChannelEnvelopeParts(kind, channelName, packetName, payload, timeoutMs, topic, codecs, correlationId, createFlow = true, metadata = EMPTY_OUTBOUND_METADATA) {
|
|
41
|
-
|
|
42
|
-
const encoded = encodePayload(payload, (0, channel_framework_packets_1.codecsForFrameworkPacket)(messageName, codecs), messageName, 'payload');
|
|
43
|
-
const flow = createFlow ? (0, flow_context_1.currentOrCreateFlow)('Application') : undefined;
|
|
44
|
-
const envelopeCorrelationId = correlationIdForOutboundKind(kind, correlationId);
|
|
45
|
-
return [
|
|
46
|
-
encodeChannelHeader(kind, channelName, messageName, encoded.contentType, envelopeCorrelationId, timeoutMs === undefined ? null : new Date(Date.now() + timeoutMs).toISOString(), topic ?? null, null, null, undefined, applicationMetadataRecord(metadata), flow?.flowId, flow?.flowOrigin),
|
|
47
|
-
encoded.message
|
|
48
|
-
];
|
|
41
|
+
return encodeChannelEnvelopePartsAtDeadline(kind, channelName, packetName, payload, timeoutMs === undefined ? undefined : Date.now() + timeoutMs, topic, codecs, correlationId, createFlow, metadata);
|
|
49
42
|
}
|
|
50
43
|
/**
|
|
51
44
|
* Encodes an outbound channel envelope with a deadline that was established
|
|
@@ -54,7 +47,8 @@ function encodeChannelEnvelopeParts(kind, channelName, packetName, payload, time
|
|
|
54
47
|
* while the message is being serialized.
|
|
55
48
|
*/
|
|
56
49
|
function encodeChannelEnvelopePartsAtDeadline(kind, channelName, packetName, payload, deadlineUnixMs, topic, codecs, correlationId, createFlow = true, metadata = EMPTY_OUTBOUND_METADATA) {
|
|
57
|
-
if (
|
|
50
|
+
if (deadlineUnixMs !== undefined &&
|
|
51
|
+
(!Number.isSafeInteger(deadlineUnixMs) || deadlineUnixMs <= 0)) {
|
|
58
52
|
throw new RangeError('deadlineUnixMs must be a positive safe integer.');
|
|
59
53
|
}
|
|
60
54
|
const messageName = (0, packet_name_1.resolveFrameworkPacketName)(payload, packetName, 'Channel');
|
|
@@ -62,7 +56,7 @@ function encodeChannelEnvelopePartsAtDeadline(kind, channelName, packetName, pay
|
|
|
62
56
|
const flow = createFlow ? (0, flow_context_1.currentOrCreateFlow)('Application') : undefined;
|
|
63
57
|
const envelopeCorrelationId = correlationIdForOutboundKind(kind, correlationId);
|
|
64
58
|
return [
|
|
65
|
-
encodeChannelHeader(kind, channelName, messageName, encoded.contentType, envelopeCorrelationId, new Date(deadlineUnixMs).toISOString(), topic ?? null, null, null, undefined, applicationMetadataRecord(metadata), flow?.flowId, flow?.flowOrigin),
|
|
59
|
+
encodeChannelHeader(kind, channelName, messageName, encoded.contentType, envelopeCorrelationId, deadlineUnixMs === undefined ? null : new Date(deadlineUnixMs).toISOString(), topic ?? null, null, null, undefined, applicationMetadataRecord(metadata), flow?.flowId, flow?.flowOrigin),
|
|
66
60
|
encoded.message
|
|
67
61
|
];
|
|
68
62
|
}
|
|
@@ -10,7 +10,7 @@ export declare class ZLinkChannelOutboundOperations {
|
|
|
10
10
|
private readonly pendingRequests;
|
|
11
11
|
constructor(sockets: ZLinkChannelSocketRegistry, codecs: ZLinkChannelEnvelopeCodecRegistry, dispatchServices: ZLinkChannelDispatchServices);
|
|
12
12
|
pendingRequestCount(channelName: string): number;
|
|
13
|
-
send(channelName: string, packetName: string | undefined, message: unknown,
|
|
13
|
+
send(channelName: string, packetName: string | undefined, message: unknown, metadata?: ReadonlyMap<string, string>): Promise<ZLinkSubmitResult>;
|
|
14
14
|
private sendScoped;
|
|
15
15
|
private traceSend;
|
|
16
16
|
request<TReply>(channelName: string, packetName: string | undefined, request: unknown, timeoutMs: number | undefined, signal?: AbortSignal, metadata?: ReadonlyMap<string, string>): Promise<TReply>;
|
|
@@ -19,7 +19,7 @@ export declare class ZLinkChannelOutboundOperations {
|
|
|
19
19
|
private tryPublishScoped;
|
|
20
20
|
publish(channelName: string, topic: string, packetName: string | undefined, event: unknown, signal?: AbortSignal, metadata?: ReadonlyMap<string, string>): Promise<ZLinkSubmitResult>;
|
|
21
21
|
private publishScoped;
|
|
22
|
-
routeSubmit(routerChannelId: string, targetNodeRid: string, packetName: string | undefined, message: unknown,
|
|
22
|
+
routeSubmit(routerChannelId: string, targetNodeRid: string, packetName: string | undefined, message: unknown, metadata?: ReadonlyMap<string, string>): Promise<ZLinkSubmitResult>;
|
|
23
23
|
private routeSubmitScoped;
|
|
24
24
|
private traceRouteSend;
|
|
25
25
|
routeRequest<TReply>(routerChannelId: string, targetNodeRid: string, packetName: string | undefined, request: unknown, timeoutMs: number | undefined, signal?: AbortSignal, metadata?: ReadonlyMap<string, string>): Promise<TReply>;
|