@zlink-systems/framework 0.29.0 → 0.30.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/Configuration/Builders.d.ts +1 -2
- package/dist/contracts/Configuration/Configs.d.ts +0 -5
- package/dist/contracts/Configuration/RegistrationBuilders.js +6 -4
- package/dist/contracts/Configuration/RegistrationTypes.d.ts +1 -6
- package/dist/contracts/Configuration/RegistrationValidators.js +4 -4
- package/dist/contracts/Configuration/index.d.ts +1 -1
- package/dist/internal.d.ts +1 -0
- package/dist/internal.js +3 -1
- package/dist/runtime/actors/actor-handoff.d.ts +3 -2
- package/dist/runtime/actors/actor-handoff.js +9 -4
- package/dist/runtime/actors/actor-runtime-contracts.d.ts +1 -0
- package/dist/runtime/actors/index.d.ts +2 -0
- package/dist/runtime/actors/index.js +21 -6
- package/dist/runtime/application-jobs/application-ingress-record-owner.d.ts +3 -1
- package/dist/runtime/application-jobs/application-ingress-record-owner.js +6 -1
- package/dist/runtime/application-jobs/application-job-queue-scope.d.ts +3 -1
- package/dist/runtime/application-jobs/application-job-queue-scope.js +5 -0
- package/dist/runtime/application-jobs/contracts.d.ts +5 -1
- package/dist/runtime/backend/contracts/index.d.ts +10 -19
- package/dist/runtime/backend/mesh-completion-table.d.ts +6 -4
- package/dist/runtime/backend/mesh-completion-table.js +28 -18
- package/dist/runtime/backend/mesh-dispatch-pump.js +21 -25
- package/dist/runtime/backend/node/node-backend-adapter-factory.js +6 -1
- package/dist/runtime/backend/node/node-backend-adapter-support.d.ts +3 -3
- package/dist/runtime/backend/node/node-backend-adapter-support.js +24 -29
- package/dist/runtime/backend/node/node-mesh-backend-adapter.d.ts +1 -9
- package/dist/runtime/backend/node/node-mesh-backend-adapter.js +1 -1
- package/dist/runtime/backend/node/node-raw-binding-port.js +11 -6
- package/dist/runtime/backend/node/node-raw-mesh-backend.d.ts +10 -12
- package/dist/runtime/backend/node/node-raw-mesh-backend.js +64 -98
- package/dist/runtime/backend/node/node-socket-backend-adapter.js +10 -5
- package/dist/runtime/backend/raw-binding-port.d.ts +9 -2
- package/dist/runtime/channels/channel-receive-loops.js +3 -3
- package/dist/runtime/channels/channel-runtime-lifecycle.js +2 -1
- package/dist/runtime/channels/channel-socket-registry.d.ts +10 -3
- package/dist/runtime/channels/channel-socket-registry.js +59 -82
- package/dist/runtime/diagnostics/message-flow.d.ts +1 -0
- package/dist/runtime/diagnostics/message-flow.js +3 -3
- package/dist/runtime/foundation/raw-service-mesh-runtime.d.ts +15 -1
- package/dist/runtime/foundation/raw-service-mesh-runtime.js +193 -64
- package/dist/runtime/foundation/service-liveness-registry.d.ts +20 -8
- package/dist/runtime/foundation/service-liveness-registry.js +57 -44
- package/dist/runtime/foundation/service-mailbox.d.ts +3 -0
- package/dist/runtime/foundation/service-mailbox.js +2 -1
- package/dist/runtime/foundation/service-stateful-runtime.d.ts +7 -6
- package/dist/runtime/foundation/service-stateful-runtime.js +60 -41
- package/dist/runtime/foundation/service-stateful-wire-codec.d.ts +5 -2
- package/dist/runtime/foundation/service-stateful-wire-codec.js +43 -61
- package/dist/runtime/foundation/service-topology-registry.d.ts +5 -3
- package/dist/runtime/foundation/service-topology-registry.js +9 -4
- package/dist/runtime/handlers/handler-instance-scope.js +1 -1
- package/dist/runtime/host/actor-packet-relay.js +7 -7
- package/dist/runtime/host/actor-placement-coordinator.d.ts +2 -1
- package/dist/runtime/host/actor-placement-coordinator.js +2 -1
- package/dist/runtime/host/actor-runtime-options-factory.d.ts +2 -1
- package/dist/runtime/host/actor-runtime-options-factory.js +2 -1
- package/dist/runtime/host/application-job-queue.d.ts +11 -4
- package/dist/runtime/host/application-job-queue.js +66 -10
- package/dist/runtime/host/entry-actor-runtime.js +1 -1
- package/dist/runtime/host/index.d.ts +1 -1
- package/dist/runtime/host/index.js +18 -13
- package/dist/runtime/host/instance-activation-authority.d.ts +2 -1
- package/dist/runtime/host/instance-activation-authority.js +89 -25
- package/dist/runtime/host/service-relocation-host-runtime.js +2 -2
- package/dist/runtime/host/spot-address-transport.d.ts +1 -0
- package/dist/runtime/host/spot-address-transport.js +25 -12
- package/dist/runtime/host/spot-runtime-options-factory.js +2 -2
- package/dist/runtime/host/user-spot-creation-coordinator.d.ts +1 -0
- package/dist/runtime/host/user-spot-creation-coordinator.js +1 -0
- package/dist/runtime/locations/domain-store-contract.d.ts +3 -2
- package/dist/runtime/locations/in-memory-authority-store.d.ts +5 -2
- package/dist/runtime/locations/in-memory-authority-store.js +107 -14
- package/dist/runtime/locations/in-memory-location-store.d.ts +3 -3
- package/dist/runtime/locations/in-memory-location-store.js +31 -13
- package/dist/runtime/locations/internal-location-contracts.d.ts +8 -0
- package/dist/runtime/locations/location-store-repository.d.ts +4 -2
- package/dist/runtime/locations/location-store-repository.js +209 -33
- package/dist/runtime/locations/resolvers.d.ts +2 -1
- package/dist/runtime/locations/resolvers.js +10 -1
- package/dist/runtime/messaging/submission-result.d.ts +1 -1
- package/dist/runtime/messaging/submission-result.js +2 -2
- package/dist/runtime/spots/formal-remote-actor-admission-registry.d.ts +2 -0
- package/dist/runtime/spots/index.d.ts +4 -3
- package/dist/runtime/spots/index.js +14 -14
- package/dist/runtime/spots/spot-activation.d.ts +2 -1
- package/dist/runtime/spots/spot-activation.js +4 -4
- package/dist/runtime/spots/spot-actor-admission-coordinator.d.ts +2 -1
- package/dist/runtime/spots/spot-actor-admission-coordinator.js +11 -10
- package/dist/runtime/spots/spot-actor-packet-dispatch.d.ts +4 -1
- package/dist/runtime/spots/spot-actor-packet-dispatch.js +7 -5
- package/dist/runtime/spots/spot-actor-packet-drain.js +2 -0
- package/dist/runtime/spots/spot-actor-packet-relay-dispatch.js +1 -0
- package/dist/runtime/spots/spot-entry-activation.d.ts +1 -0
- package/dist/runtime/spots/spot-entry-activation.js +6 -1
- package/dist/runtime/spots/spot-node-runtime-manager.d.ts +3 -1
- package/dist/runtime/spots/spot-node-runtime-manager.js +10 -11
- package/dist/runtime/spots/spot-routing-internal.d.ts +6 -0
- package/dist/runtime/spots/spot-runtime-ports.d.ts +2 -1
- package/dist/runtime/spots/spot-serial-executor.d.ts +1 -0
- package/dist/runtime/spots/spot-serial-executor.js +10 -1
- package/dist/runtime/streams/stream-session-runtime.js +1 -1
- package/package.json +3 -3
- package/src/contracts/Configuration/Builders.ts +1 -2
- package/src/contracts/Configuration/Configs.ts +0 -6
- package/src/contracts/Configuration/RegistrationBuilders.ts +8 -12
- package/src/contracts/Configuration/RegistrationTypes.ts +1 -6
- package/src/contracts/Configuration/RegistrationValidators.ts +9 -10
- package/src/contracts/Configuration/index.ts +1 -6
- package/src/internal.ts +1 -0
- package/src/runtime/actors/actor-handoff.ts +13 -4
- package/src/runtime/actors/actor-runtime-contracts.ts +4 -0
- package/src/runtime/actors/index.ts +77 -42
- package/src/runtime/application-jobs/application-ingress-record-owner.ts +12 -2
- package/src/runtime/application-jobs/application-job-queue-scope.ts +6 -1
- package/src/runtime/application-jobs/contracts.ts +14 -1
- package/src/runtime/backend/contracts/index.ts +10 -18
- package/src/runtime/backend/mesh-completion-table.ts +36 -19
- package/src/runtime/backend/mesh-dispatch-pump.ts +19 -22
- package/src/runtime/backend/node/node-backend-adapter-factory.ts +12 -5
- package/src/runtime/backend/node/node-backend-adapter-support.ts +31 -29
- package/src/runtime/backend/node/node-mesh-backend-adapter.ts +3 -10
- package/src/runtime/backend/node/node-raw-binding-port.ts +19 -10
- package/src/runtime/backend/node/node-raw-mesh-backend.ts +81 -111
- package/src/runtime/backend/node/node-socket-backend-adapter.ts +12 -8
- package/src/runtime/backend/raw-binding-port.ts +12 -2
- package/src/runtime/channels/channel-receive-loops.ts +3 -3
- package/src/runtime/channels/channel-runtime-lifecycle.ts +7 -1
- package/src/runtime/channels/channel-socket-registry.ts +84 -130
- package/src/runtime/diagnostics/message-flow.ts +1 -1
- package/src/runtime/foundation/raw-service-mesh-runtime.ts +268 -70
- package/src/runtime/foundation/service-liveness-registry.ts +68 -59
- package/src/runtime/foundation/service-mailbox.ts +7 -1
- package/src/runtime/foundation/service-stateful-runtime.ts +109 -77
- package/src/runtime/foundation/service-stateful-wire-codec.ts +55 -79
- package/src/runtime/foundation/service-topology-registry.ts +13 -7
- package/src/runtime/handlers/handler-instance-scope.ts +2 -1
- package/src/runtime/host/actor-packet-relay.ts +7 -0
- package/src/runtime/host/actor-placement-coordinator.ts +8 -2
- package/src/runtime/host/actor-runtime-options-factory.ts +7 -0
- package/src/runtime/host/application-job-queue.ts +77 -10
- package/src/runtime/host/entry-actor-runtime.ts +1 -0
- package/src/runtime/host/index.ts +30 -7
- package/src/runtime/host/instance-activation-authority.ts +132 -27
- package/src/runtime/host/service-relocation-host-runtime.ts +2 -0
- package/src/runtime/host/spot-address-transport.ts +45 -22
- package/src/runtime/host/spot-runtime-options-factory.ts +2 -0
- package/src/runtime/host/user-spot-creation-coordinator.ts +8 -0
- package/src/runtime/locations/domain-store-contract.ts +6 -2
- package/src/runtime/locations/in-memory-authority-store.ts +153 -12
- package/src/runtime/locations/in-memory-location-store.ts +39 -13
- package/src/runtime/locations/internal-location-contracts.ts +10 -0
- package/src/runtime/locations/location-store-repository.ts +295 -36
- package/src/runtime/locations/resolvers.ts +25 -2
- package/src/runtime/messaging/submission-result.ts +2 -2
- package/src/runtime/spots/formal-remote-actor-admission-registry.ts +2 -0
- package/src/runtime/spots/index.ts +16 -0
- package/src/runtime/spots/spot-activation.ts +5 -0
- package/src/runtime/spots/spot-actor-admission-coordinator.ts +13 -0
- package/src/runtime/spots/spot-actor-packet-dispatch.ts +10 -0
- package/src/runtime/spots/spot-actor-packet-drain.ts +2 -0
- package/src/runtime/spots/spot-actor-packet-relay-dispatch.ts +1 -0
- package/src/runtime/spots/spot-entry-activation.ts +7 -0
- package/src/runtime/spots/spot-node-runtime-manager.ts +14 -12
- package/src/runtime/spots/spot-routing-internal.ts +14 -0
- package/src/runtime/spots/spot-runtime-ports.ts +2 -0
- package/src/runtime/spots/spot-serial-executor.ts +10 -4
- package/src/runtime/streams/stream-session-runtime.ts +1 -1
|
@@ -192,7 +192,7 @@ class ZLinkMeshDispatchPump {
|
|
|
192
192
|
async drainDomain(domain, readyBatch, receiveBatch, claimBudget) {
|
|
193
193
|
let claimsDrained = 0;
|
|
194
194
|
try {
|
|
195
|
-
|
|
195
|
+
while (!this.disposed) {
|
|
196
196
|
if (claimBudget !== undefined && claimsDrained >= claimBudget) {
|
|
197
197
|
// Lifecycle work has priority, but a bounded turn lets application
|
|
198
198
|
// work make progress when lifecycle records keep arriving.
|
|
@@ -217,20 +217,18 @@ class ZLinkMeshDispatchPump {
|
|
|
217
217
|
try {
|
|
218
218
|
ownerReceiveBatch ??= this.node.createReceiveBatch(MESH_DISPATCH_RECEIVE_CAPACITY, this.options.partCapacity ?? DEFAULT_MESH_PART_CAPACITY);
|
|
219
219
|
const capacity = owner.ordinaryIngressPreAdmitted === true ? MESH_DISPATCH_RECEIVE_CAPACITY : 1;
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
break;
|
|
233
|
-
// This owner keeps its claim while it drains, so its records stay in FIFO order.
|
|
220
|
+
let claimPermit = owner.terminalCompletion === true ||
|
|
221
|
+
owner.ordinaryIngressPreAdmitted === true ||
|
|
222
|
+
domain === service_runtime_contracts_1.ReadyDomain.Infrastructure
|
|
223
|
+
? undefined
|
|
224
|
+
: await this.acquirePermit();
|
|
225
|
+
try {
|
|
226
|
+
if (this.capacityStop.signal.aborted)
|
|
227
|
+
return;
|
|
228
|
+
ownerReceiveBatch.reset(capacity);
|
|
229
|
+
const received = claim.recvBatch(ownerReceiveBatch, runtime_values_1.ZLINK_BACKEND_RECV_DONT_WAIT);
|
|
230
|
+
if (received.ok) {
|
|
231
|
+
// The bounded batch stays in claim order until its records finish.
|
|
234
232
|
try {
|
|
235
233
|
for (const record of received.records) {
|
|
236
234
|
if (this.disposed)
|
|
@@ -263,9 +261,6 @@ class ZLinkMeshDispatchPump {
|
|
|
263
261
|
claimPermit = undefined;
|
|
264
262
|
await (0, application_job_queue_scope_1.runWithApplicationJobPermit)(permit, dispatch);
|
|
265
263
|
}
|
|
266
|
-
const yieldTurn = this.yieldIfNeeded();
|
|
267
|
-
if (yieldTurn !== undefined)
|
|
268
|
-
await yieldTurn;
|
|
269
264
|
}
|
|
270
265
|
}
|
|
271
266
|
finally {
|
|
@@ -278,9 +273,9 @@ class ZLinkMeshDispatchPump {
|
|
|
278
273
|
}
|
|
279
274
|
}
|
|
280
275
|
}
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
276
|
+
}
|
|
277
|
+
finally {
|
|
278
|
+
claimPermit?.releaseAfterInternalProcessing();
|
|
284
279
|
}
|
|
285
280
|
}
|
|
286
281
|
finally {
|
|
@@ -288,6 +283,9 @@ class ZLinkMeshDispatchPump {
|
|
|
288
283
|
if (receiveBatch === undefined)
|
|
289
284
|
ownerReceiveBatch?.close();
|
|
290
285
|
}
|
|
286
|
+
const yieldTurn = this.yieldIfNeeded();
|
|
287
|
+
if (yieldTurn !== undefined)
|
|
288
|
+
await yieldTurn;
|
|
291
289
|
};
|
|
292
290
|
// An application worker drains the one owner it claimed. Infrastructure owners
|
|
293
291
|
// drain independently, so a suspended owner does not hold the other claims.
|
|
@@ -310,10 +308,8 @@ class ZLinkMeshDispatchPump {
|
|
|
310
308
|
const yieldTurn = this.yieldIfNeeded();
|
|
311
309
|
if (yieldTurn !== undefined)
|
|
312
310
|
await yieldTurn;
|
|
313
|
-
if (!drained.hasResidue) {
|
|
314
|
-
return false;
|
|
315
|
-
}
|
|
316
311
|
}
|
|
312
|
+
return false;
|
|
317
313
|
}
|
|
318
314
|
finally {
|
|
319
315
|
readyBatch.reset();
|
|
@@ -334,7 +330,7 @@ class ZLinkMeshDispatchPump {
|
|
|
334
330
|
}
|
|
335
331
|
async acquirePermit() {
|
|
336
332
|
try {
|
|
337
|
-
return await this.options.applicationJobQueue.acquire(this.capacityStop.signal);
|
|
333
|
+
return await this.options.applicationJobQueue.acquire(this.capacityStop.signal, 'remote');
|
|
338
334
|
}
|
|
339
335
|
catch (error) {
|
|
340
336
|
if (this.disposed || this.capacityStop.signal.aborted)
|
|
@@ -34,7 +34,12 @@ class ZLinkNodeChannelBackendAdapter {
|
|
|
34
34
|
return (0, node_socket_backend_adapter_1.wrapSocket)(node_backend_adapter_support_1.zlink.createDealerSocket(asNodeContext(context)), true);
|
|
35
35
|
}
|
|
36
36
|
createRouterSocket(context) {
|
|
37
|
-
|
|
37
|
+
const socket = node_backend_adapter_support_1.zlink.createRouterSocket(asNodeContext(context));
|
|
38
|
+
const adapter = (0, node_socket_backend_adapter_1.wrapSocket)(socket, true);
|
|
39
|
+
adapter.setReceiveFlowState = (state) => {
|
|
40
|
+
socket.setReceiveFlowState(state);
|
|
41
|
+
};
|
|
42
|
+
return adapter;
|
|
38
43
|
}
|
|
39
44
|
createPublisherSocket(context) {
|
|
40
45
|
return (0, node_socket_backend_adapter_1.wrapSocket)(node_backend_adapter_support_1.zlink.createPubSocket(asNodeContext(context)));
|
|
@@ -38,9 +38,10 @@ export declare function isRouteRecvRetryable(error: unknown): boolean;
|
|
|
38
38
|
export declare function submitBindingPublish(operation: ZLinkBindingPublishOperation, payload: unknown): void;
|
|
39
39
|
export declare function submitBindingReply(operation: ZLinkBindingReplyOperation, payload: unknown): void;
|
|
40
40
|
export declare function submitBindingAsyncSend(operation: ZLinkBindingAsyncSendOperation, payload: unknown): Promise<void>;
|
|
41
|
+
export declare function submitBindingSend(operation: ZLinkBindingAsyncSendOperation, payload: unknown): import('../raw-binding-port').ZLinkRawSendSubmission;
|
|
41
42
|
export declare function submitBindingSyncSend(operation: ZLinkBindingAsyncSendOperation, payload: unknown): void;
|
|
42
|
-
export declare function submitBindingRequest(operation: ZLinkBindingRequestOperation, payload: unknown, timeoutMs: number | undefined): Promise<readonly unknown[]>;
|
|
43
|
-
export declare function bindingRequestReply(submission: import('@zlink-systems/zlink').RequestSubmission, deadlineMs: number | undefined): Promise<import('@zlink-systems/zlink').Message[]>;
|
|
43
|
+
export declare function submitBindingRequest(operation: ZLinkBindingRequestOperation, payload: unknown, timeoutMs: number | undefined, recordReceived?: () => void): Promise<readonly unknown[]>;
|
|
44
|
+
export declare function bindingRequestReply(submission: import('@zlink-systems/zlink').RequestSubmission, deadlineMs: number | undefined, recordReceived?: () => void): Promise<import('@zlink-systems/zlink').Message[]>;
|
|
44
45
|
export declare function closeBindingReply(replies: readonly import('@zlink-systems/zlink').Message[]): void;
|
|
45
46
|
/**
|
|
46
47
|
* Closes a binding handle once. An already closed or terminated handle counts as
|
|
@@ -50,7 +51,6 @@ export declare function closeBindingHandle(target: {
|
|
|
50
51
|
close(): void;
|
|
51
52
|
}): void;
|
|
52
53
|
export declare function isContextTerminatedError(error: unknown): boolean;
|
|
53
|
-
export declare function disableSocketLinger(target: unknown): void;
|
|
54
54
|
export declare function toNativeRoutingId(routingId: unknown): unknown;
|
|
55
55
|
export declare function translateBindingResultError(error: unknown, phase?: 'submit' | 'completion'): unknown;
|
|
56
56
|
export declare function toNativeActorRef(actor: unknown): unknown;
|
|
@@ -6,13 +6,13 @@ exports.isRouteRecvRetryable = isRouteRecvRetryable;
|
|
|
6
6
|
exports.submitBindingPublish = submitBindingPublish;
|
|
7
7
|
exports.submitBindingReply = submitBindingReply;
|
|
8
8
|
exports.submitBindingAsyncSend = submitBindingAsyncSend;
|
|
9
|
+
exports.submitBindingSend = submitBindingSend;
|
|
9
10
|
exports.submitBindingSyncSend = submitBindingSyncSend;
|
|
10
11
|
exports.submitBindingRequest = submitBindingRequest;
|
|
11
12
|
exports.bindingRequestReply = bindingRequestReply;
|
|
12
13
|
exports.closeBindingReply = closeBindingReply;
|
|
13
14
|
exports.closeBindingHandle = closeBindingHandle;
|
|
14
15
|
exports.isContextTerminatedError = isContextTerminatedError;
|
|
15
|
-
exports.disableSocketLinger = disableSocketLinger;
|
|
16
16
|
exports.toNativeRoutingId = toNativeRoutingId;
|
|
17
17
|
exports.translateBindingResultError = translateBindingResultError;
|
|
18
18
|
exports.toNativeActorRef = toNativeActorRef;
|
|
@@ -76,6 +76,11 @@ function submitBindingReply(operation, payload) {
|
|
|
76
76
|
}
|
|
77
77
|
}
|
|
78
78
|
async function submitBindingAsyncSend(operation, payload) {
|
|
79
|
+
const submission = submitBindingSend(operation, payload);
|
|
80
|
+
if (submission.result === runtime_values_1.SubmitResult.Backpressured)
|
|
81
|
+
await submission.admitted;
|
|
82
|
+
}
|
|
83
|
+
function submitBindingSend(operation, payload) {
|
|
79
84
|
let submission;
|
|
80
85
|
try {
|
|
81
86
|
let current;
|
|
@@ -91,13 +96,14 @@ async function submitBindingAsyncSend(operation, payload) {
|
|
|
91
96
|
throw translateBindingResultError(error, 'submit');
|
|
92
97
|
}
|
|
93
98
|
if (submission.result === runtime_values_1.SubmitResult.Backpressured) {
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
}
|
|
99
|
+
return {
|
|
100
|
+
result: submission.result,
|
|
101
|
+
admitted: submission.admitted.catch((error) => {
|
|
102
|
+
throw translateBindingResultError(error, 'completion');
|
|
103
|
+
})
|
|
104
|
+
};
|
|
100
105
|
}
|
|
106
|
+
return { result: runtime_values_1.SubmitResult.Ok, admitted: submission.admitted };
|
|
101
107
|
}
|
|
102
108
|
function submitBindingSyncSend(operation, payload) {
|
|
103
109
|
try {
|
|
@@ -114,7 +120,7 @@ function submitBindingSyncSend(operation, payload) {
|
|
|
114
120
|
throw translateBindingResultError(error);
|
|
115
121
|
}
|
|
116
122
|
}
|
|
117
|
-
async function submitBindingRequest(operation, payload, timeoutMs) {
|
|
123
|
+
async function submitBindingRequest(operation, payload, timeoutMs, recordReceived) {
|
|
118
124
|
const deadlineMs = timeoutMs === undefined ? undefined : performance.now() + timeoutMs;
|
|
119
125
|
try {
|
|
120
126
|
let current;
|
|
@@ -132,25 +138,31 @@ async function submitBindingRequest(operation, payload, timeoutMs) {
|
|
|
132
138
|
if (timeoutMs !== undefined) {
|
|
133
139
|
current = current.timeout(timeoutMs);
|
|
134
140
|
}
|
|
135
|
-
return await bindingRequestReply(current.submit(), deadlineMs);
|
|
141
|
+
return await bindingRequestReply(current.submit(), deadlineMs, recordReceived);
|
|
136
142
|
}
|
|
137
143
|
catch (error) {
|
|
138
144
|
throw translateBindingResultError(error);
|
|
139
145
|
}
|
|
140
146
|
}
|
|
141
|
-
async function bindingRequestReply(submission, deadlineMs) {
|
|
147
|
+
async function bindingRequestReply(submission, deadlineMs, recordReceived) {
|
|
142
148
|
const reply = submission.reply;
|
|
143
149
|
if (submission.result === runtime_values_1.SubmitResult.Backpressured) {
|
|
144
150
|
try {
|
|
145
151
|
const [, replies] = await (0, request_deadline_1.waitRequestReply)(Promise.all([submission.admitted, reply]), 'Request', deadlineMs);
|
|
152
|
+
recordReceived?.();
|
|
146
153
|
return replies;
|
|
147
154
|
}
|
|
148
155
|
catch (error) {
|
|
149
|
-
void reply.then(
|
|
156
|
+
void reply.then((parts) => {
|
|
157
|
+
recordReceived?.();
|
|
158
|
+
closeBindingReply(parts);
|
|
159
|
+
}, () => undefined);
|
|
150
160
|
throw error;
|
|
151
161
|
}
|
|
152
162
|
}
|
|
153
|
-
|
|
163
|
+
const replies = await reply;
|
|
164
|
+
recordReceived?.();
|
|
165
|
+
return replies;
|
|
154
166
|
}
|
|
155
167
|
function closeBindingReply(replies) {
|
|
156
168
|
for (const reply of replies)
|
|
@@ -182,23 +194,6 @@ function isSuccessfulOrAlreadyShutdownCloseError(error) {
|
|
|
182
194
|
function isContextTerminatedError(error) {
|
|
183
195
|
return error instanceof Error && /context was terminated/i.test(error.message);
|
|
184
196
|
}
|
|
185
|
-
function disableSocketLinger(target) {
|
|
186
|
-
if (target !== null &&
|
|
187
|
-
typeof target === 'object' &&
|
|
188
|
-
'options' in target &&
|
|
189
|
-
typeof target.options === 'object' &&
|
|
190
|
-
target.options !== null &&
|
|
191
|
-
'linger' in target.options) {
|
|
192
|
-
try {
|
|
193
|
-
target.options.linger = 0;
|
|
194
|
-
}
|
|
195
|
-
catch (error) {
|
|
196
|
-
if (!isContextTerminatedError(error)) {
|
|
197
|
-
throw error;
|
|
198
|
-
}
|
|
199
|
-
}
|
|
200
|
-
}
|
|
201
|
-
}
|
|
202
197
|
function toNativeRoutingId(routingId) {
|
|
203
198
|
if (typeof routingId === 'string')
|
|
204
199
|
return exports.zlink.RoutingId.from(routingId);
|
|
@@ -1,12 +1,4 @@
|
|
|
1
1
|
import type { ZLinkBackendContext, ZLinkBackendMeshNode, ZLinkMeshBackendAdapter } from '../contracts';
|
|
2
2
|
export declare class ZLinkNodeMeshBackendAdapter implements ZLinkMeshBackendAdapter {
|
|
3
|
-
createMeshNode(context: ZLinkBackendContext, options:
|
|
4
|
-
readonly meshName: string;
|
|
5
|
-
readonly routingId?: string;
|
|
6
|
-
readonly receiveTimeoutMs?: number;
|
|
7
|
-
readonly trustProfile?: string;
|
|
8
|
-
readonly applicationJobQueue: import('../../application-jobs/contracts').ApplicationJobQueuePort;
|
|
9
|
-
readonly applicationJobReceiveFlowFailureSink?: (error: unknown) => void;
|
|
10
|
-
readonly peerAdmissionSealed?: () => boolean;
|
|
11
|
-
}): ZLinkBackendMeshNode;
|
|
3
|
+
createMeshNode(context: ZLinkBackendContext, options: Parameters<ZLinkMeshBackendAdapter['createMeshNode']>[1]): ZLinkBackendMeshNode;
|
|
12
4
|
}
|
|
@@ -12,7 +12,7 @@ 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, options.receiveTimeoutMs), options.applicationJobQueue, options.applicationJobReceiveFlowFailureSink, options.peerAdmissionSealed);
|
|
15
|
+
return new node_raw_mesh_backend_1.ZLinkNodeRawMeshBackend(options.meshName, options.routingId, new node_raw_binding_port_1.ZLinkNodeRawBindingPort(bindingContext, options.receiveTimeoutMs), options.applicationJobQueue, options.applicationJobReceiveFlowFailureSink, options.peerAdmissionSealed, options.infrastructureTaskRunner);
|
|
16
16
|
}
|
|
17
17
|
}
|
|
18
18
|
exports.ZLinkNodeMeshBackendAdapter = ZLinkNodeMeshBackendAdapter;
|
|
@@ -114,10 +114,6 @@ class NodeRawSocketPort {
|
|
|
114
114
|
connectable(this.socket).disconnect(endpoint);
|
|
115
115
|
this.endpoints.delete(`connect\0${endpoint}`);
|
|
116
116
|
}
|
|
117
|
-
setReceiveFlowState(state) {
|
|
118
|
-
this.requireOpen();
|
|
119
|
-
this.socket.setReceiveFlowState(state === 'paused' ? zlink_1.ReceiveFlowState.PAUSED : zlink_1.ReceiveFlowState.RUNNING);
|
|
120
|
-
}
|
|
121
117
|
monitor() {
|
|
122
118
|
this.requireOpen();
|
|
123
119
|
const nativeMonitor = this.socket.monitorOpen();
|
|
@@ -178,6 +174,10 @@ class NodeRawSocketPort {
|
|
|
178
174
|
}
|
|
179
175
|
class NodeRawRouterPort extends NodeRawSocketPort {
|
|
180
176
|
nextIncomingRequestSequence = 1n;
|
|
177
|
+
setReceiveFlowState(state) {
|
|
178
|
+
this.requireOpen();
|
|
179
|
+
this.socket.setReceiveFlowState(state === 'paused' ? zlink_1.ReceiveFlowState.PAUSED : zlink_1.ReceiveFlowState.RUNNING);
|
|
180
|
+
}
|
|
181
181
|
disconnectRid(routingId) {
|
|
182
182
|
this.requireOpen();
|
|
183
183
|
this.socket.disconnectRid(bindingRoutingId(routingId));
|
|
@@ -209,7 +209,12 @@ class NodeRawRouterPort extends NodeRawSocketPort {
|
|
|
209
209
|
requireParts(parts);
|
|
210
210
|
return (0, node_backend_adapter_support_1.submitBindingAsyncSend)(this.socket.send(bindingRoutingId(targetRid)), parts);
|
|
211
211
|
}
|
|
212
|
-
|
|
212
|
+
submitSend(targetRid, parts) {
|
|
213
|
+
this.requireOpen();
|
|
214
|
+
requireParts(parts);
|
|
215
|
+
return (0, node_backend_adapter_support_1.submitBindingSend)(this.socket.send(bindingRoutingId(targetRid)), parts);
|
|
216
|
+
}
|
|
217
|
+
async request(targetRid, parts, timeoutMs, recordReceived) {
|
|
213
218
|
this.requireOpen();
|
|
214
219
|
const deadlineMs = performance.now() + timeoutMs;
|
|
215
220
|
let submission;
|
|
@@ -222,7 +227,7 @@ class NodeRawRouterPort extends NodeRawSocketPort {
|
|
|
222
227
|
throw (0, node_backend_adapter_support_1.translateBindingResultError)(error, 'submit');
|
|
223
228
|
}
|
|
224
229
|
try {
|
|
225
|
-
const replies = await (0, node_backend_adapter_support_1.bindingRequestReply)(submission, deadlineMs);
|
|
230
|
+
const replies = await (0, node_backend_adapter_support_1.bindingRequestReply)(submission, deadlineMs, recordReceived);
|
|
226
231
|
return copyAndClose(replies);
|
|
227
232
|
}
|
|
228
233
|
catch (error) {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { SubmitResult, type RequestResult as RequestResultValue, type SubmitResult as SubmitResultValue } from '@zlink-systems/zlink';
|
|
2
|
+
import type { ZLinkMeshCompletionHandler } from '../mesh-completion-table';
|
|
2
3
|
import { type RoutingId } from '../../../contracts';
|
|
3
4
|
import type { ApplicationJobQueuePort } from '../../application-jobs/contracts';
|
|
4
5
|
import type { ZLinkDispatchErrorReporter } from '../../channels/dispatch-error-reporter';
|
|
@@ -7,7 +8,7 @@ import type { ServiceInstanceActivationRecoveryEnvelope } from '../../foundation
|
|
|
7
8
|
import { type MeshOperationId, type MeshPeerEntry, type MeshPublisher, type ReadyBatch, type ReadyRecord, type ReceiveBatch, type ServiceSpot, type StreamSessionService, MeshNodeRuntimeState } from '../../foundation/service-runtime-contracts';
|
|
8
9
|
import type { ServiceActorRef, ServiceSpotState } from '../../foundation/service-stateful-registry';
|
|
9
10
|
import { type ServiceAsyncInstanceActivationAuthority, type ServiceInstanceApplicationLifecycle, type ServicePendingInstanceActivation, type ServiceSpotMessageFollowSeal, type ServiceUserSpotOperationHandler, type ServiceUserSpotOperationResult } from '../../foundation/service-stateful-runtime';
|
|
10
|
-
import type { ServiceActorCreateRecord, ServiceDirectSpotRouteFence, ServiceInstanceActivationTarget, ServiceInstanceRouteFence, ServiceSpotRouteFence, ServiceUserSpotCloseRecord, ServiceUserSpotCreateRecord } from '../../foundation/service-stateful-wire-codec';
|
|
11
|
+
import type { ServiceActorCreateRecord, ServiceDirectSpotRouteFence, ServiceInstanceActivationTarget, ServiceInstanceColdActivationTarget, ServiceInstanceRouteFence, ServiceSpotRouteFence, ServiceUserSpotCloseRecord, ServiceUserSpotCreateRecord } from '../../foundation/service-stateful-wire-codec';
|
|
11
12
|
import type { ServiceNodeDescriptor } from '../../foundation/service-topology-registry';
|
|
12
13
|
import { type ServiceApplicationPayload } from '../../foundation/service-wire-m6a-codec';
|
|
13
14
|
import type { ZLinkBackendActorRef, ZLinkBackendMeshNode, ZLinkBackendObjectPlacement } from '../contracts';
|
|
@@ -24,12 +25,11 @@ export declare class ZLinkNodeRawMeshBackend implements ZLinkBackendMeshNode {
|
|
|
24
25
|
private readonly applicationJobQueue?;
|
|
25
26
|
private readonly applicationJobReceiveFlowFailureSink?;
|
|
26
27
|
private readonly peerAdmissionSealed?;
|
|
28
|
+
private readonly infrastructureTaskRunner?;
|
|
27
29
|
readonly nativeInstance: this;
|
|
28
30
|
private readonly channels;
|
|
29
31
|
private readonly peerIntents;
|
|
30
|
-
private
|
|
31
|
-
private completionHead;
|
|
32
|
-
private completionCount;
|
|
32
|
+
private completionHandler?;
|
|
33
33
|
private readonly routingId;
|
|
34
34
|
private readonly lifecycleGeneration;
|
|
35
35
|
private bindEndpoint?;
|
|
@@ -56,7 +56,7 @@ export declare class ZLinkNodeRawMeshBackend implements ZLinkBackendMeshNode {
|
|
|
56
56
|
private messageFollowHandler?;
|
|
57
57
|
private dispatchErrors?;
|
|
58
58
|
private readonly peerDisconnectedHandlers;
|
|
59
|
-
constructor(meshName: string, routingId: string | undefined, bindingPort: ZLinkRawBindingPort, applicationJobQueue?: ApplicationJobQueuePort | undefined, applicationJobReceiveFlowFailureSink?: ((error: unknown) => void) | undefined, peerAdmissionSealed?: (() => boolean) | undefined);
|
|
59
|
+
constructor(meshName: string, routingId: string | undefined, bindingPort: ZLinkRawBindingPort, applicationJobQueue?: ApplicationJobQueuePort | undefined, applicationJobReceiveFlowFailureSink?: ((error: unknown) => void) | undefined, peerAdmissionSealed?: (() => boolean) | undefined, infrastructureTaskRunner?: import("../../spots/spot-actor-join-dispatch").ZLinkDetachedTaskRunner | undefined);
|
|
60
60
|
configureObjectPlacement(options: {
|
|
61
61
|
readonly role: ServiceNodeDescriptor['objectRole'];
|
|
62
62
|
readonly placementWeight: number;
|
|
@@ -79,8 +79,8 @@ export declare class ZLinkNodeRawMeshBackend implements ZLinkBackendMeshNode {
|
|
|
79
79
|
onPeerDisconnected(handler: (endpoint: string) => void): void;
|
|
80
80
|
selectObjectPlacement(stableType: string): ZLinkBackendObjectPlacement;
|
|
81
81
|
instanceSpotPlacementTypes(): readonly string[];
|
|
82
|
-
sendToMissingInstanceSpot(target:
|
|
83
|
-
requestToMissingInstanceSpot(target:
|
|
82
|
+
sendToMissingInstanceSpot(target: ServiceInstanceColdActivationTarget, parts: MessageLike | readonly MessageLike[], deadlineUnixMs: bigint, sourceSpotId?: string, metadata?: ReadonlyMap<string, string>): Promise<SubmitResult>;
|
|
83
|
+
requestToMissingInstanceSpot(target: ServiceInstanceColdActivationTarget, parts: MessageLike | readonly MessageLike[], deadlineUnixMs: bigint, sourceSpotId?: string, metadata?: ReadonlyMap<string, string>): MeshOperationId;
|
|
84
84
|
setRoutingId(routingId: unknown): void;
|
|
85
85
|
setBind(endpoint: string): void;
|
|
86
86
|
setAdvertiseHost(host: string): void;
|
|
@@ -151,6 +151,7 @@ export declare class ZLinkNodeRawMeshBackend implements ZLinkBackendMeshNode {
|
|
|
151
151
|
weights: number[];
|
|
152
152
|
};
|
|
153
153
|
createPublisher(): MeshPublisher;
|
|
154
|
+
setCompletionHandler(handler: ZLinkMeshCompletionHandler): void;
|
|
154
155
|
setReadyHandler(handler: (readyDomains: number) => number): void;
|
|
155
156
|
createReadyBatch(capacity: number): ReadyBatch;
|
|
156
157
|
createReceiveBatch(messageCapacity: number, partCapacity: number): ReceiveBatch;
|
|
@@ -249,11 +250,8 @@ export declare class ZLinkNodeRawMeshBackend implements ZLinkBackendMeshNode {
|
|
|
249
250
|
private notifyReady;
|
|
250
251
|
private observeCompletion;
|
|
251
252
|
private observeStateful;
|
|
252
|
-
private
|
|
253
|
-
private
|
|
254
|
-
private drainCompletions;
|
|
255
|
-
private takeCompletion;
|
|
256
|
-
private clearCompletions;
|
|
253
|
+
private observeImmediateFailure;
|
|
254
|
+
private deliverCompletion;
|
|
257
255
|
private drainMailbox;
|
|
258
256
|
private requireRuntime;
|
|
259
257
|
private requireApplicationJobQueue;
|