@zlink-systems/framework 0.31.0 → 0.32.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/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-mailbox.d.ts +1 -1
- package/dist/runtime/actors/actor-runtime-state.d.ts +1 -1
- 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/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-mailbox.ts +1 -1
- package/src/runtime/actors/actor-runtime-state.ts +1 -1
- 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/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
|
@@ -25,13 +25,13 @@ interface ZLinkChannelRequestDispatchLoop {
|
|
|
25
25
|
readonly send?: () => ZLinkMultipartOperation<ZLinkMultipartAsyncSubmitOperation>;
|
|
26
26
|
}, router: ZLinkBackendRouterSocket & {
|
|
27
27
|
reply(routingId: unknown, replyToken: unknown): ZLinkMultipartReplyOperation;
|
|
28
|
-
}, signal?: AbortSignal, decodedHeader?: ZLinkChannelEnvelopeHeader): Promise<boolean | void>;
|
|
28
|
+
}, signal?: AbortSignal, decodedHeader?: ZLinkChannelEnvelopeHeader, receivedAt?: Date): Promise<boolean | void>;
|
|
29
29
|
}
|
|
30
30
|
interface ZLinkChannelPublishDispatchLoop {
|
|
31
31
|
dispatch(topicMessage: {
|
|
32
32
|
readonly topic: string;
|
|
33
33
|
readonly parts: readonly Message[];
|
|
34
|
-
}, signal?: AbortSignal, decodedHeader?: ZLinkChannelEnvelopeHeader): Promise<void>;
|
|
34
|
+
}, signal?: AbortSignal, decodedHeader?: ZLinkChannelEnvelopeHeader, receivedAt?: Date): Promise<void>;
|
|
35
35
|
}
|
|
36
36
|
interface ZLinkSubscriberInfrastructureResult {
|
|
37
37
|
readonly consumed: boolean;
|
|
@@ -54,7 +54,7 @@ interface ZLinkRoutePacketDispatchLoop {
|
|
|
54
54
|
readonly replyToken: unknown | null;
|
|
55
55
|
}, router: {
|
|
56
56
|
reply(routingId: unknown, replyToken: unknown): ZLinkMultipartReplyOperation;
|
|
57
|
-
}, signal?: AbortSignal, decodedHeader?: ZLinkChannelEnvelopeHeader, infrastructureChecked?: boolean): Promise<boolean | void>;
|
|
57
|
+
}, signal?: AbortSignal, decodedHeader?: ZLinkChannelEnvelopeHeader, infrastructureChecked?: boolean, receivedAt?: Date): Promise<boolean | void>;
|
|
58
58
|
}
|
|
59
59
|
interface ZLinkChannelInfrastructureHandler {
|
|
60
60
|
(received: {
|
|
@@ -87,6 +87,7 @@ export declare class ZLinkChannelReceiveLoop {
|
|
|
87
87
|
private readonly applicationJobQueue;
|
|
88
88
|
private readonly roundRobin?;
|
|
89
89
|
private readonly applicationDispatchQueue;
|
|
90
|
+
private readonly receivedAtClock;
|
|
90
91
|
private stoppedFlag;
|
|
91
92
|
private isStopped;
|
|
92
93
|
private running?;
|
|
@@ -96,7 +97,7 @@ export declare class ZLinkChannelReceiveLoop {
|
|
|
96
97
|
private readonly capacityStop;
|
|
97
98
|
constructor(channelName: string, router: ZLinkBackendRouterSocket & {
|
|
98
99
|
reply(routingId: unknown, replyToken: unknown): ZLinkMultipartReplyOperation;
|
|
99
|
-
}, dispatcher: ZLinkChannelRequestDispatchLoop, spotRouteBridge: ZLinkBackendSpotRouteBridge | undefined, infrastructureHandler: ZLinkChannelInfrastructureHandler | undefined, poller: ZLinkBackendReadablePoller, applicationJobQueue: ApplicationJobQueue, reportError?: ZLinkReceiveTaskErrorReporter, roundRobin?: ZLinkReceiveRoundRobinCoordinator | undefined, applicationDispatchQueue?: ZLinkSerialExecutionQueue);
|
|
100
|
+
}, dispatcher: ZLinkChannelRequestDispatchLoop, spotRouteBridge: ZLinkBackendSpotRouteBridge | undefined, infrastructureHandler: ZLinkChannelInfrastructureHandler | undefined, poller: ZLinkBackendReadablePoller, applicationJobQueue: ApplicationJobQueue, reportError?: ZLinkReceiveTaskErrorReporter, roundRobin?: ZLinkReceiveRoundRobinCoordinator | undefined, applicationDispatchQueue?: ZLinkSerialExecutionQueue, receivedAtClock?: () => Date);
|
|
100
101
|
run(signal?: AbortSignal): Promise<void>;
|
|
101
102
|
private runLoop;
|
|
102
103
|
stop(): Promise<void>;
|
|
@@ -111,6 +112,7 @@ export declare class ZLinkSubscriberReceiveLoop {
|
|
|
111
112
|
private readonly infrastructureHandler?;
|
|
112
113
|
private readonly roundRobin?;
|
|
113
114
|
private readonly applicationDispatchQueue;
|
|
115
|
+
private readonly receivedAtClock;
|
|
114
116
|
private stoppedFlag;
|
|
115
117
|
private isStopped;
|
|
116
118
|
private running?;
|
|
@@ -118,7 +120,7 @@ export declare class ZLinkSubscriberReceiveLoop {
|
|
|
118
120
|
private readonly receiveOwner;
|
|
119
121
|
private readonly rawReceiveReservations;
|
|
120
122
|
private readonly capacityStop;
|
|
121
|
-
constructor(adapter: ZLinkChannelBackendAdapter, subscriber: ZLinkBackendSubscriberSocket, dispatcher: ZLinkChannelPublishDispatchLoop, applicationJobQueue: ApplicationJobQueue, infrastructureHandler?: ((topicMessage: ReturnType<ZLinkChannelBackendAdapter["createTopicMessage"]>) => boolean | ZLinkSubscriberInfrastructureResult) | undefined, roundRobin?: ZLinkReceiveRoundRobinCoordinator | undefined, reportError?: ZLinkReceiveTaskErrorReporter, applicationDispatchQueue?: ZLinkSerialExecutionQueue);
|
|
123
|
+
constructor(adapter: ZLinkChannelBackendAdapter, subscriber: ZLinkBackendSubscriberSocket, dispatcher: ZLinkChannelPublishDispatchLoop, applicationJobQueue: ApplicationJobQueue, infrastructureHandler?: ((topicMessage: ReturnType<ZLinkChannelBackendAdapter["createTopicMessage"]>) => boolean | ZLinkSubscriberInfrastructureResult) | undefined, roundRobin?: ZLinkReceiveRoundRobinCoordinator | undefined, reportError?: ZLinkReceiveTaskErrorReporter, applicationDispatchQueue?: ZLinkSerialExecutionQueue, receivedAtClock?: () => Date);
|
|
122
124
|
private readonly poller;
|
|
123
125
|
run(signal?: AbortSignal): Promise<void>;
|
|
124
126
|
private runLoop;
|
|
@@ -134,6 +136,7 @@ export declare class ZLinkRouteReceiveLoop {
|
|
|
134
136
|
private readonly applicationJobQueue;
|
|
135
137
|
private readonly roundRobin?;
|
|
136
138
|
private readonly applicationDispatchQueue;
|
|
139
|
+
private readonly receivedAtClock;
|
|
137
140
|
private stoppedFlag;
|
|
138
141
|
private isStopped;
|
|
139
142
|
private running?;
|
|
@@ -143,7 +146,7 @@ export declare class ZLinkRouteReceiveLoop {
|
|
|
143
146
|
private readonly capacityStop;
|
|
144
147
|
constructor(router: ZLinkBackendRouterSocket & {
|
|
145
148
|
reply(routingId: unknown, replyToken: unknown): ZLinkMultipartReplyOperation;
|
|
146
|
-
}, dispatcher: ZLinkRoutePacketDispatchLoop, poller: ZLinkBackendReadablePoller, applicationJobQueue: ApplicationJobQueue, roundRobin?: ZLinkReceiveRoundRobinCoordinator | undefined, reportError?: ZLinkReceiveTaskErrorReporter, applicationDispatchQueue?: ZLinkSerialExecutionQueue);
|
|
149
|
+
}, dispatcher: ZLinkRoutePacketDispatchLoop, poller: ZLinkBackendReadablePoller, applicationJobQueue: ApplicationJobQueue, roundRobin?: ZLinkReceiveRoundRobinCoordinator | undefined, reportError?: ZLinkReceiveTaskErrorReporter, applicationDispatchQueue?: ZLinkSerialExecutionQueue, receivedAtClock?: () => Date);
|
|
147
150
|
run(signal?: AbortSignal): Promise<void>;
|
|
148
151
|
private runLoop;
|
|
149
152
|
stop(): Promise<void>;
|
|
@@ -9,18 +9,50 @@ const application_job_queue_scope_1 = require("../application-jobs/application-j
|
|
|
9
9
|
const serial_execution_queue_1 = require("../execution/serial-execution-queue");
|
|
10
10
|
function createChannelApplicationDispatchQueue() {
|
|
11
11
|
return new serial_execution_queue_1.ZLinkSerialExecutionQueue(async (record) => {
|
|
12
|
+
const permit = record.context;
|
|
13
|
+
const previousPermit = (0, application_job_queue_scope_1.enterApplicationJobPermitScope)(permit);
|
|
12
14
|
try {
|
|
13
15
|
void Promise.resolve(record.operation()).then((value) => {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
+
try {
|
|
17
|
+
record.resolve(value);
|
|
18
|
+
}
|
|
19
|
+
finally {
|
|
20
|
+
try {
|
|
21
|
+
record.release();
|
|
22
|
+
}
|
|
23
|
+
finally {
|
|
24
|
+
(0, application_job_queue_scope_1.releaseApplicationJobPermitTurn)(permit);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
16
27
|
}, (error) => {
|
|
17
|
-
|
|
18
|
-
|
|
28
|
+
try {
|
|
29
|
+
record.reject(error);
|
|
30
|
+
}
|
|
31
|
+
finally {
|
|
32
|
+
try {
|
|
33
|
+
record.release();
|
|
34
|
+
}
|
|
35
|
+
finally {
|
|
36
|
+
(0, application_job_queue_scope_1.releaseApplicationJobPermitTurn)(permit);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
19
39
|
});
|
|
20
40
|
}
|
|
21
41
|
catch (error) {
|
|
22
|
-
|
|
23
|
-
|
|
42
|
+
try {
|
|
43
|
+
record.reject(error);
|
|
44
|
+
}
|
|
45
|
+
finally {
|
|
46
|
+
try {
|
|
47
|
+
record.release();
|
|
48
|
+
}
|
|
49
|
+
finally {
|
|
50
|
+
(0, application_job_queue_scope_1.releaseApplicationJobPermitTurn)(permit);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
finally {
|
|
55
|
+
(0, application_job_queue_scope_1.leaveApplicationJobPermitScope)(previousPermit);
|
|
24
56
|
}
|
|
25
57
|
});
|
|
26
58
|
}
|
|
@@ -122,6 +154,7 @@ class ZLinkChannelReceiveLoop {
|
|
|
122
154
|
applicationJobQueue;
|
|
123
155
|
roundRobin;
|
|
124
156
|
applicationDispatchQueue;
|
|
157
|
+
receivedAtClock;
|
|
125
158
|
// The loop awaits between the two reads and stop() can land in that gap.
|
|
126
159
|
// Reading through a method keeps the second check honest; a field read stays
|
|
127
160
|
// narrowed to false across the await and is treated as dead code.
|
|
@@ -134,7 +167,7 @@ class ZLinkChannelReceiveLoop {
|
|
|
134
167
|
receiveOwner;
|
|
135
168
|
rawReceiveReservations;
|
|
136
169
|
capacityStop = new AbortController();
|
|
137
|
-
constructor(channelName, router, dispatcher, spotRouteBridge, infrastructureHandler, poller, applicationJobQueue, reportError, roundRobin, applicationDispatchQueue = createChannelApplicationDispatchQueue()) {
|
|
170
|
+
constructor(channelName, router, dispatcher, spotRouteBridge, infrastructureHandler, poller, applicationJobQueue, reportError, roundRobin, applicationDispatchQueue = createChannelApplicationDispatchQueue(), receivedAtClock = () => new Date()) {
|
|
138
171
|
this.channelName = channelName;
|
|
139
172
|
this.router = router;
|
|
140
173
|
this.dispatcher = dispatcher;
|
|
@@ -144,6 +177,7 @@ class ZLinkChannelReceiveLoop {
|
|
|
144
177
|
this.applicationJobQueue = applicationJobQueue;
|
|
145
178
|
this.roundRobin = roundRobin;
|
|
146
179
|
this.applicationDispatchQueue = applicationDispatchQueue;
|
|
180
|
+
this.receivedAtClock = receivedAtClock;
|
|
147
181
|
this.inFlight = new channel_receive_task_tracker_1.ZLinkReceiveTaskTracker(reportError);
|
|
148
182
|
this.receiveOwner = roundRobin?.register() ?? Symbol('channel-receive-owner');
|
|
149
183
|
this.rawReceiveReservations = new ZLinkRawReceiveReservationPool(exports.ZLINK_CHANNEL_RAW_RECEIVE_RESERVATION_LIMIT);
|
|
@@ -200,6 +234,7 @@ class ZLinkChannelReceiveLoop {
|
|
|
200
234
|
this.roundRobin?.setReady(this.receiveOwner, false);
|
|
201
235
|
break;
|
|
202
236
|
}
|
|
237
|
+
const receivedAt = this.receivedAtClock();
|
|
203
238
|
const receivedBytes = messageBytes(received.parts);
|
|
204
239
|
let classification;
|
|
205
240
|
try {
|
|
@@ -223,7 +258,7 @@ class ZLinkChannelReceiveLoop {
|
|
|
223
258
|
}
|
|
224
259
|
else {
|
|
225
260
|
applicationJobPermit.markApplicationQueued();
|
|
226
|
-
const task =
|
|
261
|
+
const task = this.applicationDispatchQueue.submitPreAdmitted(() => this.dispatchAndClose(received, signal, classification.decodedHeader, true, undefined, receivedAt), undefined, applicationJobPermit);
|
|
227
262
|
this.inFlight.track(task);
|
|
228
263
|
}
|
|
229
264
|
if (batch.record(receivedBytes))
|
|
@@ -261,7 +296,7 @@ class ZLinkChannelReceiveLoop {
|
|
|
261
296
|
this.poller.dispose();
|
|
262
297
|
}
|
|
263
298
|
}
|
|
264
|
-
async dispatchAndClose(received, signal, decodedHeader, infrastructureChecked = false, releaseRawReceive) {
|
|
299
|
+
async dispatchAndClose(received, signal, decodedHeader, infrastructureChecked = false, releaseRawReceive, receivedAt = this.receivedAtClock()) {
|
|
265
300
|
let closeReceived = true;
|
|
266
301
|
try {
|
|
267
302
|
if (!infrastructureChecked) {
|
|
@@ -272,7 +307,7 @@ class ZLinkChannelReceiveLoop {
|
|
|
272
307
|
}
|
|
273
308
|
decodedHeader = classification.decodedHeader;
|
|
274
309
|
}
|
|
275
|
-
const consumed = await this.dispatcher.dispatch(received, this.router, signal, decodedHeader);
|
|
310
|
+
const consumed = await this.dispatcher.dispatch(received, this.router, signal, decodedHeader, receivedAt);
|
|
276
311
|
if (consumed === true) {
|
|
277
312
|
closeReceived = false;
|
|
278
313
|
}
|
|
@@ -305,6 +340,7 @@ class ZLinkSubscriberReceiveLoop {
|
|
|
305
340
|
infrastructureHandler;
|
|
306
341
|
roundRobin;
|
|
307
342
|
applicationDispatchQueue;
|
|
343
|
+
receivedAtClock;
|
|
308
344
|
// The loop awaits between the two reads and stop() can land in that gap.
|
|
309
345
|
// Reading through a method keeps the second check honest; a field read stays
|
|
310
346
|
// narrowed to false across the await and is treated as dead code.
|
|
@@ -317,7 +353,7 @@ class ZLinkSubscriberReceiveLoop {
|
|
|
317
353
|
receiveOwner;
|
|
318
354
|
rawReceiveReservations;
|
|
319
355
|
capacityStop = new AbortController();
|
|
320
|
-
constructor(adapter, subscriber, dispatcher, applicationJobQueue, infrastructureHandler, roundRobin, reportError, applicationDispatchQueue = createChannelApplicationDispatchQueue()) {
|
|
356
|
+
constructor(adapter, subscriber, dispatcher, applicationJobQueue, infrastructureHandler, roundRobin, reportError, applicationDispatchQueue = createChannelApplicationDispatchQueue(), receivedAtClock = () => new Date()) {
|
|
321
357
|
this.adapter = adapter;
|
|
322
358
|
this.subscriber = subscriber;
|
|
323
359
|
this.dispatcher = dispatcher;
|
|
@@ -325,6 +361,7 @@ class ZLinkSubscriberReceiveLoop {
|
|
|
325
361
|
this.infrastructureHandler = infrastructureHandler;
|
|
326
362
|
this.roundRobin = roundRobin;
|
|
327
363
|
this.applicationDispatchQueue = applicationDispatchQueue;
|
|
364
|
+
this.receivedAtClock = receivedAtClock;
|
|
328
365
|
this.inFlight = new channel_receive_task_tracker_1.ZLinkReceiveTaskTracker(reportError);
|
|
329
366
|
this.poller = adapter.createReadablePoller(subscriber);
|
|
330
367
|
this.receiveOwner = roundRobin?.register() ?? Symbol('subscriber-receive-owner');
|
|
@@ -391,6 +428,7 @@ class ZLinkSubscriberReceiveLoop {
|
|
|
391
428
|
break;
|
|
392
429
|
continue;
|
|
393
430
|
}
|
|
431
|
+
const receivedAt = this.receivedAtClock();
|
|
394
432
|
const receivedBytes = messageBytes(topicMessage.parts);
|
|
395
433
|
let classification;
|
|
396
434
|
try {
|
|
@@ -420,7 +458,7 @@ class ZLinkSubscriberReceiveLoop {
|
|
|
420
458
|
break;
|
|
421
459
|
}
|
|
422
460
|
applicationJobPermit.markApplicationQueued();
|
|
423
|
-
const task =
|
|
461
|
+
const task = this.applicationDispatchQueue.submitPreAdmitted(() => this.dispatchAndClose(topicMessage, signal, classification.decodedHeader, true, undefined, receivedAt), undefined, applicationJobPermit);
|
|
424
462
|
releaseRawReceive();
|
|
425
463
|
this.inFlight.track(task);
|
|
426
464
|
if (batch.record(receivedBytes)) {
|
|
@@ -451,7 +489,7 @@ class ZLinkSubscriberReceiveLoop {
|
|
|
451
489
|
throw error;
|
|
452
490
|
}
|
|
453
491
|
}
|
|
454
|
-
async dispatchAndClose(topicMessage, signal, decodedHeader, infrastructureChecked = false, releaseRawReceive) {
|
|
492
|
+
async dispatchAndClose(topicMessage, signal, decodedHeader, infrastructureChecked = false, releaseRawReceive, receivedAt = this.receivedAtClock()) {
|
|
455
493
|
try {
|
|
456
494
|
if (!infrastructureChecked) {
|
|
457
495
|
const classification = this.classify(topicMessage);
|
|
@@ -459,7 +497,7 @@ class ZLinkSubscriberReceiveLoop {
|
|
|
459
497
|
return;
|
|
460
498
|
decodedHeader = classification.decodedHeader;
|
|
461
499
|
}
|
|
462
|
-
await this.dispatcher.dispatch(topicMessage, signal, decodedHeader);
|
|
500
|
+
await this.dispatcher.dispatch(topicMessage, signal, decodedHeader, receivedAt);
|
|
463
501
|
}
|
|
464
502
|
finally {
|
|
465
503
|
releaseRawReceive?.();
|
|
@@ -484,6 +522,7 @@ class ZLinkRouteReceiveLoop {
|
|
|
484
522
|
applicationJobQueue;
|
|
485
523
|
roundRobin;
|
|
486
524
|
applicationDispatchQueue;
|
|
525
|
+
receivedAtClock;
|
|
487
526
|
// The loop awaits between the two reads and stop() can land in that gap.
|
|
488
527
|
// Reading through a method keeps the second check honest; a field read stays
|
|
489
528
|
// narrowed to false across the await and is treated as dead code.
|
|
@@ -496,13 +535,14 @@ class ZLinkRouteReceiveLoop {
|
|
|
496
535
|
receiveOwner;
|
|
497
536
|
rawReceiveReservations;
|
|
498
537
|
capacityStop = new AbortController();
|
|
499
|
-
constructor(router, dispatcher, poller, applicationJobQueue, roundRobin, reportError, applicationDispatchQueue = createChannelApplicationDispatchQueue()) {
|
|
538
|
+
constructor(router, dispatcher, poller, applicationJobQueue, roundRobin, reportError, applicationDispatchQueue = createChannelApplicationDispatchQueue(), receivedAtClock = () => new Date()) {
|
|
500
539
|
this.router = router;
|
|
501
540
|
this.dispatcher = dispatcher;
|
|
502
541
|
this.poller = poller;
|
|
503
542
|
this.applicationJobQueue = applicationJobQueue;
|
|
504
543
|
this.roundRobin = roundRobin;
|
|
505
544
|
this.applicationDispatchQueue = applicationDispatchQueue;
|
|
545
|
+
this.receivedAtClock = receivedAtClock;
|
|
506
546
|
this.inFlight = new channel_receive_task_tracker_1.ZLinkReceiveTaskTracker(reportError);
|
|
507
547
|
this.receiveOwner = roundRobin?.register() ?? Symbol('route-receive-owner');
|
|
508
548
|
this.rawReceiveReservations = new ZLinkRawReceiveReservationPool(exports.ZLINK_CHANNEL_RAW_RECEIVE_RESERVATION_LIMIT);
|
|
@@ -560,6 +600,7 @@ class ZLinkRouteReceiveLoop {
|
|
|
560
600
|
break;
|
|
561
601
|
continue;
|
|
562
602
|
}
|
|
603
|
+
const receivedAt = this.receivedAtClock();
|
|
563
604
|
const receivedBytes = messageBytes(received.parts);
|
|
564
605
|
let infrastructure;
|
|
565
606
|
try {
|
|
@@ -612,7 +653,7 @@ class ZLinkRouteReceiveLoop {
|
|
|
612
653
|
break;
|
|
613
654
|
}
|
|
614
655
|
applicationJobPermit.markApplicationQueued();
|
|
615
|
-
const task =
|
|
656
|
+
const task = this.applicationDispatchQueue.submitPreAdmitted(() => this.dispatchAndClose(received, signal, true, undefined, receivedAt), undefined, applicationJobPermit);
|
|
616
657
|
releaseRawReceive();
|
|
617
658
|
this.inFlight.track(task);
|
|
618
659
|
if (batch.record(receivedBytes)) {
|
|
@@ -643,10 +684,10 @@ class ZLinkRouteReceiveLoop {
|
|
|
643
684
|
throw error;
|
|
644
685
|
}
|
|
645
686
|
}
|
|
646
|
-
async dispatchAndClose(received, signal, infrastructureChecked = false, releaseRawReceive) {
|
|
687
|
+
async dispatchAndClose(received, signal, infrastructureChecked = false, releaseRawReceive, receivedAt = this.receivedAtClock()) {
|
|
647
688
|
let closeReceived = true;
|
|
648
689
|
try {
|
|
649
|
-
const consumed = await this.dispatcher.dispatch(received, this.router, signal, (0, channel_envelope_inspection_1.tryDecodeChannelHeader)(received.parts, this.dispatcher.flowEnabled?.() ?? true), infrastructureChecked);
|
|
690
|
+
const consumed = await this.dispatcher.dispatch(received, this.router, signal, (0, channel_envelope_inspection_1.tryDecodeChannelHeader)(received.parts, this.dispatcher.flowEnabled?.() ?? true), infrastructureChecked, receivedAt);
|
|
650
691
|
if (consumed === true) {
|
|
651
692
|
closeReceived = false;
|
|
652
693
|
}
|
|
@@ -7,12 +7,30 @@ import { ZLinkLocationRuntime, type ZLinkLocationEventSink, type ZLinkLocationRu
|
|
|
7
7
|
import type { Message } from '../../contracts/Common/Message';
|
|
8
8
|
import type { ReceiveRecord } from '../foundation/service-runtime-contracts';
|
|
9
9
|
import type { RoutingId } from '../../contracts';
|
|
10
|
-
import { type ZLinkRouteRuntimeRequestHandler, type ZLinkRouteRuntimeSendHandler } from './channel-dispatchers';
|
|
10
|
+
import { ZLinkChannelPublishDispatcher, type ZLinkRouteRuntimeRequestHandler, type ZLinkRouteRuntimeSendHandler } from './channel-dispatchers';
|
|
11
|
+
import { ZLinkSubscriberReceiveLoop } from './channel-receive-loops';
|
|
11
12
|
import { ZLinkChannelDispatchServices } from './channel-dispatch-services';
|
|
12
13
|
import type { ZLinkChannelEnvelopeCodecRegistry } from './channel-envelope';
|
|
13
14
|
import { ZLinkChannelSocketRegistry } from './channel-socket-registry';
|
|
14
15
|
import { ZLinkSpotRouteDispatchStrategy } from './spot-route-dispatch-strategy';
|
|
15
16
|
import type { ApplicationJobQueue } from '../host/application-job-queue';
|
|
17
|
+
interface ManualFanoutSubscriberState {
|
|
18
|
+
readonly channelName: string;
|
|
19
|
+
readonly endpoint: string;
|
|
20
|
+
readonly index: number;
|
|
21
|
+
readonly connectionId: string;
|
|
22
|
+
readonly taskRunner: ZLinkRuntimeTaskRunner;
|
|
23
|
+
readonly dispatcher: ZLinkChannelPublishDispatcher;
|
|
24
|
+
desired: boolean;
|
|
25
|
+
transition: Promise<void>;
|
|
26
|
+
openingToken?: symbol;
|
|
27
|
+
active?: ManualFanoutSubscriberActive;
|
|
28
|
+
stopping?: ManualFanoutSubscriberActive;
|
|
29
|
+
}
|
|
30
|
+
interface ManualFanoutSubscriberActive {
|
|
31
|
+
readonly token: symbol;
|
|
32
|
+
readonly loop: ZLinkSubscriberReceiveLoop;
|
|
33
|
+
}
|
|
16
34
|
export interface ZLinkChannelRuntimeLifecycleOptions {
|
|
17
35
|
readonly registration: ZLinkFrameworkRegistration;
|
|
18
36
|
readonly adapter: ZLinkChannelBackendAdapter;
|
|
@@ -31,7 +49,7 @@ export declare class ZLinkChannelRuntimeLifecycle {
|
|
|
31
49
|
private readonly receiveRoundRobin;
|
|
32
50
|
private readonly channelReceiveLoops;
|
|
33
51
|
private readonly subscriberReceiveLoops;
|
|
34
|
-
|
|
52
|
+
readonly manualFanoutSubscribers: Map<string, ManualFanoutSubscriberState>;
|
|
35
53
|
private readonly manualFanoutSubscriberOwners;
|
|
36
54
|
private readonly routeReceiveLoops;
|
|
37
55
|
private readonly meshChannelDispatchers;
|
|
@@ -71,7 +89,7 @@ export declare class ZLinkChannelRuntimeLifecycle {
|
|
|
71
89
|
private startChannelReceivers;
|
|
72
90
|
private startSubscriberReceivers;
|
|
73
91
|
private getOrCreateManualFanoutSubscriber;
|
|
74
|
-
|
|
92
|
+
requestManualFanoutConnect(channelName: string, endpoint: string, taskRunner: ZLinkRuntimeTaskRunner, dispatcher: ZLinkChannelPublishDispatcher): void;
|
|
75
93
|
private requestManualFanoutDisconnect;
|
|
76
94
|
private enqueueManualFanoutTransition;
|
|
77
95
|
private openManualFanoutSubscriber;
|
|
@@ -85,3 +103,4 @@ export declare class ZLinkChannelRuntimeLifecycle {
|
|
|
85
103
|
private startRouteReceivers;
|
|
86
104
|
private createSpotRouteBridgeForRouter;
|
|
87
105
|
}
|
|
106
|
+
export {};
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import { inspectRuntime } from '../internal-observation';
|
|
2
2
|
import { type RoutingId, type ZLinkClientServerServerDescriptor, type ZLinkFanoutPublisherDescriptor } from '../../contracts';
|
|
3
3
|
import type { Message } from '../../contracts/Common/Message';
|
|
4
|
-
import type { ZLinkBackendContext, ZLinkBackendDealerSocket, ZLinkBackendPublisherSocket, ZLinkBackendRouterSocket, ZLinkBackendSocketMonitor, ZLinkBackendSubscriberSocket, ZLinkChannelBackendAdapter, ZLinkMonitoringBackendAdapter } from '../backend/contracts';
|
|
4
|
+
import type { ZLinkBackendContext, ZLinkBackendDealerSocket, ZLinkBackendPublisherSocket, ZLinkBackendReadablePoller, ZLinkBackendRouterSocket, ZLinkBackendSocketMonitor, ZLinkBackendSubscriberSocket, ZLinkChannelBackendAdapter, ZLinkMonitoringBackendAdapter } from '../backend/contracts';
|
|
5
5
|
import { type ZLinkFrameworkRegistration } from '../configuration';
|
|
6
6
|
import { ZLinkListenerRecords } from '../foundation/listener-records';
|
|
7
7
|
import { ServiceDiscoveryRegistry } from '../foundation/service-discovery-registry';
|
|
8
8
|
import { ServiceLivenessConnection } from '../foundation/service-liveness-registry';
|
|
9
9
|
import type { ApplicationJobQueue } from '../host/application-job-queue';
|
|
10
10
|
import type { ZLinkChannelEnvelopeHeader } from './channel-envelope';
|
|
11
|
+
import { type ZLinkClientServerAdmission } from './client-server-service-wire';
|
|
11
12
|
export interface ZLinkClientServerServerSocketIdentity {
|
|
12
13
|
readonly serverRid: string;
|
|
13
14
|
readonly lifecycleGeneration: bigint;
|
|
@@ -18,6 +19,20 @@ export interface ZLinkClientServerConnectionCallbacks {
|
|
|
18
19
|
readonly onTerminated: (routingId: string | undefined, endpoint: string) => void;
|
|
19
20
|
}
|
|
20
21
|
type ClientServerDiscoveryDescriptor = Parameters<ServiceDiscoveryRegistry['admitClientServer']>[0];
|
|
22
|
+
interface ClientServerPhysicalConnection {
|
|
23
|
+
readonly channelName: string;
|
|
24
|
+
readonly endpoint: string;
|
|
25
|
+
readonly dealer: ZLinkBackendDealerSocket;
|
|
26
|
+
readablePoller?: ZLinkBackendReadablePoller;
|
|
27
|
+
monitor?: ZLinkBackendSocketMonitor;
|
|
28
|
+
readonly aliases: Set<string>;
|
|
29
|
+
readonly callbacksByAlias: Map<string, ZLinkClientServerConnectionCallbacks>;
|
|
30
|
+
physicalConnectionId: symbol;
|
|
31
|
+
readyConnectionId?: string;
|
|
32
|
+
admittedDescriptor?: ClientServerDiscoveryDescriptor;
|
|
33
|
+
liveness?: ServiceLivenessConnection;
|
|
34
|
+
admissionAttempt?: symbol;
|
|
35
|
+
}
|
|
21
36
|
export interface ZLinkFanoutConnectionCallbacks {
|
|
22
37
|
readonly onReady: () => void;
|
|
23
38
|
readonly onTerminated: (reason: 'disconnect' | 'deadline' | 'protocol') => void;
|
|
@@ -46,7 +61,7 @@ export declare class ZLinkChannelSocketRegistry {
|
|
|
46
61
|
private readonly routeRouters;
|
|
47
62
|
private readonly routeMembers;
|
|
48
63
|
private readonly clientServerIdentities;
|
|
49
|
-
|
|
64
|
+
readonly clientServerConnections: Map<string, ClientServerPhysicalConnection>;
|
|
50
65
|
private readonly clientServerDiscovery;
|
|
51
66
|
private readonly clientServerReadyIdentities;
|
|
52
67
|
private readonly clientServerServerDescriptors;
|
|
@@ -143,9 +158,12 @@ export declare class ZLinkChannelSocketRegistry {
|
|
|
143
158
|
* the existing admission path.
|
|
144
159
|
*/
|
|
145
160
|
private restartClientServerAdmission;
|
|
146
|
-
|
|
161
|
+
applyClientServerDescriptorUpdate(connectionId: string, connection: {
|
|
162
|
+
readonly channelName: string;
|
|
163
|
+
readonly physicalConnectionId: symbol;
|
|
164
|
+
}, admission: ZLinkClientServerAdmission): void;
|
|
147
165
|
private ensureClientServerLivenessTimer;
|
|
148
|
-
|
|
166
|
+
drainSocketMonitors(): void;
|
|
149
167
|
private removeReadyConnection;
|
|
150
168
|
private requestClientServerLiveness;
|
|
151
169
|
private admitClientServerServerPeer;
|
|
@@ -169,7 +169,7 @@ export declare class ZLinkRuntimeMetrics {
|
|
|
169
169
|
recordChannelSelectionFailure(meshName: string, channelName: string, reason: string): void;
|
|
170
170
|
recordMessageDropped(meshName: string, surface: string, messageKind: string, reason: string): void;
|
|
171
171
|
startInstanceSpotActivation(meshName: string, instanceSpotType: string): ZLinkRuntimeMetricOperation;
|
|
172
|
-
startRelocation(meshName: string, objectKind: 'actor' | 'user_spot' | 'instance_spot', policy: 'recreate' | 'snapshot'): ZLinkRelocationMetricOperation;
|
|
172
|
+
startRelocation(meshName: string, objectKind: 'actor' | 'user_spot' | 'instance_spot', policy: 'recreate' | 'snapshot', onComplete?: (outcome: string) => void): ZLinkRelocationMetricOperation;
|
|
173
173
|
recordInstanceSpotClaimConflict(meshName: string, instanceSpotType: string, reason: string): void;
|
|
174
174
|
recordInstanceSpotTakeover(meshName: string, instanceSpotType: string, outcome: string): void;
|
|
175
175
|
enabled(): boolean;
|
|
@@ -426,7 +426,7 @@ class ZLinkRuntimeMetrics {
|
|
|
426
426
|
}
|
|
427
427
|
};
|
|
428
428
|
}
|
|
429
|
-
startRelocation(meshName, objectKind, policy) {
|
|
429
|
+
startRelocation(meshName, objectKind, policy, onComplete) {
|
|
430
430
|
const started = process.hrtime.bigint();
|
|
431
431
|
const startAttributes = { mesh_name: meshName, object_kind: objectKind, policy };
|
|
432
432
|
let completed = false;
|
|
@@ -444,6 +444,7 @@ class ZLinkRuntimeMetrics {
|
|
|
444
444
|
const terminal = { ...startAttributes, outcome };
|
|
445
445
|
this.count(exports.METRIC_NAMES.RelocationCompleted, 1, terminal);
|
|
446
446
|
this.duration(exports.METRIC_NAMES.RelocationDuration, Number(process.hrtime.bigint() - started) / exports.NANOSECONDS_PER_SECOND, terminal);
|
|
447
|
+
onComplete?.(outcome);
|
|
447
448
|
}
|
|
448
449
|
};
|
|
449
450
|
}
|
|
@@ -33,16 +33,28 @@ export interface ZLinkSerialWorkPreparation {
|
|
|
33
33
|
prepare(signal: AbortSignal): Promise<void>;
|
|
34
34
|
cancel(): void;
|
|
35
35
|
}
|
|
36
|
+
type SerialWorkRecord<T> = Omit<ZLinkSerialWorkRecord<T>, 'acceptedSequence'> & {
|
|
37
|
+
acceptedSequence: bigint;
|
|
38
|
+
readonly operationEnvelope: boolean;
|
|
39
|
+
readonly mailbox?: ZLinkSerialExecutionQueue;
|
|
40
|
+
readonly preparation?: ZLinkSerialWorkPreparation;
|
|
41
|
+
preparationState: 'idle' | 'pending' | 'canceling' | 'ready' | 'failed';
|
|
42
|
+
preparationController?: AbortController;
|
|
43
|
+
preparationError?: unknown;
|
|
44
|
+
};
|
|
45
|
+
interface ZLinkSerialAdmissionLane {
|
|
46
|
+
readonly records: Array<SerialWorkRecord<unknown>>;
|
|
47
|
+
}
|
|
36
48
|
/**
|
|
37
49
|
* One event-loop serial execution queue per Spot, Actor mailbox, or Stream session.
|
|
38
50
|
* Application work carries the host permit through the queue until the handler starts.
|
|
39
51
|
*/
|
|
40
52
|
export declare class ZLinkSerialExecutionQueue {
|
|
41
|
-
|
|
53
|
+
readonly executeRecord: (record: ZLinkSerialWorkRecord<unknown>) => Promise<void>;
|
|
42
54
|
private readonly sharedOwner?;
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
55
|
+
readonly application: ZLinkSerialAdmissionLane;
|
|
56
|
+
readonly lifecycle: ZLinkSerialAdmissionLane;
|
|
57
|
+
activeLifecycle?: ZLinkSerialWorkRecord<unknown>;
|
|
46
58
|
private activeRecord?;
|
|
47
59
|
/** The admitted node itself owns ready membership; no second readiness flag. */
|
|
48
60
|
private ownerMembership?;
|
|
@@ -54,7 +66,7 @@ export declare class ZLinkSerialExecutionQueue {
|
|
|
54
66
|
private lifecycleDebt;
|
|
55
67
|
private claimStartedAt?;
|
|
56
68
|
private closed;
|
|
57
|
-
|
|
69
|
+
readonly idleWaiters: Array<() => void>;
|
|
58
70
|
constructor(executeRecord: (record: ZLinkSerialWorkRecord<unknown>) => Promise<void>, options?: ZLinkSerialSchedulerOptions, sharedOwner?: ZLinkSerialExecutionQueue | undefined);
|
|
59
71
|
submit<T>(operation: () => Promise<T> | T, options?: ZLinkSerialWorkOptions, context?: unknown): Promise<T>;
|
|
60
72
|
submitDetached<T>(operation: () => Promise<T> | T, onError: (error: unknown) => void, options?: ZLinkSerialWorkOptions, context?: unknown): void;
|
|
@@ -79,22 +91,23 @@ export declare class ZLinkSerialExecutionQueue {
|
|
|
79
91
|
/** Stops admission within the lifecycle operation that owns this queue's close. */
|
|
80
92
|
closeAdmission(): void;
|
|
81
93
|
get admissionClosed(): boolean;
|
|
82
|
-
|
|
83
|
-
|
|
94
|
+
admit<T>(operation: () => Promise<T> | T, options: ZLinkSerialWorkOptions | undefined, context?: unknown, preparation?: ZLinkSerialWorkPreparation, operationEnvelope?: boolean): Promise<T>;
|
|
95
|
+
scheduleDrain(): void;
|
|
84
96
|
/** Notifications carry no payload, admission sequence, result Promise, or host permit. */
|
|
85
|
-
|
|
97
|
+
enqueueMailboxTurn(operation: () => void): void;
|
|
86
98
|
/** Called only by the shared scheduler's consumer, never by a producer. */
|
|
87
99
|
private consumeMailbox;
|
|
88
100
|
private finishMailbox;
|
|
89
|
-
|
|
101
|
+
drain(): Promise<void>;
|
|
90
102
|
private prepareSelected;
|
|
91
|
-
|
|
92
|
-
|
|
103
|
+
selectNext(): SerialWorkRecord<unknown> | undefined;
|
|
104
|
+
takeSelected(selected: SerialWorkRecord<unknown>): ZLinkSerialWorkRecord<unknown>;
|
|
93
105
|
private takeLifecycle;
|
|
94
|
-
|
|
106
|
+
takeApplication(selected: SerialWorkRecord<unknown>): ZLinkSerialWorkRecord<unknown>;
|
|
95
107
|
private startPreparation;
|
|
96
108
|
/** Returns false while an outstanding readiness attempt is being canceled. */
|
|
97
109
|
private cancelPreparationForRearbitration;
|
|
98
110
|
private shouldYield;
|
|
99
|
-
|
|
111
|
+
resolveIdleWaiters(): void;
|
|
100
112
|
}
|
|
113
|
+
export {};
|
|
@@ -3,12 +3,12 @@ import type { RequestRuntime } from './request-runtime';
|
|
|
3
3
|
import { inspectRuntime } from '../internal-observation';
|
|
4
4
|
import { ApplicationIngressRecordOwner } from '../application-jobs/application-ingress-record-owner';
|
|
5
5
|
import type { ApplicationJobQueuePort } from '../application-jobs/contracts';
|
|
6
|
-
import type { ZLinkRawBindingPort } from '../backend/raw-binding-port';
|
|
6
|
+
import type { ZLinkRawBindingPort, ZLinkRawReceivedRecord, ZLinkRawRouterPort } from '../backend/raw-binding-port';
|
|
7
7
|
import { SubmitResult } from '../backend/runtime-values';
|
|
8
8
|
import { type OperationObserver, type PendingOperation } from './operation-registry';
|
|
9
9
|
import { ServiceLivenessRegistry, type ServiceLivenessTick } from './service-liveness-registry';
|
|
10
10
|
import { ServiceMailbox, type ServiceMailboxRecord } from './service-mailbox';
|
|
11
|
-
import { ServiceTopologyRegistry, type ServiceNodeDescriptor } from './service-topology-registry';
|
|
11
|
+
import { ServiceTopologyRegistry, type PeerAdmissionResult, type ServiceNodeDescriptor } from './service-topology-registry';
|
|
12
12
|
import { type ServiceApplicationPayload } from './service-wire-m6a-codec';
|
|
13
13
|
export type RawServicePumpResult = 'noData' | 'infrastructure' | 'application' | 'dropped' | 'protocolError';
|
|
14
14
|
export type RawServicePumpObserver = (sourceRoutingId: string, byteCount: number) => void;
|
|
@@ -67,6 +67,12 @@ export interface RawServiceMeshRuntimeOptions {
|
|
|
67
67
|
}) => void;
|
|
68
68
|
}
|
|
69
69
|
export declare const RAW_MESH_RECEIVE_TIME_BUDGET_MS = 2;
|
|
70
|
+
interface ControlSendState {
|
|
71
|
+
task?: Promise<boolean>;
|
|
72
|
+
next?: () => boolean | Promise<boolean>;
|
|
73
|
+
current?: () => boolean;
|
|
74
|
+
hello?: Uint8Array;
|
|
75
|
+
}
|
|
70
76
|
/**
|
|
71
77
|
* RouteMesh M6A runtime built only on the public raw binding package.
|
|
72
78
|
* It owns protocol, admission, mailbox, request and liveness state.
|
|
@@ -85,7 +91,13 @@ export declare class RawServiceMeshRuntime {
|
|
|
85
91
|
private readonly requestOwner;
|
|
86
92
|
private readonly releaseOperations;
|
|
87
93
|
private readonly operations;
|
|
88
|
-
|
|
94
|
+
readonly expectedPeers: Map<string, {
|
|
95
|
+
readonly meshName: string;
|
|
96
|
+
readonly nodeRoutingId: string;
|
|
97
|
+
readonly endpoint?: string;
|
|
98
|
+
readonly securityIdentity?: string;
|
|
99
|
+
readonly lifecycleGeneration?: bigint;
|
|
100
|
+
}>;
|
|
89
101
|
private readonly endpointOnlyPeers;
|
|
90
102
|
private readonly peerConnectionIntentRemoved;
|
|
91
103
|
private readonly peerRouteChanged;
|
|
@@ -93,7 +105,7 @@ export declare class RawServiceMeshRuntime {
|
|
|
93
105
|
* The last observed Core selected route of each RID (Core ROUTER §10.1):
|
|
94
106
|
* RID -> route generation. Only `observeSelectedRoutes` replaces it.
|
|
95
107
|
*/
|
|
96
|
-
|
|
108
|
+
selectedRoutes: Map<string, bigint>;
|
|
97
109
|
private connectionAttempts;
|
|
98
110
|
private readonly bindingPort;
|
|
99
111
|
private readonly applicationJobQueue;
|
|
@@ -103,7 +115,7 @@ export declare class RawServiceMeshRuntime {
|
|
|
103
115
|
private receiveAcquisition?;
|
|
104
116
|
private receivePermit?;
|
|
105
117
|
private receiveRotation?;
|
|
106
|
-
|
|
118
|
+
readonly controlSends: Map<string, ControlSendState>;
|
|
107
119
|
private infrastructureFailure?;
|
|
108
120
|
private readonly onReceiveReady?;
|
|
109
121
|
private readonly infrastructureTaskRunner?;
|
|
@@ -114,7 +126,7 @@ export declare class RawServiceMeshRuntime {
|
|
|
114
126
|
private readonly resolveAdvertisedEndpoint?;
|
|
115
127
|
private descriptor;
|
|
116
128
|
private host?;
|
|
117
|
-
|
|
129
|
+
router?: ZLinkRawRouterPort;
|
|
118
130
|
private nextCorrelation;
|
|
119
131
|
private serviceIngress?;
|
|
120
132
|
private serviceIngressAccepts?;
|
|
@@ -186,9 +198,9 @@ export declare class RawServiceMeshRuntime {
|
|
|
186
198
|
private acquireReceivePermit;
|
|
187
199
|
private finishPendingReceive;
|
|
188
200
|
private finishReceive;
|
|
189
|
-
|
|
201
|
+
reportProtocolError(received: import('../backend/node/node-raw-binding-port').ZLinkRawReceivedRecord): void;
|
|
190
202
|
private replyGenericProtocolError;
|
|
191
|
-
|
|
203
|
+
processReceived(received: ZLinkRawReceivedRecord, nowMs: number, applicationJobOwner: ApplicationIngressRecordOwner): RawServicePumpResult | Promise<RawServicePumpResult>;
|
|
192
204
|
private finishPendingProtocolReceive;
|
|
193
205
|
private finishPendingStatefulReceive;
|
|
194
206
|
private receiveProtocolFailure;
|
|
@@ -223,14 +235,18 @@ export declare class RawServiceMeshRuntime {
|
|
|
223
235
|
*/
|
|
224
236
|
private applicationFrame;
|
|
225
237
|
private applicationPayload;
|
|
226
|
-
|
|
238
|
+
admitPeer(descriptor: ServiceNodeDescriptor, connectionId: string | bigint, nowMs: number, expected?: {
|
|
239
|
+
readonly endpoint?: string;
|
|
240
|
+
readonly securityIdentity?: string;
|
|
241
|
+
readonly lifecycleGeneration?: bigint;
|
|
242
|
+
}, command?: number, descriptorBytes?: Uint8Array): PeerAdmissionResult;
|
|
227
243
|
private retireNotRequiredExpectedPeer;
|
|
228
244
|
private selectBilateralConnection;
|
|
229
245
|
private removePeer;
|
|
230
246
|
private requireStarted;
|
|
231
|
-
|
|
247
|
+
sendControl(targetNodeRoutingId: string, parts: readonly Uint8Array[]): Promise<boolean>;
|
|
232
248
|
private submitControl;
|
|
233
|
-
|
|
249
|
+
startControlSend(target: string, command: number, attempt: () => boolean | Promise<boolean>, current?: () => boolean, hello?: Uint8Array): boolean;
|
|
234
250
|
reportInfrastructureFailure(error: unknown): void;
|
|
235
251
|
private observeInfrastructureFailure;
|
|
236
252
|
private send;
|