@zlink-systems/framework 0.27.0 → 0.29.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 +2 -1
- package/dist/contracts/Configuration/Configs.d.ts +0 -1
- package/dist/contracts/Configuration/InternalDefaults.d.ts +3 -0
- package/dist/contracts/Configuration/InternalDefaults.js +4 -1
- package/dist/contracts/Configuration/RegistrationBuilders.js +9 -0
- package/dist/contracts/Configuration/RegistrationNormalizers.d.ts +1 -0
- package/dist/contracts/Configuration/RegistrationNormalizers.js +16 -0
- package/dist/contracts/Configuration/RegistrationTypes.d.ts +3 -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-mailbox.d.ts +2 -2
- package/dist/runtime/actors/actor-mailbox.js +2 -2
- 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-raw-mesh-backend.js +1 -3
- 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/execution/serial-execution-queue.d.ts +12 -3
- package/dist/runtime/execution/serial-execution-queue.js +116 -28
- package/dist/runtime/foundation/operation-registry.d.ts +3 -2
- package/dist/runtime/foundation/operation-registry.js +5 -1
- package/dist/runtime/foundation/raw-service-mesh-runtime.js +17 -11
- package/dist/runtime/foundation/service-authority-payload-codec.d.ts +0 -2
- package/dist/runtime/foundation/service-authority-payload-codec.js +0 -43
- package/dist/runtime/foundation/service-stateful-registry.d.ts +4 -3
- package/dist/runtime/foundation/service-stateful-registry.js +5 -2
- package/dist/runtime/foundation/service-stateful-runtime.d.ts +1 -8
- package/dist/runtime/foundation/service-stateful-runtime.js +78 -126
- package/dist/runtime/foundation/service-stateful-wire-codec.d.ts +0 -11
- package/dist/runtime/foundation/service-stateful-wire-codec.js +1 -23
- package/dist/runtime/foundation/service-topology-registry.d.ts +5 -0
- package/dist/runtime/foundation/service-topology-registry.js +16 -17
- 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/instance-activation-authority.d.ts +0 -1
- package/dist/runtime/host/instance-activation-authority.js +46 -97
- 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 +47 -87
- package/dist/runtime/host/stateful-authority-route-runtime.d.ts +1 -0
- package/dist/runtime/host/stateful-authority-route-runtime.js +17 -9
- package/dist/runtime/locations/domain-store-contract.d.ts +1 -0
- package/dist/runtime/locations/in-memory-authority-store.d.ts +2 -0
- package/dist/runtime/locations/in-memory-authority-store.js +22 -8
- package/dist/runtime/locations/in-memory-location-store.d.ts +1 -0
- package/dist/runtime/locations/in-memory-location-store.js +3 -0
- package/dist/runtime/locations/internal-store-contracts.d.ts +1 -1
- package/dist/runtime/locations/location-store-repository.d.ts +1 -0
- package/dist/runtime/locations/location-store-repository.js +98 -53
- 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/spots/spot-serial-executor.js +4 -1
- package/dist/runtime/spots/spot-serial-turn-executor.d.ts +3 -0
- package/dist/runtime/spots/spot-serial-turn-executor.js +5 -0
- 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 -3
- package/dist/runtime/streams/index.js +6 -5
- 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/protocol.js +0 -9
- 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 -8
- package/dist/runtime/streams/session-context.js +3 -32
- package/dist/runtime/streams/session-serial-executor.d.ts +0 -1
- package/dist/runtime/streams/session-serial-executor.js +0 -3
- package/dist/runtime/streams/stream-message-utils.d.ts +0 -1
- package/dist/runtime/streams/stream-message-utils.js +0 -20
- package/dist/runtime/streams/stream-session-runtime.d.ts +6 -3
- package/dist/runtime/streams/stream-session-runtime.js +40 -85
- 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 +2 -1
- package/src/contracts/Configuration/Configs.ts +0 -1
- package/src/contracts/Configuration/InternalDefaults.ts +4 -0
- package/src/contracts/Configuration/RegistrationBuilders.ts +13 -3
- package/src/contracts/Configuration/RegistrationNormalizers.ts +25 -0
- package/src/contracts/Configuration/RegistrationTypes.ts +3 -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-mailbox.ts +7 -2
- 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-raw-mesh-backend.ts +1 -7
- 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/execution/serial-execution-queue.ts +117 -29
- package/src/runtime/foundation/operation-registry.ts +16 -9
- package/src/runtime/foundation/raw-service-mesh-runtime.ts +17 -14
- package/src/runtime/foundation/service-authority-payload-codec.ts +0 -46
- package/src/runtime/foundation/service-stateful-registry.ts +10 -5
- package/src/runtime/foundation/service-stateful-runtime.ts +103 -181
- package/src/runtime/foundation/service-stateful-wire-codec.ts +0 -25
- package/src/runtime/foundation/service-topology-registry.ts +30 -20
- package/src/runtime/host/actor-packet-relay.ts +8 -15
- package/src/runtime/host/index.ts +2 -26
- package/src/runtime/host/instance-activation-authority.ts +58 -125
- package/src/runtime/host/remote-bound-session-relay.ts +8 -16
- package/src/runtime/host/spot-address-transport.ts +107 -166
- package/src/runtime/host/stateful-authority-route-runtime.ts +22 -9
- package/src/runtime/locations/domain-store-contract.ts +5 -0
- package/src/runtime/locations/in-memory-authority-store.ts +42 -8
- package/src/runtime/locations/in-memory-location-store.ts +8 -0
- package/src/runtime/locations/internal-store-contracts.ts +1 -0
- package/src/runtime/locations/location-store-repository.ts +130 -68
- package/src/runtime/messaging/request-deadline.ts +58 -0
- package/src/runtime/messaging/submission-result.ts +18 -4
- package/src/runtime/protocol/service_wire_pilot_codec.generated.ts +1 -1
- package/src/runtime/spots/spot-outbound.ts +14 -24
- package/src/runtime/spots/spot-serial-executor.ts +4 -1
- package/src/runtime/spots/spot-serial-turn-executor.ts +10 -0
- 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 +5 -5
- package/src/runtime/streams/managed-stream.ts +3 -13
- package/src/runtime/streams/native-fallback-bound-session.ts +13 -25
- package/src/runtime/streams/protocol.ts +0 -13
- package/src/runtime/streams/session-calls.ts +8 -34
- package/src/runtime/streams/session-context.ts +6 -47
- package/src/runtime/streams/session-serial-executor.ts +0 -8
- package/src/runtime/streams/stream-message-utils.ts +1 -27
- package/src/runtime/streams/stream-session-runtime.ts +54 -97
- package/dist/runtime/streams/session-requests.d.ts +0 -25
- package/dist/runtime/streams/session-requests.js +0 -101
- package/src/runtime/streams/session-requests.ts +0 -110
|
@@ -30,6 +30,9 @@ export interface ZLinkStreamSessionContextFactory {
|
|
|
30
30
|
createSessionContext(stream: ZLinkManagedStream, close?: (signal?: AbortSignal) => Promise<void>, providerResolver?: ZLinkProviderResolver): DefaultZLinkSessionContext;
|
|
31
31
|
}
|
|
32
32
|
export interface ZLinkStreamSessionRuntimeOptions {
|
|
33
|
+
readonly heartbeatIntervalMs?: number;
|
|
34
|
+
readonly heartbeatTimeoutMs?: number;
|
|
35
|
+
readonly idleTimeoutMs?: number;
|
|
33
36
|
readonly socket: ZLinkBackendStreamSocket;
|
|
34
37
|
readonly nativeSessionService?: StreamSessionService;
|
|
35
38
|
readonly meshCompletions?: ZLinkMeshCompletionTable;
|
|
@@ -66,8 +69,10 @@ export declare class ZLinkStreamSessionRuntime {
|
|
|
66
69
|
private closeReason;
|
|
67
70
|
private metricsClosed;
|
|
68
71
|
private readonly livenessClock;
|
|
72
|
+
private readonly liveness;
|
|
69
73
|
private lastApplicationActivityAt;
|
|
70
74
|
private lastInboundFrameAt;
|
|
75
|
+
private lastHeartbeatPingAt;
|
|
71
76
|
private livenessTimer;
|
|
72
77
|
constructor(options: ZLinkStreamSessionRuntimeOptions & ZLinkStreamLivenessOptions, routingId: unknown, removeSession?: (sessionId: string, session: ZLinkStreamSessionRuntime) => void);
|
|
73
78
|
get session(): Promise<ZLinkSession>;
|
|
@@ -79,8 +84,7 @@ export declare class ZLinkStreamSessionRuntime {
|
|
|
79
84
|
enqueuePacket(payload: Message, decodedHeader: ZLinkStreamFrameHeader, terminalOwner?: ZLinkRetainedStreamOwner, applicationJobPermit?: ApplicationJobPermitPort): void;
|
|
80
85
|
enqueueDisconnected(error?: unknown): void;
|
|
81
86
|
/**
|
|
82
|
-
*
|
|
83
|
-
* without retaining that lane while application code awaits unrelated work.
|
|
87
|
+
* Retains the session turn through the callback's terminal result.
|
|
84
88
|
*/
|
|
85
89
|
enqueueActorBindingReplaced(actor: ServiceActorRef, retiredSession: ServiceRetiredBoundSessionRouteFence): void;
|
|
86
90
|
close(signal?: AbortSignal): Promise<void>;
|
|
@@ -105,7 +109,6 @@ export declare class ZLinkStreamSessionRuntime {
|
|
|
105
109
|
private queueDisconnect;
|
|
106
110
|
private cleanup;
|
|
107
111
|
private enqueueControl;
|
|
108
|
-
private enqueueInfrastructure;
|
|
109
112
|
private enqueueApplication;
|
|
110
113
|
/**
|
|
111
114
|
* Spec 26 §2.1/§3.1: a frame discarded because the session serial lane is
|
|
@@ -19,19 +19,18 @@ const protocol_1 = require("./protocol");
|
|
|
19
19
|
const session_context_1 = require("./session-context");
|
|
20
20
|
const session_serial_executor_1 = require("./session-serial-executor");
|
|
21
21
|
const stream_message_utils_1 = require("./stream-message-utils");
|
|
22
|
+
const RegistrationNormalizers_1 = require("../../contracts/Configuration/RegistrationNormalizers");
|
|
22
23
|
const ZLINK_SEND_DONT_WAIT = 1;
|
|
23
24
|
const ZLINK_RECV_DONT_WAIT = 1;
|
|
24
|
-
const ZLINK_STREAM_HEARTBEAT_INTERVAL_MS = 1_000;
|
|
25
|
-
const ZLINK_STREAM_HEARTBEAT_TIMEOUT_MS = 5_000;
|
|
26
|
-
const ZLINK_STREAM_APPLICATION_IDLE_TIMEOUT_MS = 30_000;
|
|
27
25
|
const ZLINK_STREAM_RECEIVE_FRAME_BATCH_LIMIT = 64;
|
|
28
26
|
const ZLINK_STREAM_ACTOR_BINDING_REPLACEMENT_CLOSE_DELAY_MS = 100;
|
|
29
27
|
const ZLINK_STREAM_MONITOR_IDLE_MIN_DELAY_MS = 1;
|
|
30
28
|
const ZLINK_STREAM_MONITOR_IDLE_MAX_DELAY_MS = 20;
|
|
31
29
|
const ZLINK_STREAM_MONITOR_IDLE_MAX_STEPS = 7;
|
|
30
|
+
const MAX_TIMER_DELAY_MS = 2_147_483_647;
|
|
32
31
|
const systemLivenessClock = {
|
|
33
32
|
now: () => performance.now(),
|
|
34
|
-
setTimer: (callback, delayMs) => setTimeout(callback, delayMs),
|
|
33
|
+
setTimer: (callback, delayMs) => setTimeout(callback, Math.min(delayMs, MAX_TIMER_DELAY_MS)),
|
|
35
34
|
clearTimer: (timer) => clearTimeout(timer)
|
|
36
35
|
};
|
|
37
36
|
class ZLinkStreamReceiveWake {
|
|
@@ -69,12 +68,15 @@ class ZLinkStreamSessionRuntime {
|
|
|
69
68
|
closeReason = 'client_close';
|
|
70
69
|
metricsClosed = false;
|
|
71
70
|
livenessClock;
|
|
71
|
+
liveness;
|
|
72
72
|
lastApplicationActivityAt = 0;
|
|
73
73
|
lastInboundFrameAt = 0;
|
|
74
|
+
lastHeartbeatPingAt = 0;
|
|
74
75
|
livenessTimer;
|
|
75
76
|
constructor(options, routingId, removeSession = () => { }) {
|
|
76
77
|
this.options = options;
|
|
77
78
|
this.removeSession = removeSession;
|
|
79
|
+
this.liveness = (0, RegistrationNormalizers_1.normalizeStreamLiveness)(options);
|
|
78
80
|
this.livenessClock = options.livenessClock ?? systemLivenessClock;
|
|
79
81
|
this.stream = new managed_stream_1.ZLinkManagedStream(options.socket, routingId, options.messageSerializers, options.nativeSessionService, options.meshCompletions, undefined, options.nativeSessionRouteForMesh);
|
|
80
82
|
this.context = options.bindingRuntime.createSessionContext(this.stream, (signal) => this.close(signal), options.providerResolver);
|
|
@@ -112,7 +114,7 @@ class ZLinkStreamSessionRuntime {
|
|
|
112
114
|
return this.sessionReady;
|
|
113
115
|
}
|
|
114
116
|
enqueueConnected(localAddr, remoteAddr) {
|
|
115
|
-
this.serial.
|
|
117
|
+
this.serial.executeControl(async () => this.markConnected(localAddr, remoteAddr));
|
|
116
118
|
}
|
|
117
119
|
enqueuePacket(payload, decodedHeader, terminalOwner, applicationJobPermit) {
|
|
118
120
|
this.lastInboundFrameAt = Math.max(this.lastInboundFrameAt, this.livenessClock.now());
|
|
@@ -124,41 +126,20 @@ class ZLinkStreamSessionRuntime {
|
|
|
124
126
|
terminalOwner?.close();
|
|
125
127
|
};
|
|
126
128
|
if (decodedHeader.kind === protocol_1.ZLinkStreamMessageKind.Control) {
|
|
127
|
-
|
|
128
|
-
(
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
this.options.onError?.(error);
|
|
133
|
-
})
|
|
134
|
-
.finally(() => {
|
|
135
|
-
applicationJobPermit?.releaseAfterInternalProcessing();
|
|
136
|
-
payload.close();
|
|
137
|
-
releaseTerminal();
|
|
138
|
-
});
|
|
139
|
-
return;
|
|
140
|
-
}
|
|
141
|
-
this.enqueueControl(async () => {
|
|
142
|
-
try {
|
|
143
|
-
const dispatch = () => this.dispatchPacket(payload, decodedHeader);
|
|
144
|
-
if (applicationJobPermit === undefined)
|
|
145
|
-
await dispatch();
|
|
146
|
-
else
|
|
147
|
-
await (0, application_job_queue_scope_1.runWithApplicationJobPermit)(applicationJobPermit, dispatch);
|
|
148
|
-
}
|
|
149
|
-
finally {
|
|
150
|
-
releaseTerminal();
|
|
151
|
-
}
|
|
152
|
-
}, () => {
|
|
129
|
+
void this.handleControl(decodedHeader, payload)
|
|
130
|
+
.catch((error) => {
|
|
131
|
+
this.options.onError?.(error);
|
|
132
|
+
})
|
|
133
|
+
.finally(() => {
|
|
153
134
|
applicationJobPermit?.releaseAfterInternalProcessing();
|
|
154
135
|
payload.close();
|
|
155
136
|
releaseTerminal();
|
|
156
|
-
}
|
|
137
|
+
});
|
|
157
138
|
return;
|
|
158
139
|
}
|
|
159
140
|
if (decodedHeader.kind === protocol_1.ZLinkStreamMessageKind.Response ||
|
|
160
141
|
decodedHeader.kind === protocol_1.ZLinkStreamMessageKind.Error) {
|
|
161
|
-
this.
|
|
142
|
+
this.enqueueControl(async () => {
|
|
162
143
|
try {
|
|
163
144
|
await this.dispatchPacket(payload, decodedHeader);
|
|
164
145
|
}
|
|
@@ -198,8 +179,7 @@ class ZLinkStreamSessionRuntime {
|
|
|
198
179
|
this.queueDisconnect(error);
|
|
199
180
|
}
|
|
200
181
|
/**
|
|
201
|
-
*
|
|
202
|
-
* without retaining that lane while application code awaits unrelated work.
|
|
182
|
+
* Retains the session turn through the callback's terminal result.
|
|
203
183
|
*/
|
|
204
184
|
enqueueActorBindingReplaced(actor, retiredSession) {
|
|
205
185
|
this.serial.executeControl(async () => {
|
|
@@ -209,7 +189,6 @@ class ZLinkStreamSessionRuntime {
|
|
|
209
189
|
return;
|
|
210
190
|
const session = await this.requireSession();
|
|
211
191
|
let callbackDeadlineTimer;
|
|
212
|
-
let callbackTerminal = false;
|
|
213
192
|
let forcedClose = false;
|
|
214
193
|
const scheduleClose = () => {
|
|
215
194
|
if (forcedClose)
|
|
@@ -223,25 +202,6 @@ class ZLinkStreamSessionRuntime {
|
|
|
223
202
|
void this.close().catch((error) => this.options.onError?.(error));
|
|
224
203
|
}, ZLINK_STREAM_ACTOR_BINDING_REPLACEMENT_CLOSE_DELAY_MS);
|
|
225
204
|
};
|
|
226
|
-
const completeCallback = () => {
|
|
227
|
-
if (callbackTerminal)
|
|
228
|
-
return;
|
|
229
|
-
callbackTerminal = true;
|
|
230
|
-
if (callbackDeadlineTimer !== undefined) {
|
|
231
|
-
this.livenessClock.clearTimer(callbackDeadlineTimer);
|
|
232
|
-
callbackDeadlineTimer = undefined;
|
|
233
|
-
}
|
|
234
|
-
scheduleClose();
|
|
235
|
-
};
|
|
236
|
-
const reportCallbackFailure = (error) => {
|
|
237
|
-
try {
|
|
238
|
-
this.options.onError?.(error);
|
|
239
|
-
}
|
|
240
|
-
catch {
|
|
241
|
-
// Diagnostics must not prevent the lifecycle terminal transition.
|
|
242
|
-
}
|
|
243
|
-
completeCallback();
|
|
244
|
-
};
|
|
245
205
|
callbackDeadlineTimer = this.livenessClock.setTimer(() => {
|
|
246
206
|
if (this.disposed ||
|
|
247
207
|
this.disconnected ||
|
|
@@ -251,19 +211,17 @@ class ZLinkStreamSessionRuntime {
|
|
|
251
211
|
forcedClose = true;
|
|
252
212
|
void this.close().catch((error) => this.options.onError?.(error));
|
|
253
213
|
}, this.options.replacementCallbackTimeoutMs ?? Registration_1.DEFAULT_SESSION_REPLACEMENT_CALLBACK_TIMEOUT_MS);
|
|
254
|
-
const callback = session.onActorBindingReplaced;
|
|
255
|
-
if (callback === undefined) {
|
|
256
|
-
completeCallback();
|
|
257
|
-
return;
|
|
258
|
-
}
|
|
259
214
|
try {
|
|
260
|
-
|
|
261
|
-
// serial lane while application code awaits an unrelated operation.
|
|
262
|
-
const result = callback.call(session, this.context, actor.actorId);
|
|
263
|
-
void Promise.resolve(result).then(() => completeCallback(), reportCallbackFailure);
|
|
215
|
+
await session.onActorBindingReplaced?.(this.context, actor.actorId);
|
|
264
216
|
}
|
|
265
217
|
catch (error) {
|
|
266
|
-
|
|
218
|
+
this.options.onError?.(error);
|
|
219
|
+
}
|
|
220
|
+
finally {
|
|
221
|
+
if (callbackDeadlineTimer !== undefined) {
|
|
222
|
+
this.livenessClock.clearTimer(callbackDeadlineTimer);
|
|
223
|
+
}
|
|
224
|
+
scheduleClose();
|
|
267
225
|
}
|
|
268
226
|
});
|
|
269
227
|
}
|
|
@@ -313,6 +271,7 @@ class ZLinkStreamSessionRuntime {
|
|
|
313
271
|
this.connected = true;
|
|
314
272
|
const connectedAt = this.livenessClock.now();
|
|
315
273
|
this.lastApplicationActivityAt = connectedAt;
|
|
274
|
+
this.lastHeartbeatPingAt = connectedAt;
|
|
316
275
|
this.lastInboundFrameAt = Math.max(this.lastInboundFrameAt, connectedAt);
|
|
317
276
|
this.scheduleLivenessCheck();
|
|
318
277
|
this.options.metrics?.change(runtime_metrics_1.METRIC_NAMES.StreamConnectionsActive, 1, { transport: 'tcp' });
|
|
@@ -324,15 +283,8 @@ class ZLinkStreamSessionRuntime {
|
|
|
324
283
|
let dispatchPayload = payload;
|
|
325
284
|
let enteredDispatch = false;
|
|
326
285
|
try {
|
|
327
|
-
if (decodedHeader.kind === protocol_1.ZLinkStreamMessageKind.Control) {
|
|
328
|
-
await this.handleControl(decodedHeader, payload);
|
|
329
|
-
return;
|
|
330
|
-
}
|
|
331
286
|
this.lastApplicationActivityAt = this.livenessClock.now();
|
|
332
287
|
dispatchPayload = this.context.payloadForHeader(decodedHeader, payload);
|
|
333
|
-
if (this.context.tryCompleteResponse(decodedHeader, dispatchPayload)) {
|
|
334
|
-
return;
|
|
335
|
-
}
|
|
336
288
|
const dispatchActor = this.context.actorForSlot(decodedHeader.actorSlot);
|
|
337
289
|
if (decodedHeader.actorSlot !== undefined && dispatchActor === undefined) {
|
|
338
290
|
const staleFlowEnabled = this.options.dispatchErrors?.flow.flowCreationEnabled() ?? true;
|
|
@@ -466,25 +418,33 @@ class ZLinkStreamSessionRuntime {
|
|
|
466
418
|
if (this.disposed || this.disconnected || this.livenessTimer !== undefined) {
|
|
467
419
|
return;
|
|
468
420
|
}
|
|
421
|
+
const now = this.livenessClock.now();
|
|
422
|
+
const due = Math.min(this.lastHeartbeatPingAt + this.liveness.heartbeatIntervalMs, this.lastInboundFrameAt + this.liveness.heartbeatTimeoutMs, this.liveness.idleTimeoutMs > 0
|
|
423
|
+
? this.lastApplicationActivityAt + this.liveness.idleTimeoutMs
|
|
424
|
+
: Infinity);
|
|
469
425
|
this.livenessTimer = this.livenessClock.setTimer(() => {
|
|
470
426
|
this.livenessTimer = undefined;
|
|
471
|
-
|
|
472
|
-
},
|
|
427
|
+
void this.runLivenessCheck().catch((error) => this.options.onError?.(error));
|
|
428
|
+
}, Math.max(0, due - now));
|
|
473
429
|
}
|
|
474
430
|
async runLivenessCheck() {
|
|
475
431
|
if (this.disposed || this.disconnected || !this.connected) {
|
|
476
432
|
return;
|
|
477
433
|
}
|
|
478
434
|
const now = this.livenessClock.now();
|
|
479
|
-
if (
|
|
435
|
+
if (this.liveness.idleTimeoutMs > 0 &&
|
|
436
|
+
now - this.lastApplicationActivityAt >= this.liveness.idleTimeoutMs) {
|
|
480
437
|
await this.closeForLiveness(protocol_1.ZLinkStreamCloseReasonCode.IdleTimeout, 'idle_timeout', 'Application idle timeout.');
|
|
481
438
|
return;
|
|
482
439
|
}
|
|
483
|
-
if (now - this.lastInboundFrameAt >=
|
|
440
|
+
if (now - this.lastInboundFrameAt >= this.liveness.heartbeatTimeoutMs) {
|
|
484
441
|
await this.closeForLiveness(protocol_1.ZLinkStreamCloseReasonCode.HeartbeatTimeout, 'heartbeat_timeout', 'Heartbeat timeout.');
|
|
485
442
|
return;
|
|
486
443
|
}
|
|
487
|
-
|
|
444
|
+
if (now - this.lastHeartbeatPingAt >= this.liveness.heartbeatIntervalMs) {
|
|
445
|
+
this.lastHeartbeatPingAt = now;
|
|
446
|
+
await this.stream.writeControl(protocol_1.ZLINK_STREAM_HEARTBEAT_PING);
|
|
447
|
+
}
|
|
488
448
|
this.scheduleLivenessCheck();
|
|
489
449
|
}
|
|
490
450
|
async closeForLiveness(reason, closeReason, diagnostic) {
|
|
@@ -496,7 +456,9 @@ class ZLinkStreamSessionRuntime {
|
|
|
496
456
|
this.closeReason = closeReason;
|
|
497
457
|
this.stopLivenessChecks();
|
|
498
458
|
await this.stream.closeForReason(reason, diagnostic);
|
|
499
|
-
|
|
459
|
+
void this.serial
|
|
460
|
+
.executeFinal(async () => this.complete(undefined, true))
|
|
461
|
+
.catch((error) => this.options.onError?.(error));
|
|
500
462
|
}
|
|
501
463
|
stopLivenessChecks() {
|
|
502
464
|
if (this.livenessTimer !== undefined) {
|
|
@@ -609,13 +571,6 @@ class ZLinkStreamSessionRuntime {
|
|
|
609
571
|
onRejected?.();
|
|
610
572
|
}
|
|
611
573
|
}
|
|
612
|
-
enqueueInfrastructure(work, onRejected, onShutdownRejected) {
|
|
613
|
-
if (!this.serial.executeInfrastructure(work, {}, onRejected)) {
|
|
614
|
-
// The serial lane only refuses new work after dispose() closed it.
|
|
615
|
-
onShutdownRejected?.();
|
|
616
|
-
onRejected?.();
|
|
617
|
-
}
|
|
618
|
-
}
|
|
619
574
|
enqueueApplication(work, onRejected, onShutdownRejected) {
|
|
620
575
|
let claim;
|
|
621
576
|
try {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zlink-systems/framework",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.29.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.29.0",
|
|
23
|
+
"@zlink-systems/zlink": "1.17.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 {
|
|
@@ -100,7 +100,6 @@ export interface ZLinkMeshNodeSocketConfig {
|
|
|
100
100
|
sendHighWaterMark: number;
|
|
101
101
|
receiveHighWaterMark: number;
|
|
102
102
|
receiveTimeoutMs?: number;
|
|
103
|
-
sendTimeoutMs?: number;
|
|
104
103
|
}
|
|
105
104
|
|
|
106
105
|
export interface ZLinkStreamSocketConfig {
|
|
@@ -188,6 +187,8 @@ export interface ZLinkFanoutChannelBuilder {
|
|
|
188
187
|
}
|
|
189
188
|
|
|
190
189
|
export interface ZLinkStreamNodeBuilder {
|
|
190
|
+
setHeartbeat(intervalMs: number, timeoutMs: number): this;
|
|
191
|
+
setIdleTimeout(timeoutMs: number): this;
|
|
191
192
|
bind(endpointOrPort?: string | number): this;
|
|
192
193
|
setBindHost(bindHost: string): this;
|
|
193
194
|
setAdvertiseHost(advertiseHost: string): this;
|
|
@@ -22,3 +22,7 @@ export const ZLINK_RELOCATION_MAX_BLOB_REFERENCE_BYTES = 4096;
|
|
|
22
22
|
export const AUTHORITY_ENVELOPE_MAX_BYTES = 1024 * 1024;
|
|
23
23
|
export const CREATION_INTENT_MAX_BYTES = 1024 * 1024;
|
|
24
24
|
export const CREATION_TERMINAL_ENVELOPE_MAX_BYTES = 1024 * 1024;
|
|
25
|
+
|
|
26
|
+
export const DEFAULT_STREAM_HEARTBEAT_INTERVAL_MS = 1_000;
|
|
27
|
+
export const DEFAULT_STREAM_HEARTBEAT_TIMEOUT_MS = 5_000;
|
|
28
|
+
export const DEFAULT_STREAM_IDLE_TIMEOUT_MS = 0;
|
|
@@ -689,6 +689,16 @@ class DefaultClientServerChannelServerBuilder implements ZLinkClientServerChanne
|
|
|
689
689
|
}
|
|
690
690
|
|
|
691
691
|
class DefaultStreamNodeBuilder implements ZLinkStreamNodeBuilder {
|
|
692
|
+
setHeartbeat(intervalMs: number, timeoutMs: number): this {
|
|
693
|
+
this.streamNode.heartbeatIntervalMs = intervalMs;
|
|
694
|
+
this.streamNode.heartbeatTimeoutMs = timeoutMs;
|
|
695
|
+
return this;
|
|
696
|
+
}
|
|
697
|
+
setIdleTimeout(timeoutMs: number): this {
|
|
698
|
+
this.streamNode.idleTimeoutMs = timeoutMs;
|
|
699
|
+
return this;
|
|
700
|
+
}
|
|
701
|
+
|
|
692
702
|
constructor(private readonly streamNode: MutableStreamNodeOptions) {}
|
|
693
703
|
|
|
694
704
|
bind(endpointOrPort: string | number = 0): this {
|
|
@@ -1586,7 +1596,6 @@ interface MutableServerCapabilityOptions {
|
|
|
1586
1596
|
weight?: number;
|
|
1587
1597
|
sendHighWaterMark?: number;
|
|
1588
1598
|
receiveHighWaterMark?: number;
|
|
1589
|
-
sendTimeoutMs?: number;
|
|
1590
1599
|
maxMessageSize?: number;
|
|
1591
1600
|
}
|
|
1592
1601
|
|
|
@@ -1594,7 +1603,6 @@ interface MutableClientCapabilityOptions {
|
|
|
1594
1603
|
manualConnections?: string[];
|
|
1595
1604
|
sendHighWaterMark?: number;
|
|
1596
1605
|
receiveHighWaterMark?: number;
|
|
1597
|
-
sendTimeoutMs?: number;
|
|
1598
1606
|
maxMessageSize?: number;
|
|
1599
1607
|
}
|
|
1600
1608
|
|
|
@@ -1607,6 +1615,9 @@ interface MutablePublisherCapabilityOptions {
|
|
|
1607
1615
|
}
|
|
1608
1616
|
|
|
1609
1617
|
interface MutableStreamNodeOptions {
|
|
1618
|
+
heartbeatIntervalMs?: number;
|
|
1619
|
+
heartbeatTimeoutMs?: number;
|
|
1620
|
+
idleTimeoutMs?: number;
|
|
1610
1621
|
bind?: string;
|
|
1611
1622
|
bindHost?: string;
|
|
1612
1623
|
advertiseHost?: string;
|
|
@@ -1690,7 +1701,6 @@ interface MutableSpotRouterCapabilityOptions {
|
|
|
1690
1701
|
sendHighWaterMark?: number;
|
|
1691
1702
|
receiveHighWaterMark?: number;
|
|
1692
1703
|
receiveTimeoutMs?: number;
|
|
1693
|
-
sendTimeoutMs?: number;
|
|
1694
1704
|
}
|
|
1695
1705
|
|
|
1696
1706
|
interface MutableSpotPubSubCapabilityOptions {
|
|
@@ -21,6 +21,9 @@ import { normalizeEndpoint, parseEndpointHostPort } from './EndpointNotation';
|
|
|
21
21
|
import {
|
|
22
22
|
defaultWorkerMaxThreads,
|
|
23
23
|
DEFAULT_STREAM_NODE_MAX_MESSAGE_SIZE,
|
|
24
|
+
DEFAULT_STREAM_HEARTBEAT_INTERVAL_MS,
|
|
25
|
+
DEFAULT_STREAM_HEARTBEAT_TIMEOUT_MS,
|
|
26
|
+
DEFAULT_STREAM_IDLE_TIMEOUT_MS,
|
|
24
27
|
DEFAULT_WORKER_IDLE_TIMEOUT_MS,
|
|
25
28
|
DEFAULT_WORKER_MIN_THREADS
|
|
26
29
|
} from './InternalDefaults';
|
|
@@ -77,6 +80,27 @@ export function toChannelMap(
|
|
|
77
80
|
);
|
|
78
81
|
}
|
|
79
82
|
|
|
83
|
+
export function normalizeStreamLiveness(
|
|
84
|
+
options: ZLinkStreamNodeOptions
|
|
85
|
+
): Required<
|
|
86
|
+
Pick<ZLinkStreamNodeOptions, 'heartbeatIntervalMs' | 'heartbeatTimeoutMs' | 'idleTimeoutMs'>
|
|
87
|
+
> {
|
|
88
|
+
const heartbeatIntervalMs = options.heartbeatIntervalMs ?? DEFAULT_STREAM_HEARTBEAT_INTERVAL_MS;
|
|
89
|
+
const heartbeatTimeoutMs = options.heartbeatTimeoutMs ?? DEFAULT_STREAM_HEARTBEAT_TIMEOUT_MS;
|
|
90
|
+
const idleTimeoutMs = options.idleTimeoutMs ?? DEFAULT_STREAM_IDLE_TIMEOUT_MS;
|
|
91
|
+
if (!Number.isFinite(heartbeatIntervalMs) || heartbeatIntervalMs <= 0)
|
|
92
|
+
throw new ZLinkConfigurationException('STREAM heartbeat interval must be positive.');
|
|
93
|
+
if (!Number.isFinite(heartbeatTimeoutMs) || heartbeatTimeoutMs <= 0)
|
|
94
|
+
throw new ZLinkConfigurationException('STREAM heartbeat timeout must be positive.');
|
|
95
|
+
if (heartbeatTimeoutMs <= heartbeatIntervalMs)
|
|
96
|
+
throw new ZLinkConfigurationException(
|
|
97
|
+
'STREAM heartbeat timeout must be greater than interval.'
|
|
98
|
+
);
|
|
99
|
+
if (!Number.isFinite(idleTimeoutMs) || idleTimeoutMs < 0)
|
|
100
|
+
throw new ZLinkConfigurationException('STREAM idle timeout must not be negative.');
|
|
101
|
+
return { heartbeatIntervalMs, heartbeatTimeoutMs, idleTimeoutMs };
|
|
102
|
+
}
|
|
103
|
+
|
|
80
104
|
export function toStreamNodeMap(
|
|
81
105
|
streamNodes: ZLinkFrameworkRegistrationOptions['streamNodes'],
|
|
82
106
|
network: ZLinkNetworkOptions
|
|
@@ -88,6 +112,7 @@ export function toStreamNodeMap(
|
|
|
88
112
|
name,
|
|
89
113
|
{
|
|
90
114
|
...normalized,
|
|
115
|
+
...normalizeStreamLiveness(streamNode),
|
|
91
116
|
maxMessageSize: streamNode.maxMessageSize ?? DEFAULT_STREAM_NODE_MAX_MESSAGE_SIZE
|
|
92
117
|
}
|
|
93
118
|
];
|
|
@@ -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,13 +227,15 @@ 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[];
|
|
237
233
|
}
|
|
238
234
|
|
|
239
235
|
export interface ZLinkStreamNodeOptions {
|
|
236
|
+
readonly heartbeatIntervalMs?: number;
|
|
237
|
+
readonly heartbeatTimeoutMs?: number;
|
|
238
|
+
readonly idleTimeoutMs?: number;
|
|
240
239
|
readonly bind?: string;
|
|
241
240
|
readonly bindHost?: string;
|
|
242
241
|
readonly advertiseHost?: string;
|
|
@@ -430,7 +429,6 @@ export interface ZLinkSpotRouterCapabilityOptions {
|
|
|
430
429
|
readonly sendHighWaterMark?: number;
|
|
431
430
|
readonly receiveHighWaterMark?: number;
|
|
432
431
|
readonly receiveTimeoutMs?: number;
|
|
433
|
-
readonly sendTimeoutMs?: number;
|
|
434
432
|
}
|
|
435
433
|
|
|
436
434
|
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,
|