@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
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ZLinkBoundActorRelaySender = exports.DEFAULT_RELAY_ACTOR_BIND_TIMEOUT_MS = void 0;
|
|
4
4
|
const ZLinkDispatchOptions_1 = require("../../contracts/Dispatch/ZLinkDispatchOptions");
|
|
5
|
-
const abort_1 = require("../abort");
|
|
6
5
|
const diagnostics_1 = require("../diagnostics");
|
|
7
6
|
const payload_codec_1 = require("../messaging/payload-codec");
|
|
8
7
|
const submission_result_1 = require("../messaging/submission-result");
|
|
@@ -22,15 +21,15 @@ class ZLinkBoundActorRelaySender {
|
|
|
22
21
|
this.options = options;
|
|
23
22
|
this.lifecycle = lifecycle;
|
|
24
23
|
}
|
|
25
|
-
async relay(actor, payload,
|
|
24
|
+
async relay(actor, payload, dispatchHeader) {
|
|
26
25
|
const header = dispatchHeader === undefined
|
|
27
26
|
? await this.currentHeader(actor)
|
|
28
27
|
: await this.requireDispatchHeader(actor, dispatchHeader);
|
|
29
28
|
if (header.kind === protocol_1.ZLinkStreamMessageKind.Request && header.requestSeq !== undefined) {
|
|
30
29
|
const operation = async () => {
|
|
31
|
-
const admission = await this.routes.beginAcceptedRequestFrameWhenReady(actor.actorId, actor.bindingToken
|
|
30
|
+
const admission = await this.routes.beginAcceptedRequestFrameWhenReady(actor.actorId, actor.bindingToken);
|
|
32
31
|
try {
|
|
33
|
-
return await this.relayAcceptedFrame(actor, payload,
|
|
32
|
+
return await this.relayAcceptedFrame(actor, payload, header, admission);
|
|
34
33
|
}
|
|
35
34
|
finally {
|
|
36
35
|
await admission.complete();
|
|
@@ -38,13 +37,12 @@ class ZLinkBoundActorRelaySender {
|
|
|
38
37
|
};
|
|
39
38
|
return await operation();
|
|
40
39
|
}
|
|
41
|
-
(0, abort_1.throwIfAborted)(signal);
|
|
42
40
|
const held = await this.routes.acceptOneWay(actor.actorId, actor.bindingToken, () => {
|
|
43
41
|
let heldMessage = (0, payload_codec_1.encodeFrameworkPayloadMessage)(payload, this.options.messageSerializers);
|
|
44
42
|
return {
|
|
45
43
|
deliver: async () => {
|
|
46
44
|
try {
|
|
47
|
-
const result = await this.routes.runAcceptedFrameWhenReady(actor.actorId, actor.bindingToken, () => this.relayAcceptedFrame(actor, payload,
|
|
45
|
+
const result = await this.routes.runAcceptedFrameWhenReady(actor.actorId, actor.bindingToken, () => this.relayAcceptedFrame(actor, payload, header, undefined, heldMessage));
|
|
48
46
|
if (result.status !== submission_result_1.ZLinkSubmitStatus.Submitted) {
|
|
49
47
|
this.traceHeldDrop(header, result.status === submission_result_1.ZLinkSubmitStatus.Backpressured ||
|
|
50
48
|
result.status === submission_result_1.ZLinkSubmitStatus.TimedOut
|
|
@@ -69,7 +67,7 @@ class ZLinkBoundActorRelaySender {
|
|
|
69
67
|
if (held) {
|
|
70
68
|
return { status: submission_result_1.ZLinkSubmitStatus.Submitted };
|
|
71
69
|
}
|
|
72
|
-
return this.routes.runAcceptedFrameWhenReady(actor.actorId, actor.bindingToken, () => this.relayAcceptedFrame(actor, payload
|
|
70
|
+
return this.routes.runAcceptedFrameWhenReady(actor.actorId, actor.bindingToken, () => this.relayAcceptedFrame(actor, payload));
|
|
73
71
|
}
|
|
74
72
|
traceHeldDrop(header, reason, error) {
|
|
75
73
|
(0, diagnostics_1.flowIfEnabled)(this.options.dispatchErrors?.flow, ZLinkDispatchOptions_1.ZLinkRuntimeMessageFlowOutcome.Dropped, undefined, header.flowId)?.trace({
|
|
@@ -84,10 +82,10 @@ class ZLinkBoundActorRelaySender {
|
|
|
84
82
|
...(error instanceof Error ? { errorType: error.name, errorMessage: error.message } : {})
|
|
85
83
|
});
|
|
86
84
|
}
|
|
87
|
-
async relayAcceptedFrame(actor, payload,
|
|
85
|
+
async relayAcceptedFrame(actor, payload, header, requestAdmission, acceptedPayload) {
|
|
88
86
|
const activeHeader = header ?? (await this.currentHeader(actor));
|
|
89
87
|
const started = await this.lifecycle.run(actor.actorId, async () => {
|
|
90
|
-
const completion = this.relayInsideLifecycle(actor, payload,
|
|
88
|
+
const completion = this.relayInsideLifecycle(actor, payload, activeHeader, requestAdmission, acceptedPayload);
|
|
91
89
|
if (activeHeader.kind === protocol_1.ZLinkStreamMessageKind.Request &&
|
|
92
90
|
activeHeader.requestSeq !== undefined) {
|
|
93
91
|
// A routed REQUEST only needs this lane while its ordered submission
|
|
@@ -119,16 +117,15 @@ class ZLinkBoundActorRelaySender {
|
|
|
119
117
|
}
|
|
120
118
|
return header;
|
|
121
119
|
}
|
|
122
|
-
async relayInsideLifecycle(actor, payload,
|
|
120
|
+
async relayInsideLifecycle(actor, payload, currentHeader, requestAdmission, acceptedPayload) {
|
|
123
121
|
const header = currentHeader ?? (await this.currentHeader(actor));
|
|
124
|
-
const held = requestAdmission?.beginSubmission(
|
|
122
|
+
const held = requestAdmission?.beginSubmission();
|
|
125
123
|
if (held !== undefined)
|
|
126
124
|
await held;
|
|
127
|
-
(0, abort_1.throwIfAborted)(signal);
|
|
128
125
|
const payloadMessage = acceptedPayload ?? (0, payload_codec_1.encodeFrameworkPayloadMessage)(payload, this.options.messageSerializers);
|
|
129
126
|
try {
|
|
130
127
|
if (this.options.relay !== undefined) {
|
|
131
|
-
const handled = await this.options.relay(actor, header, payloadMessage
|
|
128
|
+
const handled = await this.options.relay(actor, header, payloadMessage);
|
|
132
129
|
if (handled) {
|
|
133
130
|
return { status: submission_result_1.ZLinkSubmitStatus.Submitted };
|
|
134
131
|
}
|
|
@@ -140,7 +137,10 @@ class ZLinkBoundActorRelaySender {
|
|
|
140
137
|
const headerMessage = this.frameMessages.createBinaryMessage((0, protocol_1.encodeStreamHeader)(header));
|
|
141
138
|
const framePayloadMessage = this.frameMessages.createBinaryMessage((0, protocol_1.messageToBytes)(payloadMessage));
|
|
142
139
|
try {
|
|
143
|
-
return await route.context.stream.submitBoundActor(actor.actorId, [
|
|
140
|
+
return await route.context.stream.submitBoundActor(actor.actorId, [
|
|
141
|
+
headerMessage,
|
|
142
|
+
framePayloadMessage
|
|
143
|
+
]);
|
|
144
144
|
}
|
|
145
145
|
finally {
|
|
146
146
|
headerMessage.close();
|
|
@@ -47,7 +47,7 @@ class ZLinkBoundSessionService {
|
|
|
47
47
|
if ((await this.routes.route(actorId))?.bindingToken !== route.bindingToken) {
|
|
48
48
|
return { status: submission_result_1.ZLinkSubmitStatus.TargetNotFound };
|
|
49
49
|
}
|
|
50
|
-
return await route.context.stream.submitRaw(frame
|
|
50
|
+
return await route.context.stream.submitRaw(frame);
|
|
51
51
|
}
|
|
52
52
|
finally {
|
|
53
53
|
frame.close();
|
|
@@ -16,7 +16,6 @@ import { ZLinkStreamCodec, ZLinkStreamMessageKind, type ZLinkStreamFrameHeader,
|
|
|
16
16
|
import { DefaultZLinkSessionActor, DefaultZLinkSessionContext } from './session-context';
|
|
17
17
|
import type { ZLinkActorRouteCommitOptions, ZLinkSessionBindingConfirmationOptions, ZLinkSessionBindingIdentity } from './stream-binding-runtime-ports';
|
|
18
18
|
import { ZLinkStreamSessionNodeRuntime as ZLinkStreamSessionNodeRuntimeCore, ZLinkStreamSessionRuntime as ZLinkStreamSessionRuntimeCore, type ZLinkStreamSessionNodeRuntimeOptions as ZLinkStreamSessionNodeRuntimeCoreOptions, type ZLinkStreamSessionRuntimeOptions as ZLinkStreamSessionRuntimeCoreOptions } from './stream-session-runtime';
|
|
19
|
-
export { ZLinkPendingSessionRequest } from './session-requests';
|
|
20
19
|
export { ZLinkActorSessionLifecycleCoordinator } from './actor-session-lifecycle-coordinator';
|
|
21
20
|
export { ZLinkActorSessionBindingRegistry } from './actor-session-binding-registry';
|
|
22
21
|
export { zlinkStreamLz4CompressionCodec } from './stream-frame-factory';
|
|
@@ -45,7 +44,7 @@ export interface ZLinkStreamBindingRuntimeOptions {
|
|
|
45
44
|
readonly errorSink?: () => {
|
|
46
45
|
reportRuntimeTaskException(taskName: string, error: unknown): void;
|
|
47
46
|
} | undefined;
|
|
48
|
-
readonly relay?: (actor: ZLinkSessionActor, header: ZLinkStreamFrameHeader, payload: Message
|
|
47
|
+
readonly relay?: (actor: ZLinkSessionActor, header: ZLinkStreamFrameHeader, payload: Message) => Promise<boolean>;
|
|
49
48
|
readonly notifyDisconnected?: (actor: ZLinkSessionActor, signal?: AbortSignal) => Promise<void>;
|
|
50
49
|
readonly flowCreationEnabled?: () => boolean;
|
|
51
50
|
readonly metrics?: import('../diagnostics').ZLinkRuntimeMetrics;
|
|
@@ -143,7 +142,7 @@ export declare class ZLinkStreamBindingRuntime {
|
|
|
143
142
|
disconnectNativeBoundSession(node: ZLinkBackendActorSessionNode, actorRef: ActorRef, signal?: AbortSignal): Promise<void>;
|
|
144
143
|
disconnectBoundSession(actorId: string, signal?: AbortSignal): Promise<void>;
|
|
145
144
|
closeSessionBinding(actorId: string, expected: ZLinkSessionBindingIdentity, signal?: AbortSignal): Promise<void>;
|
|
146
|
-
relay(actor: DefaultZLinkSessionActor, payload: ZLinkMessage,
|
|
145
|
+
relay(actor: DefaultZLinkSessionActor, payload: ZLinkMessage, dispatchHeader?: ZLinkStreamFrameHeader): Promise<ZLinkSubmitResult>;
|
|
147
146
|
notifyDisconnected(actor: DefaultZLinkSessionActor, signal?: AbortSignal): Promise<void>;
|
|
148
147
|
createTextMessage(payload: string): Message;
|
|
149
148
|
createBinaryMessage(payload: Uint8Array): Message;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ZLinkStreamBindingRuntime = exports.ZLinkStreamSessionNodeRuntime = exports.ZLinkStreamSessionRuntime = exports.ZLinkStreamRuntimeManager = exports.DefaultZLinkSessionContext = exports.DefaultZLinkSessionActor = exports.DefaultZLinkBoundSessionFactory = exports.DefaultZLinkBoundSession = exports.ZLinkManagedStream = exports.zlinkStreamLz4CompressionCodec = exports.ZLinkActorSessionBindingRegistry = exports.ZLinkActorSessionLifecycleCoordinator =
|
|
3
|
+
exports.ZLinkStreamBindingRuntime = exports.ZLinkStreamSessionNodeRuntime = exports.ZLinkStreamSessionRuntime = exports.ZLinkStreamRuntimeManager = exports.DefaultZLinkSessionContext = exports.DefaultZLinkSessionActor = exports.DefaultZLinkBoundSessionFactory = exports.DefaultZLinkBoundSession = exports.ZLinkManagedStream = exports.zlinkStreamLz4CompressionCodec = exports.ZLinkActorSessionBindingRegistry = exports.ZLinkActorSessionLifecycleCoordinator = void 0;
|
|
4
4
|
const InternalDefaults_1 = require("../../contracts/Configuration/InternalDefaults");
|
|
5
5
|
const Options_1 = require("../../contracts/Locations/Options");
|
|
6
6
|
const configuration_1 = require("../configuration");
|
|
@@ -20,8 +20,6 @@ const stream_frame_factory_1 = require("./stream-frame-factory");
|
|
|
20
20
|
const stream_message_utils_1 = require("./stream-message-utils");
|
|
21
21
|
const stream_session_runtime_1 = require("./stream-session-runtime");
|
|
22
22
|
const DEFAULT_STREAM_SERVICE_SHUTDOWN_TIMEOUT_MS = 1000;
|
|
23
|
-
var session_requests_1 = require("./session-requests");
|
|
24
|
-
Object.defineProperty(exports, "ZLinkPendingSessionRequest", { enumerable: true, get: function () { return session_requests_1.ZLinkPendingSessionRequest; } });
|
|
25
23
|
var actor_session_lifecycle_coordinator_2 = require("./actor-session-lifecycle-coordinator");
|
|
26
24
|
Object.defineProperty(exports, "ZLinkActorSessionLifecycleCoordinator", { enumerable: true, get: function () { return actor_session_lifecycle_coordinator_2.ZLinkActorSessionLifecycleCoordinator; } });
|
|
27
25
|
var actor_session_binding_registry_2 = require("./actor-session-binding-registry");
|
|
@@ -116,6 +114,9 @@ class ZLinkStreamRuntimeManager {
|
|
|
116
114
|
const readablePoller = streamAdapter.createReadablePoller(socket);
|
|
117
115
|
const runtime = new stream_session_runtime_1.ZLinkStreamSessionNodeRuntime({
|
|
118
116
|
nodeName,
|
|
117
|
+
heartbeatIntervalMs: streamNode.heartbeatIntervalMs,
|
|
118
|
+
heartbeatTimeoutMs: streamNode.heartbeatTimeoutMs,
|
|
119
|
+
idleTimeoutMs: streamNode.idleTimeoutMs,
|
|
119
120
|
socket,
|
|
120
121
|
createPacket: () => streamAdapter.createStreamPacket(),
|
|
121
122
|
readablePoller,
|
|
@@ -327,8 +328,8 @@ class ZLinkStreamBindingRuntime {
|
|
|
327
328
|
async closeSessionBinding(actorId, expected, signal) {
|
|
328
329
|
await this.boundSessions.closeSessionBinding(actorId, expected, signal);
|
|
329
330
|
}
|
|
330
|
-
async relay(actor, payload,
|
|
331
|
-
return await this.boundActorRelay.relay(actor, payload,
|
|
331
|
+
async relay(actor, payload, dispatchHeader) {
|
|
332
|
+
return await this.boundActorRelay.relay(actor, payload, dispatchHeader);
|
|
332
333
|
}
|
|
333
334
|
async notifyDisconnected(actor, signal) {
|
|
334
335
|
await this.boundActorRelay.notifyDisconnected(actor, signal);
|
|
@@ -37,8 +37,8 @@ export declare class ZLinkManagedStream implements ZLinkStream {
|
|
|
37
37
|
get remoteAddr(): string | undefined;
|
|
38
38
|
write(payload: ZLinkMessage, flags?: ZLinkBackendSendFlags): boolean;
|
|
39
39
|
writeRaw(payload: Message, flags?: ZLinkBackendSendFlags): boolean;
|
|
40
|
-
submitRaw(payload: Message
|
|
41
|
-
submitBoundActor(actorId: string, parts: readonly Message[]
|
|
40
|
+
submitRaw(payload: Message): Promise<ZLinkSubmitResult>;
|
|
41
|
+
submitBoundActor(actorId: string, parts: readonly Message[]): Promise<ZLinkSubmitResult>;
|
|
42
42
|
close(signal?: AbortSignal): Promise<void>;
|
|
43
43
|
closeForDrain(signal?: AbortSignal): Promise<void>;
|
|
44
44
|
writeControl(name: string): Promise<void>;
|
|
@@ -75,10 +75,9 @@ class ZLinkManagedStream {
|
|
|
75
75
|
writeRaw(payload, flags) {
|
|
76
76
|
return this.socket.send(this.backendRoutingId(), payload, flags ?? 0);
|
|
77
77
|
}
|
|
78
|
-
async submitRaw(payload
|
|
78
|
+
async submitRaw(payload) {
|
|
79
79
|
try {
|
|
80
|
-
(
|
|
81
|
-
await this.socket.submit(this.backendRoutingId(), payload, timeoutMs);
|
|
80
|
+
await this.socket.submit(this.backendRoutingId(), payload);
|
|
82
81
|
return { status: submission_result_1.ZLinkSubmitStatus.Submitted };
|
|
83
82
|
}
|
|
84
83
|
catch (error) {
|
|
@@ -88,8 +87,7 @@ class ZLinkManagedStream {
|
|
|
88
87
|
throw error;
|
|
89
88
|
}
|
|
90
89
|
}
|
|
91
|
-
async submitBoundActor(actorId, parts
|
|
92
|
-
(0, abort_1.throwIfAborted)(signal);
|
|
90
|
+
async submitBoundActor(actorId, parts) {
|
|
93
91
|
return (await this.sendBoundActor(actorId, parts, ZLINK_SEND_DONT_WAIT))
|
|
94
92
|
? { status: submission_result_1.ZLinkSubmitStatus.Submitted }
|
|
95
93
|
: { status: submission_result_1.ZLinkSubmitStatus.Backpressured };
|
|
@@ -9,7 +9,6 @@ const actor_packet_relay_wire_1 = require("../actors/actor-packet-relay-wire");
|
|
|
9
9
|
const bound_session_wire_1 = require("../actors/bound-session-wire");
|
|
10
10
|
const actor_routed_json_request_1 = require("../actors/actor-routed-json-request");
|
|
11
11
|
const protocol_1 = require("./protocol");
|
|
12
|
-
const abort_1 = require("../abort");
|
|
13
12
|
const packet_name_1 = require("../messaging/packet-name");
|
|
14
13
|
const flow_context_1 = require("../diagnostics/flow-context");
|
|
15
14
|
class ZLinkNativeFallbackBoundSession {
|
|
@@ -45,8 +44,7 @@ class ZLinkNativeFallbackBoundSession {
|
|
|
45
44
|
return;
|
|
46
45
|
}
|
|
47
46
|
await this.options.routedTransport.sendToSpot(target, payload, {
|
|
48
|
-
packetName: actors_1.ZLINK_REMOTE_ACTOR_PACKET_RELAY_PACKET
|
|
49
|
-
signal
|
|
47
|
+
packetName: actors_1.ZLINK_REMOTE_ACTOR_PACKET_RELAY_PACKET
|
|
50
48
|
});
|
|
51
49
|
return;
|
|
52
50
|
}
|
|
@@ -80,28 +78,27 @@ class ZLinkNativeFallbackBoundSessionSendCall {
|
|
|
80
78
|
this.selectedPacketName = packetName;
|
|
81
79
|
return this;
|
|
82
80
|
}
|
|
83
|
-
async submit(
|
|
81
|
+
async submit() {
|
|
84
82
|
if (this.executed) {
|
|
85
83
|
(0, submission_result_1.throwAlreadySubmitted)('Bound session send call');
|
|
86
84
|
}
|
|
87
85
|
const packetName = (0, packet_name_1.resolveFrameworkPacketName)(this.message, this.selectedPacketName, 'Bound session');
|
|
88
86
|
this.executed = true;
|
|
89
|
-
|
|
90
|
-
const result = await this.execute(packetName, signal);
|
|
87
|
+
const result = await this.execute(packetName);
|
|
91
88
|
(0, submission_result_1.requireOneWayCompletion)(result, 'Bound session send', framework_errors_internal_1.ZLinkFrameworkInternalErrorKind.ActorSessionNotBound);
|
|
92
89
|
}
|
|
93
|
-
execute(packetName
|
|
90
|
+
execute(packetName) {
|
|
94
91
|
// Call-scoped flow (spec 27 §4): the relay JSON flow pair and any nested
|
|
95
92
|
// routed-transport envelope share one ambient flow that does not outlive
|
|
96
93
|
// this submit call.
|
|
97
|
-
return (0, flow_context_1.runWithOutboundFlow)(this.options.flowCreationEnabled?.() ?? true, () => this.executeScoped(packetName
|
|
94
|
+
return (0, flow_context_1.runWithOutboundFlow)(this.options.flowCreationEnabled?.() ?? true, () => this.executeScoped(packetName));
|
|
98
95
|
}
|
|
99
|
-
async executeScoped(packetName
|
|
96
|
+
async executeScoped(packetName) {
|
|
100
97
|
const localActor = this.options.localActorProvider?.() === true;
|
|
101
98
|
const remoteTarget = this.options.remoteBoundSessionTargetProvider();
|
|
102
99
|
let nativeAttempted = false;
|
|
103
100
|
if (localActor) {
|
|
104
|
-
const result = await this.options.runtime.submitLocalBoundSession(this.options.actorId, this.message, packetName, this.selectedMetadata
|
|
101
|
+
const result = await this.options.runtime.submitLocalBoundSession(this.options.actorId, this.message, packetName, this.selectedMetadata);
|
|
105
102
|
if (result.status !== submission_result_1.ZLinkSubmitStatus.TargetNotFound) {
|
|
106
103
|
this.traceSubmitted(result, packetName);
|
|
107
104
|
return result;
|
|
@@ -115,7 +112,7 @@ class ZLinkNativeFallbackBoundSessionSendCall {
|
|
|
115
112
|
const bindingGeneration = currentBindingGeneration(actorRef);
|
|
116
113
|
if (actorRef !== undefined && node !== undefined && bindingGeneration !== undefined) {
|
|
117
114
|
nativeAttempted = true;
|
|
118
|
-
const result = await this.options.runtime.sendNativeBoundSession(node, actorRef, this.message, packetName, this.selectedMetadata
|
|
115
|
+
const result = await this.options.runtime.sendNativeBoundSession(node, actorRef, this.message, packetName, this.selectedMetadata);
|
|
119
116
|
if (result.status !== submission_result_1.ZLinkSubmitStatus.TargetNotFound) {
|
|
120
117
|
this.traceSubmitted(result, packetName);
|
|
121
118
|
return result;
|
|
@@ -150,12 +147,12 @@ class ZLinkNativeFallbackBoundSessionSendCall {
|
|
|
150
147
|
targetNodeRid: remoteTarget.targetNodeRid,
|
|
151
148
|
spotId: remoteTarget.spotId,
|
|
152
149
|
spotKind: contracts_1.ZLinkSpotKind.Entry
|
|
153
|
-
}, payload, { packetName: actors_1.ZLINK_REMOTE_BOUND_SESSION_SEND_PACKET
|
|
154
|
-
: await submit.call(this.options.routedTransport, remoteTarget.routerChannelId, String(remoteTarget.targetNodeRid), actors_1.ZLINK_REMOTE_BOUND_SESSION_SEND_PACKET, payload
|
|
150
|
+
}, payload, { packetName: actors_1.ZLINK_REMOTE_BOUND_SESSION_SEND_PACKET })
|
|
151
|
+
: await submit.call(this.options.routedTransport, remoteTarget.routerChannelId, String(remoteTarget.targetNodeRid), actors_1.ZLINK_REMOTE_BOUND_SESSION_SEND_PACKET, payload);
|
|
155
152
|
this.traceSubmitted(result, packetName);
|
|
156
153
|
return result;
|
|
157
154
|
}
|
|
158
|
-
const localResult = await this.options.runtime.submitLocalBoundSession(this.options.actorId, this.message, packetName, this.selectedMetadata
|
|
155
|
+
const localResult = await this.options.runtime.submitLocalBoundSession(this.options.actorId, this.message, packetName, this.selectedMetadata);
|
|
159
156
|
if (localResult.status !== submission_result_1.ZLinkSubmitStatus.TargetNotFound) {
|
|
160
157
|
this.traceSubmitted(localResult, packetName);
|
|
161
158
|
return localResult;
|
|
@@ -167,14 +164,14 @@ class ZLinkNativeFallbackBoundSessionSendCall {
|
|
|
167
164
|
actorRef !== undefined &&
|
|
168
165
|
node !== undefined &&
|
|
169
166
|
bindingGeneration !== undefined) {
|
|
170
|
-
const result = await this.options.runtime.sendNativeBoundSession(node, actorRef, this.message, packetName, this.selectedMetadata
|
|
167
|
+
const result = await this.options.runtime.sendNativeBoundSession(node, actorRef, this.message, packetName, this.selectedMetadata);
|
|
171
168
|
this.traceSubmitted(result, packetName);
|
|
172
169
|
return result;
|
|
173
170
|
}
|
|
174
171
|
if (localActor) {
|
|
175
172
|
throw (0, framework_errors_internal_1.createInternalFrameworkException)(framework_errors_internal_1.ZLinkFrameworkInternalErrorKind.ActorSessionNotBound, `No current session binding exists for actor '${this.options.actorId}'.`, true);
|
|
176
173
|
}
|
|
177
|
-
const result = await this.options.runtime.sendBoundSession(this.options.actorId, this.message, packetName, this.selectedMetadata
|
|
174
|
+
const result = await this.options.runtime.sendBoundSession(this.options.actorId, this.message, packetName, this.selectedMetadata);
|
|
178
175
|
this.traceSubmitted(result, packetName);
|
|
179
176
|
return result;
|
|
180
177
|
}
|
|
@@ -118,15 +118,6 @@ function decodeStreamHeader(header, flowEnabled = true) {
|
|
|
118
118
|
const decoded = (0, stream_wire_1.decodeStreamWireHeader)(header, undefined, flowEnabled);
|
|
119
119
|
const kind = decoded.kind;
|
|
120
120
|
const flags = decoded.flags;
|
|
121
|
-
const hasRequestSeq = (flags & stream_wire_1.ZlinkStreamHeaderFlags.HasRequestSeq) !== 0;
|
|
122
|
-
const hasMetadata = (flags & stream_wire_1.ZlinkStreamHeaderFlags.HasMetadata) !== 0;
|
|
123
|
-
const hasCorrelation = (flags & stream_wire_1.ZlinkStreamHeaderFlags.HasCorrelationId) !== 0;
|
|
124
|
-
const hasFlow = (flags & stream_wire_1.ZlinkStreamHeaderFlags.HasFlowId) !== 0;
|
|
125
|
-
const hasActorSlot = (flags & stream_wire_1.ZlinkStreamHeaderFlags.HasActorSlot) !== 0;
|
|
126
|
-
if (kind === stream_wire_1.ZlinkStreamMessageKind.Control &&
|
|
127
|
-
(hasCorrelation || hasRequestSeq || hasMetadata || hasFlow || hasActorSlot)) {
|
|
128
|
-
throw new Error('Control packet must not contain a request sequence, metadata, correlation id, or flow id.');
|
|
129
|
-
}
|
|
130
121
|
const metadata = publicStreamMetadata(decoded.metadata);
|
|
131
122
|
return {
|
|
132
123
|
kind,
|
|
@@ -3,12 +3,12 @@ import type { Message } from '../../contracts/Common/Message';
|
|
|
3
3
|
import { type ZLinkSubmitResult } from '../messaging/submission-result';
|
|
4
4
|
import { type ZLinkStreamFrameHeader, ZLinkStreamMessageKind, type ZLinkStreamReplyMessageKind } from './protocol';
|
|
5
5
|
export interface ZLinkBoundSessionSendRuntime {
|
|
6
|
-
sendBoundSession(actorId: string, message: unknown, packetName: string | undefined, metadata: ReadonlyMap<string, string
|
|
6
|
+
sendBoundSession(actorId: string, message: unknown, packetName: string | undefined, metadata: ReadonlyMap<string, string>): Promise<ZLinkSubmitResult>;
|
|
7
7
|
}
|
|
8
8
|
export interface ZLinkSessionCallContext {
|
|
9
9
|
readonly stream: {
|
|
10
10
|
writeRaw(payload: Message): boolean;
|
|
11
|
-
submitRaw(payload: Message
|
|
11
|
+
submitRaw(payload: Message): Promise<ZLinkSubmitResult>;
|
|
12
12
|
};
|
|
13
13
|
readonly dispatchHeader: ZLinkStreamFrameHeader | undefined;
|
|
14
14
|
createJsonFrameMessage(kind: ZLinkStreamMessageKind, packetName: string, metadata: ReadonlyMap<string, string>, compressed: boolean, requestSeq: bigint | undefined, payload: unknown, correlationId?: string): Message;
|
|
@@ -31,7 +31,7 @@ export declare class DefaultZLinkBoundSessionSendCall implements ZLinkBoundSessi
|
|
|
31
31
|
constructor(runtime: ZLinkBoundSessionSendRuntime, actorId: string, message: unknown);
|
|
32
32
|
metadata(key: string, value: string): this;
|
|
33
33
|
packetName(packetName: string): this;
|
|
34
|
-
submit(
|
|
34
|
+
submit(): Promise<void>;
|
|
35
35
|
}
|
|
36
36
|
export declare class DefaultZLinkSessionSendCall implements ZLinkSessionSendCall {
|
|
37
37
|
private readonly context;
|
|
@@ -39,14 +39,12 @@ export declare class DefaultZLinkSessionSendCall implements ZLinkSessionSendCall
|
|
|
39
39
|
private selectedPacketName;
|
|
40
40
|
private readonly selectedMetadata;
|
|
41
41
|
private compressionEnabled;
|
|
42
|
-
private selectedTimeoutMs;
|
|
43
42
|
private executed;
|
|
44
43
|
constructor(context: ZLinkSessionCallContext, message: unknown);
|
|
45
44
|
metadata(key: string, value: string): this;
|
|
46
45
|
packetName(packetName: string): this;
|
|
47
46
|
compress(enabled?: boolean): this;
|
|
48
|
-
|
|
49
|
-
submit(signal?: AbortSignal): Promise<void>;
|
|
47
|
+
submit(): Promise<void>;
|
|
50
48
|
}
|
|
51
49
|
export declare class DefaultZLinkSessionReplyCall implements ZLinkSessionReplyCall {
|
|
52
50
|
private readonly context;
|
|
@@ -55,5 +53,5 @@ export declare class DefaultZLinkSessionReplyCall implements ZLinkSessionReplyCa
|
|
|
55
53
|
private executed;
|
|
56
54
|
constructor(context: ZLinkSessionCallContext, message: unknown);
|
|
57
55
|
compress(enabled?: boolean): this;
|
|
58
|
-
submit(
|
|
56
|
+
submit(): Promise<void>;
|
|
59
57
|
}
|
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.DefaultZLinkSessionReplyCall = exports.DefaultZLinkSessionSendCall = exports.DefaultZLinkBoundSessionSendCall = void 0;
|
|
4
|
-
const SendTimeoutValidation_1 = require("../../contracts/Configuration/SendTimeoutValidation");
|
|
5
|
-
const abort_1 = require("../abort");
|
|
6
|
-
const configuration_1 = require("../configuration");
|
|
7
4
|
const framework_errors_internal_1 = require("../framework-errors-internal");
|
|
8
5
|
const submission_result_1 = require("../messaging/submission-result");
|
|
9
6
|
const protocol_1 = require("./protocol");
|
|
@@ -27,12 +24,11 @@ class DefaultZLinkBoundSessionSendCall {
|
|
|
27
24
|
this.selectedPacketName = packetName;
|
|
28
25
|
return this;
|
|
29
26
|
}
|
|
30
|
-
async submit(
|
|
27
|
+
async submit() {
|
|
31
28
|
(0, protocol_1.ensureSingleSubmit)(this.executed);
|
|
32
29
|
const packetName = (0, protocol_1.resolvePacketName)(this.message, this.selectedPacketName);
|
|
33
30
|
this.executed = true;
|
|
34
|
-
(
|
|
35
|
-
const result = await this.runtime.sendBoundSession(this.actorId, this.message, packetName, this.selectedMetadata, signal);
|
|
31
|
+
const result = await this.runtime.sendBoundSession(this.actorId, this.message, packetName, this.selectedMetadata);
|
|
36
32
|
(0, submission_result_1.requireOneWayCompletion)(result, 'Bound session send', framework_errors_internal_1.ZLinkFrameworkInternalErrorKind.ActorSessionNotBound);
|
|
37
33
|
}
|
|
38
34
|
}
|
|
@@ -43,7 +39,6 @@ class DefaultZLinkSessionSendCall {
|
|
|
43
39
|
selectedPacketName;
|
|
44
40
|
selectedMetadata = new Map();
|
|
45
41
|
compressionEnabled = false;
|
|
46
|
-
selectedTimeoutMs;
|
|
47
42
|
executed = false;
|
|
48
43
|
constructor(context, message) {
|
|
49
44
|
this.context = context;
|
|
@@ -61,21 +56,13 @@ class DefaultZLinkSessionSendCall {
|
|
|
61
56
|
this.compressionEnabled = enabled;
|
|
62
57
|
return this;
|
|
63
58
|
}
|
|
64
|
-
|
|
65
|
-
if (!Number.isInteger(timeoutMs) || timeoutMs < 1 || timeoutMs > SendTimeoutValidation_1.ZLINK_MAX_SEND_TIMEOUT_MS) {
|
|
66
|
-
throw new configuration_1.ZLinkConfigurationException(`STREAM session send timeout must be an integer from 1 through ${SendTimeoutValidation_1.ZLINK_MAX_SEND_TIMEOUT_MS} milliseconds.`);
|
|
67
|
-
}
|
|
68
|
-
this.selectedTimeoutMs = timeoutMs;
|
|
69
|
-
return this;
|
|
70
|
-
}
|
|
71
|
-
async submit(signal) {
|
|
59
|
+
async submit() {
|
|
72
60
|
(0, protocol_1.ensureSingleSubmit)(this.executed);
|
|
73
61
|
const packetName = (0, protocol_1.resolvePacketName)(this.message, this.selectedPacketName);
|
|
74
62
|
this.executed = true;
|
|
75
|
-
(0, abort_1.throwIfAborted)(signal);
|
|
76
63
|
const message = this.context.createJsonFrameMessage(protocol_1.ZLinkStreamMessageKind.Send, packetName, this.selectedMetadata, this.compressionEnabled, undefined, this.message);
|
|
77
64
|
try {
|
|
78
|
-
const result = await this.context.stream.submitRaw(message
|
|
65
|
+
const result = await this.context.stream.submitRaw(message);
|
|
79
66
|
(0, submission_result_1.requireOneWayCompletion)(result, 'STREAM session send');
|
|
80
67
|
this.context.traceFrameWritten?.(protocol_1.ZLinkStreamMessageKind.Send, packetName, undefined);
|
|
81
68
|
}
|
|
@@ -98,7 +85,7 @@ class DefaultZLinkSessionReplyCall {
|
|
|
98
85
|
this.compressionEnabled = enabled;
|
|
99
86
|
return this;
|
|
100
87
|
}
|
|
101
|
-
async submit(
|
|
88
|
+
async submit() {
|
|
102
89
|
(0, protocol_1.ensureSingleSubmit)(this.executed);
|
|
103
90
|
this.executed = true;
|
|
104
91
|
const requestHeader = this.context.dispatchHeader;
|
|
@@ -106,13 +93,9 @@ class DefaultZLinkSessionReplyCall {
|
|
|
106
93
|
throw new Error('Reply is only available while handling a request packet.');
|
|
107
94
|
}
|
|
108
95
|
this.context.claimReply(requestHeader);
|
|
109
|
-
// Reply-token validity wins over caller cancellation. Claiming before the
|
|
110
|
-
// pre-cancel check keeps duplicate calls deterministic while still making
|
|
111
|
-
// a pre-cancelled first call perform no transport admission.
|
|
112
|
-
(0, abort_1.throwIfAborted)(signal);
|
|
113
96
|
const message = this.context.createJsonReplyFrameMessage(requestHeader, protocol_1.ZLinkStreamMessageKind.Response, new Map(), this.compressionEnabled, this.message);
|
|
114
97
|
try {
|
|
115
|
-
const result = await this.context.stream.submitRaw(message
|
|
98
|
+
const result = await this.context.stream.submitRaw(message);
|
|
116
99
|
(0, submission_result_1.requireOneWayCompletion)(result, 'STREAM session reply');
|
|
117
100
|
this.context.traceFrameWritten?.(protocol_1.ZLinkStreamMessageKind.Response, requestHeader.name, requestHeader.correlationId);
|
|
118
101
|
}
|
|
@@ -6,10 +6,9 @@ import type { ServiceRetiredBoundSessionRouteFence } from '../foundation/service
|
|
|
6
6
|
import { type ZLinkSubmitResult } from '../messaging/submission-result';
|
|
7
7
|
import { ZLinkStreamMessageKind, type ZLinkStreamFrameHeader, type ZLinkStreamReplyMessageKind } from './protocol';
|
|
8
8
|
import { DefaultZLinkBoundSessionSendCall } from './session-calls';
|
|
9
|
-
import { type ZLinkPendingSessionRequest } from './session-requests';
|
|
10
9
|
export interface ZLinkSessionContextStream extends ZLinkStream {
|
|
11
10
|
writeRaw(payload: Message, flags?: number): boolean;
|
|
12
|
-
submitRaw(payload: Message
|
|
11
|
+
submitRaw(payload: Message): Promise<ZLinkSubmitResult>;
|
|
13
12
|
enqueueActorBound?(actorSlot: number, actorId: string): Promise<void>;
|
|
14
13
|
enqueueActorUnbound?(actorSlot: number): Promise<void>;
|
|
15
14
|
}
|
|
@@ -22,7 +21,7 @@ interface ZLinkSessionContextRuntime {
|
|
|
22
21
|
decompressPayload(payload: Message): Message;
|
|
23
22
|
bind(context: DefaultZLinkSessionContext, actor: ZLinkActor | ActorRef, signal?: AbortSignal): Promise<DefaultZLinkSessionActor>;
|
|
24
23
|
bindOrGet(context: DefaultZLinkSessionContext, actorRef: ActorRef, signal?: AbortSignal): Promise<DefaultZLinkSessionActor>;
|
|
25
|
-
relay(actor: DefaultZLinkSessionActor, payload: ZLinkMessage,
|
|
24
|
+
relay(actor: DefaultZLinkSessionActor, payload: ZLinkMessage, dispatchHeader?: ZLinkStreamFrameHeader): Promise<ZLinkSubmitResult>;
|
|
26
25
|
notifyDisconnected(actor: DefaultZLinkSessionActor, signal?: AbortSignal): Promise<void>;
|
|
27
26
|
}
|
|
28
27
|
export type ZLinkActorBindingReplacementHandler = (actor: ServiceActorRef, retiredSession: ServiceRetiredBoundSessionRouteFence) => void;
|
|
@@ -42,7 +41,6 @@ export declare class DefaultZLinkSessionContext implements ZLinkSessionContext {
|
|
|
42
41
|
private readonly handlerRegistry;
|
|
43
42
|
readonly handlers: ZLinkSessionHandlerRegistry;
|
|
44
43
|
private readonly localActors;
|
|
45
|
-
private readonly requests;
|
|
46
44
|
private currentDispatchHeader;
|
|
47
45
|
private currentReplyClaimed;
|
|
48
46
|
private actorBindingReplacementHandler?;
|
|
@@ -73,8 +71,6 @@ export declare class DefaultZLinkSessionContext implements ZLinkSessionContext {
|
|
|
73
71
|
/** True while the current request dispatch has already submitted its reply. */
|
|
74
72
|
get replyClaimed(): boolean;
|
|
75
73
|
claimReply(requestHeader: ZLinkStreamFrameHeader): void;
|
|
76
|
-
startRequest(timeoutMs?: number): ZLinkPendingSessionRequest;
|
|
77
|
-
tryCompleteResponse(header: ZLinkStreamFrameHeader, payload: Message): boolean;
|
|
78
74
|
payloadForHeader(header: ZLinkStreamFrameHeader, payload: Message): Message;
|
|
79
75
|
get boundActors(): readonly DefaultZLinkSessionActor[];
|
|
80
76
|
findBoundActor(actorId: string): DefaultZLinkSessionActor | undefined;
|
|
@@ -95,8 +91,8 @@ export declare class DefaultZLinkSessionActor implements ZLinkSessionActor {
|
|
|
95
91
|
constructor(runtime: ZLinkSessionContextRuntime, ref: ActorRef, bindingToken: string);
|
|
96
92
|
get ref(): ActorRef;
|
|
97
93
|
updateRef(ref: ActorRef): void;
|
|
98
|
-
relay(payload: ZLinkMessage
|
|
99
|
-
relay(dispatch: ZLinkSessionDispatchContext, payload: ZLinkMessage
|
|
94
|
+
relay(payload: ZLinkMessage): Promise<void>;
|
|
95
|
+
relay(dispatch: ZLinkSessionDispatchContext, payload: ZLinkMessage): Promise<void>;
|
|
100
96
|
notifyDisconnected(signal?: AbortSignal): Promise<void>;
|
|
101
97
|
}
|
|
102
98
|
export declare function createSessionDispatchContext(header: ZLinkStreamFrameHeader, actor?: DefaultZLinkSessionActor): ZLinkSessionDispatchContext;
|
|
@@ -12,7 +12,6 @@ const submission_result_1 = require("../messaging/submission-result");
|
|
|
12
12
|
const protocol_1 = require("./protocol");
|
|
13
13
|
const session_calls_1 = require("./session-calls");
|
|
14
14
|
const session_local_actors_1 = require("./session-local-actors");
|
|
15
|
-
const session_requests_1 = require("./session-requests");
|
|
16
15
|
class DefaultZLinkSessionContext {
|
|
17
16
|
runtime;
|
|
18
17
|
stream;
|
|
@@ -22,7 +21,6 @@ class DefaultZLinkSessionContext {
|
|
|
22
21
|
handlerRegistry;
|
|
23
22
|
handlers;
|
|
24
23
|
localActors = new session_local_actors_1.ZLinkSessionLocalActorBindings();
|
|
25
|
-
requests = new session_requests_1.ZLinkSessionRequestTracker();
|
|
26
24
|
currentDispatchHeader;
|
|
27
25
|
currentReplyClaimed = false;
|
|
28
26
|
actorBindingReplacementHandler;
|
|
@@ -137,21 +135,6 @@ class DefaultZLinkSessionContext {
|
|
|
137
135
|
}
|
|
138
136
|
this.currentReplyClaimed = true;
|
|
139
137
|
}
|
|
140
|
-
startRequest(timeoutMs) {
|
|
141
|
-
return this.requests.start(timeoutMs);
|
|
142
|
-
}
|
|
143
|
-
tryCompleteResponse(header, payload) {
|
|
144
|
-
if (header.requestSeq === undefined) {
|
|
145
|
-
return false;
|
|
146
|
-
}
|
|
147
|
-
if (header.kind === protocol_1.ZLinkStreamMessageKind.Response) {
|
|
148
|
-
return this.requests.complete(header.requestSeq, payload);
|
|
149
|
-
}
|
|
150
|
-
if (header.kind === protocol_1.ZLinkStreamMessageKind.Error) {
|
|
151
|
-
return this.requests.fail(header.requestSeq, decodeStreamErrorPayload(payload));
|
|
152
|
-
}
|
|
153
|
-
return false;
|
|
154
|
-
}
|
|
155
138
|
payloadForHeader(header, payload) {
|
|
156
139
|
if ((header.flags & protocol_1.ZLinkStreamHeaderFlags.PayloadCompressed) === 0) {
|
|
157
140
|
return payload;
|
|
@@ -306,21 +289,18 @@ class DefaultZLinkSessionActor {
|
|
|
306
289
|
}
|
|
307
290
|
this.currentRef = ref;
|
|
308
291
|
}
|
|
309
|
-
async relay(dispatchOrPayload,
|
|
292
|
+
async relay(dispatchOrPayload, selectedPayload) {
|
|
310
293
|
const dispatch = isSessionDispatchContext(dispatchOrPayload) ? dispatchOrPayload : undefined;
|
|
311
294
|
let payload;
|
|
312
|
-
let relaySignal;
|
|
313
295
|
let header;
|
|
314
296
|
if (dispatch === undefined) {
|
|
315
297
|
payload = dispatchOrPayload;
|
|
316
|
-
relaySignal = payloadOrSignal;
|
|
317
298
|
}
|
|
318
299
|
else {
|
|
319
|
-
payload =
|
|
320
|
-
relaySignal = signal;
|
|
300
|
+
payload = selectedPayload;
|
|
321
301
|
header = sessionDispatchHeader(dispatch);
|
|
322
302
|
}
|
|
323
|
-
const result = await this.runtime.relay(this, payload,
|
|
303
|
+
const result = await this.runtime.relay(this, payload, header);
|
|
324
304
|
(0, submission_result_1.requireOneWayCompletion)(result, 'Session Actor relay', framework_errors_internal_1.ZLinkFrameworkInternalErrorKind.ActorSessionNotBound);
|
|
325
305
|
}
|
|
326
306
|
notifyDisconnected(signal) {
|
|
@@ -377,15 +357,6 @@ class DefaultZLinkBoundSessionFactory {
|
|
|
377
357
|
}
|
|
378
358
|
}
|
|
379
359
|
exports.DefaultZLinkBoundSessionFactory = DefaultZLinkBoundSessionFactory;
|
|
380
|
-
function decodeStreamErrorPayload(payload) {
|
|
381
|
-
try {
|
|
382
|
-
const value = JSON.parse(Buffer.from((0, protocol_1.messageToBytes)(payload)).toString());
|
|
383
|
-
return new Error(typeof value.message === 'string' ? value.message : 'Stream request failed.');
|
|
384
|
-
}
|
|
385
|
-
catch {
|
|
386
|
-
return new Error('Stream request failed.');
|
|
387
|
-
}
|
|
388
|
-
}
|
|
389
360
|
function sameRetiredSession(left, right) {
|
|
390
361
|
return (left.sessionOwnerNodeRid === right.sessionOwnerNodeRid &&
|
|
391
362
|
left.sessionOwnerNodeGeneration === right.sessionOwnerNodeGeneration &&
|
|
@@ -4,7 +4,6 @@ export declare class ZLinkSessionSerialExecutor {
|
|
|
4
4
|
private closed;
|
|
5
5
|
executeApplication(work: () => Promise<void>, options?: Omit<ZLinkSerialWorkOptions, 'lane'>, onRejected?: (error?: unknown) => void): boolean;
|
|
6
6
|
executeControl(work: () => Promise<void>, options?: Omit<ZLinkSerialWorkOptions, 'lane'>, onRejected?: (error?: unknown) => void): boolean;
|
|
7
|
-
executeInfrastructure(work: () => Promise<void>, options?: Omit<ZLinkSerialWorkOptions, 'lane'>, onRejected?: (error?: unknown) => void): boolean;
|
|
8
7
|
executeFinal(work: () => Promise<void>): Promise<void>;
|
|
9
8
|
private submit;
|
|
10
9
|
dispose(): Promise<void>;
|
|
@@ -13,9 +13,6 @@ class ZLinkSessionSerialExecutor {
|
|
|
13
13
|
executeControl(work, options = {}, onRejected) {
|
|
14
14
|
return this.submit(work, 'lifecycle', options, onRejected);
|
|
15
15
|
}
|
|
16
|
-
executeInfrastructure(work, options = {}, onRejected) {
|
|
17
|
-
return this.submit(work, 'lifecycle', options, onRejected);
|
|
18
|
-
}
|
|
19
16
|
executeFinal(work) {
|
|
20
17
|
if (this.closed) {
|
|
21
18
|
return Promise.reject((0, framework_errors_internal_1.createInternalFrameworkException)(framework_errors_internal_1.ZLinkFrameworkInternalErrorKind.RuntimeShutdown, 'Session execution queue is closed.'));
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import type { Message } from '../../contracts/Common/Message';
|
|
2
|
-
export declare function copyMessage(message: Message): Message;
|
|
3
2
|
export declare function simpleMessage(bytes: Uint8Array): unknown;
|
|
4
3
|
/** Create the structural Message used by the internal receive assembler. */
|
|
5
4
|
export declare function ownedMessage(bytes: Uint8Array): Message;
|
|
@@ -1,30 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.copyMessage = copyMessage;
|
|
4
3
|
exports.simpleMessage = simpleMessage;
|
|
5
4
|
exports.ownedMessage = ownedMessage;
|
|
6
5
|
const framework_json_v1_1 = require("../messaging/framework-json-v1");
|
|
7
6
|
const protocol_1 = require("./protocol");
|
|
8
7
|
const EMPTY_MESSAGE_BYTES = new Uint8Array(0);
|
|
9
|
-
function copyMessage(message) {
|
|
10
|
-
const value = message;
|
|
11
|
-
if (value.copy !== undefined) {
|
|
12
|
-
return value.copy();
|
|
13
|
-
}
|
|
14
|
-
if (value.toBytes !== undefined) {
|
|
15
|
-
return simpleMessage(value.toBytes());
|
|
16
|
-
}
|
|
17
|
-
if (value.data !== undefined) {
|
|
18
|
-
return simpleMessage(value.data());
|
|
19
|
-
}
|
|
20
|
-
if (value.bytes !== undefined) {
|
|
21
|
-
return simpleMessage(value.bytes);
|
|
22
|
-
}
|
|
23
|
-
if (value.getString !== undefined) {
|
|
24
|
-
return simpleMessage((0, protocol_1.utf8Encode)(value.getString()));
|
|
25
|
-
}
|
|
26
|
-
throw new Error('Stream response payload cannot be copied.');
|
|
27
|
-
}
|
|
28
8
|
function simpleMessage(bytes) {
|
|
29
9
|
return createSimpleMessage(new Uint8Array(bytes), false);
|
|
30
10
|
}
|