@zlink-systems/framework 0.11.0 → 0.12.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/EndpointNotation.d.ts +5 -4
- package/dist/contracts/Configuration/EndpointNotation.js +5 -4
- package/dist/contracts/Configuration/InternalDefaults.d.ts +0 -1
- package/dist/contracts/Configuration/InternalDefaults.js +1 -2
- package/dist/contracts/Configuration/RegistrationNormalizers.js +1 -2
- package/dist/contracts/Configuration/RegistrationTypes.d.ts +2 -5
- package/dist/contracts/Configuration/RegistrationValidators.js +0 -1
- package/dist/contracts/Errors/ZLinkFrameworkException.d.ts +6 -7
- package/dist/contracts/Errors/ZLinkFrameworkException.js +6 -7
- package/dist/runtime/actors/actor-client.js +1 -1
- package/dist/runtime/actors/actor-mailbox.js +1 -5
- package/dist/runtime/backend/contracts/index.d.ts +2 -0
- package/dist/runtime/backend/mesh-completion-table.d.ts +1 -3
- package/dist/runtime/backend/mesh-completion-table.js +11 -15
- package/dist/runtime/backend/mesh-dispatch-pump.d.ts +11 -4
- package/dist/runtime/backend/mesh-dispatch-pump.js +201 -134
- package/dist/runtime/backend/node/node-backend-adapter-factory.d.ts +3 -4
- package/dist/runtime/backend/node/node-backend-adapter-factory.js +51 -37
- package/dist/runtime/backend/node/node-backend-adapter-support.d.ts +2 -2
- package/dist/runtime/backend/node/node-backend-adapter-support.js +2 -2
- package/dist/runtime/backend/node/node-dealer-channel-client-transport.js +2 -2
- package/dist/runtime/backend/node/node-event-loop-poller.d.ts +16 -0
- package/dist/runtime/backend/node/node-event-loop-poller.js +49 -0
- package/dist/runtime/backend/node/node-raw-binding-port.js +24 -41
- package/dist/runtime/backend/node/node-raw-mesh-backend.d.ts +8 -8
- package/dist/runtime/backend/node/node-raw-mesh-backend.js +100 -107
- package/dist/runtime/backend/node/node-socket-backend-adapter.d.ts +3 -2
- package/dist/runtime/backend/node/node-socket-backend-adapter.js +18 -67
- package/dist/runtime/backend/raw-binding-port.d.ts +1 -0
- package/dist/runtime/backend/runtime-values.d.ts +5 -1
- package/dist/runtime/channels/channel-dispatchers.js +2 -2
- package/dist/runtime/channels/channel-envelope.js +324 -121
- package/dist/runtime/channels/channel-multipart.d.ts +8 -1
- package/dist/runtime/channels/channel-outbound-operations.js +0 -2
- package/dist/runtime/channels/channel-receive-loops.d.ts +1 -3
- package/dist/runtime/channels/channel-receive-loops.js +25 -65
- package/dist/runtime/channels/channel-socket-registry.js +3 -1
- package/dist/runtime/channels/channel-transports.d.ts +2 -1
- package/dist/runtime/channels/channel-transports.js +12 -10
- package/dist/runtime/execution/serial-execution-queue.d.ts +5 -18
- package/dist/runtime/execution/serial-execution-queue.js +16 -80
- package/dist/runtime/foundation/event-loop-resources.d.ts +0 -3
- package/dist/runtime/foundation/event-loop-resources.js +2 -11
- package/dist/runtime/foundation/operation-registry.d.ts +2 -8
- package/dist/runtime/foundation/operation-registry.js +3 -21
- package/dist/runtime/foundation/raw-service-mesh-runtime.d.ts +19 -7
- package/dist/runtime/foundation/raw-service-mesh-runtime.js +56 -10
- package/dist/runtime/foundation/service-mailbox.d.ts +1 -7
- package/dist/runtime/foundation/service-mailbox.js +3 -2
- package/dist/runtime/foundation/service-runtime-contracts.d.ts +2 -1
- package/dist/runtime/foundation/service-stateful-registry.d.ts +1 -1
- package/dist/runtime/foundation/service-stateful-registry.js +2 -2
- package/dist/runtime/foundation/service-stateful-runtime.js +14 -14
- package/dist/runtime/framework-errors-internal.d.ts +4 -4
- package/dist/runtime/framework-errors-internal.js +8 -10
- package/dist/runtime/host/actor-placement-coordinator.js +1 -1
- package/dist/runtime/host/index.js +1 -1
- package/dist/runtime/host/service-relocation-host-runtime.js +0 -4
- package/dist/runtime/host/spot-address-transport.js +1 -1
- package/dist/runtime/host/user-spot-creation-coordinator.js +1 -1
- package/dist/runtime/spots/spot-node-runtime-manager.d.ts +0 -12
- package/dist/runtime/spots/spot-node-runtime-manager.js +6 -166
- package/dist/runtime/spots/spot-serial-turn-executor.js +1 -4
- package/dist/runtime/spots/spot-timer.d.ts +3 -0
- package/dist/runtime/spots/spot-timer.js +87 -18
- package/dist/runtime/streams/session-serial-executor.js +1 -3
- package/dist/runtime/streams/stream-session-runtime.d.ts +2 -2
- package/dist/runtime/streams/stream-session-runtime.js +13 -19
- package/dist/runtime/workers/index.d.ts +0 -1
- package/dist/runtime/workers/index.js +1 -9
- package/package.json +3 -3
- package/src/contracts/Configuration/EndpointNotation.ts +5 -4
- package/src/contracts/Configuration/InternalDefaults.ts +0 -1
- package/src/contracts/Configuration/RegistrationNormalizers.ts +2 -4
- package/src/contracts/Configuration/RegistrationTypes.ts +2 -5
- package/src/contracts/Configuration/RegistrationValidators.ts +0 -1
- package/src/contracts/Errors/ZLinkFrameworkException.ts +6 -7
- package/src/runtime/actors/actor-client.ts +1 -1
- package/src/runtime/actors/actor-mailbox.ts +1 -12
- package/src/runtime/backend/contracts/index.ts +2 -0
- package/src/runtime/backend/mesh-completion-table.ts +12 -23
- package/src/runtime/backend/mesh-dispatch-pump.ts +206 -138
- package/src/runtime/backend/node/node-backend-adapter-factory.ts +66 -35
- package/src/runtime/backend/node/node-backend-adapter-support.ts +4 -4
- package/src/runtime/backend/node/node-dealer-channel-client-transport.ts +2 -2
- package/src/runtime/backend/node/node-event-loop-poller.ts +55 -0
- package/src/runtime/backend/node/node-raw-binding-port.ts +30 -45
- package/src/runtime/backend/node/node-raw-mesh-backend.ts +97 -110
- package/src/runtime/backend/node/node-socket-backend-adapter.ts +23 -69
- package/src/runtime/backend/raw-binding-port.ts +1 -0
- package/src/runtime/backend/runtime-values.ts +7 -1
- package/src/runtime/channels/channel-dispatchers.ts +2 -2
- package/src/runtime/channels/channel-envelope.ts +379 -109
- package/src/runtime/channels/channel-multipart.ts +9 -1
- package/src/runtime/channels/channel-outbound-operations.ts +0 -1
- package/src/runtime/channels/channel-receive-loops.ts +24 -75
- package/src/runtime/channels/channel-socket-registry.ts +4 -1
- package/src/runtime/channels/channel-transports.ts +20 -10
- package/src/runtime/execution/serial-execution-queue.ts +16 -108
- package/src/runtime/foundation/event-loop-resources.ts +2 -11
- package/src/runtime/foundation/operation-registry.ts +2 -22
- package/src/runtime/foundation/raw-service-mesh-runtime.ts +74 -19
- package/src/runtime/foundation/service-mailbox.ts +3 -13
- package/src/runtime/foundation/service-runtime-contracts.ts +2 -1
- package/src/runtime/foundation/service-stateful-registry.ts +2 -2
- package/src/runtime/foundation/service-stateful-runtime.ts +14 -14
- package/src/runtime/framework-errors-internal.ts +8 -10
- package/src/runtime/host/actor-placement-coordinator.ts +1 -1
- package/src/runtime/host/index.ts +2 -1
- package/src/runtime/host/service-relocation-host-runtime.ts +0 -4
- package/src/runtime/host/spot-address-transport.ts +1 -1
- package/src/runtime/host/user-spot-creation-coordinator.ts +1 -1
- package/src/runtime/spots/spot-node-runtime-manager.ts +13 -233
- package/src/runtime/spots/spot-serial-turn-executor.ts +1 -8
- package/src/runtime/spots/spot-timer.ts +109 -18
- package/src/runtime/streams/session-serial-executor.ts +1 -7
- package/src/runtime/streams/stream-session-runtime.ts +13 -17
- package/src/runtime/workers/index.ts +2 -17
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.OperationRegistry = exports.
|
|
3
|
+
exports.OperationRegistry = exports.OperationCancelledError = exports.OperationTimeoutError = void 0;
|
|
4
4
|
class OperationTimeoutError extends Error {
|
|
5
5
|
operationId;
|
|
6
6
|
constructor(operationId) {
|
|
@@ -19,15 +19,6 @@ class OperationCancelledError extends Error {
|
|
|
19
19
|
}
|
|
20
20
|
}
|
|
21
21
|
exports.OperationCancelledError = OperationCancelledError;
|
|
22
|
-
class OperationCapacityExceededError extends Error {
|
|
23
|
-
maxPendingOperations;
|
|
24
|
-
constructor(maxPendingOperations) {
|
|
25
|
-
super(`Operation capacity ${maxPendingOperations} is exhausted.`);
|
|
26
|
-
this.maxPendingOperations = maxPendingOperations;
|
|
27
|
-
this.name = 'OperationCapacityExceededError';
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
exports.OperationCapacityExceededError = OperationCapacityExceededError;
|
|
31
22
|
const systemClock = {
|
|
32
23
|
setTimeout(callback, delayMs) {
|
|
33
24
|
// A request promise is live work. Raw RouteMesh polling deliberately
|
|
@@ -42,28 +33,19 @@ const systemClock = {
|
|
|
42
33
|
/** Owns request completion so reply, timeout, cancellation, and shutdown race safely. */
|
|
43
34
|
class OperationRegistry {
|
|
44
35
|
clock;
|
|
45
|
-
maxPendingOperations;
|
|
46
|
-
static DEFAULT_MAX_PENDING_OPERATIONS = 4_096;
|
|
47
36
|
entries = new Map();
|
|
48
37
|
nextId = 1n;
|
|
49
38
|
generation = 1n;
|
|
50
39
|
closed = false;
|
|
51
|
-
constructor(clock = systemClock
|
|
40
|
+
constructor(clock = systemClock) {
|
|
52
41
|
this.clock = clock;
|
|
53
|
-
this.maxPendingOperations = maxPendingOperations;
|
|
54
|
-
if (!Number.isSafeInteger(maxPendingOperations) || maxPendingOperations <= 0) {
|
|
55
|
-
throw new RangeError('maxPendingOperations must be a positive safe integer.');
|
|
56
|
-
}
|
|
57
42
|
}
|
|
58
|
-
|
|
43
|
+
register(timeoutMs, timeoutOwner = 'registry') {
|
|
59
44
|
if (this.closed)
|
|
60
45
|
throw new Error('Operation registry is closed.');
|
|
61
46
|
if (!Number.isFinite(timeoutMs) || timeoutMs < 0) {
|
|
62
47
|
throw new RangeError('timeoutMs must be a non-negative finite number.');
|
|
63
48
|
}
|
|
64
|
-
if (this.entries.size >= this.maxPendingOperations) {
|
|
65
|
-
throw new OperationCapacityExceededError(this.maxPendingOperations);
|
|
66
|
-
}
|
|
67
49
|
const id = this.nextId++;
|
|
68
50
|
const generation = this.generation;
|
|
69
51
|
let resolve;
|
|
@@ -3,7 +3,7 @@ import type { ApplicationJobQueuePort } from '../application-jobs/contracts';
|
|
|
3
3
|
import { ApplicationIngressRecordOwner } from '../application-jobs/application-ingress-record-owner';
|
|
4
4
|
import { type PendingOperation } from './operation-registry';
|
|
5
5
|
import { ServiceLivenessRegistry, type ServiceLivenessTick } from './service-liveness-registry';
|
|
6
|
-
import { ServiceMailbox, type
|
|
6
|
+
import { ServiceMailbox, type ServiceMailboxRecord } from './service-mailbox';
|
|
7
7
|
import { ServiceTopologyRegistry, type ServiceNodeDescriptor } from './service-topology-registry';
|
|
8
8
|
import { type ServiceApplicationPayload } from './service-wire-m6a-codec';
|
|
9
9
|
export type RawServicePumpResult = 'noData' | 'infrastructure' | 'application' | 'dropped' | 'protocolError';
|
|
@@ -13,6 +13,8 @@ export interface RawServiceRequestResult {
|
|
|
13
13
|
readonly failureCode: number;
|
|
14
14
|
readonly payload?: ServiceApplicationPayload;
|
|
15
15
|
}
|
|
16
|
+
/** An M6A application frame already owned by the Framework runtime. */
|
|
17
|
+
type ServiceApplicationPayloadInput = ServiceApplicationPayload | Buffer;
|
|
16
18
|
export interface RawServiceIngressRecord {
|
|
17
19
|
readonly command: number;
|
|
18
20
|
readonly flags: number;
|
|
@@ -28,7 +30,6 @@ export type RawServiceIngressHandler = (record: RawServiceIngressRecord) => RawS
|
|
|
28
30
|
export interface RawServiceMeshRuntimeOptions {
|
|
29
31
|
readonly descriptor: ServiceNodeDescriptor;
|
|
30
32
|
readonly resolveAdvertisedEndpoint?: (boundEndpoint: string) => string;
|
|
31
|
-
readonly mailbox?: Partial<ServiceMailboxLimits>;
|
|
32
33
|
readonly probeIntervalMs?: number;
|
|
33
34
|
readonly peerTimeoutMs?: number;
|
|
34
35
|
readonly bindingPort: ZLinkRawBindingPort;
|
|
@@ -105,18 +106,22 @@ export declare class RawServiceMeshRuntime {
|
|
|
105
106
|
}): Promise<void>;
|
|
106
107
|
replaceDiscoveredNotRequired(descriptors: readonly ServiceNodeDescriptor[]): void;
|
|
107
108
|
isObjectClientNodeDirectTarget(nodeRoutingId: string): boolean;
|
|
108
|
-
sendToNode(targetNodeRoutingId: string, payload:
|
|
109
|
-
sendToChannel(channelName: string, payload:
|
|
110
|
-
requestToNode(targetNodeRoutingId: string, payload:
|
|
111
|
-
requestToChannel(channelName: string, payload:
|
|
109
|
+
sendToNode(targetNodeRoutingId: string, payload: ServiceApplicationPayloadInput): Promise<boolean>;
|
|
110
|
+
sendToChannel(channelName: string, payload: ServiceApplicationPayloadInput): Promise<boolean>;
|
|
111
|
+
requestToNode(targetNodeRoutingId: string, payload: ServiceApplicationPayloadInput, timeoutMs: number): PendingOperation<RawServiceRequestResult>;
|
|
112
|
+
requestToChannel(channelName: string, payload: ServiceApplicationPayloadInput, timeoutMs: number): PendingOperation<RawServiceRequestResult> | undefined;
|
|
112
113
|
private isLocalOrReadyPeer;
|
|
113
114
|
setServiceIngress(handler: RawServiceIngressHandler): void;
|
|
114
115
|
reserveLocalIngress(signal?: AbortSignal): Promise<ApplicationIngressRecordOwner>;
|
|
115
116
|
sendService(targetNodeRoutingId: string, parts: readonly Uint8Array[]): Promise<boolean>;
|
|
116
117
|
requestService(targetNodeRoutingId: string, parts: readonly Uint8Array[], timeoutMs: number): Promise<readonly Buffer[]>;
|
|
117
118
|
replyService(record: Pick<RawServiceIngressRecord, 'sourceRoutingId' | 'sourceRoute' | 'requestSequence' | 'reply'>, parts: readonly Uint8Array[]): void;
|
|
118
|
-
reply(request: ServiceMailboxRecord, payload:
|
|
119
|
+
reply(request: ServiceMailboxRecord, payload: ServiceApplicationPayloadInput, terminalResult?: number, failureCode?: number): void;
|
|
119
120
|
pumpOne(nowMs?: number, observe?: RawServicePumpObserver): Promise<RawServicePumpResult>;
|
|
121
|
+
setReadableHandler(handler: () => void): void;
|
|
122
|
+
/** Returns whether a receive budget ended before no-data; idle ticks only maintain peers. */
|
|
123
|
+
pumpBatch(receiveReady?: boolean): Promise<boolean>;
|
|
124
|
+
private receiveOne;
|
|
120
125
|
private pullMonitorEvents;
|
|
121
126
|
private reportProtocolError;
|
|
122
127
|
private replyGenericProtocolError;
|
|
@@ -125,6 +130,12 @@ export declare class RawServiceMeshRuntime {
|
|
|
125
130
|
drainMonitorEvents(nowMs?: number): Promise<number>;
|
|
126
131
|
close(): void;
|
|
127
132
|
private requestToTarget;
|
|
133
|
+
/**
|
|
134
|
+
* The generic node/channel backend may supply its single owned M6A frame
|
|
135
|
+
* directly. All other callers keep the typed application-payload boundary.
|
|
136
|
+
*/
|
|
137
|
+
private applicationFrame;
|
|
138
|
+
private applicationPayload;
|
|
128
139
|
private admitPeer;
|
|
129
140
|
private currentConnectionCandidate;
|
|
130
141
|
private createConnectionCandidate;
|
|
@@ -141,3 +152,4 @@ export declare class RawServiceMeshRuntime {
|
|
|
141
152
|
private requireStarted;
|
|
142
153
|
private send;
|
|
143
154
|
}
|
|
155
|
+
export {};
|
|
@@ -66,7 +66,7 @@ class RawServiceMeshRuntime {
|
|
|
66
66
|
constructor(options) {
|
|
67
67
|
this.descriptor = options.descriptor;
|
|
68
68
|
this.topology = new service_topology_registry_1.ServiceTopologyRegistry(options.descriptor);
|
|
69
|
-
this.mailbox = new service_mailbox_1.ServiceMailbox(
|
|
69
|
+
this.mailbox = new service_mailbox_1.ServiceMailbox(options.onMailboxReady);
|
|
70
70
|
this.liveness = new service_liveness_registry_1.ServiceLivenessRegistry(options.probeIntervalMs, options.peerTimeoutMs);
|
|
71
71
|
this.bindingPort = options.bindingPort;
|
|
72
72
|
if (options.applicationJobQueue === undefined) {
|
|
@@ -302,12 +302,13 @@ class RawServiceMeshRuntime {
|
|
|
302
302
|
return descriptor?.objectRole === 'client';
|
|
303
303
|
}
|
|
304
304
|
async sendToNode(targetNodeRoutingId, payload) {
|
|
305
|
-
return this.send(targetNodeRoutingId, [(0, service_wire_m6a_codec_1.encodeNodeSendHeader)(),
|
|
305
|
+
return this.send(targetNodeRoutingId, [(0, service_wire_m6a_codec_1.encodeNodeSendHeader)(), this.applicationFrame(payload)]);
|
|
306
306
|
}
|
|
307
307
|
async sendToChannel(channelName, payload) {
|
|
308
308
|
const selected = this.topology.selectChannel(channelName, peer => this.isLocalOrReadyPeer(peer.descriptor.nodeRoutingId));
|
|
309
309
|
if (selected === undefined)
|
|
310
310
|
return false;
|
|
311
|
+
const applicationFrame = this.applicationFrame(payload);
|
|
311
312
|
if (selected.descriptor.nodeRoutingId === this.descriptor.nodeRoutingId) {
|
|
312
313
|
const applicationJobOwner = await this.reserveLocalIngress();
|
|
313
314
|
try {
|
|
@@ -315,7 +316,7 @@ class RawServiceMeshRuntime {
|
|
|
315
316
|
const accepted = this.mailbox.tryEnqueue({
|
|
316
317
|
owner: `channel:${channelName}`,
|
|
317
318
|
domain: 'application',
|
|
318
|
-
parts: [(0, service_wire_m6a_codec_1.encodeChannelSendHeader)(channelName),
|
|
319
|
+
parts: [(0, service_wire_m6a_codec_1.encodeChannelSendHeader)(channelName), applicationFrame],
|
|
319
320
|
sourceRoutingId: this.descriptor.nodeRoutingId,
|
|
320
321
|
applicationJob
|
|
321
322
|
});
|
|
@@ -329,7 +330,7 @@ class RawServiceMeshRuntime {
|
|
|
329
330
|
}
|
|
330
331
|
return this.send(selected.descriptor.nodeRoutingId, [
|
|
331
332
|
(0, service_wire_m6a_codec_1.encodeChannelSendHeader)(channelName),
|
|
332
|
-
|
|
333
|
+
applicationFrame
|
|
333
334
|
]);
|
|
334
335
|
}
|
|
335
336
|
requestToNode(targetNodeRoutingId, payload, timeoutMs) {
|
|
@@ -375,7 +376,7 @@ class RawServiceMeshRuntime {
|
|
|
375
376
|
}
|
|
376
377
|
reply(request, payload, terminalResult = 0, failureCode = 0) {
|
|
377
378
|
if (request.localReply !== undefined) {
|
|
378
|
-
request.localReply(terminalResult, failureCode, terminalResult === 0 ? payload : undefined);
|
|
379
|
+
request.localReply(terminalResult, failureCode, terminalResult === 0 ? this.applicationPayload(payload) : undefined);
|
|
379
380
|
return;
|
|
380
381
|
}
|
|
381
382
|
if (request.reply === undefined || request.correlation === undefined) {
|
|
@@ -383,12 +384,43 @@ class RawServiceMeshRuntime {
|
|
|
383
384
|
}
|
|
384
385
|
request.reply([
|
|
385
386
|
(0, service_wire_m6a_codec_1.encodeReplyHeader)(request.correlation, terminalResult, failureCode),
|
|
386
|
-
...(terminalResult === 0 ? [
|
|
387
|
+
...(terminalResult === 0 ? [this.applicationFrame(payload)] : [])
|
|
387
388
|
]);
|
|
388
389
|
}
|
|
389
390
|
async pumpOne(nowMs = performance.now(), observe) {
|
|
390
|
-
const router = this.requireStarted();
|
|
391
391
|
this.pullMonitorEvents();
|
|
392
|
+
return this.receiveOne(nowMs, observe);
|
|
393
|
+
}
|
|
394
|
+
setReadableHandler(handler) {
|
|
395
|
+
this.requireStarted().setReadableHandler(handler);
|
|
396
|
+
}
|
|
397
|
+
/** Returns whether a receive budget ended before no-data; idle ticks only maintain peers. */
|
|
398
|
+
async pumpBatch(receiveReady = true) {
|
|
399
|
+
await this.drainMonitorEvents();
|
|
400
|
+
const startedAtMs = performance.now();
|
|
401
|
+
let messages = 0;
|
|
402
|
+
let bytes = 0;
|
|
403
|
+
const observe = (_source, byteCount) => { bytes += byteCount; };
|
|
404
|
+
while (receiveReady && messages < 64 && !this.closed) {
|
|
405
|
+
const result = await this.receiveOne(performance.now(), observe);
|
|
406
|
+
if (result === 'noData') {
|
|
407
|
+
receiveReady = false;
|
|
408
|
+
break;
|
|
409
|
+
}
|
|
410
|
+
messages += 1;
|
|
411
|
+
// Core owns the per-peer fair-queue cursor. The Framework limit bounds
|
|
412
|
+
// the entire round, so changing peers does not renew its byte/count budget.
|
|
413
|
+
if (bytes >= 4 * 1024 * 1024 || performance.now() - startedAtMs >= 2)
|
|
414
|
+
break;
|
|
415
|
+
}
|
|
416
|
+
if (!this.closed) {
|
|
417
|
+
await this.announceExpectedPeers();
|
|
418
|
+
await this.tickLiveness();
|
|
419
|
+
}
|
|
420
|
+
return receiveReady && messages > 0;
|
|
421
|
+
}
|
|
422
|
+
async receiveOne(nowMs, observe) {
|
|
423
|
+
const router = this.requireStarted();
|
|
392
424
|
let permit;
|
|
393
425
|
try {
|
|
394
426
|
permit = await this.applicationJobQueue.acquire(this.applicationJobStop.signal);
|
|
@@ -398,6 +430,10 @@ class RawServiceMeshRuntime {
|
|
|
398
430
|
return 'noData';
|
|
399
431
|
throw error;
|
|
400
432
|
}
|
|
433
|
+
if (this.closed) {
|
|
434
|
+
permit.releaseAfterInternalProcessing();
|
|
435
|
+
return 'noData';
|
|
436
|
+
}
|
|
401
437
|
let received;
|
|
402
438
|
try {
|
|
403
439
|
received = router.receive(true);
|
|
@@ -825,8 +861,8 @@ class RawServiceMeshRuntime {
|
|
|
825
861
|
const header = channelName === undefined
|
|
826
862
|
? (0, service_wire_m6a_codec_1.encodeNodeRequestHeader)(correlation)
|
|
827
863
|
: (0, service_wire_m6a_codec_1.encodeChannelRequestHeader)(correlation, channelName);
|
|
828
|
-
const encodedPayload =
|
|
829
|
-
const pending = this.operations.
|
|
864
|
+
const encodedPayload = this.applicationFrame(payload);
|
|
865
|
+
const pending = this.operations.register(timeoutMs);
|
|
830
866
|
let selectedTargetNodeRoutingId = targetNodeRoutingId;
|
|
831
867
|
if (selectedTargetNodeRoutingId !== this.descriptor.nodeRoutingId
|
|
832
868
|
&& !this.isPeerRouteReady(selectedTargetNodeRoutingId)) {
|
|
@@ -945,7 +981,7 @@ class RawServiceMeshRuntime {
|
|
|
945
981
|
failureCode: reply.failureCode
|
|
946
982
|
};
|
|
947
983
|
this.operations.complete(pending.id, reply.terminalResult === 0
|
|
948
|
-
? { ...result, payload: (0, service_wire_m6a_codec_1.
|
|
984
|
+
? { ...result, payload: (0, service_wire_m6a_codec_1.decodeApplicationPayloadView)(replyParts[1]) }
|
|
949
985
|
: result);
|
|
950
986
|
}
|
|
951
987
|
catch (error) {
|
|
@@ -956,6 +992,16 @@ class RawServiceMeshRuntime {
|
|
|
956
992
|
});
|
|
957
993
|
return pending;
|
|
958
994
|
}
|
|
995
|
+
/**
|
|
996
|
+
* The generic node/channel backend may supply its single owned M6A frame
|
|
997
|
+
* directly. All other callers keep the typed application-payload boundary.
|
|
998
|
+
*/
|
|
999
|
+
applicationFrame(payload) {
|
|
1000
|
+
return Buffer.isBuffer(payload) ? payload : (0, service_wire_m6a_codec_1.encodeApplicationPayload)(payload);
|
|
1001
|
+
}
|
|
1002
|
+
applicationPayload(payload) {
|
|
1003
|
+
return Buffer.isBuffer(payload) ? (0, service_wire_m6a_codec_1.decodeApplicationPayloadView)(payload) : payload;
|
|
1004
|
+
}
|
|
959
1005
|
admitPeer(descriptor, connection, nowMs, expected) {
|
|
960
1006
|
const previous = this.topology.peer(descriptor.nodeRoutingId);
|
|
961
1007
|
if (previous !== undefined
|
|
@@ -29,12 +29,6 @@ export interface ServiceMailboxRelocationSeal {
|
|
|
29
29
|
readonly serial: bigint;
|
|
30
30
|
readonly captured: readonly ServiceMailboxRecord[];
|
|
31
31
|
}
|
|
32
|
-
export interface ServiceMailboxLimits {
|
|
33
|
-
readonly applicationMessages: number;
|
|
34
|
-
readonly applicationBytes: number;
|
|
35
|
-
readonly infrastructureMessages: number;
|
|
36
|
-
readonly infrastructureBytes: number;
|
|
37
|
-
}
|
|
38
32
|
/** Level-triggered queues with one active application claim per owner. */
|
|
39
33
|
export declare class ServiceMailbox {
|
|
40
34
|
private readonly onReady?;
|
|
@@ -45,7 +39,7 @@ export declare class ServiceMailbox {
|
|
|
45
39
|
private nextClaimSerial;
|
|
46
40
|
private nextRelocationSerial;
|
|
47
41
|
private closed;
|
|
48
|
-
constructor(
|
|
42
|
+
constructor(onReady?: ((domain: ServiceMailboxDomain) => void) | undefined);
|
|
49
43
|
releaseClaimedPayload(record: ServiceMailboxRecord): void;
|
|
50
44
|
tryEnqueue(record: ServiceMailboxRecord): boolean;
|
|
51
45
|
tryClaim(domain: ServiceMailboxDomain, messageBudget: number, byteBudget: number): ServiceMailboxClaim | undefined;
|
|
@@ -11,7 +11,7 @@ class ServiceMailbox {
|
|
|
11
11
|
nextClaimSerial = 1n;
|
|
12
12
|
nextRelocationSerial = 1n;
|
|
13
13
|
closed = false;
|
|
14
|
-
constructor(
|
|
14
|
+
constructor(onReady) {
|
|
15
15
|
this.onReady = onReady;
|
|
16
16
|
// Host ApplicationJobQueue permits own ordinary-record admission. The
|
|
17
17
|
// Framework-owned payload lifetime does not retain Core HWM credit. A
|
|
@@ -56,8 +56,8 @@ class ServiceMailbox {
|
|
|
56
56
|
if (!queue.claimed && !target.indexed.has(record.owner)) {
|
|
57
57
|
target.indexed.add(record.owner);
|
|
58
58
|
target.ready.push(record.owner);
|
|
59
|
+
this.onReady?.(record.domain);
|
|
59
60
|
}
|
|
60
|
-
this.onReady?.(record.domain);
|
|
61
61
|
return true;
|
|
62
62
|
}
|
|
63
63
|
tryClaim(domain, messageBudget, byteBudget) {
|
|
@@ -112,6 +112,7 @@ class ServiceMailbox {
|
|
|
112
112
|
else if (!target.indexed.has(claim.owner)) {
|
|
113
113
|
target.indexed.add(claim.owner);
|
|
114
114
|
target.ready.push(claim.owner);
|
|
115
|
+
this.onReady?.(claim.domain);
|
|
115
116
|
}
|
|
116
117
|
return true;
|
|
117
118
|
}
|
|
@@ -224,7 +224,8 @@ export interface ReadyBatch {
|
|
|
224
224
|
close(): void;
|
|
225
225
|
}
|
|
226
226
|
export interface ReceiveBatch {
|
|
227
|
-
|
|
227
|
+
/** Reuses the batch, limiting this receive to the admitted record count. */
|
|
228
|
+
reset(messageCapacity?: number): void;
|
|
228
229
|
close(): void;
|
|
229
230
|
}
|
|
230
231
|
export interface MeshNodeStatus {
|
|
@@ -132,7 +132,7 @@ export declare class ServiceStatefulRegistry {
|
|
|
132
132
|
export declare class ServiceTerminalOperationRegistry<T> {
|
|
133
133
|
private readonly operations;
|
|
134
134
|
constructor(operations?: OperationRegistry<T>);
|
|
135
|
-
|
|
135
|
+
register(timeoutMs: number, timeoutOwner?: 'registry' | 'sender'): PendingOperation<T>;
|
|
136
136
|
reply(id: bigint, value: T): boolean;
|
|
137
137
|
fail(id: bigint, error: unknown): boolean;
|
|
138
138
|
cancel(id: bigint): boolean;
|
|
@@ -427,8 +427,8 @@ class ServiceTerminalOperationRegistry {
|
|
|
427
427
|
constructor(operations = new operation_registry_1.OperationRegistry()) {
|
|
428
428
|
this.operations = operations;
|
|
429
429
|
}
|
|
430
|
-
|
|
431
|
-
return this.operations.
|
|
430
|
+
register(timeoutMs, timeoutOwner = 'registry') {
|
|
431
|
+
return this.operations.register(timeoutMs, timeoutOwner);
|
|
432
432
|
}
|
|
433
433
|
reply(id, value) {
|
|
434
434
|
return this.operations.complete(id, value);
|
|
@@ -650,7 +650,7 @@ class ServiceStatefulRuntime {
|
|
|
650
650
|
return this.submitOneWay(target.targetNodeRid, [header, (0, service_wire_m6a_codec_1.encodeApplicationPayload)(payload)]);
|
|
651
651
|
}
|
|
652
652
|
requestToSpot(sourceSpotId, requested, payload, timeoutMs) {
|
|
653
|
-
const pending = this.operations.
|
|
653
|
+
const pending = this.operations.register(timeoutMs);
|
|
654
654
|
const target = this.acceptSpotAuthority(requested);
|
|
655
655
|
if (target === undefined) {
|
|
656
656
|
this.operations.reply(pending.id, {
|
|
@@ -676,7 +676,7 @@ class ServiceStatefulRuntime {
|
|
|
676
676
|
return this.submitOneWay(target.nodeRid, [header, (0, service_wire_m6a_codec_1.encodeApplicationPayload)(payload)]);
|
|
677
677
|
}
|
|
678
678
|
requestToActor(target, _targetNodeGeneration, _authorityOwnerGeneration, payload, timeoutMs, sourceActor, boundSession) {
|
|
679
|
-
const pending = this.operations.
|
|
679
|
+
const pending = this.operations.register(timeoutMs);
|
|
680
680
|
const route = this.tryActorFence(target);
|
|
681
681
|
if (route === undefined) {
|
|
682
682
|
this.operations.reply(pending.id, {
|
|
@@ -711,7 +711,7 @@ class ServiceStatefulRuntime {
|
|
|
711
711
|
], metadataFrame));
|
|
712
712
|
}
|
|
713
713
|
requestToInstanceSpot(route, payload, timeoutMs, sourceSpotId, metadataFrame) {
|
|
714
|
-
const pending = this.operations.
|
|
714
|
+
const pending = this.operations.register(timeoutMs);
|
|
715
715
|
this.submitRequest(pending, route.targetNodeRid, instanceOperationParts([
|
|
716
716
|
(0, service_stateful_wire_codec_1.encodeInstanceSpotHeader)(route, this.nodeGeneration, this.nodeRid, sourceSpotId, 'request', { high: 2n, low: pending.id }, pending.id, metadataFrame !== undefined),
|
|
717
717
|
(0, service_wire_m6a_codec_1.encodeApplicationPayload)(payload)
|
|
@@ -725,7 +725,7 @@ class ServiceStatefulRuntime {
|
|
|
725
725
|
}
|
|
726
726
|
requestToMissingInstanceSpotFrame(target, payloadFrame, deadlineUnixMs, sourceSpotId, metadataFrame) {
|
|
727
727
|
const timeoutMs = remainingDeadlineMs(deadlineUnixMs);
|
|
728
|
-
const pending = this.operations.
|
|
728
|
+
const pending = this.operations.register(timeoutMs);
|
|
729
729
|
this.submitRequest(pending, target.targetNodeRid, instanceOperationParts([
|
|
730
730
|
(0, service_stateful_wire_codec_1.encodeInstanceSpotActivationHeader)(target, this.nodeGeneration, this.nodeRid, sourceSpotId, 'request', { high: this.nodeGeneration, low: pending.id }, deadlineUnixMs, pending.id, metadataFrame !== undefined),
|
|
731
731
|
payloadFrame
|
|
@@ -733,12 +733,12 @@ class ServiceStatefulRuntime {
|
|
|
733
733
|
return pending;
|
|
734
734
|
}
|
|
735
735
|
lookupRemoteActor(targetNodeRid, actorId, timeoutMs) {
|
|
736
|
-
const pending = this.operations.
|
|
736
|
+
const pending = this.operations.register(timeoutMs);
|
|
737
737
|
this.submitRequest(pending, targetNodeRid, [(0, service_stateful_wire_codec_1.encodeActorLookupHeader)(pending.id, actorId)], timeoutMs, 'actorLookup');
|
|
738
738
|
return pending;
|
|
739
739
|
}
|
|
740
740
|
destroyActor(actor, timeoutMs) {
|
|
741
|
-
const pending = this.operations.
|
|
741
|
+
const pending = this.operations.register(timeoutMs);
|
|
742
742
|
const local = actor.nodeRid === this.nodeRid;
|
|
743
743
|
if (local) {
|
|
744
744
|
queueMicrotask(() => {
|
|
@@ -758,7 +758,7 @@ class ServiceStatefulRuntime {
|
|
|
758
758
|
}
|
|
759
759
|
joinActor(actor, targetNodeRid, targetSpot, targetSpotGeneration, payload, timeoutMs) {
|
|
760
760
|
const deadlineMs = performance.now() + timeoutMs;
|
|
761
|
-
const pending = this.operations.
|
|
761
|
+
const pending = this.operations.register(timeoutMs, targetNodeRid === this.nodeRid ? 'registry' : 'sender');
|
|
762
762
|
const target = this.trySpotFence(targetNodeRid, {
|
|
763
763
|
...targetSpot,
|
|
764
764
|
generation: targetSpotGeneration
|
|
@@ -768,7 +768,7 @@ class ServiceStatefulRuntime {
|
|
|
768
768
|
}
|
|
769
769
|
joinActorCanonical(actor, targetNodeRid, targetSpot, targetSpotGeneration, request, actorFence, local, timeoutMs) {
|
|
770
770
|
const deadlineMs = performance.now() + timeoutMs;
|
|
771
|
-
const pending = this.operations.
|
|
771
|
+
const pending = this.operations.register(timeoutMs, targetNodeRid === this.nodeRid ? 'registry' : 'sender');
|
|
772
772
|
const target = this.trySpotFence(targetNodeRid, {
|
|
773
773
|
...targetSpot,
|
|
774
774
|
generation: targetSpotGeneration
|
|
@@ -778,18 +778,18 @@ class ServiceStatefulRuntime {
|
|
|
778
778
|
}
|
|
779
779
|
joinActorEntrySpot(actor, targetNodeRid, payload, timeoutMs) {
|
|
780
780
|
const deadlineMs = performance.now() + timeoutMs;
|
|
781
|
-
const pending = this.operations.
|
|
781
|
+
const pending = this.operations.register(timeoutMs, targetNodeRid === this.nodeRid ? 'registry' : 'sender');
|
|
782
782
|
this.submitActorJoin(pending, actor, targetNodeRid, this.tryEntrySpotFence(targetNodeRid), payload, deadlineMs);
|
|
783
783
|
return pending;
|
|
784
784
|
}
|
|
785
785
|
joinActorEntrySpotCanonical(actor, targetNodeRid, request, actorFence, local, timeoutMs) {
|
|
786
786
|
const deadlineMs = performance.now() + timeoutMs;
|
|
787
|
-
const pending = this.operations.
|
|
787
|
+
const pending = this.operations.register(timeoutMs, targetNodeRid === this.nodeRid ? 'registry' : 'sender');
|
|
788
788
|
this.submitActorJoin(pending, actor, targetNodeRid, this.tryEntrySpotFence(targetNodeRid), request, deadlineMs, { request, actorFence, local });
|
|
789
789
|
return pending;
|
|
790
790
|
}
|
|
791
791
|
leaveActor(actor, expectedMembershipEpoch, timeoutMs) {
|
|
792
|
-
const pending = this.operations.
|
|
792
|
+
const pending = this.operations.register(timeoutMs);
|
|
793
793
|
queueMicrotask(() => {
|
|
794
794
|
try {
|
|
795
795
|
const transition = this.registry.leaveActor(actor, expectedMembershipEpoch);
|
|
@@ -816,7 +816,7 @@ class ServiceStatefulRuntime {
|
|
|
816
816
|
}
|
|
817
817
|
bindSession(sessionRid, actor, timeoutMs, deliver, onBindingReplaced, bindingIngress, actorAuthority) {
|
|
818
818
|
const deadlineMs = performance.now() + timeoutMs;
|
|
819
|
-
const pending = this.operations.
|
|
819
|
+
const pending = this.operations.register(timeoutMs, 'sender');
|
|
820
820
|
const generation = this.nextSessionSequence++;
|
|
821
821
|
const localBinding = {
|
|
822
822
|
actor,
|
|
@@ -931,7 +931,7 @@ class ServiceStatefulRuntime {
|
|
|
931
931
|
};
|
|
932
932
|
}
|
|
933
933
|
unbindSession(sessionRid, actor, expectedBindingGeneration, timeoutMs) {
|
|
934
|
-
const pending = this.operations.
|
|
934
|
+
const pending = this.operations.register(timeoutMs);
|
|
935
935
|
const delivery = this.sessionDeliveries.get(actorKey(actor));
|
|
936
936
|
if (delivery === undefined
|
|
937
937
|
|| delivery.binding.sessionRid !== sessionRid
|
|
@@ -1559,7 +1559,7 @@ class ServiceStatefulRuntime {
|
|
|
1559
1559
|
}
|
|
1560
1560
|
return;
|
|
1561
1561
|
}
|
|
1562
|
-
const pending = this.operations.
|
|
1562
|
+
const pending = this.operations.register(remainingMs);
|
|
1563
1563
|
this.submitRequest(pending, route.targetNodeRid, instanceOperationParts([
|
|
1564
1564
|
(0, service_stateful_wire_codec_1.encodeInstanceSpotActivationHeader)(redirectedTarget, this.nodeGeneration, this.nodeRid, record.sourceSpotId, 'request', record.operation, record.deadlineUnixMs, pending.id, metadataFrame !== undefined),
|
|
1565
1565
|
payloadFrame
|
|
@@ -54,8 +54,8 @@ export declare function internalFrameworkErrorKind(error: ZLinkFrameworkExceptio
|
|
|
54
54
|
* terminal is classified identically across languages instead of collapsing to
|
|
55
55
|
* Unavailable. Spec 32-framework-error-model:81-92 (request-terminal
|
|
56
56
|
* classification); a deadline yields DeadlineExceeded, a lost route Unavailable.
|
|
57
|
-
* Backpressure
|
|
58
|
-
* one-way
|
|
57
|
+
* Backpressure waits in Core until the operation deadline, so request and
|
|
58
|
+
* one-way terminals both surface DeadlineExceeded when that wait expires.
|
|
59
59
|
*/
|
|
60
60
|
export declare function requestResultToPublicErrorKind(result: number): ZLinkFrameworkErrorKind;
|
|
61
61
|
/**
|
|
@@ -65,8 +65,8 @@ export declare function requestResultToPublicErrorKind(result: number): ZLinkFra
|
|
|
65
65
|
* coarse terminal; when absent (0) or unrecognised, the coarse terminal
|
|
66
66
|
* classifies. Remote another-node queue/operation-table saturation
|
|
67
67
|
* (Conflict/Busy) is Unavailable — a resource this runtime does not own — while
|
|
68
|
-
*
|
|
69
|
-
*
|
|
68
|
+
* placement admission terminal Backpressured(113) is Unavailable because no
|
|
69
|
+
* node can host the Spot. Shared by the lifecycle
|
|
70
70
|
* completion paths (Actor join, User Spot create/close) so they classify
|
|
71
71
|
* identically to the request path instead of collapsing to a single kind.
|
|
72
72
|
*/
|
|
@@ -78,7 +78,7 @@ const INTERNAL_TO_PUBLIC = Object.freeze({
|
|
|
78
78
|
[ZLinkFrameworkInternalErrorKind.RequestRejected]: ZLinkFrameworkException_1.ZLinkFrameworkErrorKind.Rejected,
|
|
79
79
|
[ZLinkFrameworkInternalErrorKind.RequestProtocolError]: ZLinkFrameworkException_1.ZLinkFrameworkErrorKind.ProtocolError,
|
|
80
80
|
[ZLinkFrameworkInternalErrorKind.RequestFailed]: ZLinkFrameworkException_1.ZLinkFrameworkErrorKind.InternalFailure,
|
|
81
|
-
[ZLinkFrameworkInternalErrorKind.WorkerQueueFull]: ZLinkFrameworkException_1.ZLinkFrameworkErrorKind.
|
|
81
|
+
[ZLinkFrameworkInternalErrorKind.WorkerQueueFull]: ZLinkFrameworkException_1.ZLinkFrameworkErrorKind.Unavailable,
|
|
82
82
|
[ZLinkFrameworkInternalErrorKind.WorkerTimedOut]: ZLinkFrameworkException_1.ZLinkFrameworkErrorKind.DeadlineExceeded,
|
|
83
83
|
[ZLinkFrameworkInternalErrorKind.WorkerFailed]: ZLinkFrameworkException_1.ZLinkFrameworkErrorKind.InternalFailure,
|
|
84
84
|
[ZLinkFrameworkInternalErrorKind.ActorLocationStale]: ZLinkFrameworkException_1.ZLinkFrameworkErrorKind.Unavailable,
|
|
@@ -91,7 +91,7 @@ const INTERNAL_TO_PUBLIC = Object.freeze({
|
|
|
91
91
|
[ZLinkFrameworkInternalErrorKind.ActorGenerationStale]: ZLinkFrameworkException_1.ZLinkFrameworkErrorKind.InvalidOperation,
|
|
92
92
|
[ZLinkFrameworkInternalErrorKind.ActorMoving]: ZLinkFrameworkException_1.ZLinkFrameworkErrorKind.Unavailable,
|
|
93
93
|
[ZLinkFrameworkInternalErrorKind.DeadlineExceeded]: ZLinkFrameworkException_1.ZLinkFrameworkErrorKind.DeadlineExceeded,
|
|
94
|
-
[ZLinkFrameworkInternalErrorKind.PlacementCapacityExhausted]: ZLinkFrameworkException_1.ZLinkFrameworkErrorKind.
|
|
94
|
+
[ZLinkFrameworkInternalErrorKind.PlacementCapacityExhausted]: ZLinkFrameworkException_1.ZLinkFrameworkErrorKind.Unavailable,
|
|
95
95
|
[ZLinkFrameworkInternalErrorKind.RoutingIdConflict]: ZLinkFrameworkException_1.ZLinkFrameworkErrorKind.AlreadyExists,
|
|
96
96
|
[ZLinkFrameworkInternalErrorKind.SpotGenerationStale]: ZLinkFrameworkException_1.ZLinkFrameworkErrorKind.InvalidOperation,
|
|
97
97
|
[ZLinkFrameworkInternalErrorKind.SpotMoving]: ZLinkFrameworkException_1.ZLinkFrameworkErrorKind.Unavailable,
|
|
@@ -152,8 +152,7 @@ const INTERNAL_KIND_BY_WIRE_FAILURE_CODE = new Map([
|
|
|
152
152
|
...Object.entries(exports.ZLINK_FRAMEWORK_INTERNAL_ERROR_KIND_VALUES)
|
|
153
153
|
.map(([kind, code]) => [code + 1, kind]),
|
|
154
154
|
// Spec 32-framework-error-model:99-103 — a workerQueueFull(18) received in a
|
|
155
|
-
// remote reply is the target's queue state
|
|
156
|
-
// CapacityExceeded that the wire-value-minus-one derivation would give.
|
|
155
|
+
// remote reply is the target's queue state and maps to Unavailable.
|
|
157
156
|
[18, ZLinkFrameworkInternalErrorKind.RouteNotConnected]
|
|
158
157
|
]);
|
|
159
158
|
const WIRE_TERMINAL_RESULT_BY_FAILURE_CODE = new Map([
|
|
@@ -179,8 +178,8 @@ function internalFrameworkErrorKind(error) {
|
|
|
179
178
|
* terminal is classified identically across languages instead of collapsing to
|
|
180
179
|
* Unavailable. Spec 32-framework-error-model:81-92 (request-terminal
|
|
181
180
|
* classification); a deadline yields DeadlineExceeded, a lost route Unavailable.
|
|
182
|
-
* Backpressure
|
|
183
|
-
* one-way
|
|
181
|
+
* Backpressure waits in Core until the operation deadline, so request and
|
|
182
|
+
* one-way terminals both surface DeadlineExceeded when that wait expires.
|
|
184
183
|
*/
|
|
185
184
|
function requestResultToPublicErrorKind(result) {
|
|
186
185
|
switch (result) {
|
|
@@ -195,8 +194,7 @@ function requestResultToPublicErrorKind(result) {
|
|
|
195
194
|
case runtime_values_1.RequestResult.Rejected:
|
|
196
195
|
return ZLinkFrameworkException_1.ZLinkFrameworkErrorKind.Rejected;
|
|
197
196
|
case runtime_values_1.RequestResult.Backpressured:
|
|
198
|
-
|
|
199
|
-
return ZLinkFrameworkException_1.ZLinkFrameworkErrorKind.CapacityExceeded;
|
|
197
|
+
return ZLinkFrameworkException_1.ZLinkFrameworkErrorKind.DeadlineExceeded;
|
|
200
198
|
case runtime_values_1.RequestResult.Conflict:
|
|
201
199
|
case runtime_values_1.RequestResult.Busy:
|
|
202
200
|
case runtime_values_1.RequestResult.NotConnected:
|
|
@@ -219,8 +217,8 @@ function requestResultToPublicErrorKind(result) {
|
|
|
219
217
|
* coarse terminal; when absent (0) or unrecognised, the coarse terminal
|
|
220
218
|
* classifies. Remote another-node queue/operation-table saturation
|
|
221
219
|
* (Conflict/Busy) is Unavailable — a resource this runtime does not own — while
|
|
222
|
-
*
|
|
223
|
-
*
|
|
220
|
+
* placement admission terminal Backpressured(113) is Unavailable because no
|
|
221
|
+
* node can host the Spot. Shared by the lifecycle
|
|
224
222
|
* completion paths (Actor join, User Spot create/close) so they classify
|
|
225
223
|
* identically to the request path instead of collapsing to a single kind.
|
|
226
224
|
*/
|
|
@@ -82,7 +82,7 @@ class ZLinkActorPlacementCoordinator {
|
|
|
82
82
|
// ownership-aware translator instead of collapsing every non-OK
|
|
83
83
|
// remote create to InternalFailure (spec 32-framework-error-model:
|
|
84
84
|
// 83-118, 99-108). Backpressured(113) still surfaces as target
|
|
85
|
-
// placement capacity ->
|
|
85
|
+
// placement capacity -> Unavailable through the shared path.
|
|
86
86
|
throw (0, framework_errors_internal_1.wireReplyFailureException)(remote.terminalResult, remote.failureCode, `Remote Actor '${actorId}' creation failed with result ${remote.terminalResult}, `
|
|
87
87
|
+ `failure code ${remote.failureCode}, and tail ${remote.tail?.kind ?? 'none'}.`);
|
|
88
88
|
}
|
|
@@ -161,7 +161,7 @@ class ZLinkFrameworkRuntimeHost {
|
|
|
161
161
|
return sendTimeoutMsForSpotMesh(routeChannelId);
|
|
162
162
|
};
|
|
163
163
|
const defaultSpotSendTimeoutMs = Math.max(LEGACY_MESH_SEND_TIMEOUT_MS, ...[...options.registration.spotNodes.values()].map(node => node.router?.sendTimeoutMs ?? LEGACY_MESH_SEND_TIMEOUT_MS), ...[...options.registration.routeChannelOptions.values()].map(route => route.sendTimeoutMs ?? LEGACY_MESH_SEND_TIMEOUT_MS));
|
|
164
|
-
this.routeTransport = new channels_1.ZLinkRuntimeRouteTransport(() => this.channelRuntime, (routerChannelId) => this.meshRouters.canUseRouterChannel(routerChannelId), () => this.spotNodeRuntime, { serializers: options.registration.messageSerializers }, (meshName, targetNodeRid) => this.meshRouters.classifyManualNodeTarget(meshName, targetNodeRid), (meshName, sourceNodeRid, parts) => this.submitLocalMeshRoute(meshName, sourceNodeRid, parts), this.metrics);
|
|
164
|
+
this.routeTransport = new channels_1.ZLinkRuntimeRouteTransport(() => this.channelRuntime, (routerChannelId) => this.meshRouters.canUseRouterChannel(routerChannelId), () => this.spotNodeRuntime, { serializers: options.registration.messageSerializers }, (meshName, targetNodeRid) => this.meshRouters.classifyManualNodeTarget(meshName, targetNodeRid), (meshName, sourceNodeRid, parts) => this.submitLocalMeshRoute(meshName, sourceNodeRid, parts), this.metrics, () => this.flowCreationEnabled());
|
|
165
165
|
this.spotAddressTransport = new spot_address_transport_1.ZLinkHostSpotAddressTransport({
|
|
166
166
|
resolver: () => this.createLocationSpotRouteResolver(),
|
|
167
167
|
routed: this.routeTransport,
|
|
@@ -3464,10 +3464,6 @@ function relocationFailedFailureCode(error, objectKind) {
|
|
|
3464
3464
|
return service_wire_constants_generated_1.ServiceWireFrameworkErrorCode.requestRejected;
|
|
3465
3465
|
case contracts_1.ZLinkFrameworkErrorKind.ProtocolError:
|
|
3466
3466
|
return service_wire_constants_generated_1.ServiceWireFrameworkErrorCode.requestProtocolError;
|
|
3467
|
-
// No dedicated "capacity exceeded" wire code exists; a full queue is
|
|
3468
|
-
// the closest capacity-shaped signal.
|
|
3469
|
-
case contracts_1.ZLinkFrameworkErrorKind.CapacityExceeded:
|
|
3470
|
-
return service_wire_constants_generated_1.ServiceWireFrameworkErrorCode.workerQueueFull;
|
|
3471
3467
|
// No dedicated "deadline exceeded" wire code exists; a worker timeout
|
|
3472
3468
|
// is the closest timeout-shaped signal.
|
|
3473
3469
|
case contracts_1.ZLinkFrameworkErrorKind.DeadlineExceeded:
|
|
@@ -417,7 +417,7 @@ function missingInstanceRequestFailure(result, nativeErrno) {
|
|
|
417
417
|
? framework_errors_internal_1.ZLinkFrameworkInternalErrorKind.RuntimeShutdown
|
|
418
418
|
: result === runtime_values_1.RequestResult.Backpressured
|
|
419
419
|
// Spec 32-framework-error-model:104-108 — the bounded admission
|
|
420
|
-
// terminal is target placement capacity:
|
|
420
|
+
// terminal is target placement capacity: Unavailable.
|
|
421
421
|
? framework_errors_internal_1.ZLinkFrameworkInternalErrorKind.PlacementCapacityExhausted
|
|
422
422
|
: result === runtime_values_1.RequestResult.NotConnected
|
|
423
423
|
? framework_errors_internal_1.ZLinkFrameworkInternalErrorKind.RouteNotConnected
|
|
@@ -712,7 +712,7 @@ function remoteUserSpotFailure(terminalResult, failureCode, message) {
|
|
|
712
712
|
// Remote operation-table saturation Busy(108)+None is Unavailable,
|
|
713
713
|
// InvalidState(111)+None is InvalidOperation, every fine code follows the
|
|
714
714
|
// shared table, and only placement admission Backpressured(113) stays
|
|
715
|
-
//
|
|
715
|
+
// Unavailable.
|
|
716
716
|
return (0, framework_errors_internal_1.wireReplyFailureException)(terminalResult, failureCode, `${message} terminalResult=${terminalResult}, failureCode=${failureCode}.`);
|
|
717
717
|
}
|
|
718
718
|
function createDeadline(timeoutMs, parent) {
|
|
@@ -59,8 +59,6 @@ export declare class ZLinkSpotNodeRuntimeManager {
|
|
|
59
59
|
private readonly entryActivations;
|
|
60
60
|
private readonly entryActivationStarts;
|
|
61
61
|
private readonly publishers;
|
|
62
|
-
private readonly activePublishes;
|
|
63
|
-
private readonly publishSlotWaiters;
|
|
64
62
|
private disposed;
|
|
65
63
|
private readonly autoConnectLoops;
|
|
66
64
|
private readonly publishedMeshNodeDescriptors;
|
|
@@ -123,15 +121,5 @@ export declare class ZLinkSpotNodeRuntimeManager {
|
|
|
123
121
|
private executePublish;
|
|
124
122
|
tryPublish(meshName: string, channelName: string, topic: string, packetName: string | undefined, event: Message, metadata?: ReadonlyMap<string, string>): ZLinkSubmitResult;
|
|
125
123
|
private publishWithFlags;
|
|
126
|
-
private acquirePublishSlot;
|
|
127
|
-
private publishTimedOut;
|
|
128
|
-
private releasePublishSlot;
|
|
129
|
-
private settlePublishSlotWaiter;
|
|
130
|
-
private rejectPublishSlotWaiter;
|
|
131
|
-
private removePublishSlotWaiter;
|
|
132
|
-
private cleanupPublishSlotWaiter;
|
|
133
|
-
private rejectPublishSlotWaiters;
|
|
134
|
-
private takePublishSlotWaiter;
|
|
135
|
-
private compactPublishSlotWaiters;
|
|
136
124
|
}
|
|
137
125
|
export declare function createFrameworkEntrySpotId(prefix: string): string;
|