@zlink-systems/framework 0.25.0 → 0.26.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/Channels/IZLinkFanoutClient.d.ts +0 -6
- package/dist/contracts/RouteMesh/RuntimeTopology.d.ts +8 -0
- package/dist/internal.d.ts +1 -0
- package/dist/internal.js +1 -0
- package/dist/runtime/activation-admission.d.ts +29 -0
- package/dist/runtime/activation-admission.js +61 -0
- package/dist/runtime/actors/actor-context.js +6 -6
- package/dist/runtime/actors/actor-handoff.d.ts +9 -3
- package/dist/runtime/actors/actor-handoff.js +28 -17
- package/dist/runtime/actors/actor-local-native-join.js +2 -18
- package/dist/runtime/actors/actor-remote-joiner.d.ts +2 -2
- package/dist/runtime/actors/actor-remote-joiner.js +6 -8
- package/dist/runtime/actors/actor-runtime-contracts.d.ts +4 -2
- package/dist/runtime/actors/actor-source-transfer.d.ts +5 -5
- package/dist/runtime/actors/deferred-join-completion.d.ts +14 -0
- package/dist/runtime/actors/deferred-join-completion.js +20 -0
- package/dist/runtime/actors/index.d.ts +1 -1
- package/dist/runtime/actors/index.js +15 -5
- package/dist/runtime/admission.d.ts +5 -1
- package/dist/runtime/admission.js +4 -0
- package/dist/runtime/backend/contracts/index.d.ts +2 -10
- package/dist/runtime/backend/mesh-actor-session-node-adapter.js +2 -9
- package/dist/runtime/backend/node/node-backend-adapter-factory.d.ts +1 -2
- package/dist/runtime/backend/node/node-backend-adapter-factory.js +4 -18
- package/dist/runtime/backend/node/node-backend-adapter-support.d.ts +6 -3
- package/dist/runtime/backend/node/node-backend-adapter-support.js +12 -28
- package/dist/runtime/backend/node/node-event-loop-poller.d.ts +1 -1
- package/dist/runtime/backend/node/node-event-loop-poller.js +8 -2
- package/dist/runtime/backend/node/node-raw-binding-port.d.ts +1 -1
- package/dist/runtime/backend/node/node-raw-binding-port.js +11 -3
- package/dist/runtime/backend/node/node-raw-mesh-backend.d.ts +12 -9
- package/dist/runtime/backend/node/node-raw-mesh-backend.js +61 -29
- package/dist/runtime/backend/node/node-socket-backend-adapter.js +1 -1
- package/dist/runtime/backend/raw-binding-port.d.ts +12 -0
- package/dist/runtime/channels/channel-clients.d.ts +0 -1
- package/dist/runtime/channels/channel-clients.js +0 -8
- package/dist/runtime/channels/channel-outbound-operations.js +2 -10
- package/dist/runtime/channels/channel-runtime-manager.d.ts +2 -5
- package/dist/runtime/channels/channel-runtime-manager.js +1 -12
- package/dist/runtime/channels/channel-socket-registry.d.ts +17 -4
- package/dist/runtime/channels/channel-socket-registry.js +49 -62
- package/dist/runtime/channels/channel-transports.d.ts +0 -3
- package/dist/runtime/channels/fanout-location-runtime.js +3 -9
- package/dist/runtime/execution/index.d.ts +18 -8
- package/dist/runtime/execution/index.js +55 -29
- package/dist/runtime/execution/serial-execution-queue.d.ts +5 -6
- package/dist/runtime/execution/serial-execution-queue.js +49 -15
- package/dist/runtime/foundation/listener-records.d.ts +11 -0
- package/dist/runtime/foundation/listener-records.js +20 -0
- package/dist/runtime/foundation/raw-service-mesh-runtime.d.ts +10 -21
- package/dist/runtime/foundation/raw-service-mesh-runtime.js +66 -392
- package/dist/runtime/foundation/service-authority-payload-codec.d.ts +1 -0
- package/dist/runtime/foundation/service-authority-payload-codec.js +8 -0
- package/dist/runtime/foundation/service-maintenance-runtime.js +23 -2
- package/dist/runtime/foundation/service-relocation-coordinator.d.ts +9 -0
- package/dist/runtime/foundation/service-relocation-coordinator.js +14 -1
- package/dist/runtime/foundation/service-relocation-object-owner.d.ts +8 -0
- package/dist/runtime/foundation/service-relocation-object-owner.js +16 -4
- package/dist/runtime/foundation/service-session-binding-ingress-port.d.ts +6 -13
- package/dist/runtime/foundation/service-stateful-runtime.d.ts +10 -7
- package/dist/runtime/foundation/service-stateful-runtime.js +100 -60
- package/dist/runtime/foundation/service-stateful-wire-codec.d.ts +9 -4
- package/dist/runtime/foundation/service-stateful-wire-codec.js +153 -90
- package/dist/runtime/foundation/service-topology-registry.d.ts +1 -2
- package/dist/runtime/foundation/service-topology-registry.js +6 -30
- package/dist/runtime/host/actor-transfer-runtime.d.ts +17 -15
- package/dist/runtime/host/actor-transfer-runtime.js +73 -86
- package/dist/runtime/host/index.d.ts +6 -2
- package/dist/runtime/host/index.js +63 -37
- package/dist/runtime/host/remote-bound-session-relay.js +4 -3
- package/dist/runtime/host/route-mesh-runtime.d.ts +2 -0
- package/dist/runtime/host/route-mesh-runtime.js +7 -5
- package/dist/runtime/host/service-relocation-host-runtime.d.ts +50 -8
- package/dist/runtime/host/service-relocation-host-runtime.js +343 -270
- package/dist/runtime/host/spot-runtime-options-factory.d.ts +7 -4
- package/dist/runtime/host/spot-runtime-options-factory.js +4 -8
- package/dist/runtime/host/stateful-authority-route-runtime.js +6 -2
- package/dist/runtime/host/user-spot-creation-coordinator.d.ts +11 -3
- package/dist/runtime/host/user-spot-creation-coordinator.js +85 -87
- package/dist/runtime/locations/in-memory-provider-location-store.js +8 -6
- package/dist/runtime/locations/lifecycle.d.ts +1 -1
- package/dist/runtime/locations/lifecycle.js +2 -2
- package/dist/runtime/locations/resolvers.js +7 -2
- package/dist/runtime/locations/spot-location-claims.d.ts +2 -2
- package/dist/runtime/locations/spot-location-claims.js +3 -27
- package/dist/runtime/protocol/service_wire_codec.generated.d.ts +1 -0
- package/dist/runtime/protocol/service_wire_codec.generated.js +5 -1
- package/dist/runtime/protocol/service_wire_pilot_codec.generated.d.ts +1 -0
- package/dist/runtime/protocol/service_wire_pilot_codec.generated.js +3 -2
- package/dist/runtime/spots/formal-remote-actor-admission-registry.d.ts +3 -3
- package/dist/runtime/spots/formal-remote-actor-admission-registry.js +4 -4
- package/dist/runtime/spots/formal-remote-actor-transfer-registry.d.ts +3 -3
- package/dist/runtime/spots/index.d.ts +25 -19
- package/dist/runtime/spots/index.js +207 -205
- package/dist/runtime/spots/spot-activation-registry.d.ts +4 -2
- package/dist/runtime/spots/spot-activation-registry.js +34 -31
- package/dist/runtime/spots/spot-activation-state.d.ts +2 -11
- package/dist/runtime/spots/spot-activation-state.js +4 -17
- package/dist/runtime/spots/spot-activation.d.ts +8 -6
- package/dist/runtime/spots/spot-activation.js +54 -49
- package/dist/runtime/spots/spot-actor-admission-coordinator.d.ts +1 -1
- package/dist/runtime/spots/spot-actor-admission-coordinator.js +1 -1
- package/dist/runtime/spots/spot-actor-join-dispatch.d.ts +2 -2
- package/dist/runtime/spots/spot-actor-join-dispatch.js +3 -5
- package/dist/runtime/spots/spot-actor-lifecycle-drain.js +2 -2
- package/dist/runtime/spots/spot-actor-membership.d.ts +4 -0
- package/dist/runtime/spots/spot-actor-membership.js +26 -12
- package/dist/runtime/spots/spot-entry-activation.d.ts +1 -2
- package/dist/runtime/spots/spot-entry-activation.js +0 -1
- package/dist/runtime/spots/spot-manager-public.js +1 -1
- package/dist/runtime/spots/spot-native-actor-join-admission.d.ts +1 -1
- package/dist/runtime/spots/spot-native-actor-join-admission.js +2 -2
- package/dist/runtime/spots/spot-node-runtime-manager.d.ts +5 -5
- package/dist/runtime/spots/spot-node-runtime-manager.js +7 -11
- package/dist/runtime/spots/spot-outbound.js +1 -29
- package/dist/runtime/spots/spot-routed-actor-admission.d.ts +1 -0
- package/dist/runtime/spots/spot-routed-actor-admission.js +10 -0
- package/dist/runtime/spots/spot-routed-frame-dispatch.d.ts +2 -6
- package/dist/runtime/spots/spot-routed-frame-dispatch.js +2 -70
- package/dist/runtime/spots/spot-runtime-ports.d.ts +3 -5
- package/dist/runtime/spots/spot-serial-executor.d.ts +5 -0
- package/dist/runtime/spots/spot-serial-executor.js +8 -1
- package/dist/runtime/spots/spot-serial-turn-executor.d.ts +3 -0
- package/dist/runtime/spots/spot-serial-turn-executor.js +8 -4
- package/dist/runtime/streams/actor-session-binding-registry.d.ts +13 -15
- package/dist/runtime/streams/actor-session-binding-registry.js +19 -171
- package/dist/runtime/streams/actor-session-binding-runtime-owner.d.ts +3 -4
- package/dist/runtime/streams/bound-session-service.js +1 -18
- package/dist/runtime/streams/index.d.ts +2 -0
- package/dist/runtime/streams/index.js +19 -19
- package/dist/runtime/streams/session-serial-executor.js +2 -2
- package/package.json +3 -3
- package/src/contracts/Channels/IZLinkFanoutClient.ts +0 -7
- package/src/contracts/RouteMesh/RuntimeTopology.ts +10 -0
- package/src/internal.ts +1 -0
- package/src/runtime/activation-admission.ts +78 -0
- package/src/runtime/actors/actor-context.ts +6 -6
- package/src/runtime/actors/actor-handoff.ts +31 -23
- package/src/runtime/actors/actor-local-native-join.ts +3 -42
- package/src/runtime/actors/actor-remote-joiner.ts +6 -25
- package/src/runtime/actors/actor-runtime-contracts.ts +4 -10
- package/src/runtime/actors/actor-source-transfer.ts +5 -18
- package/src/runtime/actors/deferred-join-completion.ts +40 -0
- package/src/runtime/actors/index.ts +22 -9
- package/src/runtime/admission.ts +5 -1
- package/src/runtime/backend/contracts/index.ts +2 -13
- package/src/runtime/backend/mesh-actor-session-node-adapter.ts +2 -10
- package/src/runtime/backend/node/node-backend-adapter-factory.ts +5 -25
- package/src/runtime/backend/node/node-backend-adapter-support.ts +9 -29
- package/src/runtime/backend/node/node-event-loop-poller.ts +14 -2
- package/src/runtime/backend/node/node-raw-binding-port.ts +17 -3
- package/src/runtime/backend/node/node-raw-mesh-backend.ts +65 -32
- package/src/runtime/backend/node/node-socket-backend-adapter.ts +2 -2
- package/src/runtime/backend/raw-binding-port.ts +13 -0
- package/src/runtime/channels/channel-clients.ts +0 -11
- package/src/runtime/channels/channel-outbound-operations.ts +3 -11
- package/src/runtime/channels/channel-runtime-manager.ts +4 -15
- package/src/runtime/channels/channel-socket-registry.ts +69 -71
- package/src/runtime/channels/channel-transports.ts +0 -3
- package/src/runtime/channels/fanout-location-runtime.ts +4 -16
- package/src/runtime/execution/index.ts +68 -30
- package/src/runtime/execution/serial-execution-queue.ts +52 -20
- package/src/runtime/foundation/listener-records.ts +21 -0
- package/src/runtime/foundation/raw-service-mesh-runtime.ts +66 -466
- package/src/runtime/foundation/service-authority-payload-codec.ts +10 -0
- package/src/runtime/foundation/service-maintenance-runtime.ts +30 -9
- package/src/runtime/foundation/service-relocation-coordinator.ts +13 -0
- package/src/runtime/foundation/service-relocation-object-owner.ts +18 -5
- package/src/runtime/foundation/service-session-binding-ingress-port.ts +6 -14
- package/src/runtime/foundation/service-stateful-runtime.ts +151 -89
- package/src/runtime/foundation/service-stateful-wire-codec.ts +203 -121
- package/src/runtime/foundation/service-topology-registry.ts +8 -48
- package/src/runtime/host/actor-transfer-runtime.ts +94 -166
- package/src/runtime/host/index.ts +119 -54
- package/src/runtime/host/remote-bound-session-relay.ts +4 -3
- package/src/runtime/host/route-mesh-runtime.ts +9 -5
- package/src/runtime/host/service-relocation-host-runtime.ts +495 -376
- package/src/runtime/host/spot-runtime-options-factory.ts +24 -13
- package/src/runtime/host/stateful-authority-route-runtime.ts +8 -4
- package/src/runtime/host/user-spot-creation-coordinator.ts +147 -142
- package/src/runtime/locations/in-memory-provider-location-store.ts +11 -7
- package/src/runtime/locations/lifecycle.ts +3 -2
- package/src/runtime/locations/resolvers.ts +19 -13
- package/src/runtime/locations/spot-location-claims.ts +5 -34
- package/src/runtime/protocol/service_wire_codec.generated.ts +9 -2
- package/src/runtime/protocol/service_wire_pilot_codec.generated.ts +4 -4
- package/src/runtime/spots/formal-remote-actor-admission-registry.ts +6 -6
- package/src/runtime/spots/formal-remote-actor-transfer-registry.ts +3 -3
- package/src/runtime/spots/index.ts +341 -295
- package/src/runtime/spots/spot-activation-registry.ts +41 -31
- package/src/runtime/spots/spot-activation-state.ts +4 -16
- package/src/runtime/spots/spot-activation.ts +102 -80
- package/src/runtime/spots/spot-actor-admission-coordinator.ts +2 -2
- package/src/runtime/spots/spot-actor-join-dispatch.ts +6 -7
- package/src/runtime/spots/spot-actor-lifecycle-drain.ts +20 -18
- package/src/runtime/spots/spot-actor-membership.ts +81 -17
- package/src/runtime/spots/spot-entry-activation.ts +0 -3
- package/src/runtime/spots/spot-manager-public.ts +8 -4
- package/src/runtime/spots/spot-native-actor-join-admission.ts +2 -2
- package/src/runtime/spots/spot-node-runtime-manager.ts +12 -18
- package/src/runtime/spots/spot-outbound.ts +4 -47
- package/src/runtime/spots/spot-routed-actor-admission.ts +20 -0
- package/src/runtime/spots/spot-routed-frame-dispatch.ts +6 -76
- package/src/runtime/spots/spot-runtime-ports.ts +6 -17
- package/src/runtime/spots/spot-serial-executor.ts +9 -1
- package/src/runtime/spots/spot-serial-turn-executor.ts +10 -4
- package/src/runtime/streams/actor-session-binding-registry.ts +20 -308
- package/src/runtime/streams/actor-session-binding-runtime-owner.ts +2 -12
- package/src/runtime/streams/bound-session-service.ts +2 -36
- package/src/runtime/streams/index.ts +29 -27
- package/src/runtime/streams/session-serial-executor.ts +2 -2
- package/dist/runtime/actors/deferred-join-accepted-journal.d.ts +0 -47
- package/dist/runtime/actors/deferred-join-accepted-journal.js +0 -992
- package/src/runtime/actors/deferred-join-accepted-journal.ts +0 -1346
|
@@ -1,11 +1,5 @@
|
|
|
1
1
|
import type { ZLinkFanoutPublishCall } from './Calls';
|
|
2
|
-
export interface ZLinkFanoutListenerStatus {
|
|
3
|
-
readonly channelName: string;
|
|
4
|
-
readonly endpoint: string;
|
|
5
|
-
readonly observedAt: Date;
|
|
6
|
-
}
|
|
7
2
|
export interface ZLinkFanoutClient {
|
|
8
3
|
publish(channelName: string, event: unknown): ZLinkFanoutPublishCall;
|
|
9
4
|
publish(channelName: string, topic: string, event: unknown): ZLinkFanoutPublishCall;
|
|
10
|
-
getListenerStatus(channelName: string): ZLinkFanoutListenerStatus;
|
|
11
5
|
}
|
|
@@ -123,11 +123,19 @@ export interface ZLinkHostCapacityStatus {
|
|
|
123
123
|
}
|
|
124
124
|
export interface ZLinkFrameworkRuntime {
|
|
125
125
|
readonly status: ZLinkFrameworkRuntimeStatus;
|
|
126
|
+
getListenerStatus(kind: ZLinkListenerKind, name: string): ZLinkListenerStatus;
|
|
126
127
|
observe(signal?: AbortSignal): AsyncIterable<ZLinkObservedStatus<ZLinkFrameworkRuntimeStatus>>;
|
|
127
128
|
resetCapacityMetrics(): void;
|
|
128
129
|
relocate(options: ZLinkFrameworkRelocationOptions): Promise<ZLinkFrameworkRelocationResult>;
|
|
129
130
|
shutdown(options?: ZLinkFrameworkLifecycleOptions): Promise<ZLinkFrameworkTerminationResult>;
|
|
130
131
|
}
|
|
132
|
+
export type ZLinkListenerKind = 'routeMesh' | 'clientServer' | 'fanout' | 'stream';
|
|
133
|
+
export interface ZLinkListenerStatus {
|
|
134
|
+
readonly kind: ZLinkListenerKind;
|
|
135
|
+
readonly name: string;
|
|
136
|
+
readonly endpoint: string;
|
|
137
|
+
readonly observedAt: Date;
|
|
138
|
+
}
|
|
131
139
|
export type ZLinkClientServerRole = 'client' | 'server' | 'clientAndServer';
|
|
132
140
|
export interface ZLinkClientServerTargetStatus {
|
|
133
141
|
readonly nodeRid: RoutingId;
|
package/dist/internal.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ export * from './index';
|
|
|
3
3
|
export * from './runtime/diagnostics';
|
|
4
4
|
export * from './runtime/host';
|
|
5
5
|
export * from './runtime/admission';
|
|
6
|
+
export * from './runtime/activation-admission';
|
|
6
7
|
export * from './runtime/streams';
|
|
7
8
|
export * from './runtime/streams/protocol';
|
|
8
9
|
export * from './runtime/actors';
|
package/dist/internal.js
CHANGED
|
@@ -20,6 +20,7 @@ __exportStar(require("./index"), exports);
|
|
|
20
20
|
__exportStar(require("./runtime/diagnostics"), exports);
|
|
21
21
|
__exportStar(require("./runtime/host"), exports);
|
|
22
22
|
__exportStar(require("./runtime/admission"), exports);
|
|
23
|
+
__exportStar(require("./runtime/activation-admission"), exports);
|
|
23
24
|
__exportStar(require("./runtime/streams"), exports);
|
|
24
25
|
__exportStar(require("./runtime/streams/protocol"), exports);
|
|
25
26
|
__exportStar(require("./runtime/actors"), exports);
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/** Current activation admission count and limit of one MeshNode. */
|
|
2
|
+
export interface ZLinkActivationConcurrency {
|
|
3
|
+
readonly active: number;
|
|
4
|
+
readonly limit: number;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* MeshNode §5.1 "Pending activation": the single per-MeshNode record of activation admissions.
|
|
8
|
+
*
|
|
9
|
+
* Actor creation, User Spot creation, Instance Spot cold activation and a relocation target's
|
|
10
|
+
* Restore each hold one admission from the moment the target MeshNode receives the operation
|
|
11
|
+
* until Ready or its target commit, or until it ends by rejection, failure or cleanup. Entry Spot
|
|
12
|
+
* and Actor Join never acquire one. The limit is enforced here, and the status current value and
|
|
13
|
+
* the placement `IsAvailable` headroom both read this record.
|
|
14
|
+
*/
|
|
15
|
+
export declare class ZLinkActivationAdmission {
|
|
16
|
+
private readonly limitOf;
|
|
17
|
+
private readonly changed?;
|
|
18
|
+
private readonly records;
|
|
19
|
+
constructor(limitOf: (meshName: string) => number, changed?: ((meshName: string) => void) | undefined);
|
|
20
|
+
current(meshName: string): ZLinkActivationConcurrency;
|
|
21
|
+
hasHeadroom(meshName: string): boolean;
|
|
22
|
+
/**
|
|
23
|
+
* Holds one admission for `meshName`. A MeshNode without headroom does not accept a new
|
|
24
|
+
* admission (MeshNode §5.1): the operation fails as Unavailable at once. The returned release
|
|
25
|
+
* is idempotent.
|
|
26
|
+
*/
|
|
27
|
+
acquire(meshName: string, signal?: AbortSignal): Promise<() => void>;
|
|
28
|
+
private record;
|
|
29
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ZLinkActivationAdmission = void 0;
|
|
4
|
+
const framework_errors_internal_1 = require("./framework-errors-internal");
|
|
5
|
+
/**
|
|
6
|
+
* MeshNode §5.1 "Pending activation": the single per-MeshNode record of activation admissions.
|
|
7
|
+
*
|
|
8
|
+
* Actor creation, User Spot creation, Instance Spot cold activation and a relocation target's
|
|
9
|
+
* Restore each hold one admission from the moment the target MeshNode receives the operation
|
|
10
|
+
* until Ready or its target commit, or until it ends by rejection, failure or cleanup. Entry Spot
|
|
11
|
+
* and Actor Join never acquire one. The limit is enforced here, and the status current value and
|
|
12
|
+
* the placement `IsAvailable` headroom both read this record.
|
|
13
|
+
*/
|
|
14
|
+
class ZLinkActivationAdmission {
|
|
15
|
+
limitOf;
|
|
16
|
+
changed;
|
|
17
|
+
records = new Map();
|
|
18
|
+
constructor(limitOf, changed) {
|
|
19
|
+
this.limitOf = limitOf;
|
|
20
|
+
this.changed = changed;
|
|
21
|
+
}
|
|
22
|
+
current(meshName) {
|
|
23
|
+
const record = this.records.get(meshName);
|
|
24
|
+
return { active: record?.active ?? 0, limit: record?.limit ?? this.limitOf(meshName) };
|
|
25
|
+
}
|
|
26
|
+
hasHeadroom(meshName) {
|
|
27
|
+
const { active, limit } = this.current(meshName);
|
|
28
|
+
return active < limit;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Holds one admission for `meshName`. A MeshNode without headroom does not accept a new
|
|
32
|
+
* admission (MeshNode §5.1): the operation fails as Unavailable at once. The returned release
|
|
33
|
+
* is idempotent.
|
|
34
|
+
*/
|
|
35
|
+
async acquire(meshName, signal) {
|
|
36
|
+
signal?.throwIfAborted();
|
|
37
|
+
const record = this.record(meshName);
|
|
38
|
+
if (record.active >= record.limit) {
|
|
39
|
+
throw (0, framework_errors_internal_1.createInternalFrameworkException)(framework_errors_internal_1.ZLinkFrameworkInternalErrorKind.PlacementCapacityExhausted, `MeshNode '${meshName}' has no activation admission headroom.`);
|
|
40
|
+
}
|
|
41
|
+
record.active += 1;
|
|
42
|
+
this.changed?.(meshName);
|
|
43
|
+
let released = false;
|
|
44
|
+
return () => {
|
|
45
|
+
if (released)
|
|
46
|
+
return;
|
|
47
|
+
released = true;
|
|
48
|
+
record.active -= 1;
|
|
49
|
+
this.changed?.(meshName);
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
record(meshName) {
|
|
53
|
+
let record = this.records.get(meshName);
|
|
54
|
+
if (record === undefined) {
|
|
55
|
+
record = { meshName, limit: this.limitOf(meshName), active: 0 };
|
|
56
|
+
this.records.set(meshName, record);
|
|
57
|
+
}
|
|
58
|
+
return record;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
exports.ZLinkActivationAdmission = ZLinkActivationAdmission;
|
|
@@ -146,7 +146,7 @@ class DefaultZLinkActorJoinSpotCall {
|
|
|
146
146
|
discarded = true;
|
|
147
147
|
this.state.endDeferredJoin();
|
|
148
148
|
try {
|
|
149
|
-
await this.coordinator.abortDeferredJoin?.(this.actor, this.state
|
|
149
|
+
await this.coordinator.abortDeferredJoin?.(this.actor, this.state);
|
|
150
150
|
}
|
|
151
151
|
finally {
|
|
152
152
|
deadline.close();
|
|
@@ -164,7 +164,7 @@ class DefaultZLinkActorJoinSpotCall {
|
|
|
164
164
|
// The provisional ingress fence is installed only after the
|
|
165
165
|
// handler terminal. Target admission starts before reply encoding,
|
|
166
166
|
// while completion and finalization remain in execute().
|
|
167
|
-
this.coordinator.beginDeferredJoin?.(this.actor, this.state
|
|
167
|
+
this.coordinator.beginDeferredJoin?.(this.actor, this.state);
|
|
168
168
|
pendingJoin = this.coordinator.joinSpot(this.actor, this.state, this.spotId, requestMessage, remainingJoinTimeout(deadline.atMs), deadline.signal, operationId);
|
|
169
169
|
if (this.turn === undefined) {
|
|
170
170
|
await pendingJoin.catch(() => undefined);
|
|
@@ -189,7 +189,7 @@ class DefaultZLinkActorJoinSpotCall {
|
|
|
189
189
|
catch (error) {
|
|
190
190
|
this.state.endDeferredJoin();
|
|
191
191
|
await this.coordinator
|
|
192
|
-
.abortDeferredJoin?.(this.actor, this.state
|
|
192
|
+
.abortDeferredJoin?.(this.actor, this.state)
|
|
193
193
|
.catch(() => undefined);
|
|
194
194
|
await notifyJoinFailure(this.actor, operationId, error, this.coordinator);
|
|
195
195
|
return;
|
|
@@ -271,7 +271,7 @@ class DefaultZLinkActorJoinEntrySpotCall {
|
|
|
271
271
|
discarded = true;
|
|
272
272
|
this.state.endDeferredJoin();
|
|
273
273
|
try {
|
|
274
|
-
await this.coordinator.abortDeferredJoin?.(this.actor, this.state
|
|
274
|
+
await this.coordinator.abortDeferredJoin?.(this.actor, this.state);
|
|
275
275
|
}
|
|
276
276
|
finally {
|
|
277
277
|
deadline.close();
|
|
@@ -286,7 +286,7 @@ class DefaultZLinkActorJoinEntrySpotCall {
|
|
|
286
286
|
prepared = true;
|
|
287
287
|
this.state.endDeferredJoin();
|
|
288
288
|
try {
|
|
289
|
-
this.coordinator.beginDeferredJoin?.(this.actor, this.state
|
|
289
|
+
this.coordinator.beginDeferredJoin?.(this.actor, this.state);
|
|
290
290
|
pendingJoin = this.coordinator.joinEntrySpot(this.actor, this.state, undefined, requestMessage, remainingJoinTimeout(deadline.atMs), deadline.signal, operationId);
|
|
291
291
|
if (this.turn === undefined) {
|
|
292
292
|
await pendingJoin.catch(() => undefined);
|
|
@@ -311,7 +311,7 @@ class DefaultZLinkActorJoinEntrySpotCall {
|
|
|
311
311
|
catch (error) {
|
|
312
312
|
this.state.endDeferredJoin();
|
|
313
313
|
await this.coordinator
|
|
314
|
-
.abortDeferredJoin?.(this.actor, this.state
|
|
314
|
+
.abortDeferredJoin?.(this.actor, this.state)
|
|
315
315
|
.catch(() => undefined);
|
|
316
316
|
await notifyJoinFailure(this.actor, operationId, error, this.coordinator);
|
|
317
317
|
return;
|
|
@@ -115,14 +115,14 @@ export declare class ZLinkActorHandoffCoordinator {
|
|
|
115
115
|
private readonly replyRoutes;
|
|
116
116
|
constructor(options: ZLinkActorHandoffCoordinatorOptions);
|
|
117
117
|
begin(actorId: string, oldGeneration: bigint): void;
|
|
118
|
-
beginProvisional(actorId: string,
|
|
118
|
+
beginProvisional(actorId: string, oldGeneration: bigint): void;
|
|
119
119
|
private startHandoff;
|
|
120
120
|
isActive(actorId: string): boolean;
|
|
121
121
|
isProvisional(actorId: string): boolean;
|
|
122
|
-
promoteProvisional(actorId: string
|
|
122
|
+
promoteProvisional(actorId: string): void;
|
|
123
123
|
sealConnectionBoundIngress(actorId: string): void;
|
|
124
124
|
activeSourceOwner(actorId: string): ZLinkActorMessageFollowOwnerFence | undefined;
|
|
125
|
-
releaseDeferred(actorId: string,
|
|
125
|
+
releaseDeferred(actorId: string, dispatch?: ZLinkActorHandoffDispatch, admission?: ZLinkActorHandoffReplayAdmission): Promise<void>;
|
|
126
126
|
releaseCanceled(actorId: string, dispatch: ZLinkActorHandoffDispatch, admission?: ZLinkActorHandoffReplayAdmission): Promise<void>;
|
|
127
127
|
private admitHandoffPrefix;
|
|
128
128
|
private admitPendingPrefix;
|
|
@@ -134,6 +134,12 @@ export declare class ZLinkActorHandoffCoordinator {
|
|
|
134
134
|
private replayReleasedBacklog;
|
|
135
135
|
private replayReleasedPending;
|
|
136
136
|
private failReleasedPending;
|
|
137
|
+
/**
|
|
138
|
+
* Expired-owner terminal of a relocation (spec 28 §4.4): every pending
|
|
139
|
+
* record without a terminal fails once with `reason`. The handoff stays
|
|
140
|
+
* active, so the source never dispatches the Actor again.
|
|
141
|
+
*/
|
|
142
|
+
failPending(actorId: string, reason: unknown): void;
|
|
137
143
|
cancel(actorId: string): void;
|
|
138
144
|
capture(actorId: string, parts: readonly Message[], returnResponse?: boolean, remoteBoundSessionTarget?: ZLinkRemoteBoundSessionTarget, fallbackActorRef?: ActorRef, deadlineUnixMs?: number, messageFollowOrigin?: ZLinkMessageFollowOrigin, provisionalReplay?: ZLinkActorHandoffDispatch): Promise<unknown> | undefined;
|
|
139
145
|
snapshot(actorId: string): readonly ZLinkActorHandoffPacket[];
|
|
@@ -50,12 +50,12 @@ class ZLinkActorHandoffCoordinator {
|
|
|
50
50
|
options.messageFollowDurationMs ?? exports.DEFAULT_MESSAGE_FOLLOW_DURATION_MS;
|
|
51
51
|
}
|
|
52
52
|
begin(actorId, oldGeneration) {
|
|
53
|
-
this.startHandoff(actorId, oldGeneration,
|
|
53
|
+
this.startHandoff(actorId, oldGeneration, 'relocating');
|
|
54
54
|
}
|
|
55
|
-
beginProvisional(actorId,
|
|
56
|
-
this.startHandoff(actorId, oldGeneration,
|
|
55
|
+
beginProvisional(actorId, oldGeneration) {
|
|
56
|
+
this.startHandoff(actorId, oldGeneration, 'provisional');
|
|
57
57
|
}
|
|
58
|
-
startHandoff(actorId, oldGeneration,
|
|
58
|
+
startHandoff(actorId, oldGeneration, phase) {
|
|
59
59
|
if (this.active.has(actorId)) {
|
|
60
60
|
throw new Error(`Actor '${actorId}' already has an active packet handoff.`);
|
|
61
61
|
}
|
|
@@ -98,8 +98,8 @@ class ZLinkActorHandoffCoordinator {
|
|
|
98
98
|
oldNodeRidHex: sourceEvidence.nodeRidHex,
|
|
99
99
|
sourceEvidence,
|
|
100
100
|
sourceOwner,
|
|
101
|
-
phase
|
|
102
|
-
|
|
101
|
+
phase,
|
|
102
|
+
deferredJoin: phase === 'provisional',
|
|
103
103
|
connectionBoundSealed: false,
|
|
104
104
|
pending: [],
|
|
105
105
|
nextIndex: 0,
|
|
@@ -113,14 +113,11 @@ class ZLinkActorHandoffCoordinator {
|
|
|
113
113
|
isProvisional(actorId) {
|
|
114
114
|
return this.active.get(actorId)?.phase === 'provisional';
|
|
115
115
|
}
|
|
116
|
-
promoteProvisional(actorId
|
|
116
|
+
promoteProvisional(actorId) {
|
|
117
117
|
const handoff = this.active.get(actorId);
|
|
118
|
-
if (handoff
|
|
118
|
+
if (handoff?.phase !== 'provisional') {
|
|
119
119
|
throw new Error(`Actor '${actorId}' does not have a provisional packet handoff.`);
|
|
120
120
|
}
|
|
121
|
-
if (handoff.phase !== 'provisional' || handoff.operationId !== operationId) {
|
|
122
|
-
throw new Error(`Actor '${actorId}' packet handoff belongs to another operation.`);
|
|
123
|
-
}
|
|
124
121
|
handoff.phase = 'relocating';
|
|
125
122
|
}
|
|
126
123
|
sealConnectionBoundIngress(actorId) {
|
|
@@ -131,12 +128,12 @@ class ZLinkActorHandoffCoordinator {
|
|
|
131
128
|
activeSourceOwner(actorId) {
|
|
132
129
|
return this.active.get(actorId)?.sourceOwner;
|
|
133
130
|
}
|
|
134
|
-
async releaseDeferred(actorId,
|
|
131
|
+
async releaseDeferred(actorId, dispatch, admission) {
|
|
135
132
|
const handoff = this.active.get(actorId);
|
|
136
133
|
if (handoff === undefined)
|
|
137
134
|
return;
|
|
138
|
-
if (handoff.
|
|
139
|
-
throw new Error(`Actor '${actorId}' packet handoff
|
|
135
|
+
if (!handoff.deferredJoin) {
|
|
136
|
+
throw new Error(`Actor '${actorId}' packet handoff was not started by a deferred Join.`);
|
|
140
137
|
}
|
|
141
138
|
await this.releaseHandoff(actorId, handoff, dispatch ?? handoff.replay, admission);
|
|
142
139
|
}
|
|
@@ -153,12 +150,12 @@ class ZLinkActorHandoffCoordinator {
|
|
|
153
150
|
*
|
|
154
151
|
* @internal
|
|
155
152
|
*/
|
|
156
|
-
admitDeferredPrefix(actorId,
|
|
153
|
+
admitDeferredPrefix(actorId, queue, preparation, start = Promise.resolve()) {
|
|
157
154
|
const handoff = this.active.get(actorId);
|
|
158
155
|
if (handoff === undefined)
|
|
159
156
|
return { terminal: Promise.resolve() };
|
|
160
|
-
if (handoff.
|
|
161
|
-
throw new Error(`Actor '${actorId}' packet handoff
|
|
157
|
+
if (!handoff.deferredJoin) {
|
|
158
|
+
throw new Error(`Actor '${actorId}' packet handoff was not started by a deferred Join.`);
|
|
162
159
|
}
|
|
163
160
|
return this.admitHandoffPrefix(actorId, handoff, queue, preparation, start);
|
|
164
161
|
}
|
|
@@ -396,6 +393,20 @@ class ZLinkActorHandoffCoordinator {
|
|
|
396
393
|
}
|
|
397
394
|
pending.reject?.(error);
|
|
398
395
|
}
|
|
396
|
+
/**
|
|
397
|
+
* Expired-owner terminal of a relocation (spec 28 §4.4): every pending
|
|
398
|
+
* record without a terminal fails once with `reason`. The handoff stays
|
|
399
|
+
* active, so the source never dispatches the Actor again.
|
|
400
|
+
*/
|
|
401
|
+
failPending(actorId, reason) {
|
|
402
|
+
const handoff = this.active.get(actorId);
|
|
403
|
+
if (handoff === undefined)
|
|
404
|
+
return;
|
|
405
|
+
for (const pending of handoff.pending.splice(0))
|
|
406
|
+
this.failReleasedPending(pending, reason);
|
|
407
|
+
handoff.snapshotIndex = -1;
|
|
408
|
+
handoff.pendingBytes = 0;
|
|
409
|
+
}
|
|
399
410
|
cancel(actorId) {
|
|
400
411
|
const handoff = this.active.get(actorId);
|
|
401
412
|
if (handoff === undefined)
|
|
@@ -193,7 +193,7 @@ class ZLinkLocalNativeActorJoin {
|
|
|
193
193
|
// (spec 32-framework-error-model:83-118); an OK terminal with no join
|
|
194
194
|
// control is a protocol violation.
|
|
195
195
|
throw admission.terminalResult !== 0 || admission.failureErrno !== 0
|
|
196
|
-
?
|
|
196
|
+
? (0, framework_errors_internal_1.wireReplyFailureException)(admission.terminalResult, admission.failureErrno, message)
|
|
197
197
|
: (0, framework_errors_internal_1.createInternalFrameworkException)(framework_errors_internal_1.ZLinkFrameworkInternalErrorKind.RequestProtocolError, message);
|
|
198
198
|
}
|
|
199
199
|
if (control.joinResult !== 0) {
|
|
@@ -210,7 +210,7 @@ class ZLinkLocalNativeActorJoin {
|
|
|
210
210
|
}
|
|
211
211
|
if (admission.terminalResult !== 0 || admission.failureErrno !== 0) {
|
|
212
212
|
(0, mesh_completion_table_1.closeMeshCompletion)(admission);
|
|
213
|
-
throw
|
|
213
|
+
throw (0, framework_errors_internal_1.wireReplyFailureException)(admission.terminalResult, admission.failureErrno, `Actor admission failed for '${actor.context.actorId}' with result '${admission.terminalResult}' and errno '${admission.failureErrno}'.`);
|
|
214
214
|
}
|
|
215
215
|
disposeParts(admission.parts.slice(1));
|
|
216
216
|
if (control.canonicalHandoffId !== undefined) {
|
|
@@ -359,22 +359,6 @@ function canonicalHandoffRelocationId(handoffId) {
|
|
|
359
359
|
return (`${hex.slice(0, 8)}-${hex.slice(8, 12)}-${hex.slice(12, 16)}` +
|
|
360
360
|
`-${hex.slice(16, 20)}-${hex.slice(20)}`);
|
|
361
361
|
}
|
|
362
|
-
function remoteActorJoinFailureException(node, target, terminalResult, failureErrno, message) {
|
|
363
|
-
const failure = (0, framework_errors_internal_1.wireReplyFailureException)(terminalResult, failureErrno, message);
|
|
364
|
-
const targetGeneration = target.targetNodeGeneration;
|
|
365
|
-
if (failure.kind === contracts_1.ZLinkFrameworkErrorKind.DeadlineExceeded &&
|
|
366
|
-
targetGeneration !== undefined &&
|
|
367
|
-
targetGeneration !== 0n &&
|
|
368
|
-
!node
|
|
369
|
-
.peers()
|
|
370
|
-
.some((peer) => peer.state === 3 &&
|
|
371
|
-
peer.routingId !== null &&
|
|
372
|
-
(0, routing_id_2.routingIdsEqual)(peer.routingId, target.targetNodeRid) &&
|
|
373
|
-
peer.lifecycleGeneration === targetGeneration)) {
|
|
374
|
-
return (0, framework_errors_internal_1.createInternalFrameworkException)(framework_errors_internal_1.ZLinkFrameworkInternalErrorKind.RouteNotConnected, 'wire Actor join target RouteMesh peer became unavailable');
|
|
375
|
-
}
|
|
376
|
-
return failure;
|
|
377
|
-
}
|
|
378
362
|
function runtimeActorMeshName(actor, state, fallback) {
|
|
379
363
|
const context = actor.context;
|
|
380
364
|
const stateMeshName = state?.meshName;
|
|
@@ -28,8 +28,8 @@ export declare class ZLinkActorNativeJoinCoordinator implements ZLinkActorJoinCo
|
|
|
28
28
|
private readonly localJoin;
|
|
29
29
|
messageFlow(): import('../diagnostics/message-flow').ZLinkMessageFlowTracer | undefined;
|
|
30
30
|
constructor(options: ZLinkActorNativeJoinCoordinatorOptions);
|
|
31
|
-
beginDeferredJoin(actor: ZLinkActor, state: ZLinkActorRuntimeState
|
|
32
|
-
abortDeferredJoin(actor: ZLinkActor, state: ZLinkActorRuntimeState
|
|
31
|
+
beginDeferredJoin(actor: ZLinkActor, state: ZLinkActorRuntimeState): void;
|
|
32
|
+
abortDeferredJoin(actor: ZLinkActor, state: ZLinkActorRuntimeState): Promise<void>;
|
|
33
33
|
joinSpot(actor: ZLinkActor, state: ZLinkActorRuntimeState, spotId: RoutingId, request: Message, timeoutMs: number | undefined, signal: AbortSignal | undefined, completionOperationId?: import('../../contracts').ZLinkActorJoinOperationId): Promise<ZLinkActorJoinRuntimeResult<Message>>;
|
|
34
34
|
joinEntrySpot(actor: ZLinkActor, state: ZLinkActorRuntimeState, nodeRid: RoutingId | undefined, request: Message, timeoutMs: number | undefined, signal: AbortSignal | undefined, completionOperationId?: import('../../contracts').ZLinkActorJoinOperationId): Promise<ZLinkActorJoinRuntimeResult<Message>>;
|
|
35
35
|
private withDeferredJoinFinalizer;
|
|
@@ -7,7 +7,6 @@ const actor_native_lookup_1 = require("./actor-native-lookup");
|
|
|
7
7
|
const post_commit_actor_location_1 = require("./post-commit-actor-location");
|
|
8
8
|
const actor_local_native_join_1 = require("./actor-local-native-join");
|
|
9
9
|
const post_commit_actor_binder_1 = require("./post-commit-actor-binder");
|
|
10
|
-
const operation_identity_1 = require("../foundation/operation-identity");
|
|
11
10
|
/** Selects local native join or remote two-phase transfer for each destination. */
|
|
12
11
|
class ZLinkActorNativeJoinCoordinator {
|
|
13
12
|
options;
|
|
@@ -38,11 +37,11 @@ class ZLinkActorNativeJoinCoordinator {
|
|
|
38
37
|
messageSerializers: options.messageSerializers
|
|
39
38
|
});
|
|
40
39
|
}
|
|
41
|
-
beginDeferredJoin(actor, state
|
|
42
|
-
this.options.sourceTransfer?.beginDeferredActorHandoff?.(actor, state
|
|
40
|
+
beginDeferredJoin(actor, state) {
|
|
41
|
+
this.options.sourceTransfer?.beginDeferredActorHandoff?.(actor, state);
|
|
43
42
|
}
|
|
44
|
-
async abortDeferredJoin(actor, state
|
|
45
|
-
await this.options.sourceTransfer?.cancelDeferredActorHandoff?.(actor, state
|
|
43
|
+
async abortDeferredJoin(actor, state) {
|
|
44
|
+
await this.options.sourceTransfer?.cancelDeferredActorHandoff?.(actor, state);
|
|
46
45
|
}
|
|
47
46
|
async joinSpot(actor, state, spotId, request, timeoutMs, signal, completionOperationId) {
|
|
48
47
|
(0, abort_1.throwIfAborted)(signal);
|
|
@@ -85,15 +84,14 @@ class ZLinkActorNativeJoinCoordinator {
|
|
|
85
84
|
withDeferredJoinFinalizer(actor, state, target, result, operationId) {
|
|
86
85
|
if (operationId === undefined || this.options.sourceTransfer === undefined)
|
|
87
86
|
return result;
|
|
88
|
-
const key = (0, operation_identity_1.operationIdentityKey)(operationId);
|
|
89
87
|
return {
|
|
90
88
|
...result,
|
|
91
89
|
finalizeDeferredJoin: async () => {
|
|
92
90
|
if (result.accepted && result.actor !== undefined && target !== undefined) {
|
|
93
|
-
await this.options.sourceTransfer.completeDeferredActorHandoff?.(actor, target, result.actor
|
|
91
|
+
await this.options.sourceTransfer.completeDeferredActorHandoff?.(actor, target, result.actor);
|
|
94
92
|
}
|
|
95
93
|
else {
|
|
96
|
-
await this.options.sourceTransfer.cancelDeferredActorHandoff?.(actor, state
|
|
94
|
+
await this.options.sourceTransfer.cancelDeferredActorHandoff?.(actor, state);
|
|
97
95
|
}
|
|
98
96
|
}
|
|
99
97
|
};
|
|
@@ -6,6 +6,7 @@ import type { ZLinkLocationLifecycle } from '../locations';
|
|
|
6
6
|
import type { ZLinkActorRuntimeState } from './actor-runtime-state';
|
|
7
7
|
import type { ZLinkActorTransferRegistry } from './actor-transfer-registry';
|
|
8
8
|
import type { ZLinkRuntimeAdmissionGate } from '../admission';
|
|
9
|
+
import type { ZLinkActivationAdmission } from '../activation-admission';
|
|
9
10
|
export interface ZLinkActorJoinRuntimeResult<TReply> {
|
|
10
11
|
readonly accepted: boolean;
|
|
11
12
|
readonly actor?: import('../../contracts').ActorRef;
|
|
@@ -34,6 +35,7 @@ export interface ZLinkActorManagerOptions {
|
|
|
34
35
|
readonly shutdownSignal?: AbortSignal;
|
|
35
36
|
readonly metrics?: import('../diagnostics').ZLinkRuntimeMetrics;
|
|
36
37
|
readonly admission?: ZLinkRuntimeAdmissionGate;
|
|
38
|
+
readonly activationAdmission?: ZLinkActivationAdmission;
|
|
37
39
|
readonly placementCreate?: (actorId: string, actorType: string, createOnly: boolean, options: {
|
|
38
40
|
readonly meshName?: string;
|
|
39
41
|
readonly request?: unknown;
|
|
@@ -56,8 +58,8 @@ export interface ZLinkActorJoinCoordinator {
|
|
|
56
58
|
* lookup. This is an internal ordering fence; it is not part of the public
|
|
57
59
|
* actor context contract.
|
|
58
60
|
*/
|
|
59
|
-
beginDeferredJoin?(actor: ZLinkActor, state: ZLinkActorRuntimeState
|
|
60
|
-
abortDeferredJoin?(actor: ZLinkActor, state: ZLinkActorRuntimeState
|
|
61
|
+
beginDeferredJoin?(actor: ZLinkActor, state: ZLinkActorRuntimeState): void;
|
|
62
|
+
abortDeferredJoin?(actor: ZLinkActor, state: ZLinkActorRuntimeState): Promise<void>;
|
|
61
63
|
joinSpot(actor: ZLinkActor, state: ZLinkActorRuntimeState, spotId: RoutingId, request: Message, timeoutMs: number | undefined, signal: AbortSignal | undefined, completionOperationId?: import('../../contracts').ZLinkActorJoinOperationId): Promise<ZLinkActorJoinRuntimeResult<Message>>;
|
|
62
64
|
joinEntrySpot(actor: ZLinkActor, state: ZLinkActorRuntimeState, nodeRid: RoutingId | undefined, request: Message, timeoutMs: number | undefined, signal: AbortSignal | undefined, completionOperationId?: import('../../contracts').ZLinkActorJoinOperationId): Promise<ZLinkActorJoinRuntimeResult<Message>>;
|
|
63
65
|
}
|
|
@@ -16,12 +16,12 @@ export interface ZLinkPreparedActorSource {
|
|
|
16
16
|
}
|
|
17
17
|
export interface ZLinkActorSourceTransfer {
|
|
18
18
|
/** Starts the ingress handoff before target route lookup. */
|
|
19
|
-
beginDeferredActorHandoff?(actor: ZLinkActor, state: ZLinkActorRuntimeState
|
|
19
|
+
beginDeferredActorHandoff?(actor: ZLinkActor, state: ZLinkActorRuntimeState): void;
|
|
20
20
|
/** Changes a provisional ingress fence into a relocation handoff. */
|
|
21
|
-
promoteDeferredActorHandoff?(actor: ZLinkActor, state: ZLinkActorRuntimeState
|
|
21
|
+
promoteDeferredActorHandoff?(actor: ZLinkActor, state: ZLinkActorRuntimeState): void;
|
|
22
22
|
/** Finishes a same-node deferred Join handoff after completion callback. */
|
|
23
|
-
completeDeferredActorHandoff?(actor: ZLinkActor, target: ZLinkSpotRouteTarget, targetActorRef: ActorRef
|
|
23
|
+
completeDeferredActorHandoff?(actor: ZLinkActor, target: ZLinkSpotRouteTarget, targetActorRef: ActorRef): Promise<void>;
|
|
24
24
|
/** Releases an early handoff when Join cannot commit. */
|
|
25
|
-
cancelDeferredActorHandoff?(actor: ZLinkActor, state: ZLinkActorRuntimeState
|
|
26
|
-
prepareSource(actor: ZLinkActor, state: ZLinkActorRuntimeState, signal?: AbortSignal, lifecycleAuthority?: 'framework' | 'core',
|
|
25
|
+
cancelDeferredActorHandoff?(actor: ZLinkActor, state: ZLinkActorRuntimeState): Promise<void>;
|
|
26
|
+
prepareSource(actor: ZLinkActor, state: ZLinkActorRuntimeState, signal?: AbortSignal, lifecycleAuthority?: 'framework' | 'core', deferredJoin?: boolean, relocation?: ServiceWireOperationId): Promise<ZLinkPreparedActorSource>;
|
|
27
27
|
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { ActorRef, ZLinkActorJoinOperationId } from '../../contracts';
|
|
2
|
+
/**
|
|
3
|
+
* The Accepted completion of a deferred cross-node Join. Spot Actor membership
|
|
4
|
+
* sections 4-5: the public OperationId, the optional reply and the delivery
|
|
5
|
+
* state live only while the current source and target processes run. The
|
|
6
|
+
* completion is never written to a Store and never replayed after a restart.
|
|
7
|
+
*/
|
|
8
|
+
export interface ZLinkDeferredJoinCompletion {
|
|
9
|
+
readonly operationId: ZLinkActorJoinOperationId;
|
|
10
|
+
readonly actor: ActorRef;
|
|
11
|
+
readonly rawReply: Buffer;
|
|
12
|
+
readonly replyContentType?: string;
|
|
13
|
+
}
|
|
14
|
+
export declare function createDeferredJoinCompletion(actorId: string, operationId: ZLinkActorJoinOperationId, actor: ActorRef, rawReply: Uint8Array, replyContentType?: string): ZLinkDeferredJoinCompletion;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createDeferredJoinCompletion = createDeferredJoinCompletion;
|
|
4
|
+
function createDeferredJoinCompletion(actorId, operationId, actor, rawReply, replyContentType) {
|
|
5
|
+
if (actorId.length === 0 ||
|
|
6
|
+
actor.actorId !== actorId ||
|
|
7
|
+
actor.objectGeneration <= 0n ||
|
|
8
|
+
(operationId.high === 0n && operationId.low === 0n)) {
|
|
9
|
+
throw new Error('Deferred Join completion identity is invalid.');
|
|
10
|
+
}
|
|
11
|
+
if (replyContentType !== undefined && replyContentType.length === 0) {
|
|
12
|
+
throw new TypeError('Deferred Join reply content type must be non-empty.');
|
|
13
|
+
}
|
|
14
|
+
return {
|
|
15
|
+
operationId,
|
|
16
|
+
actor,
|
|
17
|
+
rawReply: Buffer.from(rawReply),
|
|
18
|
+
...(replyContentType === undefined ? {} : { replyContentType })
|
|
19
|
+
};
|
|
20
|
+
}
|
|
@@ -7,7 +7,7 @@ export { ZLinkActorSerialExecutor } from './actor-mailbox';
|
|
|
7
7
|
export { DEFAULT_MESSAGE_FOLLOW_DURATION_MS, ZLinkActorHandoffCoordinator, decodeHandoffPacket, type ZLinkActorHandoffPacket, type ZLinkActorHandoffDispatch, type ZLinkActorHandoffPrefixAdmission, type ZLinkActorHandoffPrefixQueue, type ZLinkActorHandoffPrefixRecord, type ZLinkActorHandoffPreparedReplayAdmission, type ZLinkActorHandoffReplayAdmission, type ZLinkActorHandoffReplayPreparation, type ZLinkActorHandoffResult } from './actor-handoff';
|
|
8
8
|
export { actorMessageFollowContext, attachActorMessageFollowContext, decodeActorMessageFollowContext, type ZLinkActorMessageFollowContext, type ZLinkActorMessageFollowOwnerFence } from './actor-message-follow-context';
|
|
9
9
|
export { ZLinkActorRuntimeState, mergeRemoteBoundSessionTarget, preferredRemoteBoundSessionTarget, toFrameworkActorRef, toFrameworkRoutingId, type ZLinkActorCreationOperation, type ZLinkRemoteActorPacketTarget, type ZLinkRemoteBoundSessionTarget } from './actor-runtime-state';
|
|
10
|
-
export {
|
|
10
|
+
export { createDeferredJoinCompletion, type ZLinkDeferredJoinCompletion } from './deferred-join-completion';
|
|
11
11
|
export { decodeActorAuthorityIdentity, decodeRelocatingActorAuthorityIdentity, encodeActorAuthorityIdentity, isActorAuthorityPayload, rewriteActorAuthorityRoute, rewriteActorAuthorityOwner, publishInitialActorAuthority, type ZLinkActorAuthorityIdentity } from './actor-authority-publication';
|
|
12
12
|
import { ZLinkActorRuntimeState } from './actor-runtime-state';
|
|
13
13
|
export { ZLinkActorPacketKind, ZLinkSpotActorDispatcher, ZLinkSpotActorHandlerRegistryRuntime, type ZLinkActorPacketDescriptor, type ZLinkSpotActorDispatcherOptions } from './spot-actor-dispatch';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.DefaultZLinkActorManager = exports.ZLINK_ACTOR_LIFECYCLE_SNAPSHOT = exports.createActorMembership = exports.createActorJoinRequest = exports.actorJoinIdentity = exports.ZLinkRemoteBoundSessionFenceError = exports.isRemoteBoundSessionFenceError = exports.encodeRemoteBoundSessionNack = exports.ZLINK_REMOTE_BOUND_SESSION_SEND_PACKET = exports.ZLINK_REMOTE_BOUND_SESSION_RESPONSE_PACKET = exports.ZLINK_REMOTE_BOUND_SESSION_FENCE_NACK_CODE = exports.ZLINK_REMOTE_BOUND_SESSION_ERROR_PACKET = exports.ZLINK_REMOTE_ACTOR_SESSION_DISCONNECTED_PACKET = exports.ZLINK_REMOTE_ACTOR_PACKET_RELAY_PACKET = exports.decodeRemoteActorSourceLeaveTerminal = exports.ZLINK_REMOTE_ACTOR_SOURCE_LEAVE_TERMINAL = exports.ZLINK_REMOTE_ACTOR_JOIN_PACKET = exports.ZLinkActorTransferRegistry = exports.ZLinkActorNativeJoinCoordinator = exports.ZLinkSpotActorHandlerRegistryRuntime = exports.ZLinkSpotActorDispatcher = exports.ZLinkActorPacketKind = exports.publishInitialActorAuthority = exports.rewriteActorAuthorityOwner = exports.rewriteActorAuthorityRoute = exports.isActorAuthorityPayload = exports.encodeActorAuthorityIdentity = exports.decodeRelocatingActorAuthorityIdentity = exports.decodeActorAuthorityIdentity = exports.
|
|
3
|
+
exports.DefaultZLinkActorManager = exports.ZLINK_ACTOR_LIFECYCLE_SNAPSHOT = exports.createActorMembership = exports.createActorJoinRequest = exports.actorJoinIdentity = exports.ZLinkRemoteBoundSessionFenceError = exports.isRemoteBoundSessionFenceError = exports.encodeRemoteBoundSessionNack = exports.ZLINK_REMOTE_BOUND_SESSION_SEND_PACKET = exports.ZLINK_REMOTE_BOUND_SESSION_RESPONSE_PACKET = exports.ZLINK_REMOTE_BOUND_SESSION_FENCE_NACK_CODE = exports.ZLINK_REMOTE_BOUND_SESSION_ERROR_PACKET = exports.ZLINK_REMOTE_ACTOR_SESSION_DISCONNECTED_PACKET = exports.ZLINK_REMOTE_ACTOR_PACKET_RELAY_PACKET = exports.decodeRemoteActorSourceLeaveTerminal = exports.ZLINK_REMOTE_ACTOR_SOURCE_LEAVE_TERMINAL = exports.ZLINK_REMOTE_ACTOR_JOIN_PACKET = exports.ZLinkActorTransferRegistry = exports.ZLinkActorNativeJoinCoordinator = exports.ZLinkSpotActorHandlerRegistryRuntime = exports.ZLinkSpotActorDispatcher = exports.ZLinkActorPacketKind = exports.publishInitialActorAuthority = exports.rewriteActorAuthorityOwner = exports.rewriteActorAuthorityRoute = exports.isActorAuthorityPayload = exports.encodeActorAuthorityIdentity = exports.decodeRelocatingActorAuthorityIdentity = exports.decodeActorAuthorityIdentity = exports.createDeferredJoinCompletion = exports.toFrameworkRoutingId = exports.toFrameworkActorRef = exports.preferredRemoteBoundSessionTarget = exports.mergeRemoteBoundSessionTarget = exports.ZLinkActorRuntimeState = exports.decodeActorMessageFollowContext = exports.attachActorMessageFollowContext = exports.actorMessageFollowContext = exports.decodeHandoffPacket = exports.ZLinkActorHandoffCoordinator = exports.DEFAULT_MESSAGE_FOLLOW_DURATION_MS = exports.ZLinkActorSerialExecutor = exports.ZLINK_ACTOR_JOIN_ENTRY_SPOT_RUNTIME = exports.DefaultZLinkActorContext = exports.forwardEncodedActorPacket = exports.DefaultZLinkActorClient = void 0;
|
|
4
4
|
const framework_errors_internal_1 = require("../framework-errors-internal");
|
|
5
5
|
const contracts_1 = require("../../contracts");
|
|
6
6
|
const runtime_message_1 = require("../backend/runtime-message");
|
|
@@ -34,9 +34,8 @@ Object.defineProperty(exports, "mergeRemoteBoundSessionTarget", { enumerable: tr
|
|
|
34
34
|
Object.defineProperty(exports, "preferredRemoteBoundSessionTarget", { enumerable: true, get: function () { return actor_runtime_state_1.preferredRemoteBoundSessionTarget; } });
|
|
35
35
|
Object.defineProperty(exports, "toFrameworkActorRef", { enumerable: true, get: function () { return actor_runtime_state_1.toFrameworkActorRef; } });
|
|
36
36
|
Object.defineProperty(exports, "toFrameworkRoutingId", { enumerable: true, get: function () { return actor_runtime_state_1.toFrameworkRoutingId; } });
|
|
37
|
-
var
|
|
38
|
-
Object.defineProperty(exports, "
|
|
39
|
-
Object.defineProperty(exports, "ZLinkDeferredJoinAcceptedJournal", { enumerable: true, get: function () { return deferred_join_accepted_journal_1.ZLinkDeferredJoinAcceptedJournal; } });
|
|
37
|
+
var deferred_join_completion_1 = require("./deferred-join-completion");
|
|
38
|
+
Object.defineProperty(exports, "createDeferredJoinCompletion", { enumerable: true, get: function () { return deferred_join_completion_1.createDeferredJoinCompletion; } });
|
|
40
39
|
var actor_authority_publication_1 = require("./actor-authority-publication");
|
|
41
40
|
Object.defineProperty(exports, "decodeActorAuthorityIdentity", { enumerable: true, get: function () { return actor_authority_publication_1.decodeActorAuthorityIdentity; } });
|
|
42
41
|
Object.defineProperty(exports, "decodeRelocatingActorAuthorityIdentity", { enumerable: true, get: function () { return actor_authority_publication_1.decodeRelocatingActorAuthorityIdentity; } });
|
|
@@ -451,7 +450,18 @@ class DefaultZLinkActorManager {
|
|
|
451
450
|
if (request !== undefined && createRequest.nativeRequest !== undefined) {
|
|
452
451
|
state.setCreateRequestPayload(createRequest.nativeRequest.data());
|
|
453
452
|
}
|
|
454
|
-
const operation = state.getOrStartCreation(actorType, failIfExists, () =>
|
|
453
|
+
const operation = state.getOrStartCreation(actorType, failIfExists, async () => {
|
|
454
|
+
const meshName = state.meshName ?? this.options.actorMeshNameProvider?.(actorType);
|
|
455
|
+
const release = meshName === undefined
|
|
456
|
+
? undefined
|
|
457
|
+
: await this.options.activationAdmission?.acquire(meshName, signal);
|
|
458
|
+
try {
|
|
459
|
+
return await this.creation.createActor(actorId, actorType, state, createRequest, claimLocation, signal);
|
|
460
|
+
}
|
|
461
|
+
finally {
|
|
462
|
+
release?.();
|
|
463
|
+
}
|
|
464
|
+
});
|
|
455
465
|
if (operation.created) {
|
|
456
466
|
void operation.task.then((result) => {
|
|
457
467
|
if (result.status !== 'created') {
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
import { ZLinkFrameworkInternalErrorKind } from './framework-errors-internal';
|
|
2
2
|
export declare class ZLinkRuntimeAdmissionGate {
|
|
3
|
-
|
|
3
|
+
readonly ownerAdmissionOpen: () => boolean;
|
|
4
4
|
private readonly meshes;
|
|
5
|
+
/**
|
|
6
|
+
* Location runtime §5: the host's single new-work decision (local admission deadline and host
|
|
7
|
+
* execution combination). A host without a Location Store has no such block.
|
|
8
|
+
*/
|
|
5
9
|
constructor(ownerAdmissionOpen?: () => boolean);
|
|
6
10
|
get acceptsNewWork(): boolean;
|
|
7
11
|
register(meshName: string): void;
|
|
@@ -5,6 +5,10 @@ const framework_errors_internal_1 = require("./framework-errors-internal");
|
|
|
5
5
|
class ZLinkRuntimeAdmissionGate {
|
|
6
6
|
ownerAdmissionOpen;
|
|
7
7
|
meshes = new Map();
|
|
8
|
+
/**
|
|
9
|
+
* Location runtime §5: the host's single new-work decision (local admission deadline and host
|
|
10
|
+
* execution combination). A host without a Location Store has no such block.
|
|
11
|
+
*/
|
|
8
12
|
constructor(ownerAdmissionOpen = () => true) {
|
|
9
13
|
this.ownerAdmissionOpen = ownerAdmissionOpen;
|
|
10
14
|
}
|