@zlink-systems/framework 0.31.0 → 0.32.1
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/ZLinkActor.d.ts +2 -0
- package/dist/contracts/Actors/ZLinkSessionBindingIdentity.d.ts +6 -0
- package/dist/contracts/Actors/ZLinkSessionBindingIdentity.js +2 -0
- package/dist/contracts/Actors/index.d.ts +1 -0
- package/dist/contracts/Actors/index.js +1 -0
- package/dist/contracts/Common/payload-slab.d.ts +4 -0
- package/dist/contracts/Common/payload-slab.js +30 -0
- package/dist/contracts/Handlers/Contexts.d.ts +1 -0
- package/dist/internal.d.ts +9 -0
- package/dist/internal.js +23 -1
- package/dist/runtime/actors/actor-client.d.ts +1 -1
- package/dist/runtime/actors/actor-client.js +32 -23
- package/dist/runtime/actors/actor-context.js +1 -1
- package/dist/runtime/actors/actor-creation.js +1 -1
- package/dist/runtime/actors/actor-mailbox.d.ts +1 -1
- package/dist/runtime/actors/actor-runtime-state.d.ts +3 -2
- package/dist/runtime/actors/actor-runtime-state.js +24 -8
- package/dist/runtime/actors/index.d.ts +3 -3
- package/dist/runtime/actors/index.js +19 -32
- package/dist/runtime/actors/spot-actor-dispatch.d.ts +4 -2
- package/dist/runtime/actors/spot-actor-dispatch.js +2 -1
- package/dist/runtime/application-jobs/application-ingress-record-owner.d.ts +1 -0
- package/dist/runtime/application-jobs/application-ingress-record-owner.js +3 -0
- package/dist/runtime/backend/contracts/index.d.ts +2 -0
- package/dist/runtime/backend/mesh-completion-table.d.ts +1 -0
- package/dist/runtime/backend/mesh-completion-table.js +1 -0
- package/dist/runtime/backend/node/node-mesh-backend-adapter.js +5 -1
- package/dist/runtime/backend/node/node-raw-binding-port.d.ts +7 -2
- package/dist/runtime/backend/node/node-raw-binding-port.js +17 -11
- package/dist/runtime/backend/node/node-raw-mesh-backend.d.ts +2 -2
- package/dist/runtime/backend/node/node-raw-mesh-backend.js +15 -8
- package/dist/runtime/channels/channel-dispatch-pipeline.d.ts +7 -6
- package/dist/runtime/channels/channel-dispatch-pipeline.js +1 -0
- package/dist/runtime/channels/channel-dispatchers.d.ts +7 -3
- package/dist/runtime/channels/channel-dispatchers.js +27 -19
- package/dist/runtime/channels/channel-envelope.js +543 -23
- package/dist/runtime/channels/channel-receive-loops.d.ts +9 -6
- package/dist/runtime/channels/channel-receive-loops.js +59 -18
- package/dist/runtime/channels/channel-runtime-lifecycle.d.ts +22 -3
- package/dist/runtime/channels/channel-socket-registry.d.ts +22 -4
- package/dist/runtime/diagnostics/runtime-metrics.d.ts +1 -1
- package/dist/runtime/diagnostics/runtime-metrics.js +2 -1
- package/dist/runtime/execution/serial-execution-queue.d.ts +26 -13
- package/dist/runtime/foundation/raw-service-mesh-runtime.d.ts +27 -11
- package/dist/runtime/foundation/raw-service-mesh-runtime.js +29 -25
- package/dist/runtime/foundation/service-liveness-registry.d.ts +1 -1
- package/dist/runtime/foundation/service-mailbox.d.ts +3 -1
- package/dist/runtime/foundation/service-mailbox.js +4 -1
- package/dist/runtime/foundation/service-runtime-contracts.d.ts +3 -1
- package/dist/runtime/foundation/service-stateful-registry.d.ts +2 -0
- package/dist/runtime/foundation/service-stateful-registry.js +28 -12
- package/dist/runtime/foundation/service-stateful-runtime.d.ts +51 -19
- package/dist/runtime/foundation/service-stateful-runtime.js +54 -5
- package/dist/runtime/foundation/service-stateful-wire-codec.d.ts +3 -0
- package/dist/runtime/foundation/service-stateful-wire-codec.js +15 -0
- package/dist/runtime/foundation/service-wire-constants.generated.d.ts +1 -0
- package/dist/runtime/foundation/service-wire-constants.generated.js +12 -0
- package/dist/runtime/foundation/service-wire-m6a-codec.d.ts +2 -0
- package/dist/runtime/foundation/service-wire-m6a-codec.js +17 -7
- package/dist/runtime/host/actor-placement-coordinator.d.ts +1 -1
- package/dist/runtime/host/actor-transfer-runtime.d.ts +3 -3
- package/dist/runtime/host/application-job-queue.d.ts +1 -1
- package/dist/runtime/host/index.d.ts +89 -36
- package/dist/runtime/host/index.js +101 -7
- package/dist/runtime/host/location-runtime-owner.d.ts +2 -2
- package/dist/runtime/host/service-relocation-host-runtime.d.ts +181 -44
- package/dist/runtime/host/service-relocation-host-runtime.js +47 -13
- package/dist/runtime/host/spot-address-transport.js +50 -42
- package/dist/runtime/locations/actor-location-claims.js +9 -10
- package/dist/runtime/locations/auto-connect-loop.d.ts +0 -1
- package/dist/runtime/locations/auto-connect-loop.js +25 -19
- package/dist/runtime/locations/auto-connect-planner.js +2 -5
- package/dist/runtime/locations/auto-connect-reconciler.d.ts +1 -0
- package/dist/runtime/locations/auto-connect-reconciler.js +35 -23
- package/dist/runtime/locations/in-memory-location-store.d.ts +0 -2
- package/dist/runtime/locations/in-memory-location-store.js +1 -38
- package/dist/runtime/locations/location-store-repository.d.ts +0 -1
- package/dist/runtime/locations/location-store-repository.js +13 -115
- package/dist/runtime/locations/runtime.d.ts +3 -3
- package/dist/runtime/locations/runtime.js +12 -16
- package/dist/runtime/messaging/creation-payload-codec.js +2 -2
- package/dist/runtime/protocol/service_wire_codec.generated.d.ts +4 -0
- package/dist/runtime/protocol/service_wire_codec.generated.js +17 -7
- package/dist/runtime/spots/index.d.ts +20 -5
- package/dist/runtime/spots/index.js +14 -0
- package/dist/runtime/spots/spot-actor-admission-coordinator.d.ts +3 -3
- package/dist/runtime/spots/spot-actor-packet-dispatch.d.ts +1 -0
- package/dist/runtime/spots/spot-actor-packet-dispatch.js +13 -7
- package/dist/runtime/spots/spot-actor-packet-drain.d.ts +1 -0
- package/dist/runtime/spots/spot-actor-packet-drain.js +12 -5
- package/dist/runtime/spots/spot-entry-activation.d.ts +2 -1
- package/dist/runtime/spots/spot-node-runtime-manager.d.ts +8 -6
- package/dist/runtime/spots/spot-node-runtime-manager.js +2 -0
- package/dist/runtime/spots/spot-route-packet-dispatch.js +7 -4
- package/dist/runtime/spots/spot-routed-spot-packet-dispatch.js +3 -1
- package/dist/runtime/spots/spot-serial-executor.d.ts +2 -1
- package/dist/runtime/spots/spot-subscription-dispatch.js +3 -1
- package/dist/runtime/spots/spot-timer.d.ts +1 -1
- package/dist/runtime/streams/actor-session-binding-registry.d.ts +9 -3
- package/dist/runtime/streams/actor-session-binding-registry.js +17 -0
- package/dist/runtime/streams/index.d.ts +3 -3
- package/dist/runtime/streams/index.js +22 -2
- package/dist/runtime/streams/managed-stream.js +2 -1
- package/dist/runtime/streams/session-calls.d.ts +1 -1
- package/dist/runtime/streams/session-calls.js +3 -9
- package/dist/runtime/streams/session-context.d.ts +2 -2
- package/dist/runtime/streams/session-context.js +2 -2
- package/dist/runtime/streams/stream-session-runtime.d.ts +1 -0
- package/dist/runtime/streams/stream-session-runtime.js +37 -12
- package/package.json +3 -3
- package/src/contracts/Actors/ZLinkActor.ts +6 -0
- package/src/contracts/Actors/ZLinkSessionBindingIdentity.ts +7 -0
- package/src/contracts/Actors/index.ts +1 -0
- package/src/contracts/Common/payload-slab.ts +29 -0
- package/src/contracts/Handlers/Contexts.ts +1 -0
- package/src/internal.ts +17 -0
- package/src/runtime/actors/actor-client.ts +48 -23
- package/src/runtime/actors/actor-context.ts +1 -1
- package/src/runtime/actors/actor-creation.ts +1 -1
- package/src/runtime/actors/actor-mailbox.ts +1 -1
- package/src/runtime/actors/actor-runtime-state.ts +28 -10
- package/src/runtime/actors/index.ts +30 -35
- package/src/runtime/actors/spot-actor-dispatch.ts +4 -3
- package/src/runtime/application-jobs/application-ingress-record-owner.ts +4 -0
- package/src/runtime/backend/contracts/index.ts +2 -0
- package/src/runtime/backend/mesh-completion-table.ts +2 -0
- package/src/runtime/backend/node/node-mesh-backend-adapter.ts +5 -1
- package/src/runtime/backend/node/node-raw-binding-port.ts +20 -7
- package/src/runtime/backend/node/node-raw-mesh-backend.ts +18 -10
- package/src/runtime/channels/channel-dispatch-pipeline.ts +6 -5
- package/src/runtime/channels/channel-dispatchers.ts +39 -19
- package/src/runtime/channels/channel-envelope.ts +547 -20
- package/src/runtime/channels/channel-receive-loops.ts +93 -36
- package/src/runtime/channels/channel-runtime-lifecycle.ts +2 -2
- package/src/runtime/channels/channel-socket-registry.ts +3 -3
- package/src/runtime/diagnostics/runtime-metrics.ts +3 -1
- package/src/runtime/execution/serial-execution-queue.ts +13 -13
- package/src/runtime/foundation/raw-service-mesh-runtime.ts +40 -39
- package/src/runtime/foundation/service-liveness-registry.ts +1 -1
- package/src/runtime/foundation/service-mailbox.ts +6 -1
- package/src/runtime/foundation/service-runtime-contracts.ts +7 -1
- package/src/runtime/foundation/service-stateful-registry.ts +39 -14
- package/src/runtime/foundation/service-stateful-runtime.ts +87 -21
- package/src/runtime/foundation/service-stateful-wire-codec.ts +18 -0
- package/src/runtime/foundation/service-wire-constants.generated.ts +10 -0
- package/src/runtime/foundation/service-wire-m6a-codec.ts +29 -7
- package/src/runtime/host/actor-placement-coordinator.ts +1 -1
- package/src/runtime/host/actor-transfer-runtime.ts +3 -3
- package/src/runtime/host/application-job-queue.ts +1 -1
- package/src/runtime/host/index.ts +183 -44
- package/src/runtime/host/location-runtime-owner.ts +2 -2
- package/src/runtime/host/service-relocation-host-runtime.ts +101 -65
- package/src/runtime/host/spot-address-transport.ts +67 -61
- package/src/runtime/locations/actor-location-claims.ts +14 -14
- package/src/runtime/locations/auto-connect-loop.ts +24 -16
- package/src/runtime/locations/auto-connect-planner.ts +2 -5
- package/src/runtime/locations/auto-connect-reconciler.ts +37 -24
- package/src/runtime/locations/in-memory-location-store.ts +1 -74
- package/src/runtime/locations/location-store-repository.ts +32 -153
- package/src/runtime/locations/runtime.ts +16 -28
- package/src/runtime/messaging/creation-payload-codec.ts +3 -3
- package/src/runtime/protocol/service_wire_codec.generated.ts +18 -8
- package/src/runtime/protocol/service_wire_pilot_codec.generated.ts +1 -1
- package/src/runtime/spots/index.ts +28 -4
- package/src/runtime/spots/spot-actor-admission-coordinator.ts +1 -1
- package/src/runtime/spots/spot-actor-packet-dispatch.ts +16 -6
- package/src/runtime/spots/spot-actor-packet-drain.ts +21 -6
- package/src/runtime/spots/spot-entry-activation.ts +1 -1
- package/src/runtime/spots/spot-node-runtime-manager.ts +8 -6
- package/src/runtime/spots/spot-route-packet-dispatch.ts +8 -4
- package/src/runtime/spots/spot-routed-spot-packet-dispatch.ts +3 -1
- package/src/runtime/spots/spot-serial-executor.ts +1 -1
- package/src/runtime/spots/spot-subscription-dispatch.ts +3 -1
- package/src/runtime/spots/spot-timer.ts +1 -1
- package/src/runtime/streams/actor-session-binding-registry.ts +30 -3
- package/src/runtime/streams/index.ts +30 -4
- package/src/runtime/streams/managed-stream.ts +2 -1
- package/src/runtime/streams/session-calls.ts +9 -14
- package/src/runtime/streams/session-context.ts +6 -11
- package/src/runtime/streams/stream-session-runtime.ts +49 -20
|
@@ -9,6 +9,7 @@ export interface ZLinkMeshCompletionDiagnostic {
|
|
|
9
9
|
export interface ZLinkMeshCompletion {
|
|
10
10
|
readonly terminalResult: number;
|
|
11
11
|
readonly failureErrno: number;
|
|
12
|
+
readonly failureMessage?: string;
|
|
12
13
|
readonly operationKind: number;
|
|
13
14
|
readonly kindData: ReceiveKindData | null;
|
|
14
15
|
readonly parts: Message[];
|
|
@@ -269,6 +269,7 @@ function retainCompletion(record) {
|
|
|
269
269
|
return {
|
|
270
270
|
terminalResult: record.terminalResult,
|
|
271
271
|
failureErrno: record.failureErrno,
|
|
272
|
+
...(record.failureMessage === undefined ? {} : { failureMessage: record.failureMessage }),
|
|
272
273
|
operationKind: record.operationKind,
|
|
273
274
|
kindData: record.kindData,
|
|
274
275
|
parts
|
|
@@ -12,7 +12,11 @@ class ZLinkNodeMeshBackendAdapter {
|
|
|
12
12
|
if (!isBindingContext(bindingContext)) {
|
|
13
13
|
throw new TypeError('Node MeshNode creation requires the Node binding Context owned by the host.');
|
|
14
14
|
}
|
|
15
|
-
return new node_raw_mesh_backend_1.ZLinkNodeRawMeshBackend(options.meshName, options.routingId, new node_raw_binding_port_1.ZLinkNodeRawBindingPort(bindingContext,
|
|
15
|
+
return new node_raw_mesh_backend_1.ZLinkNodeRawMeshBackend(options.meshName, options.routingId, new node_raw_binding_port_1.ZLinkNodeRawBindingPort(bindingContext, {
|
|
16
|
+
sendHighWaterMark: options.sendHighWaterMark,
|
|
17
|
+
receiveHighWaterMark: options.receiveHighWaterMark,
|
|
18
|
+
receiveTimeoutMs: options.receiveTimeoutMs
|
|
19
|
+
}), options.applicationJobQueue, options.applicationJobReceiveFlowFailureSink, options.peerAdmissionSealed, options.infrastructureTaskRunner);
|
|
16
20
|
}
|
|
17
21
|
}
|
|
18
22
|
exports.ZLinkNodeMeshBackendAdapter = ZLinkNodeMeshBackendAdapter;
|
|
@@ -1,9 +1,14 @@
|
|
|
1
1
|
import { type Context } from '@zlink-systems/zlink';
|
|
2
2
|
import type { ZLinkRawBindingPort, ZLinkRawHostPort } from '../raw-binding-port';
|
|
3
|
+
interface ZLinkNodeRawRouterSocketOptions {
|
|
4
|
+
readonly sendHighWaterMark?: number;
|
|
5
|
+
readonly receiveHighWaterMark?: number;
|
|
6
|
+
readonly receiveTimeoutMs?: number;
|
|
7
|
+
}
|
|
3
8
|
export type { ZLinkRawBindingPort, ZLinkRawDealerPort, ZLinkRawHostPort, ZLinkRawMonitorPort, ZLinkRawMonitorRecord, ZLinkRawReceivedRecord, ZLinkRawRouterPort, ZLinkRawRouterRoute, ZLinkRawSocketPort } from '../raw-binding-port';
|
|
4
9
|
export declare class ZLinkNodeRawBindingPort implements ZLinkRawBindingPort {
|
|
5
10
|
private readonly sharedContext?;
|
|
6
|
-
private readonly
|
|
7
|
-
constructor(sharedContext?: Context | undefined,
|
|
11
|
+
private readonly routerSocketOptions?;
|
|
12
|
+
constructor(sharedContext?: Context | undefined, routerSocketOptions?: ZLinkNodeRawRouterSocketOptions | undefined);
|
|
8
13
|
createHost(): ZLinkRawHostPort;
|
|
9
14
|
}
|
|
@@ -11,30 +11,30 @@ const node_event_loop_poller_1 = require("./node-event-loop-poller");
|
|
|
11
11
|
const runtime_message_1 = require("../runtime-message");
|
|
12
12
|
class ZLinkNodeRawBindingPort {
|
|
13
13
|
sharedContext;
|
|
14
|
-
|
|
15
|
-
constructor(sharedContext,
|
|
14
|
+
routerSocketOptions;
|
|
15
|
+
constructor(sharedContext, routerSocketOptions) {
|
|
16
16
|
this.sharedContext = sharedContext;
|
|
17
|
-
this.
|
|
17
|
+
this.routerSocketOptions = routerSocketOptions;
|
|
18
18
|
}
|
|
19
19
|
createHost() {
|
|
20
|
-
return new NodeRawHostPort(this.sharedContext ?? (0, zlink_1.createContext)(), this.sharedContext === undefined, this.
|
|
20
|
+
return new NodeRawHostPort(this.sharedContext ?? (0, zlink_1.createContext)(), this.sharedContext === undefined, this.routerSocketOptions);
|
|
21
21
|
}
|
|
22
22
|
}
|
|
23
23
|
exports.ZLinkNodeRawBindingPort = ZLinkNodeRawBindingPort;
|
|
24
24
|
class NodeRawHostPort {
|
|
25
25
|
context;
|
|
26
26
|
ownsContext;
|
|
27
|
-
|
|
27
|
+
routerSocketOptions;
|
|
28
28
|
resources = [];
|
|
29
29
|
state = 'open';
|
|
30
|
-
constructor(context, ownsContext,
|
|
30
|
+
constructor(context, ownsContext, routerSocketOptions) {
|
|
31
31
|
this.context = context;
|
|
32
32
|
this.ownsContext = ownsContext;
|
|
33
|
-
this.
|
|
33
|
+
this.routerSocketOptions = routerSocketOptions;
|
|
34
34
|
}
|
|
35
35
|
createRouter() {
|
|
36
36
|
this.requireOpen();
|
|
37
|
-
return this.own(new NodeRawRouterPort((0, zlink_1.createRouterSocket)(this.context), this.
|
|
37
|
+
return this.own(new NodeRawRouterPort((0, zlink_1.createRouterSocket)(this.context), this.routerSocketOptions));
|
|
38
38
|
}
|
|
39
39
|
createDealer() {
|
|
40
40
|
this.requireOpen();
|
|
@@ -218,13 +218,19 @@ class NodeRawRouterPort extends NodeRawSocketPort {
|
|
|
218
218
|
this.requireOpen();
|
|
219
219
|
(0, node_socket_backend_adapter_1.disconnectSocketPeer)(this.socket, this.preparedRoutingId(routingId));
|
|
220
220
|
}
|
|
221
|
-
constructor(socket,
|
|
221
|
+
constructor(socket, options) {
|
|
222
222
|
super(socket, true);
|
|
223
223
|
socket.options.handover = true;
|
|
224
224
|
socket.options.mandatory = true;
|
|
225
225
|
socket.options.probe = true;
|
|
226
|
-
if (
|
|
227
|
-
socket.options.
|
|
226
|
+
if (options?.sendHighWaterMark !== undefined) {
|
|
227
|
+
socket.options.sendHwm = BigInt(options.sendHighWaterMark);
|
|
228
|
+
}
|
|
229
|
+
if (options?.receiveHighWaterMark !== undefined) {
|
|
230
|
+
socket.options.recvHwm = BigInt(options.receiveHighWaterMark);
|
|
231
|
+
}
|
|
232
|
+
if (options?.receiveTimeoutMs !== undefined) {
|
|
233
|
+
socket.options.recvTimeout = options.receiveTimeoutMs;
|
|
228
234
|
}
|
|
229
235
|
}
|
|
230
236
|
localEndpoint() {
|
|
@@ -36,7 +36,7 @@ export declare class ZLinkNodeRawMeshBackend implements ZLinkBackendMeshNode {
|
|
|
36
36
|
private readonly lifecycleGeneration;
|
|
37
37
|
private bindEndpoint?;
|
|
38
38
|
private advertiseHost?;
|
|
39
|
-
|
|
39
|
+
runtime?: RawServiceMeshRuntime;
|
|
40
40
|
private stateful?;
|
|
41
41
|
private readyHandler?;
|
|
42
42
|
private maintenanceTimer?;
|
|
@@ -277,7 +277,7 @@ export declare class ZLinkNodeRawMeshBackend implements ZLinkBackendMeshNode {
|
|
|
277
277
|
setSpotSubscription(state: ServiceSpotState, channelName: string, topicFilter: string): void;
|
|
278
278
|
unsetSpotSubscription(state: ServiceSpotState, channelName: string, topicFilter: string): void;
|
|
279
279
|
clearSpotSubscriptions(state: ServiceSpotState): void;
|
|
280
|
-
|
|
280
|
+
createDescriptor(): ServiceNodeDescriptor;
|
|
281
281
|
private resolveAdvertisedEndpoint;
|
|
282
282
|
/**
|
|
283
283
|
* Arms the one maintenance timer for the nearest management deadline
|
|
@@ -369,6 +369,7 @@ class ZLinkNodeRawMeshBackend {
|
|
|
369
369
|
}
|
|
370
370
|
expectPeer(peer) {
|
|
371
371
|
this.requireRuntime().expectPeerByRoutingId(peer.endpoint, peer.nodeRoutingId, peer.securityIdentity, peer.lifecycleGeneration);
|
|
372
|
+
this.scheduleMaintenance();
|
|
372
373
|
}
|
|
373
374
|
removePeerConnection(intentId) {
|
|
374
375
|
const intent = this.peerIntents.get(intentId);
|
|
@@ -1447,6 +1448,9 @@ function completionRecord(operationId, operationKind, result) {
|
|
|
1447
1448
|
kindData: 'kindData' in result ? (result.kindData ?? null) : null,
|
|
1448
1449
|
terminalResult: result.terminalResult,
|
|
1449
1450
|
failureErrno: result.failureCode,
|
|
1451
|
+
...('failureMessage' in result && result.failureMessage !== undefined
|
|
1452
|
+
? { failureMessage: result.failureMessage }
|
|
1453
|
+
: {}),
|
|
1450
1454
|
parts: payload === undefined
|
|
1451
1455
|
? []
|
|
1452
1456
|
: payload.contentType === MULTIPART_CONTENT_TYPE
|
|
@@ -1667,10 +1671,10 @@ function decodeStatefulRecord(record, stateful) {
|
|
|
1667
1671
|
});
|
|
1668
1672
|
return accepted ? zlink_1.SubmitResult.Ok : zlink_1.SubmitResult.InvalidState;
|
|
1669
1673
|
},
|
|
1670
|
-
replyFailure(terminalResult, failureCode) {
|
|
1674
|
+
replyFailure(terminalResult, failureCode, tail) {
|
|
1671
1675
|
if (stateful.reply === undefined)
|
|
1672
1676
|
return zlink_1.SubmitResult.InvalidState;
|
|
1673
|
-
return stateful.reply(terminalResult, failureCode)
|
|
1677
|
+
return stateful.reply(terminalResult, failureCode, undefined, tail)
|
|
1674
1678
|
? zlink_1.SubmitResult.Ok
|
|
1675
1679
|
: zlink_1.SubmitResult.InvalidState;
|
|
1676
1680
|
}
|
|
@@ -1678,12 +1682,15 @@ function decodeStatefulRecord(record, stateful) {
|
|
|
1678
1682
|
}
|
|
1679
1683
|
function receiveIngressLifecycle(record) {
|
|
1680
1684
|
const applicationJob = record.applicationJob;
|
|
1681
|
-
return
|
|
1682
|
-
? {}
|
|
1683
|
-
|
|
1684
|
-
|
|
1685
|
-
|
|
1686
|
-
|
|
1685
|
+
return {
|
|
1686
|
+
...(record.receivedAt === undefined ? {} : { receivedAt: record.receivedAt }),
|
|
1687
|
+
...(applicationJob === undefined
|
|
1688
|
+
? {}
|
|
1689
|
+
: {
|
|
1690
|
+
applicationJobPermit: applicationJob,
|
|
1691
|
+
releaseRetainedIngress: () => applicationJob.close()
|
|
1692
|
+
})
|
|
1693
|
+
};
|
|
1687
1694
|
}
|
|
1688
1695
|
function prepareStatefulMailboxDispatch(signal) {
|
|
1689
1696
|
const mailboxRecord = this.statefulMailboxRecord;
|
|
@@ -2,7 +2,7 @@ import type { ZLinkHandlerMessageType } from '../../contracts/Common/HandlerMess
|
|
|
2
2
|
import type { ZLinkMeshDispatchAdmission } from '../admission';
|
|
3
3
|
import type { ZLinkMessageContext, ZLinkHandlerFilter, ZLinkUnhandledDispatchOptions, ZLinkFlowOrigin } from '../../contracts';
|
|
4
4
|
import { ZLinkFrameworkException } from '../../contracts';
|
|
5
|
-
import { ZLinkDispatchMessageKind, ZLinkDispatchErrorSurface } from '../../contracts/Dispatch/ZLinkDispatchOptions';
|
|
5
|
+
import { ZLinkRuntimeMessageFlowOutcome as ZLinkMessageFlowOutcome, ZLinkDispatchMessageKind, ZLinkDispatchErrorSurface } from '../../contracts/Dispatch/ZLinkDispatchOptions';
|
|
6
6
|
import { type ZLinkChannelEnvelope, type ZLinkChannelEnvelopeCodecRegistry } from './channel-envelope';
|
|
7
7
|
import type { ZLinkMalformedChannelHeaderInfo } from './channel-envelope-inspection';
|
|
8
8
|
import type { ZLinkDispatchErrorReporter } from './dispatch-error-reporter';
|
|
@@ -47,8 +47,8 @@ export interface ZLinkRequestDispatch<TContext extends ZLinkMessageContext> {
|
|
|
47
47
|
readonly writeError: (error: unknown) => void | Promise<void>;
|
|
48
48
|
}
|
|
49
49
|
export declare class ZLinkChannelDispatchPipeline {
|
|
50
|
-
|
|
51
|
-
|
|
50
|
+
readonly options: ZLinkChannelDispatchPipelineOptions;
|
|
51
|
+
readonly filters: readonly ZLinkHandlerFilter[];
|
|
52
52
|
private readonly unhandled;
|
|
53
53
|
constructor(options: ZLinkChannelDispatchPipelineOptions);
|
|
54
54
|
/**
|
|
@@ -67,7 +67,7 @@ export declare class ZLinkChannelDispatchPipeline {
|
|
|
67
67
|
*/
|
|
68
68
|
dispatchRequest<TContext extends ZLinkMessageContext>(dispatch: ZLinkRequestDispatch<TContext>, admit?: ZLinkMeshDispatchAdmission): void | Promise<void>;
|
|
69
69
|
private dispatchMissingRequest;
|
|
70
|
-
|
|
70
|
+
invokeInFlow<TContext extends ZLinkMessageContext, TResult>(dispatch: ZLinkOneWayDispatch<TContext> | ZLinkRequestDispatch<TContext>, handler: ZLinkChannelDispatchHandler<TContext, TResult>): unknown;
|
|
71
71
|
private completeRequest;
|
|
72
72
|
private replyPathMissing;
|
|
73
73
|
private failRequest;
|
|
@@ -87,13 +87,14 @@ export declare class ZLinkChannelDispatchPipeline {
|
|
|
87
87
|
readonly sourceRid?: string;
|
|
88
88
|
readonly writeProtocolError?: (error: ZLinkFrameworkException) => Promise<void>;
|
|
89
89
|
}): Promise<void>;
|
|
90
|
-
|
|
90
|
+
invoke<TContext extends ZLinkMessageContext, TResult>(dispatch: ZLinkOneWayDispatch<TContext> | ZLinkRequestDispatch<TContext>, handler: ZLinkChannelDispatchHandler<TContext, TResult>): TResult | undefined | typeof HANDLER_FILTER_REJECTED | Promise<TResult | undefined | typeof HANDLER_FILTER_REJECTED>;
|
|
91
91
|
private invokeFiltered;
|
|
92
92
|
private createFilterContext;
|
|
93
93
|
private dispatchKind;
|
|
94
94
|
private report;
|
|
95
|
-
|
|
95
|
+
trace(outcome: ZLinkMessageFlowOutcome, fields: ZLinkChannelDispatchFields): void;
|
|
96
96
|
private failureReason;
|
|
97
97
|
private applyOneWayUnhandled;
|
|
98
98
|
}
|
|
99
|
+
declare const HANDLER_FILTER_REJECTED: unique symbol;
|
|
99
100
|
export {};
|
|
@@ -13,6 +13,7 @@ import { type ZLinkOneWayDispatch, type ZLinkRequestDispatch } from './channel-d
|
|
|
13
13
|
export interface ZLinkChannelRequestDispatcherOptions {
|
|
14
14
|
readonly meshName?: string;
|
|
15
15
|
readonly channelName: string;
|
|
16
|
+
readonly receivedAtClock?: () => Date;
|
|
16
17
|
/**
|
|
17
18
|
* Mesh channels use the routed message context so a handler can associate
|
|
18
19
|
* a report with the node that sent it.
|
|
@@ -57,7 +58,7 @@ export declare class ZLinkChannelRequestDispatcher {
|
|
|
57
58
|
send?: () => ZLinkMultipartOperation<ZLinkMultipartAsyncSubmitOperation>;
|
|
58
59
|
}, router: {
|
|
59
60
|
reply(routingId: unknown, replyToken: unknown): ZLinkMultipartReplyOperation;
|
|
60
|
-
}, signal?: AbortSignal, decodedHeader?: ZLinkChannelEnvelopeHeader): Promise<boolean | void>;
|
|
61
|
+
}, signal?: AbortSignal, decodedHeader?: ZLinkChannelEnvelopeHeader, receivedAt?: Date): Promise<boolean | void>;
|
|
61
62
|
dispatchMesh(record: ReceiveRecord, signal?: AbortSignal, admit?: ZLinkMeshDispatchAdmission): void | Promise<void>;
|
|
62
63
|
private submitReply;
|
|
63
64
|
private createMeshContext;
|
|
@@ -65,6 +66,7 @@ export declare class ZLinkChannelRequestDispatcher {
|
|
|
65
66
|
export interface ZLinkChannelPublishDispatcherOptions {
|
|
66
67
|
readonly meshName?: string;
|
|
67
68
|
readonly channelName: string;
|
|
69
|
+
readonly receivedAtClock?: () => Date;
|
|
68
70
|
readonly codecs?: ZLinkChannelEnvelopeCodecRegistry;
|
|
69
71
|
readonly dispatchErrors: ZLinkDispatchErrorReporter;
|
|
70
72
|
readonly handlers: ReadonlyMap<string, Pick<ZLinkOneWayDispatch<ZLinkPublishMessageContext>, 'handler' | 'messageType'>>;
|
|
@@ -82,10 +84,11 @@ export declare class ZLinkChannelPublishDispatcher {
|
|
|
82
84
|
dispatch(topicMessage: {
|
|
83
85
|
readonly topic: string;
|
|
84
86
|
readonly parts: readonly Message[];
|
|
85
|
-
}, signal?: AbortSignal, decodedHeader?: ZLinkChannelEnvelopeHeader): Promise<void>;
|
|
87
|
+
}, signal?: AbortSignal, decodedHeader?: ZLinkChannelEnvelopeHeader, receivedAt?: Date): Promise<void>;
|
|
86
88
|
}
|
|
87
89
|
export interface ZLinkRoutePacketDispatcherOptions {
|
|
88
90
|
readonly routerChannelId: string;
|
|
91
|
+
readonly receivedAtClock?: () => Date;
|
|
89
92
|
readonly codecs?: ZLinkChannelEnvelopeCodecRegistry;
|
|
90
93
|
readonly dispatchErrors: ZLinkDispatchErrorReporter;
|
|
91
94
|
readonly handlers: readonly ZLinkRouteHandlerRegistration[];
|
|
@@ -98,6 +101,7 @@ export declare class ZLinkRoutePacketDispatcher {
|
|
|
98
101
|
private readonly sendHandlers;
|
|
99
102
|
private readonly requestHandlers;
|
|
100
103
|
private readonly codecs?;
|
|
104
|
+
private readonly receivedAtClock;
|
|
101
105
|
private readonly pipeline;
|
|
102
106
|
constructor(options: ZLinkRoutePacketDispatcherOptions);
|
|
103
107
|
private readonly routerChannelId;
|
|
@@ -120,7 +124,7 @@ export declare class ZLinkRoutePacketDispatcher {
|
|
|
120
124
|
send?: () => ZLinkMultipartOperation<ZLinkMultipartAsyncSubmitOperation>;
|
|
121
125
|
}, router: {
|
|
122
126
|
reply(routingId: unknown, replyToken: unknown): ZLinkMultipartReplyOperation;
|
|
123
|
-
}, signal?: AbortSignal, decodedHeader?: ZLinkChannelEnvelopeHeader, infrastructureChecked?: boolean): Promise<boolean | void>;
|
|
127
|
+
}, signal?: AbortSignal, decodedHeader?: ZLinkChannelEnvelopeHeader, infrastructureChecked?: boolean, receivedAt?: Date): Promise<boolean | void>;
|
|
124
128
|
dispatchMesh(record: ReceiveRecord, signal?: AbortSignal, admit?: ZLinkMeshDispatchAdmission): void | Promise<void>;
|
|
125
129
|
dispatchLocalCommand(parts: readonly Message[], sourceNodeRid: RoutingId, signal?: AbortSignal): Promise<void>;
|
|
126
130
|
private dispatchMeshCommand;
|
|
@@ -30,7 +30,7 @@ class ZLinkChannelRequestDispatcher {
|
|
|
30
30
|
flowEnabled() {
|
|
31
31
|
return this.options.dispatchErrors.flow.flowCreationEnabled();
|
|
32
32
|
}
|
|
33
|
-
async dispatch(received, router, signal, decodedHeader) {
|
|
33
|
+
async dispatch(received, router, signal, decodedHeader, receivedAt = this.options.receivedAtClock?.() ?? new Date()) {
|
|
34
34
|
if (received.spotId !== null && received.spotId !== undefined) {
|
|
35
35
|
if (received.send === undefined) {
|
|
36
36
|
throw new configuration_1.ZLinkConfigurationException('Routed SPOT packet is missing a local SPOT delivery context.');
|
|
@@ -78,7 +78,8 @@ class ZLinkChannelRequestDispatcher {
|
|
|
78
78
|
contentType: envelope.header.contentType,
|
|
79
79
|
packetName,
|
|
80
80
|
metadata: (0, contracts_1.zlinkMessageMetadata)(envelope.header.metadata),
|
|
81
|
-
correlationId
|
|
81
|
+
correlationId,
|
|
82
|
+
receivedAt
|
|
82
83
|
};
|
|
83
84
|
await this.pipeline.dispatchOneWay({
|
|
84
85
|
fields,
|
|
@@ -113,7 +114,8 @@ class ZLinkChannelRequestDispatcher {
|
|
|
113
114
|
contentType: envelope.header.contentType,
|
|
114
115
|
packetName,
|
|
115
116
|
metadata: (0, contracts_1.zlinkMessageMetadata)(envelope.header.metadata),
|
|
116
|
-
correlationId
|
|
117
|
+
correlationId,
|
|
118
|
+
receivedAt
|
|
117
119
|
};
|
|
118
120
|
await this.pipeline.dispatchRequest({
|
|
119
121
|
fields: requestFields,
|
|
@@ -167,7 +169,7 @@ class ZLinkChannelRequestDispatcher {
|
|
|
167
169
|
codecs: this.options.codecs,
|
|
168
170
|
handler: handler?.handler,
|
|
169
171
|
messageType: handler?.messageType,
|
|
170
|
-
context: this.createMeshContext(envelope, record.sourceNodeRid),
|
|
172
|
+
context: this.createMeshContext(envelope, record.sourceNodeRid, record.receivedAt),
|
|
171
173
|
signal
|
|
172
174
|
}, admit);
|
|
173
175
|
}
|
|
@@ -181,7 +183,7 @@ class ZLinkChannelRequestDispatcher {
|
|
|
181
183
|
flowId: envelope.header.flowId,
|
|
182
184
|
flowOrigin: envelope.header.flowOrigin
|
|
183
185
|
};
|
|
184
|
-
return this.pipeline.dispatchRequest(new ZLinkMeshRequestDispatch(fields, envelope, this.options.codecs, this.options.handlers.get(packetName), this.createMeshContext(envelope, record.sourceNodeRid), signal, record, 'channel', this.options.channelName), admit);
|
|
186
|
+
return this.pipeline.dispatchRequest(new ZLinkMeshRequestDispatch(fields, envelope, this.options.codecs, this.options.handlers.get(packetName), this.createMeshContext(envelope, record.sourceNodeRid, record.receivedAt), signal, record, 'channel', this.options.channelName), admit);
|
|
185
187
|
}
|
|
186
188
|
submitReply(operation, signal) {
|
|
187
189
|
void signal;
|
|
@@ -190,14 +192,15 @@ class ZLinkChannelRequestDispatcher {
|
|
|
190
192
|
}
|
|
191
193
|
return completedChannelReply;
|
|
192
194
|
}
|
|
193
|
-
createMeshContext(envelope, sourceNodeRid) {
|
|
195
|
+
createMeshContext(envelope, sourceNodeRid, receivedAt) {
|
|
194
196
|
const base = {
|
|
195
197
|
meshName: this.options.meshName,
|
|
196
198
|
channelName: this.options.channelName,
|
|
197
199
|
contentType: envelope.header.contentType,
|
|
198
200
|
packetName: envelope.packetName,
|
|
199
201
|
metadata: (0, contracts_1.zlinkMessageMetadata)(envelope.header.metadata),
|
|
200
|
-
correlationId: envelope.header.correlationId ?? undefined
|
|
202
|
+
correlationId: envelope.header.correlationId ?? undefined,
|
|
203
|
+
receivedAt: receivedAt ?? this.options.receivedAtClock?.() ?? new Date()
|
|
201
204
|
};
|
|
202
205
|
if (this.options.routeMesh !== true) {
|
|
203
206
|
return base;
|
|
@@ -270,7 +273,7 @@ class ZLinkChannelPublishDispatcher {
|
|
|
270
273
|
unhandled: options.unhandled
|
|
271
274
|
});
|
|
272
275
|
}
|
|
273
|
-
async dispatch(topicMessage, signal, decodedHeader) {
|
|
276
|
+
async dispatch(topicMessage, signal, decodedHeader, receivedAt = this.options.receivedAtClock?.() ?? new Date()) {
|
|
274
277
|
if (topicMessage.parts.length === 0 || topicMessage.parts[0].data().length === 0) {
|
|
275
278
|
return;
|
|
276
279
|
}
|
|
@@ -315,7 +318,8 @@ class ZLinkChannelPublishDispatcher {
|
|
|
315
318
|
topic: publishTopic,
|
|
316
319
|
source: publishSource,
|
|
317
320
|
metadata: (0, contracts_1.zlinkMessageMetadata)(envelope.header.metadata),
|
|
318
|
-
correlationId: publishCorr
|
|
321
|
+
correlationId: publishCorr,
|
|
322
|
+
receivedAt
|
|
319
323
|
};
|
|
320
324
|
await this.pipeline.dispatchOneWay({
|
|
321
325
|
fields,
|
|
@@ -346,10 +350,12 @@ class ZLinkRoutePacketDispatcher {
|
|
|
346
350
|
sendHandlers = new Map();
|
|
347
351
|
requestHandlers = new Map();
|
|
348
352
|
codecs;
|
|
353
|
+
receivedAtClock;
|
|
349
354
|
pipeline;
|
|
350
355
|
constructor(options) {
|
|
351
356
|
this.routerChannelId = options.routerChannelId;
|
|
352
357
|
this.codecs = options.codecs;
|
|
358
|
+
this.receivedAtClock = options.receivedAtClock ?? (() => new Date());
|
|
353
359
|
this.dispatchErrors = options.dispatchErrors;
|
|
354
360
|
this.pipeline = new channel_dispatch_pipeline_1.ZLinkChannelDispatchPipeline({
|
|
355
361
|
dispatchErrors: options.dispatchErrors,
|
|
@@ -389,7 +395,7 @@ class ZLinkRoutePacketDispatcher {
|
|
|
389
395
|
}
|
|
390
396
|
return false;
|
|
391
397
|
}
|
|
392
|
-
async dispatch(received, router, signal, decodedHeader, infrastructureChecked = false) {
|
|
398
|
+
async dispatch(received, router, signal, decodedHeader, infrastructureChecked = false, receivedAt = this.receivedAtClock()) {
|
|
393
399
|
const channelHeader = decodedHeader ?? (0, channel_envelope_inspection_1.tryDecodeChannelHeader)(received.parts, this.flowEnabled());
|
|
394
400
|
if (!infrastructureChecked) {
|
|
395
401
|
const infrastructure = this.dispatchInfrastructure(received);
|
|
@@ -442,7 +448,7 @@ class ZLinkRoutePacketDispatcher {
|
|
|
442
448
|
codecs: (0, channel_framework_packets_1.codecsForFrameworkPacket)(packetName, this.codecs),
|
|
443
449
|
handler: handler?.handler,
|
|
444
450
|
messageType: handler?.messageType,
|
|
445
|
-
context: this.createRouteContext(envelope, received.routingId),
|
|
451
|
+
context: this.createRouteContext(envelope, received.routingId, receivedAt),
|
|
446
452
|
signal
|
|
447
453
|
});
|
|
448
454
|
return;
|
|
@@ -478,7 +484,7 @@ class ZLinkRoutePacketDispatcher {
|
|
|
478
484
|
codecs,
|
|
479
485
|
handler: handler?.handler,
|
|
480
486
|
messageType: handler?.messageType,
|
|
481
|
-
context: this.createRouteContext(envelope, received.routingId),
|
|
487
|
+
context: this.createRouteContext(envelope, received.routingId, receivedAt),
|
|
482
488
|
signal,
|
|
483
489
|
missingHandlerMessage: `No routed request handler is registered for '${this.routerChannelId}:${packetName}'.`,
|
|
484
490
|
writeReply: (reply) => this.submitReply((0, channel_multipart_1.appendParts)(router.reply(received.routingId, replyToken), (0, channel_envelope_1.encodeChannelReplyParts)(envelope.header, reply, codecs))),
|
|
@@ -512,7 +518,7 @@ class ZLinkRoutePacketDispatcher {
|
|
|
512
518
|
const sourceNodeRid = String(record.sourceNodeRid ?? '');
|
|
513
519
|
const correlationId = envelope.header.correlationId ?? undefined;
|
|
514
520
|
if (envelope.header.kind === 3 /* ZLinkChannelMessageKind.Command */) {
|
|
515
|
-
return this.dispatchMeshCommand(envelope, packetName, sourceNodeRid, record.sourceNodeRid, signal, admit);
|
|
521
|
+
return this.dispatchMeshCommand(envelope, packetName, sourceNodeRid, record.sourceNodeRid, signal, admit, record.receivedAt ?? this.receivedAtClock());
|
|
516
522
|
}
|
|
517
523
|
if (envelope.header.kind !== 1 /* ZLinkChannelMessageKind.Request */) {
|
|
518
524
|
return completedChannelReply;
|
|
@@ -525,9 +531,10 @@ class ZLinkRoutePacketDispatcher {
|
|
|
525
531
|
flowId: envelope.header.flowId,
|
|
526
532
|
flowOrigin: envelope.header.flowOrigin
|
|
527
533
|
};
|
|
528
|
-
return this.pipeline.dispatchRequest(new ZLinkMeshRequestDispatch(fields, envelope, (0, channel_framework_packets_1.codecsForFrameworkPacket)(packetName, this.codecs), this.requestHandlers.get(packetName), this.createRouteContext(envelope, record.sourceNodeRid), signal, record, 'routed', this.routerChannelId), admit);
|
|
534
|
+
return this.pipeline.dispatchRequest(new ZLinkMeshRequestDispatch(fields, envelope, (0, channel_framework_packets_1.codecsForFrameworkPacket)(packetName, this.codecs), this.requestHandlers.get(packetName), this.createRouteContext(envelope, record.sourceNodeRid, record.receivedAt), signal, record, 'routed', this.routerChannelId), admit);
|
|
529
535
|
}
|
|
530
536
|
async dispatchLocalCommand(parts, sourceNodeRid, signal) {
|
|
537
|
+
const receivedAt = this.receivedAtClock();
|
|
531
538
|
if (parts.length === 0 || parts[0].data().length === 0)
|
|
532
539
|
return;
|
|
533
540
|
let envelope;
|
|
@@ -551,9 +558,9 @@ class ZLinkRoutePacketDispatcher {
|
|
|
551
558
|
if (packetName === undefined) {
|
|
552
559
|
throw new configuration_1.ZLinkConfigurationException('Route packet is missing packetName.');
|
|
553
560
|
}
|
|
554
|
-
await this.dispatchMeshCommand(envelope, packetName, String(sourceNodeRid), sourceNodeRid, signal);
|
|
561
|
+
await this.dispatchMeshCommand(envelope, packetName, String(sourceNodeRid), sourceNodeRid, signal, undefined, receivedAt);
|
|
555
562
|
}
|
|
556
|
-
dispatchMeshCommand(envelope, packetName, sourceRid, sourceNodeRid, signal, admit) {
|
|
563
|
+
dispatchMeshCommand(envelope, packetName, sourceRid, sourceNodeRid, signal, admit, receivedAt = this.receivedAtClock()) {
|
|
557
564
|
const handler = this.sendHandlers.get(packetName);
|
|
558
565
|
return this.pipeline.dispatchOneWay({
|
|
559
566
|
fields: {
|
|
@@ -568,7 +575,7 @@ class ZLinkRoutePacketDispatcher {
|
|
|
568
575
|
codecs: (0, channel_framework_packets_1.codecsForFrameworkPacket)(packetName, this.codecs),
|
|
569
576
|
handler: handler?.handler,
|
|
570
577
|
messageType: handler?.messageType,
|
|
571
|
-
context: this.createRouteContext(envelope, sourceNodeRid),
|
|
578
|
+
context: this.createRouteContext(envelope, sourceNodeRid, receivedAt),
|
|
572
579
|
signal
|
|
573
580
|
}, admit);
|
|
574
581
|
}
|
|
@@ -578,7 +585,7 @@ class ZLinkRoutePacketDispatcher {
|
|
|
578
585
|
}
|
|
579
586
|
return completedChannelReply;
|
|
580
587
|
}
|
|
581
|
-
createRouteContext(envelope, sourceRid) {
|
|
588
|
+
createRouteContext(envelope, sourceRid, receivedAt = this.receivedAtClock()) {
|
|
582
589
|
const sourceNodeRid = String(sourceRid ?? '');
|
|
583
590
|
return {
|
|
584
591
|
meshName: this.routerChannelId,
|
|
@@ -586,7 +593,8 @@ class ZLinkRoutePacketDispatcher {
|
|
|
586
593
|
contentType: envelope.header.contentType,
|
|
587
594
|
sourceNodeRid,
|
|
588
595
|
metadata: (0, contracts_1.zlinkMessageMetadata)(envelope.header.metadata),
|
|
589
|
-
correlationId: envelope.header.correlationId ?? undefined
|
|
596
|
+
correlationId: envelope.header.correlationId ?? undefined,
|
|
597
|
+
receivedAt
|
|
590
598
|
};
|
|
591
599
|
}
|
|
592
600
|
}
|