@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
|
@@ -306,21 +306,18 @@ class DefaultZLinkSessionActor {
|
|
|
306
306
|
}
|
|
307
307
|
this.currentRef = ref;
|
|
308
308
|
}
|
|
309
|
-
async relay(dispatchOrPayload,
|
|
309
|
+
async relay(dispatchOrPayload, selectedPayload) {
|
|
310
310
|
const dispatch = isSessionDispatchContext(dispatchOrPayload) ? dispatchOrPayload : undefined;
|
|
311
311
|
let payload;
|
|
312
|
-
let relaySignal;
|
|
313
312
|
let header;
|
|
314
313
|
if (dispatch === undefined) {
|
|
315
314
|
payload = dispatchOrPayload;
|
|
316
|
-
relaySignal = payloadOrSignal;
|
|
317
315
|
}
|
|
318
316
|
else {
|
|
319
|
-
payload =
|
|
320
|
-
relaySignal = signal;
|
|
317
|
+
payload = selectedPayload;
|
|
321
318
|
header = sessionDispatchHeader(dispatch);
|
|
322
319
|
}
|
|
323
|
-
const result = await this.runtime.relay(this, payload,
|
|
320
|
+
const result = await this.runtime.relay(this, payload, header);
|
|
324
321
|
(0, submission_result_1.requireOneWayCompletion)(result, 'Session Actor relay', framework_errors_internal_1.ZLinkFrameworkInternalErrorKind.ActorSessionNotBound);
|
|
325
322
|
}
|
|
326
323
|
notifyDisconnected(signal) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zlink-systems/framework",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.28.0",
|
|
4
4
|
"license": "SEE LICENSE IN LICENSE",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
"dependencies": {
|
|
20
20
|
"@opentelemetry/api": "^1.9.1",
|
|
21
21
|
"@opentelemetry/api-logs": "^0.221.0",
|
|
22
|
-
"@zlink-systems/stream-wire": "0.
|
|
23
|
-
"@zlink-systems/zlink": "1.
|
|
22
|
+
"@zlink-systems/stream-wire": "0.28.0",
|
|
23
|
+
"@zlink-systems/zlink": "1.15.0"
|
|
24
24
|
}
|
|
25
25
|
}
|
|
@@ -3,7 +3,7 @@ import type { ZLinkMessageMetadata } from '../Common';
|
|
|
3
3
|
export interface ZLinkSendCall {
|
|
4
4
|
metadata(key: string, value: string): this;
|
|
5
5
|
metadata(metadata: ZLinkMessageMetadata): this;
|
|
6
|
-
submit(
|
|
6
|
+
submit(): Promise<void>;
|
|
7
7
|
}
|
|
8
8
|
|
|
9
9
|
export interface ZLinkRequestCall {
|
|
@@ -1586,7 +1586,6 @@ interface MutableServerCapabilityOptions {
|
|
|
1586
1586
|
weight?: number;
|
|
1587
1587
|
sendHighWaterMark?: number;
|
|
1588
1588
|
receiveHighWaterMark?: number;
|
|
1589
|
-
sendTimeoutMs?: number;
|
|
1590
1589
|
maxMessageSize?: number;
|
|
1591
1590
|
}
|
|
1592
1591
|
|
|
@@ -1594,7 +1593,6 @@ interface MutableClientCapabilityOptions {
|
|
|
1594
1593
|
manualConnections?: string[];
|
|
1595
1594
|
sendHighWaterMark?: number;
|
|
1596
1595
|
receiveHighWaterMark?: number;
|
|
1597
|
-
sendTimeoutMs?: number;
|
|
1598
1596
|
maxMessageSize?: number;
|
|
1599
1597
|
}
|
|
1600
1598
|
|
|
@@ -1690,7 +1688,6 @@ interface MutableSpotRouterCapabilityOptions {
|
|
|
1690
1688
|
sendHighWaterMark?: number;
|
|
1691
1689
|
receiveHighWaterMark?: number;
|
|
1692
1690
|
receiveTimeoutMs?: number;
|
|
1693
|
-
sendTimeoutMs?: number;
|
|
1694
1691
|
}
|
|
1695
1692
|
|
|
1696
1693
|
interface MutableSpotPubSubCapabilityOptions {
|
|
@@ -183,7 +183,6 @@ export interface ZLinkChannelOptions {
|
|
|
183
183
|
readonly weight?: number;
|
|
184
184
|
readonly sendHighWaterMark?: number;
|
|
185
185
|
readonly receiveHighWaterMark?: number;
|
|
186
|
-
readonly sendTimeoutMs?: number;
|
|
187
186
|
readonly maxMessageSize?: number;
|
|
188
187
|
};
|
|
189
188
|
readonly subscriber?: ZLinkClientCapabilityOptions;
|
|
@@ -193,7 +192,6 @@ export interface ZLinkClientCapabilityOptions {
|
|
|
193
192
|
readonly manualConnections?: readonly string[];
|
|
194
193
|
readonly sendHighWaterMark?: number;
|
|
195
194
|
readonly receiveHighWaterMark?: number;
|
|
196
|
-
readonly sendTimeoutMs?: number;
|
|
197
195
|
readonly maxMessageSize?: number;
|
|
198
196
|
}
|
|
199
197
|
|
|
@@ -214,7 +212,6 @@ export interface ZLinkRouteMeshChannelOptions {
|
|
|
214
212
|
readonly weight?: number;
|
|
215
213
|
readonly sendHighWaterMark?: number;
|
|
216
214
|
readonly receiveHighWaterMark?: number;
|
|
217
|
-
readonly sendTimeoutMs?: number;
|
|
218
215
|
readonly sendHandlers?: readonly ZLinkRouteChannelSendHandlerRegistration[];
|
|
219
216
|
readonly requestHandlers?: readonly ZLinkRouteChannelRequestHandlerRegistration[];
|
|
220
217
|
readonly handlers?: readonly ZLinkRouteChannelHandlerOptions[];
|
|
@@ -230,7 +227,6 @@ export interface ZLinkRouteChannelOptions {
|
|
|
230
227
|
readonly weight?: number;
|
|
231
228
|
readonly sendHighWaterMark?: number;
|
|
232
229
|
readonly receiveHighWaterMark?: number;
|
|
233
|
-
readonly sendTimeoutMs?: number;
|
|
234
230
|
readonly sendHandlers?: readonly ZLinkRouteChannelSendHandlerRegistration[];
|
|
235
231
|
readonly requestHandlers?: readonly ZLinkRouteChannelRequestHandlerRegistration[];
|
|
236
232
|
readonly handlers?: readonly ZLinkRouteChannelHandlerOptions[];
|
|
@@ -430,7 +426,6 @@ export interface ZLinkSpotRouterCapabilityOptions {
|
|
|
430
426
|
readonly sendHighWaterMark?: number;
|
|
431
427
|
readonly receiveHighWaterMark?: number;
|
|
432
428
|
readonly receiveTimeoutMs?: number;
|
|
433
|
-
readonly sendTimeoutMs?: number;
|
|
434
429
|
}
|
|
435
430
|
|
|
436
431
|
export interface ZLinkSpotRouterPeerConnectionOptions {
|
|
@@ -730,14 +730,12 @@ function requireSocketOptions(
|
|
|
730
730
|
options: {
|
|
731
731
|
readonly sendHighWaterMark?: number;
|
|
732
732
|
readonly receiveHighWaterMark?: number;
|
|
733
|
-
readonly sendTimeoutMs?: number;
|
|
734
733
|
readonly maxMessageSize?: number;
|
|
735
734
|
}
|
|
736
735
|
): void {
|
|
737
736
|
requireNonNegativeInteger(`${label} sendHighWaterMark`, options.sendHighWaterMark);
|
|
738
737
|
requireNonNegativeInteger(`${label} receiveHighWaterMark`, options.receiveHighWaterMark);
|
|
739
738
|
requireNonNegativeInteger(`${label} maxMessageSize`, options.maxMessageSize);
|
|
740
|
-
requireValidSendTimeoutMs(`${label} sendTimeoutMs`, options.sendTimeoutMs);
|
|
741
739
|
}
|
|
742
740
|
|
|
743
741
|
function requireRouteMeshSocketOptions(
|
|
@@ -745,10 +743,8 @@ function requireRouteMeshSocketOptions(
|
|
|
745
743
|
options: {
|
|
746
744
|
readonly sendHighWaterMark?: number;
|
|
747
745
|
readonly receiveHighWaterMark?: number;
|
|
748
|
-
readonly sendTimeoutMs?: number;
|
|
749
746
|
}
|
|
750
747
|
): void {
|
|
751
748
|
requireNonNegativeInteger(`${label} sendHighWaterMark`, options.sendHighWaterMark);
|
|
752
749
|
requireNonNegativeInteger(`${label} receiveHighWaterMark`, options.receiveHighWaterMark);
|
|
753
|
-
requireValidSendTimeoutMs(`${label} sendTimeoutMs`, options.sendTimeoutMs);
|
|
754
750
|
}
|
|
@@ -96,7 +96,7 @@ export interface ZLinkSpotSendCall {
|
|
|
96
96
|
instanceSpot(): this;
|
|
97
97
|
instanceSpot(instanceSpotType: string): this;
|
|
98
98
|
inMesh(meshName: string): this;
|
|
99
|
-
submit(
|
|
99
|
+
submit(): Promise<void>;
|
|
100
100
|
}
|
|
101
101
|
|
|
102
102
|
export interface ZLinkSpotRequestCall {
|
|
@@ -42,11 +42,10 @@ export interface ZLinkSessionClient {
|
|
|
42
42
|
export interface ZLinkSessionSendCall {
|
|
43
43
|
metadata(key: string, value: string): this;
|
|
44
44
|
compress(enabled?: boolean): this;
|
|
45
|
-
|
|
46
|
-
submit(signal?: AbortSignal): Promise<void>;
|
|
45
|
+
submit(): Promise<void>;
|
|
47
46
|
}
|
|
48
47
|
|
|
49
48
|
export interface ZLinkSessionReplyCall {
|
|
50
49
|
compress(enabled?: boolean): this;
|
|
51
|
-
submit(
|
|
50
|
+
submit(): Promise<void>;
|
|
52
51
|
}
|
|
@@ -11,11 +11,7 @@ export interface ZLinkSessionActors {
|
|
|
11
11
|
export interface ZLinkSessionActor {
|
|
12
12
|
readonly actorId: string;
|
|
13
13
|
readonly ref: ActorRef;
|
|
14
|
-
relay(payload: ZLinkMessage
|
|
15
|
-
relay(
|
|
16
|
-
dispatch: ZLinkSessionDispatchContext,
|
|
17
|
-
payload: ZLinkMessage,
|
|
18
|
-
signal?: AbortSignal
|
|
19
|
-
): Promise<void>;
|
|
14
|
+
relay(payload: ZLinkMessage): Promise<void>;
|
|
15
|
+
relay(dispatch: ZLinkSessionDispatchContext, payload: ZLinkMessage): Promise<void>;
|
|
20
16
|
notifyDisconnected(signal?: AbortSignal): Promise<void>;
|
|
21
17
|
}
|
|
@@ -13,7 +13,7 @@ import {
|
|
|
13
13
|
|
|
14
14
|
import { ZLINK_MAX_ACTOR_ID_BYTES } from '../../contracts/Common/CoreTypes';
|
|
15
15
|
import type { Message } from '../../contracts/Common/Message';
|
|
16
|
-
import {
|
|
16
|
+
import { throwIfAborted } from '../abort';
|
|
17
17
|
import {
|
|
18
18
|
type ZLinkBackendActorRef,
|
|
19
19
|
type ZLinkBackendMeshNode,
|
|
@@ -110,7 +110,7 @@ export class DefaultZLinkActorClient implements ZLinkActorClient {
|
|
|
110
110
|
sendToActor(actorId: string, message: unknown): ZLinkActorSendCall {
|
|
111
111
|
requireActorId(actorId);
|
|
112
112
|
return new DefaultZLinkActorSendCall(
|
|
113
|
-
(packetName, metadata
|
|
113
|
+
(packetName, metadata) => this.send(actorId, packetName, message, metadata),
|
|
114
114
|
message
|
|
115
115
|
);
|
|
116
116
|
}
|
|
@@ -132,11 +132,9 @@ export class DefaultZLinkActorClient implements ZLinkActorClient {
|
|
|
132
132
|
actorId: string,
|
|
133
133
|
explicitPacketName: string | undefined,
|
|
134
134
|
message: unknown,
|
|
135
|
-
metadata: ReadonlyMap<string, string
|
|
136
|
-
signal?: AbortSignal
|
|
135
|
+
metadata: ReadonlyMap<string, string>
|
|
137
136
|
): Promise<ZLinkSubmitResult> {
|
|
138
|
-
|
|
139
|
-
const route = await this.resolveActorRoute(actorId, signal);
|
|
137
|
+
const route = await this.resolveActorRoute(actorId);
|
|
140
138
|
const { meshName, actorRef: actor } = route;
|
|
141
139
|
this.throwIfKnownStale(meshName, actor);
|
|
142
140
|
const parts = this.createPacketParts(
|
|
@@ -150,9 +148,7 @@ export class DefaultZLinkActorClient implements ZLinkActorClient {
|
|
|
150
148
|
const routedActor = attachActorMessageFollowContext(actor, messageFollow);
|
|
151
149
|
try {
|
|
152
150
|
const submissionCopies =
|
|
153
|
-
(await this.options
|
|
154
|
-
.transportDeliveryGate?.()
|
|
155
|
-
?.waitBeforeSubmit(actorId, 'oneWay', signal)) ?? 1;
|
|
151
|
+
(await this.options.transportDeliveryGate?.()?.waitBeforeSubmit(actorId, 'oneWay')) ?? 1;
|
|
156
152
|
const handoff = this.options.handoffCapture?.(
|
|
157
153
|
meshName,
|
|
158
154
|
actor.actorId,
|
|
@@ -172,7 +168,7 @@ export class DefaultZLinkActorClient implements ZLinkActorClient {
|
|
|
172
168
|
);
|
|
173
169
|
if (duplicate !== undefined) submissions.push(duplicate);
|
|
174
170
|
}
|
|
175
|
-
await
|
|
171
|
+
await Promise.all(submissions);
|
|
176
172
|
return { status: ZLinkSubmitStatus.Submitted };
|
|
177
173
|
}
|
|
178
174
|
const node = this.requireNode(meshName);
|
|
@@ -662,8 +658,7 @@ class DefaultZLinkActorSendCall implements ZLinkActorSendCall {
|
|
|
662
658
|
constructor(
|
|
663
659
|
private readonly submitter: (
|
|
664
660
|
packetName: string | undefined,
|
|
665
|
-
metadata: ReadonlyMap<string, string
|
|
666
|
-
signal?: AbortSignal
|
|
661
|
+
metadata: ReadonlyMap<string, string>
|
|
667
662
|
) => Promise<ZLinkSubmitResult>,
|
|
668
663
|
private readonly message: unknown
|
|
669
664
|
) {}
|
|
@@ -678,13 +673,12 @@ class DefaultZLinkActorSendCall implements ZLinkActorSendCall {
|
|
|
678
673
|
return this;
|
|
679
674
|
}
|
|
680
675
|
|
|
681
|
-
async submit(
|
|
676
|
+
async submit(): Promise<void> {
|
|
682
677
|
ensureSingleSubmit(this.executed);
|
|
683
678
|
this.executed = true;
|
|
684
679
|
const result = await this.submitter(
|
|
685
680
|
this.packet ?? resolveFrameworkPacketName(this.message, undefined, 'Actor'),
|
|
686
|
-
this.selectedMetadata
|
|
687
|
-
signal
|
|
681
|
+
this.selectedMetadata
|
|
688
682
|
);
|
|
689
683
|
requireOneWayCompletion(
|
|
690
684
|
result,
|
|
@@ -1,49 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
} from '../framework-errors-internal';
|
|
6
|
-
|
|
7
|
-
export function remainingActorRequestTimeout(
|
|
8
|
-
actorId: string,
|
|
9
|
-
deadlineMs: number | undefined
|
|
10
|
-
): number | undefined {
|
|
11
|
-
if (deadlineMs === undefined) return undefined;
|
|
12
|
-
const remaining = deadlineMs - performance.now();
|
|
13
|
-
if (remaining <= 0) {
|
|
14
|
-
throw createInternalFrameworkException(
|
|
15
|
-
ZLinkFrameworkInternalErrorKind.DeadlineExceeded,
|
|
16
|
-
`Actor request '${actorId}' exceeded its deadline.`
|
|
17
|
-
);
|
|
18
|
-
}
|
|
19
|
-
return Math.max(1, Math.ceil(remaining));
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
/** Only actual Store, delivery-gate, and handoff waits acquire a deadline handle. */
|
|
23
|
-
export async function waitActorReply<T>(
|
|
24
|
-
reply: Promise<T>,
|
|
25
|
-
actorId: string,
|
|
26
|
-
deadlineMs: number | undefined,
|
|
27
|
-
signal?: AbortSignal
|
|
28
|
-
): Promise<T> {
|
|
29
|
-
if (deadlineMs === undefined) return await awaitWithAbort(reply, signal);
|
|
30
|
-
let timer: ReturnType<typeof setTimeout> | undefined;
|
|
31
|
-
const timeout = new Promise<never>((_resolve, reject) => {
|
|
32
|
-
const remaining = remainingActorRequestTimeout(actorId, deadlineMs);
|
|
33
|
-
timer = setTimeout(
|
|
34
|
-
() =>
|
|
35
|
-
reject(
|
|
36
|
-
createInternalFrameworkException(
|
|
37
|
-
ZLinkFrameworkInternalErrorKind.DeadlineExceeded,
|
|
38
|
-
`Actor request '${actorId}' exceeded its deadline.`
|
|
39
|
-
)
|
|
40
|
-
),
|
|
41
|
-
remaining
|
|
42
|
-
);
|
|
43
|
-
});
|
|
44
|
-
try {
|
|
45
|
-
return await awaitWithAbort(Promise.race([reply, timeout]), signal);
|
|
46
|
-
} finally {
|
|
47
|
-
clearTimeout(timer);
|
|
48
|
-
}
|
|
49
|
-
}
|
|
1
|
+
export {
|
|
2
|
+
remainingRequestTimeout as remainingActorRequestTimeout,
|
|
3
|
+
waitRequestReply as waitActorReply
|
|
4
|
+
} from '../messaging/request-deadline';
|
|
@@ -18,20 +18,18 @@ export interface ZLinkActorRoutedJoinTransport {
|
|
|
18
18
|
routerChannelId: string,
|
|
19
19
|
targetNodeRid: string,
|
|
20
20
|
packetName: string | undefined,
|
|
21
|
-
message: unknown
|
|
22
|
-
signal?: AbortSignal
|
|
21
|
+
message: unknown
|
|
23
22
|
): Promise<ZLinkSubmitResult>;
|
|
24
23
|
submitInfrastructure?(
|
|
25
24
|
routerChannelId: string,
|
|
26
25
|
targetNodeRid: string,
|
|
27
26
|
packetName: string | undefined,
|
|
28
|
-
message: unknown
|
|
29
|
-
signal?: AbortSignal
|
|
27
|
+
message: unknown
|
|
30
28
|
): Promise<ZLinkSubmitResult>;
|
|
31
29
|
sendToSpot(
|
|
32
30
|
spotRouteTarget: ZLinkSpotRouteTarget,
|
|
33
31
|
message: unknown,
|
|
34
|
-
options: { readonly packetName?: string
|
|
32
|
+
options: { readonly packetName?: string }
|
|
35
33
|
): Promise<ZLinkSubmitResult>;
|
|
36
34
|
requestRawToSpot?(
|
|
37
35
|
spotRouteTarget: ZLinkSpotRouteTarget,
|
|
@@ -492,7 +492,6 @@ export interface ZLinkBackendDealerSocket extends ZLinkBackendConnectableSocket
|
|
|
492
492
|
sendHighWaterMark: number;
|
|
493
493
|
receiveHighWaterMark: number;
|
|
494
494
|
receiveTimeoutMs: number;
|
|
495
|
-
sendTimeoutMs: number;
|
|
496
495
|
maxMessageSize: number;
|
|
497
496
|
send(message: Message | readonly Message[]): Promise<void>;
|
|
498
497
|
request(message: Message | readonly Message[], timeoutMs?: number): Promise<readonly Message[]>;
|
|
@@ -523,7 +522,6 @@ export interface ZLinkBackendRouterSocket extends ZLinkBackendConnectableSocket
|
|
|
523
522
|
sendHighWaterMark: number;
|
|
524
523
|
receiveHighWaterMark: number;
|
|
525
524
|
receiveTimeoutMs: number;
|
|
526
|
-
sendTimeoutMs: number;
|
|
527
525
|
maxMessageSize: number;
|
|
528
526
|
setRoutingId(routingId: RoutingId): void;
|
|
529
527
|
recv(flags?: ZLinkBackendRecvFlags): Received | undefined;
|
|
@@ -577,7 +575,6 @@ export interface ZLinkBackendStreamPacket {
|
|
|
577
575
|
}
|
|
578
576
|
|
|
579
577
|
export interface ZLinkBackendStreamSocket extends ZLinkBackendSocket {
|
|
580
|
-
readonly sendTimeoutMs: number;
|
|
581
578
|
readonly sendHighWaterMark: number;
|
|
582
579
|
/** Framework stream ingress uses this bound for packet payload validation. */
|
|
583
580
|
maxMessageSize: number;
|
|
@@ -588,11 +585,7 @@ export interface ZLinkBackendStreamSocket extends ZLinkBackendSocket {
|
|
|
588
585
|
payload: Message | readonly Message[],
|
|
589
586
|
flags: ZLinkBackendSendFlags
|
|
590
587
|
): boolean;
|
|
591
|
-
submit(
|
|
592
|
-
routingId: RoutingId,
|
|
593
|
-
payload: Message | readonly Message[],
|
|
594
|
-
timeoutMs?: number
|
|
595
|
-
): Promise<void>;
|
|
588
|
+
submit(routingId: RoutingId, payload: Message | readonly Message[]): Promise<void>;
|
|
596
589
|
disconnectPeer(routingId: RoutingId): void;
|
|
597
590
|
bindActor(
|
|
598
591
|
sessionRid: RoutingId,
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import { constants as osConstants } from 'node:os';
|
|
2
|
-
import {
|
|
2
|
+
import { waitRequestReply } from '../../messaging/request-deadline';
|
|
3
|
+
import {
|
|
4
|
+
requireClassicFanoutCompletion,
|
|
5
|
+
ZLinkSubmitStatus
|
|
6
|
+
} from '../../messaging/submission-result';
|
|
3
7
|
import { loadBinding } from '../node-backend-adapter';
|
|
4
8
|
import { SubmitResult, ZLinkBackendResultError } from '../runtime-values';
|
|
5
9
|
const nativeErrnoValues = osConstants.errno;
|
|
@@ -92,7 +96,7 @@ export function submitBindingPublish(
|
|
|
92
96
|
(translated.result === SubmitResult.Backpressured ||
|
|
93
97
|
translated.result === SubmitResult.NotAdmitted)
|
|
94
98
|
) {
|
|
95
|
-
|
|
99
|
+
requireClassicFanoutCompletion(
|
|
96
100
|
{ status: ZLinkSubmitStatus.Backpressured },
|
|
97
101
|
'Classic fanout publish'
|
|
98
102
|
);
|
|
@@ -119,6 +123,7 @@ export async function submitBindingAsyncSend(
|
|
|
119
123
|
operation: ZLinkBindingAsyncSendOperation,
|
|
120
124
|
payload: unknown
|
|
121
125
|
): Promise<void> {
|
|
126
|
+
let submission: import('@zlink-systems/zlink').SendSubmission;
|
|
122
127
|
try {
|
|
123
128
|
let current: ZLinkBindingAsyncSendSubmitOperation | undefined;
|
|
124
129
|
const parts = Array.isArray(payload) ? payload : [payload];
|
|
@@ -127,9 +132,16 @@ export async function submitBindingAsyncSend(
|
|
|
127
132
|
current = current === undefined ? operation.message(nativePart) : current.message(nativePart);
|
|
128
133
|
}
|
|
129
134
|
current ??= operation.message(Buffer.alloc(0));
|
|
130
|
-
|
|
135
|
+
submission = current.submit();
|
|
131
136
|
} catch (error) {
|
|
132
|
-
throw translateBindingResultError(error);
|
|
137
|
+
throw translateBindingResultError(error, 'submit');
|
|
138
|
+
}
|
|
139
|
+
if (submission.result === SubmitResult.Backpressured) {
|
|
140
|
+
try {
|
|
141
|
+
await submission.admitted;
|
|
142
|
+
} catch (error) {
|
|
143
|
+
throw translateBindingResultError(error, 'completion');
|
|
144
|
+
}
|
|
133
145
|
}
|
|
134
146
|
}
|
|
135
147
|
|
|
@@ -156,6 +168,7 @@ export async function submitBindingRequest(
|
|
|
156
168
|
payload: unknown,
|
|
157
169
|
timeoutMs: number | undefined
|
|
158
170
|
): Promise<readonly unknown[]> {
|
|
171
|
+
const deadlineMs = timeoutMs === undefined ? undefined : performance.now() + timeoutMs;
|
|
159
172
|
try {
|
|
160
173
|
let current: ZLinkBindingRequestSubmitOperation | undefined;
|
|
161
174
|
if (Array.isArray(payload)) {
|
|
@@ -171,12 +184,39 @@ export async function submitBindingRequest(
|
|
|
171
184
|
if (timeoutMs !== undefined) {
|
|
172
185
|
current = current.timeout(timeoutMs);
|
|
173
186
|
}
|
|
174
|
-
return await current.submit()
|
|
187
|
+
return await bindingRequestReply(current.submit(), deadlineMs);
|
|
175
188
|
} catch (error) {
|
|
176
189
|
throw translateBindingResultError(error);
|
|
177
190
|
}
|
|
178
191
|
}
|
|
179
192
|
|
|
193
|
+
export async function bindingRequestReply(
|
|
194
|
+
submission: import('@zlink-systems/zlink').RequestSubmission,
|
|
195
|
+
deadlineMs: number | undefined
|
|
196
|
+
): Promise<import('@zlink-systems/zlink').Message[]> {
|
|
197
|
+
const reply = submission.reply;
|
|
198
|
+
if (submission.result === SubmitResult.Backpressured) {
|
|
199
|
+
try {
|
|
200
|
+
const [, replies] = await waitRequestReply(
|
|
201
|
+
Promise.all([submission.admitted, reply]),
|
|
202
|
+
'Request',
|
|
203
|
+
deadlineMs
|
|
204
|
+
);
|
|
205
|
+
return replies;
|
|
206
|
+
} catch (error) {
|
|
207
|
+
void reply.then(closeBindingReply, () => undefined);
|
|
208
|
+
throw error;
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
return reply;
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
export function closeBindingReply(
|
|
215
|
+
replies: readonly import('@zlink-systems/zlink').Message[]
|
|
216
|
+
): void {
|
|
217
|
+
for (const reply of replies) reply.close();
|
|
218
|
+
}
|
|
219
|
+
|
|
180
220
|
/**
|
|
181
221
|
* Closes a binding handle once. An already closed or terminated handle counts as
|
|
182
222
|
* closed. A busy close propagates to the caller.
|
|
@@ -24,10 +24,8 @@ export class ZLinkDealerChannelClientTransport implements ZLinkChannelClientTran
|
|
|
24
24
|
channelName: string,
|
|
25
25
|
packetName: string | undefined,
|
|
26
26
|
message: Message,
|
|
27
|
-
signal?: AbortSignal,
|
|
28
27
|
metadata: ReadonlyMap<string, string> = EMPTY_METADATA
|
|
29
28
|
): Promise<ZLinkSubmitResult> {
|
|
30
|
-
throwIfAborted(signal);
|
|
31
29
|
// Call-scoped flow (spec 27 §4): the envelope flow pair does not outlive
|
|
32
30
|
// this outbound call.
|
|
33
31
|
await runWithOutboundFlow(
|
|
@@ -7,7 +7,6 @@ import {
|
|
|
7
7
|
createDealerSocket,
|
|
8
8
|
createRouterSocket,
|
|
9
9
|
ReceiveFlowState,
|
|
10
|
-
SubmitResult,
|
|
11
10
|
type Context,
|
|
12
11
|
type DealerSocket,
|
|
13
12
|
type MonitorEvent,
|
|
@@ -18,11 +17,13 @@ import {
|
|
|
18
17
|
type RequestOperation,
|
|
19
18
|
type RequestSubmitOperation,
|
|
20
19
|
type RouterSocket,
|
|
21
|
-
type SendOperation,
|
|
22
|
-
type SendSubmitOperation,
|
|
23
20
|
type Socket
|
|
24
21
|
} from '@zlink-systems/zlink';
|
|
25
|
-
import {
|
|
22
|
+
import {
|
|
23
|
+
translateBindingResultError,
|
|
24
|
+
bindingRequestReply,
|
|
25
|
+
submitBindingAsyncSend
|
|
26
|
+
} from './node-backend-adapter-support';
|
|
26
27
|
import { isEndpointCloseIgnorableError } from './node-socket-backend-adapter';
|
|
27
28
|
import { ZLinkNodeEventLoopPoller } from './node-event-loop-poller';
|
|
28
29
|
import type {
|
|
@@ -266,15 +267,10 @@ class NodeRawRouterPort extends NodeRawSocketPort<RouterSocket> implements ZLink
|
|
|
266
267
|
this.connect(endpoint);
|
|
267
268
|
}
|
|
268
269
|
|
|
269
|
-
|
|
270
|
+
send(targetRid: string, parts: readonly Uint8Array[]): Promise<void> {
|
|
270
271
|
this.requireOpen();
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
parts
|
|
274
|
-
).submit();
|
|
275
|
-
if (submission.result === SubmitResult.Backpressured) {
|
|
276
|
-
await submission.admitted;
|
|
277
|
-
}
|
|
272
|
+
requireParts(parts);
|
|
273
|
+
return submitBindingAsyncSend(this.socket.send(bindingRoutingId(targetRid)), parts);
|
|
278
274
|
}
|
|
279
275
|
|
|
280
276
|
async request(
|
|
@@ -283,6 +279,7 @@ class NodeRawRouterPort extends NodeRawSocketPort<RouterSocket> implements ZLink
|
|
|
283
279
|
timeoutMs: number
|
|
284
280
|
): Promise<readonly Buffer[]> {
|
|
285
281
|
this.requireOpen();
|
|
282
|
+
const deadlineMs = performance.now() + timeoutMs;
|
|
286
283
|
let submission: ReturnType<RequestSubmitOperation['submit']>;
|
|
287
284
|
try {
|
|
288
285
|
submission = appendRequestParts(this.socket.request(bindingRoutingId(targetRid)), parts)
|
|
@@ -292,7 +289,7 @@ class NodeRawRouterPort extends NodeRawSocketPort<RouterSocket> implements ZLink
|
|
|
292
289
|
throw translateBindingResultError(error, 'submit');
|
|
293
290
|
}
|
|
294
291
|
try {
|
|
295
|
-
const replies = await
|
|
292
|
+
const replies = await bindingRequestReply(submission, deadlineMs);
|
|
296
293
|
return copyAndClose(replies);
|
|
297
294
|
} catch (error) {
|
|
298
295
|
throw translateBindingResultError(error, 'completion');
|
|
@@ -338,16 +335,15 @@ class NodeRawDealerPort extends NodeRawSocketPort<DealerSocket> implements ZLink
|
|
|
338
335
|
this.socket.setRoutingId(bindingRoutingId(routingId));
|
|
339
336
|
}
|
|
340
337
|
|
|
341
|
-
|
|
338
|
+
send(parts: readonly Uint8Array[]): Promise<void> {
|
|
342
339
|
this.requireOpen();
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
await submission.admitted;
|
|
346
|
-
}
|
|
340
|
+
requireParts(parts);
|
|
341
|
+
return submitBindingAsyncSend(this.socket.send(), parts);
|
|
347
342
|
}
|
|
348
343
|
|
|
349
344
|
async request(parts: readonly Uint8Array[], timeoutMs: number): Promise<readonly Buffer[]> {
|
|
350
345
|
this.requireOpen();
|
|
346
|
+
const deadlineMs = performance.now() + timeoutMs;
|
|
351
347
|
let submission: ReturnType<RequestSubmitOperation['submit']>;
|
|
352
348
|
try {
|
|
353
349
|
submission = appendRequestParts(this.socket.request(), parts).timeout(timeoutMs).submit();
|
|
@@ -355,7 +351,7 @@ class NodeRawDealerPort extends NodeRawSocketPort<DealerSocket> implements ZLink
|
|
|
355
351
|
throw translateBindingResultError(error, 'submit');
|
|
356
352
|
}
|
|
357
353
|
try {
|
|
358
|
-
const replies = await
|
|
354
|
+
const replies = await bindingRequestReply(submission, deadlineMs);
|
|
359
355
|
return copyAndClose(replies);
|
|
360
356
|
} catch (error) {
|
|
361
357
|
throw translateBindingResultError(error, 'completion');
|
|
@@ -368,16 +364,6 @@ class NodeRawDealerPort extends NodeRawSocketPort<DealerSocket> implements ZLink
|
|
|
368
364
|
}
|
|
369
365
|
}
|
|
370
366
|
|
|
371
|
-
async function requestReply(
|
|
372
|
-
submission: ReturnType<RequestSubmitOperation['submit']>
|
|
373
|
-
): Promise<Message[]> {
|
|
374
|
-
if (submission.result === SubmitResult.Backpressured) {
|
|
375
|
-
const [, replies] = await Promise.all([submission.admitted, submission.reply]);
|
|
376
|
-
return replies;
|
|
377
|
-
}
|
|
378
|
-
return submission.reply;
|
|
379
|
-
}
|
|
380
|
-
|
|
381
367
|
class NodeRawMonitorPort implements ZLinkRawMonitorPort {
|
|
382
368
|
private closed = false;
|
|
383
369
|
|
|
@@ -410,18 +396,6 @@ class NodeRawMonitorPort implements ZLinkRawMonitorPort {
|
|
|
410
396
|
}
|
|
411
397
|
}
|
|
412
398
|
|
|
413
|
-
function appendSendParts(
|
|
414
|
-
operation: SendOperation,
|
|
415
|
-
parts: readonly Uint8Array[]
|
|
416
|
-
): SendSubmitOperation {
|
|
417
|
-
requireParts(parts);
|
|
418
|
-
let next = operation.message(parts[0]);
|
|
419
|
-
for (let index = 1; index < parts.length; index += 1) {
|
|
420
|
-
next = next.message(parts[index]);
|
|
421
|
-
}
|
|
422
|
-
return next;
|
|
423
|
-
}
|
|
424
|
-
|
|
425
399
|
function appendRequestParts(
|
|
426
400
|
operation: RequestOperation,
|
|
427
401
|
parts: readonly Uint8Array[]
|
|
@@ -194,7 +194,7 @@ export function wrapSocket<T extends { close(): void }>(
|
|
|
194
194
|
}
|
|
195
195
|
return submitBindingAsyncSend(operation, payload);
|
|
196
196
|
},
|
|
197
|
-
submit(routingId: unknown, payload: unknown
|
|
197
|
+
submit(routingId: unknown, payload: unknown): Promise<void> {
|
|
198
198
|
if (!hasStream) throw new TypeError('Async stream send requires a STREAM socket.');
|
|
199
199
|
return submitBindingAsyncSend(
|
|
200
200
|
(nativeInstance as T & { send(routingId: unknown): ZLinkBindingAsyncSendOperation }).send(
|