@zlink-systems/framework 0.30.0 → 0.30.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +150 -68
- package/dist/.tsbuildinfo +1 -1
- package/dist/contracts/Actors/ZLinkActorClient.d.ts +2 -1
- package/dist/contracts/Channels/Calls.d.ts +2 -1
- package/dist/contracts/Common/ZLinkMessageMetadata.js +11 -5
- package/dist/contracts/Handlers/Attributes.d.ts +5 -13
- package/dist/contracts/Handlers/Attributes.js +7 -11
- package/dist/contracts/Handlers/JsonContract.d.ts +2 -46
- package/dist/contracts/Handlers/JsonContract.js +4 -153
- package/dist/contracts/Spots/Contracts.d.ts +2 -1
- package/dist/nest-integration.d.ts +1 -1
- package/dist/nest-integration.js +2 -1
- package/dist/runtime/actors/actor-client.d.ts +1 -1
- package/dist/runtime/actors/actor-client.js +14 -12
- package/dist/runtime/actors/actor-handoff.d.ts +1 -1
- package/dist/runtime/actors/actor-handoff.js +7 -4
- package/dist/runtime/actors/actor-join-relocation.d.ts +1 -0
- package/dist/runtime/actors/actor-local-native-join.js +9 -12
- package/dist/runtime/actors/actor-remote-wire.js +15 -0
- package/dist/runtime/actors/actor-routed-join-transport.d.ts +6 -2
- package/dist/runtime/actors/actor-routed-json-request.d.ts +2 -0
- package/dist/runtime/actors/index.d.ts +2 -1
- package/dist/runtime/actors/index.js +18 -6
- package/dist/runtime/actors/spot-actor-dispatch.js +2 -2
- package/dist/runtime/admission.d.ts +1 -1
- package/dist/runtime/admission.js +15 -5
- package/dist/runtime/application-jobs/application-ingress-record-owner.d.ts +6 -8
- package/dist/runtime/application-jobs/application-ingress-record-owner.js +39 -22
- package/dist/runtime/application-jobs/application-job-queue-scope.d.ts +2 -1
- package/dist/runtime/application-jobs/application-job-queue-scope.js +37 -22
- package/dist/runtime/application-jobs/contracts.d.ts +10 -1
- package/dist/runtime/backend/contracts/index.d.ts +18 -9
- package/dist/runtime/backend/mesh-completion-table.d.ts +9 -1
- package/dist/runtime/backend/mesh-completion-table.js +149 -49
- package/dist/runtime/backend/mesh-dispatch-pump.d.ts +3 -0
- package/dist/runtime/backend/mesh-dispatch-pump.js +32 -11
- package/dist/runtime/backend/node/node-backend-adapter-support.d.ts +2 -2
- package/dist/runtime/backend/node/node-backend-adapter-support.js +16 -9
- package/dist/runtime/backend/node/node-dealer-channel-client-transport.d.ts +1 -1
- package/dist/runtime/backend/node/node-dealer-channel-client-transport.js +5 -2
- package/dist/runtime/backend/node/node-raw-binding-port.js +42 -22
- package/dist/runtime/backend/node/node-raw-mesh-backend.d.ts +13 -5
- package/dist/runtime/backend/node/node-raw-mesh-backend.js +69 -51
- package/dist/runtime/backend/node/node-socket-backend-adapter.js +6 -6
- package/dist/runtime/backend/raw-binding-port.d.ts +2 -2
- package/dist/runtime/backend/runtime-message.d.ts +1 -0
- package/dist/runtime/backend/runtime-message.js +5 -0
- package/dist/runtime/backend/runtime-values.d.ts +1 -0
- package/dist/runtime/backend/runtime-values.js +2 -1
- package/dist/runtime/channels/channel-clients.d.ts +1 -0
- package/dist/runtime/channels/channel-clients.js +58 -21
- package/dist/runtime/channels/channel-dispatch-pipeline.d.ts +3 -2
- package/dist/runtime/channels/channel-dispatch-pipeline.js +20 -11
- package/dist/runtime/channels/channel-dispatch-services.d.ts +1 -0
- package/dist/runtime/channels/channel-dispatch-services.js +45 -0
- package/dist/runtime/channels/channel-dispatchers.d.ts +1 -1
- package/dist/runtime/channels/channel-dispatchers.js +27 -26
- package/dist/runtime/channels/channel-envelope-inspection.d.ts +1 -2
- package/dist/runtime/channels/channel-envelope-inspection.js +1 -16
- package/dist/runtime/channels/channel-envelope.d.ts +1 -0
- package/dist/runtime/channels/channel-envelope.js +83 -8
- package/dist/runtime/channels/channel-outbound-operations.d.ts +2 -2
- package/dist/runtime/channels/channel-outbound-operations.js +8 -8
- package/dist/runtime/channels/channel-runtime-manager.d.ts +6 -6
- package/dist/runtime/channels/channel-runtime-manager.js +12 -12
- package/dist/runtime/channels/channel-transports.d.ts +18 -15
- package/dist/runtime/channels/channel-transports.js +48 -31
- package/dist/runtime/channels/local-spot-route-transport.d.ts +1 -1
- package/dist/runtime/channels/local-spot-route-transport.js +2 -1
- package/dist/runtime/channels/router-socket-spot-route-transport.d.ts +2 -2
- package/dist/runtime/channels/router-socket-spot-route-transport.js +4 -4
- package/dist/runtime/channels/source-spot-router.d.ts +2 -2
- package/dist/runtime/channels/source-spot-router.js +4 -4
- package/dist/runtime/channels/spot-node-route-transport.d.ts +2 -2
- package/dist/runtime/channels/spot-node-route-transport.js +4 -4
- package/dist/runtime/channels/spot-route-bridge-transport.d.ts +2 -2
- package/dist/runtime/channels/spot-route-bridge-transport.js +4 -4
- package/dist/runtime/channels/spot-route-dispatch-strategy.d.ts +5 -4
- package/dist/runtime/channels/spot-route-dispatch-strategy.js +18 -18
- package/dist/runtime/execution/serial-execution-queue.d.ts +1 -0
- package/dist/runtime/execution/serial-execution-queue.js +1 -0
- package/dist/runtime/foundation/actor-join-recovery-codec.js +2 -2
- package/dist/runtime/foundation/durable-service-request.d.ts +14 -0
- package/dist/runtime/foundation/durable-service-request.js +98 -0
- package/dist/runtime/foundation/operation-identity.d.ts +1 -0
- package/dist/runtime/foundation/operation-identity.js +5 -1
- package/dist/runtime/foundation/raw-service-mesh-runtime.d.ts +22 -5
- package/dist/runtime/foundation/raw-service-mesh-runtime.js +356 -232
- package/dist/runtime/foundation/service-relocation-object-owner.d.ts +1 -0
- package/dist/runtime/foundation/service-relocation-object-owner.js +1 -0
- package/dist/runtime/foundation/service-relocation-runtime.d.ts +2 -0
- package/dist/runtime/foundation/service-relocation-runtime.js +13 -1
- package/dist/runtime/foundation/service-runtime-contracts.d.ts +2 -0
- package/dist/runtime/foundation/service-stateful-runtime.d.ts +4 -4
- package/dist/runtime/foundation/service-stateful-runtime.js +44 -103
- package/dist/runtime/foundation/service-stateful-wire-codec.d.ts +0 -5
- package/dist/runtime/foundation/service-topology-registry.d.ts +12 -2
- package/dist/runtime/foundation/service-topology-registry.js +61 -27
- package/dist/runtime/foundation/service-wire-m6a-codec.d.ts +3 -3
- package/dist/runtime/foundation/service-wire-m6a-codec.js +36 -38
- package/dist/runtime/handlers/handler-instance-scope.d.ts +8 -0
- package/dist/runtime/handlers/handler-instance-scope.js +54 -11
- package/dist/runtime/host/actor-runtime-options-factory.js +2 -2
- package/dist/runtime/host/application-job-queue.d.ts +19 -7
- package/dist/runtime/host/application-job-queue.js +150 -42
- package/dist/runtime/host/entry-actor-runtime.d.ts +1 -0
- package/dist/runtime/host/entry-actor-runtime.js +3 -0
- package/dist/runtime/host/index.d.ts +7 -1
- package/dist/runtime/host/index.js +142 -118
- package/dist/runtime/host/remote-bound-session-relay.js +2 -18
- package/dist/runtime/host/route-mesh-runtime.js +1 -1
- package/dist/runtime/host/service-relocation-control.d.ts +1 -0
- package/dist/runtime/host/service-relocation-control.js +10 -4
- package/dist/runtime/host/service-relocation-host-runtime.d.ts +6 -8
- package/dist/runtime/host/service-relocation-host-runtime.js +213 -241
- package/dist/runtime/host/spot-address-transport.js +3 -2
- package/dist/runtime/host/spot-runtime-options-factory.js +1 -0
- package/dist/runtime/locations/actor-location-claims.d.ts +2 -2
- package/dist/runtime/locations/actor-location-claims.js +34 -19
- package/dist/runtime/locations/lifecycle.d.ts +1 -2
- package/dist/runtime/locations/lifecycle.js +2 -5
- package/dist/runtime/locations/runtime.d.ts +1 -1
- package/dist/runtime/locations/runtime.js +24 -23
- package/dist/runtime/messaging/framework-json-v1.d.ts +4 -6
- package/dist/runtime/messaging/framework-json-v1.js +38 -294
- package/dist/runtime/messaging/packet-name.d.ts +1 -1
- package/dist/runtime/messaging/packet-name.js +8 -24
- package/dist/runtime/messaging/request-result.d.ts +2 -0
- package/dist/runtime/messaging/request-result.js +54 -0
- package/dist/runtime/messaging/submission-result.d.ts +1 -0
- package/dist/runtime/messaging/submission-result.js +5 -2
- package/dist/runtime/protocol/service_wire_codec.generated.d.ts +15 -0
- package/dist/runtime/protocol/service_wire_codec.generated.js +144 -0
- package/dist/runtime/protocol/service_wire_pilot_codec.generated.d.ts +9 -0
- package/dist/runtime/protocol/service_wire_pilot_codec.generated.js +14 -1
- package/dist/runtime/spots/formal-remote-actor-admission-registry.d.ts +7 -2
- package/dist/runtime/spots/formal-remote-actor-admission-registry.js +33 -19
- package/dist/runtime/spots/index.d.ts +3 -0
- package/dist/runtime/spots/index.js +9 -2
- package/dist/runtime/spots/spot-activation.d.ts +1 -0
- package/dist/runtime/spots/spot-activation.js +17 -8
- package/dist/runtime/spots/spot-entry-activation.js +6 -2
- package/dist/runtime/spots/spot-handler-registry.d.ts +3 -1
- package/dist/runtime/spots/spot-handler-registry.js +18 -8
- package/dist/runtime/spots/spot-node-autoconnect.js +4 -3
- package/dist/runtime/spots/spot-outbound.d.ts +3 -0
- package/dist/runtime/spots/spot-outbound.js +24 -15
- package/dist/runtime/spots/spot-routed-spot-packet-dispatch.d.ts +1 -0
- package/dist/runtime/spots/spot-routed-spot-packet-dispatch.js +1 -1
- package/dist/runtime/spots/spot-runtime-ports.d.ts +1 -0
- package/dist/runtime/spots/spot-subscription-dispatch.js +0 -3
- package/dist/runtime/spots/spot-timer.js +1 -0
- package/dist/runtime/streams/stream-session-runtime.d.ts +1 -1
- package/dist/runtime/streams/stream-session-runtime.js +13 -27
- package/package.json +2 -2
- package/src/contracts/Actors/ZLinkActorClient.ts +2 -1
- package/src/contracts/Channels/Calls.ts +2 -1
- package/src/contracts/Common/ZLinkMessageMetadata.ts +13 -8
- package/src/contracts/Handlers/Attributes.ts +14 -21
- package/src/contracts/Handlers/JsonContract.ts +8 -216
- package/src/contracts/Spots/Contracts.ts +2 -1
- package/src/nest-integration.ts +1 -0
- package/src/runtime/actors/actor-client.ts +40 -16
- package/src/runtime/actors/actor-handoff.ts +9 -4
- package/src/runtime/actors/actor-join-relocation.ts +1 -0
- package/src/runtime/actors/actor-local-native-join.ts +17 -26
- package/src/runtime/actors/actor-remote-wire.ts +17 -0
- package/src/runtime/actors/actor-routed-join-transport.ts +14 -4
- package/src/runtime/actors/actor-routed-json-request.ts +10 -2
- package/src/runtime/actors/index.ts +19 -5
- package/src/runtime/actors/spot-actor-dispatch.ts +4 -2
- package/src/runtime/admission.ts +18 -5
- package/src/runtime/application-jobs/application-ingress-record-owner.ts +41 -25
- package/src/runtime/application-jobs/application-job-queue-scope.ts +51 -22
- package/src/runtime/application-jobs/contracts.ts +14 -1
- package/src/runtime/backend/contracts/index.ts +53 -14
- package/src/runtime/backend/mesh-completion-table.ts +156 -57
- package/src/runtime/backend/mesh-dispatch-pump.ts +40 -10
- package/src/runtime/backend/node/node-backend-adapter-support.ts +17 -8
- package/src/runtime/backend/node/node-dealer-channel-client-transport.ts +12 -2
- package/src/runtime/backend/node/node-raw-binding-port.ts +57 -30
- package/src/runtime/backend/node/node-raw-mesh-backend.ts +128 -65
- package/src/runtime/backend/node/node-socket-backend-adapter.ts +21 -6
- package/src/runtime/backend/raw-binding-port.ts +7 -2
- package/src/runtime/backend/runtime-message.ts +6 -0
- package/src/runtime/backend/runtime-values.ts +1 -0
- package/src/runtime/channels/channel-clients.ts +90 -41
- package/src/runtime/channels/channel-dispatch-pipeline.ts +69 -34
- package/src/runtime/channels/channel-dispatch-services.ts +69 -1
- package/src/runtime/channels/channel-dispatchers.ts +29 -27
- package/src/runtime/channels/channel-envelope-inspection.ts +2 -16
- package/src/runtime/channels/channel-envelope.ts +133 -8
- package/src/runtime/channels/channel-outbound-operations.ts +22 -8
- package/src/runtime/channels/channel-runtime-manager.ts +29 -12
- package/src/runtime/channels/channel-transports.ts +128 -60
- package/src/runtime/channels/local-spot-route-transport.ts +3 -1
- package/src/runtime/channels/router-socket-spot-route-transport.ts +13 -4
- package/src/runtime/channels/source-spot-router.ts +8 -4
- package/src/runtime/channels/spot-node-route-transport.ts +8 -4
- package/src/runtime/channels/spot-route-bridge-transport.ts +6 -4
- package/src/runtime/channels/spot-route-dispatch-strategy.ts +47 -18
- package/src/runtime/execution/serial-execution-queue.ts +2 -0
- package/src/runtime/foundation/actor-join-recovery-codec.ts +2 -2
- package/src/runtime/foundation/durable-service-request.ts +137 -0
- package/src/runtime/foundation/operation-identity.ts +5 -1
- package/src/runtime/foundation/raw-service-mesh-runtime.ts +484 -293
- package/src/runtime/foundation/service-relocation-object-owner.ts +2 -0
- package/src/runtime/foundation/service-relocation-runtime.ts +18 -1
- package/src/runtime/foundation/service-runtime-contracts.ts +7 -1
- package/src/runtime/foundation/service-stateful-runtime.ts +67 -125
- package/src/runtime/foundation/service-stateful-wire-codec.ts +0 -5
- package/src/runtime/foundation/service-topology-registry.ts +91 -36
- package/src/runtime/foundation/service-wire-m6a-codec.ts +57 -38
- package/src/runtime/handlers/handler-instance-scope.ts +67 -16
- package/src/runtime/host/actor-runtime-options-factory.ts +13 -2
- package/src/runtime/host/application-job-queue.ts +175 -41
- package/src/runtime/host/entry-actor-runtime.ts +4 -0
- package/src/runtime/host/index.ts +201 -156
- package/src/runtime/host/remote-bound-session-relay.ts +2 -23
- package/src/runtime/host/route-mesh-runtime.ts +1 -1
- package/src/runtime/host/service-relocation-control.ts +11 -5
- package/src/runtime/host/service-relocation-host-runtime.ts +315 -291
- package/src/runtime/host/spot-address-transport.ts +4 -2
- package/src/runtime/host/spot-runtime-options-factory.ts +2 -0
- package/src/runtime/locations/actor-location-claims.ts +52 -30
- package/src/runtime/locations/lifecycle.ts +8 -26
- package/src/runtime/locations/runtime.ts +28 -24
- package/src/runtime/messaging/framework-json-v1.ts +5 -325
- package/src/runtime/messaging/packet-name.ts +5 -25
- package/src/runtime/messaging/request-result.ts +58 -0
- package/src/runtime/messaging/submission-result.ts +5 -1
- package/src/runtime/protocol/service_wire_codec.generated.ts +131 -1
- package/src/runtime/protocol/service_wire_pilot_codec.generated.ts +4 -4
- package/src/runtime/spots/formal-remote-actor-admission-registry.ts +43 -23
- package/src/runtime/spots/index.ts +14 -2
- package/src/runtime/spots/spot-activation.ts +28 -10
- package/src/runtime/spots/spot-entry-activation.ts +9 -2
- package/src/runtime/spots/spot-handler-registry.ts +41 -8
- package/src/runtime/spots/spot-node-autoconnect.ts +6 -2
- package/src/runtime/spots/spot-outbound.ts +36 -16
- package/src/runtime/spots/spot-routed-spot-packet-dispatch.ts +2 -1
- package/src/runtime/spots/spot-runtime-ports.ts +1 -0
- package/src/runtime/spots/spot-subscription-dispatch.ts +0 -3
- package/src/runtime/spots/spot-timer.ts +5 -1
- package/src/runtime/streams/stream-session-runtime.ts +12 -29
|
@@ -13,7 +13,22 @@ exports.REMOTE_ACTOR_JOIN_PACKET = exports.ZLINK_REMOTE_ACTOR_JOIN_PACKET;
|
|
|
13
13
|
exports.REMOTE_ACTOR_JOIN_ADMISSION = 'admission';
|
|
14
14
|
exports.REMOTE_ACTOR_JOIN_COMMIT = 'commit';
|
|
15
15
|
exports.REMOTE_ACTOR_JOIN_ABORT = 'abort';
|
|
16
|
+
const JSON_OBJECT_START = '{'.charCodeAt(0);
|
|
17
|
+
const JSON_SPACE = ' '.charCodeAt(0);
|
|
18
|
+
const JSON_TAB = '\t'.charCodeAt(0);
|
|
19
|
+
const JSON_LINE_FEED = '\n'.charCodeAt(0);
|
|
20
|
+
const JSON_CARRIAGE_RETURN = '\r'.charCodeAt(0);
|
|
16
21
|
function decodeRemoteActorSourceLeaveTerminal(payload) {
|
|
22
|
+
// A SourceLeave terminal is a JSON object. Binary channel frames and JSON
|
|
23
|
+
// primitives cannot be terminals, so do not materialize or parse them.
|
|
24
|
+
let offset = 0;
|
|
25
|
+
while (payload[offset] === JSON_SPACE ||
|
|
26
|
+
payload[offset] === JSON_TAB ||
|
|
27
|
+
payload[offset] === JSON_LINE_FEED ||
|
|
28
|
+
payload[offset] === JSON_CARRIAGE_RETURN)
|
|
29
|
+
offset++;
|
|
30
|
+
if (payload[offset] !== JSON_OBJECT_START)
|
|
31
|
+
return undefined;
|
|
17
32
|
let decoded;
|
|
18
33
|
try {
|
|
19
34
|
decoded = JSON.parse(payload.toString());
|
|
@@ -6,27 +6,31 @@ export interface ZLinkActorRoutedJoinTransport {
|
|
|
6
6
|
canRouteChannel?(routerChannelId: string): boolean;
|
|
7
7
|
canRoutePacketChannel?(routerChannelId: string): boolean;
|
|
8
8
|
request<TReply>(routerChannelId: string, targetNodeRid: string, packetName: string | undefined, request: unknown, timeoutMs: number | undefined, signal?: AbortSignal): Promise<TReply>;
|
|
9
|
-
submit?(routerChannelId: string, targetNodeRid: string, packetName: string | undefined, message: unknown): Promise<ZLinkSubmitResult>;
|
|
10
|
-
submitInfrastructure?(routerChannelId: string, targetNodeRid: string, packetName: string | undefined, message: unknown): Promise<ZLinkSubmitResult>;
|
|
9
|
+
submit?(routerChannelId: string, targetNodeRid: string, packetName: string | undefined, message: unknown): ZLinkSubmitResult | Promise<ZLinkSubmitResult>;
|
|
10
|
+
submitInfrastructure?(routerChannelId: string, targetNodeRid: string, packetName: string | undefined, message: unknown): ZLinkSubmitResult | Promise<ZLinkSubmitResult>;
|
|
11
11
|
sendToSpot(spotRouteTarget: ZLinkSpotRouteTarget, message: unknown, options: {
|
|
12
12
|
readonly packetName?: string;
|
|
13
13
|
}): Promise<ZLinkSubmitResult>;
|
|
14
14
|
requestRawToSpot?(spotRouteTarget: ZLinkSpotRouteTarget, request: Message, options: {
|
|
15
15
|
readonly timeoutMs?: number;
|
|
16
16
|
readonly signal?: AbortSignal;
|
|
17
|
+
readonly onAdmitted?: () => void;
|
|
17
18
|
}): Promise<readonly Message[]>;
|
|
18
19
|
requestToSpot<TReply = unknown>(spotRouteTarget: ZLinkSpotRouteTarget, request: unknown, options: {
|
|
19
20
|
readonly packetName?: string;
|
|
20
21
|
readonly timeoutMs?: number;
|
|
21
22
|
readonly signal?: AbortSignal;
|
|
23
|
+
readonly onAdmitted?: () => void;
|
|
22
24
|
}): Promise<TReply>;
|
|
23
25
|
requestFromSpotToSpot?<TReply = unknown>(sourceSpot: ZLinkBackendSpot, spotRouteTarget: ZLinkSpotRouteTarget, request: unknown, options: {
|
|
24
26
|
readonly packetName?: string;
|
|
25
27
|
readonly timeoutMs?: number;
|
|
26
28
|
readonly signal?: AbortSignal;
|
|
29
|
+
readonly onAdmitted?: () => void;
|
|
27
30
|
}): Promise<TReply>;
|
|
28
31
|
requestRawFromSpotToSpot?(sourceSpot: ZLinkBackendSpot, spotRouteTarget: ZLinkSpotRouteTarget, request: Message, options: {
|
|
29
32
|
readonly timeoutMs?: number;
|
|
30
33
|
readonly signal?: AbortSignal;
|
|
34
|
+
readonly onAdmitted?: () => void;
|
|
31
35
|
}): Promise<readonly Message[]>;
|
|
32
36
|
}
|
|
@@ -4,8 +4,10 @@ import type { ZLinkActorRoutedJoinTransport } from './actor-routed-join-transpor
|
|
|
4
4
|
export declare function tryRequestRoutedJson(transport: ZLinkActorRoutedJoinTransport, target: ZLinkSpotRouteTarget, payload: unknown, options: {
|
|
5
5
|
readonly timeoutMs?: number;
|
|
6
6
|
readonly signal?: AbortSignal;
|
|
7
|
+
readonly onAdmitted?: () => void;
|
|
7
8
|
}): Promise<boolean>;
|
|
8
9
|
export declare function requestRoutedJsonReply<T>(transport: ZLinkActorRoutedJoinTransport, target: ZLinkSpotRouteTarget, payload: unknown, options: {
|
|
9
10
|
readonly timeoutMs?: number;
|
|
10
11
|
readonly signal?: AbortSignal;
|
|
12
|
+
readonly onAdmitted?: () => void;
|
|
11
13
|
}, unavailableMessage: string, decode: (replyParts: readonly Message[]) => T): Promise<T>;
|
|
@@ -51,7 +51,8 @@ export declare class DefaultZLinkActorManager implements ZLinkActorManager {
|
|
|
51
51
|
publishRelocationActor(actorId: string): void;
|
|
52
52
|
abortRelocationActor(actorId: string): Promise<void>;
|
|
53
53
|
completeRelocationSource(actorId: string, sourceActorRef?: ZLinkBackendActorRef): Promise<void>;
|
|
54
|
-
|
|
54
|
+
releaseSpotActorMembers(meshName: string, spotId?: RoutingId): Promise<void>;
|
|
55
|
+
private releaseLocalActor;
|
|
55
56
|
completeCoreRelocationSource(actorId: string): Promise<void>;
|
|
56
57
|
private finalizeActorState;
|
|
57
58
|
private finalizeDestroyedActor;
|
|
@@ -118,7 +118,7 @@ class DefaultZLinkActorManager {
|
|
|
118
118
|
const actorRef = this.actorRefForState(state);
|
|
119
119
|
return {
|
|
120
120
|
spotId: spotId,
|
|
121
|
-
objectGeneration: state.
|
|
121
|
+
objectGeneration: state.spotGeneration ?? 0n,
|
|
122
122
|
meshName: this.actorMeshNames.get(actorId) ?? '',
|
|
123
123
|
nodeRid: actorRef.nodeRid
|
|
124
124
|
};
|
|
@@ -302,7 +302,7 @@ class DefaultZLinkActorManager {
|
|
|
302
302
|
}
|
|
303
303
|
state.setLocationGeneration(authorityOwnerGeneration);
|
|
304
304
|
if (spotId !== undefined)
|
|
305
|
-
state.setJoinedSpot(spotId, undefined, membershipEpoch);
|
|
305
|
+
state.setJoinedSpot(spotId, undefined, membershipEpoch, spotGeneration);
|
|
306
306
|
return actor;
|
|
307
307
|
}
|
|
308
308
|
catch (error) {
|
|
@@ -321,12 +321,24 @@ class DefaultZLinkActorManager {
|
|
|
321
321
|
this.relocationStaged.delete(actorId);
|
|
322
322
|
}
|
|
323
323
|
async abortRelocationActor(actorId) {
|
|
324
|
-
await this.
|
|
324
|
+
await this.releaseLocalActor(actorId);
|
|
325
325
|
}
|
|
326
326
|
async completeRelocationSource(actorId, sourceActorRef) {
|
|
327
|
-
await this.
|
|
328
|
-
}
|
|
329
|
-
async
|
|
327
|
+
await this.releaseLocalActor(actorId, sourceActorRef);
|
|
328
|
+
}
|
|
329
|
+
async releaseSpotActorMembers(meshName, spotId) {
|
|
330
|
+
const results = await Promise.allSettled([...this.states.values()]
|
|
331
|
+
.filter((state) => state.meshName === meshName && state.spotId === spotId)
|
|
332
|
+
.map((state) => this.releaseLocalActor(state.actorId)));
|
|
333
|
+
const errors = results
|
|
334
|
+
.filter((result) => result.status === 'rejected')
|
|
335
|
+
.map((result) => result.reason);
|
|
336
|
+
if (errors.length === 1)
|
|
337
|
+
throw errors[0];
|
|
338
|
+
if (errors.length > 1)
|
|
339
|
+
throw new AggregateError(errors, 'Actor member cleanup failed.');
|
|
340
|
+
}
|
|
341
|
+
async releaseLocalActor(actorId, exactNativeActorRef) {
|
|
330
342
|
const state = this.states.get(actorId);
|
|
331
343
|
const node = this.options.nativeActorNodeProvider?.() ?? this.options.nativeActorNode;
|
|
332
344
|
const nativeActorRef = exactNativeActorRef ?? state?.nativeActorRef;
|
|
@@ -21,7 +21,7 @@ class ZLinkSpotActorHandlerRegistryRuntime {
|
|
|
21
21
|
const metadata = (0, Attributes_1.readZLinkDecoratorMetadata)(handlerType).find((entry) => entry.kind === 'spotActorSend' || entry.kind === 'spotActorRequest');
|
|
22
22
|
const resolvedPacketName = packetName ?? metadata?.packetName;
|
|
23
23
|
if (metadata === undefined || resolvedPacketName === undefined) {
|
|
24
|
-
throw
|
|
24
|
+
throw (0, framework_errors_internal_1.createInternalFrameworkException)(framework_errors_internal_1.ZLinkFrameworkInternalErrorKind.InvalidOperation, `Actor packet handler '${handlerType.name}' must declare a packet name.`);
|
|
25
25
|
}
|
|
26
26
|
return this.addPacket({
|
|
27
27
|
kind: metadata.kind === 'spotActorSend'
|
|
@@ -36,7 +36,7 @@ class ZLinkSpotActorHandlerRegistryRuntime {
|
|
|
36
36
|
addPacket(descriptor) {
|
|
37
37
|
const key = packetKey(descriptor.kind, descriptor.actorType, descriptor.packetName);
|
|
38
38
|
if (this.packets.has(key)) {
|
|
39
|
-
throw
|
|
39
|
+
throw (0, framework_errors_internal_1.createInternalFrameworkException)(framework_errors_internal_1.ZLinkFrameworkInternalErrorKind.InvalidOperation, `Actor packet '${descriptor.packetName}' for '${descriptor.actorType.name}' is already registered.`);
|
|
40
40
|
}
|
|
41
41
|
const metadata = (0, Attributes_1.readZLinkDecoratorMetadata)(descriptor.handlerType).find((entry) => entry.kind ===
|
|
42
42
|
(descriptor.kind === ZLinkActorPacketKind.Send ? 'spotActorSend' : 'spotActorRequest') &&
|
|
@@ -16,7 +16,7 @@ export declare class ZLinkRuntimeAdmissionGate {
|
|
|
16
16
|
seal(meshName: string, reason?: ZLinkFrameworkInternalErrorKind): void;
|
|
17
17
|
close(): void;
|
|
18
18
|
claim(meshName: string, operation: string): ZLinkApplicationWorkClaim;
|
|
19
|
-
run<T>(meshName: string, operation: string, work: () => Promise<T>): Promise<T>;
|
|
19
|
+
run<T>(meshName: string, operation: string, work: () => T | Promise<T>): Promise<T>;
|
|
20
20
|
awaitZero(meshName: string, signal?: AbortSignal): Promise<void>;
|
|
21
21
|
requireRequest(operation: string, meshName?: string): void;
|
|
22
22
|
requireActorCreate(actorId: string, meshName?: string): void;
|
|
@@ -77,13 +77,23 @@ class ZLinkRuntimeAdmissionGate {
|
|
|
77
77
|
}
|
|
78
78
|
throw (0, framework_errors_internal_1.createInternalFrameworkException)(state.sealedReason, `${operation} was rejected because framework admission is closed.`);
|
|
79
79
|
}
|
|
80
|
-
|
|
81
|
-
|
|
80
|
+
run(meshName, operation, work) {
|
|
81
|
+
let claim;
|
|
82
82
|
try {
|
|
83
|
-
|
|
83
|
+
claim = this.claim(meshName, operation);
|
|
84
|
+
const result = work();
|
|
85
|
+
const close = claim.close;
|
|
86
|
+
return Promise.resolve(result).then((value) => {
|
|
87
|
+
close();
|
|
88
|
+
return value;
|
|
89
|
+
}, (error) => {
|
|
90
|
+
close();
|
|
91
|
+
throw error;
|
|
92
|
+
});
|
|
84
93
|
}
|
|
85
|
-
|
|
86
|
-
claim
|
|
94
|
+
catch (error) {
|
|
95
|
+
claim?.close();
|
|
96
|
+
return Promise.reject(error);
|
|
87
97
|
}
|
|
88
98
|
}
|
|
89
99
|
awaitZero(meshName, signal) {
|
|
@@ -10,33 +10,31 @@ export interface IngressRecordPort {
|
|
|
10
10
|
*/
|
|
11
11
|
export declare class ApplicationIngressRecordOwner {
|
|
12
12
|
private readonly shared;
|
|
13
|
-
private
|
|
13
|
+
private stop?;
|
|
14
14
|
private closed;
|
|
15
15
|
private constructor();
|
|
16
16
|
static create(queue: ApplicationJobQueuePort, initialPermit: ApplicationJobPermitPort, record: IngressRecordPort): ApplicationIngressRecordOwner;
|
|
17
17
|
retain(): ApplicationIngressRecordOwner;
|
|
18
18
|
takeInitial(domain: ApplicationJobRecordDomain): ApplicationJobRecordLease;
|
|
19
|
-
acquire(domain: ApplicationJobRecordDomain, signal?: AbortSignal): Promise<ApplicationJobRecordLease>;
|
|
19
|
+
acquire(domain: ApplicationJobRecordDomain, signal?: AbortSignal): ApplicationJobRecordLease | Promise<ApplicationJobRecordLease>;
|
|
20
|
+
private acquireAdditional;
|
|
20
21
|
close(): void;
|
|
21
22
|
private requireOpen;
|
|
22
23
|
}
|
|
23
24
|
/** Queue-permit child of one shared raw ingress record. */
|
|
24
25
|
export declare class ApplicationJobRecordLease implements ApplicationJobPermitPort {
|
|
25
26
|
private readonly shared;
|
|
26
|
-
private
|
|
27
|
+
private permit;
|
|
27
28
|
private ingressClosed;
|
|
28
|
-
private permitReleased;
|
|
29
29
|
private processingTerminal;
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
constructor(shared: SharedIngressRecordState, permit: ApplicationJobPermitPort);
|
|
30
|
+
detachedForHandlerTurn: boolean;
|
|
31
|
+
constructor(shared: SharedIngressRecordState, permit: ApplicationJobPermitPort | undefined);
|
|
33
32
|
get origin(): ApplicationJobOrigin;
|
|
34
33
|
markApplicationQueued(): void;
|
|
35
34
|
detachForHandlerTurn(): void;
|
|
36
35
|
releaseBeforeHandler(): void;
|
|
37
36
|
releaseAfterInternalProcessing(): void;
|
|
38
37
|
close(): void;
|
|
39
|
-
private releasePermit;
|
|
40
38
|
private releaseJobIfTerminal;
|
|
41
39
|
}
|
|
42
40
|
declare class SharedIngressRecordState {
|
|
@@ -8,7 +8,7 @@ exports.ApplicationJobRecordLease = exports.ApplicationIngressRecordOwner = void
|
|
|
8
8
|
*/
|
|
9
9
|
class ApplicationIngressRecordOwner {
|
|
10
10
|
shared;
|
|
11
|
-
stop
|
|
11
|
+
stop;
|
|
12
12
|
closed = false;
|
|
13
13
|
constructor(shared) {
|
|
14
14
|
this.shared = shared;
|
|
@@ -29,13 +29,30 @@ class ApplicationIngressRecordOwner {
|
|
|
29
29
|
}
|
|
30
30
|
return job;
|
|
31
31
|
}
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
32
|
+
acquire(domain, signal) {
|
|
33
|
+
try {
|
|
34
|
+
this.requireOpen();
|
|
35
|
+
const initial = this.shared.takeInitialPermit(domain);
|
|
36
|
+
if (initial !== undefined)
|
|
37
|
+
return initial;
|
|
38
|
+
}
|
|
39
|
+
catch (error) {
|
|
40
|
+
return Promise.reject(error);
|
|
41
|
+
}
|
|
42
|
+
return this.acquireAdditional(domain, signal);
|
|
43
|
+
}
|
|
44
|
+
async acquireAdditional(domain, signal) {
|
|
45
|
+
const stop = (this.stop ??= new AbortController());
|
|
46
|
+
const waitSignal = signal === undefined ? stop.signal : AbortSignal.any([stop.signal, signal]);
|
|
47
|
+
let permit;
|
|
48
|
+
try {
|
|
49
|
+
permit = await this.shared.acquirePermit(waitSignal);
|
|
50
|
+
}
|
|
51
|
+
catch (error) {
|
|
52
|
+
if (error === ownerClosedError)
|
|
53
|
+
throw ownerClosedError();
|
|
54
|
+
throw error;
|
|
55
|
+
}
|
|
39
56
|
if (this.closed) {
|
|
40
57
|
permit.releaseAfterInternalProcessing();
|
|
41
58
|
throw ownerClosedError();
|
|
@@ -46,7 +63,8 @@ class ApplicationIngressRecordOwner {
|
|
|
46
63
|
if (this.closed)
|
|
47
64
|
return;
|
|
48
65
|
this.closed = true;
|
|
49
|
-
this.
|
|
66
|
+
// The queue forwards this reason; only a rejected acquisition constructs the error.
|
|
67
|
+
this.stop?.abort(ownerClosedError);
|
|
50
68
|
this.shared.releaseOwner();
|
|
51
69
|
}
|
|
52
70
|
requireOpen() {
|
|
@@ -60,10 +78,8 @@ class ApplicationJobRecordLease {
|
|
|
60
78
|
shared;
|
|
61
79
|
permit;
|
|
62
80
|
ingressClosed = false;
|
|
63
|
-
permitReleased = false;
|
|
64
81
|
processingTerminal = false;
|
|
65
82
|
detachedForHandlerTurn = false;
|
|
66
|
-
jobReleased = false;
|
|
67
83
|
constructor(shared, permit) {
|
|
68
84
|
this.shared = shared;
|
|
69
85
|
this.permit = permit;
|
|
@@ -79,11 +95,11 @@ class ApplicationJobRecordLease {
|
|
|
79
95
|
this.detachedForHandlerTurn = true;
|
|
80
96
|
}
|
|
81
97
|
releaseBeforeHandler() {
|
|
82
|
-
this.
|
|
98
|
+
this.permit?.releaseBeforeHandler();
|
|
83
99
|
}
|
|
84
100
|
releaseAfterInternalProcessing() {
|
|
85
101
|
this.processingTerminal = true;
|
|
86
|
-
this.
|
|
102
|
+
this.permit?.releaseAfterInternalProcessing();
|
|
87
103
|
this.releaseJobIfTerminal();
|
|
88
104
|
}
|
|
89
105
|
close() {
|
|
@@ -96,17 +112,17 @@ class ApplicationJobRecordLease {
|
|
|
96
112
|
}
|
|
97
113
|
this.releaseJobIfTerminal();
|
|
98
114
|
}
|
|
99
|
-
releasePermit(release) {
|
|
100
|
-
if (this.permitReleased)
|
|
101
|
-
return;
|
|
102
|
-
this.permitReleased = true;
|
|
103
|
-
release();
|
|
104
|
-
}
|
|
105
115
|
releaseJobIfTerminal() {
|
|
106
|
-
|
|
116
|
+
const permit = this.permit;
|
|
117
|
+
if (permit === undefined || !this.ingressClosed || !this.processingTerminal)
|
|
107
118
|
return;
|
|
108
|
-
this.
|
|
109
|
-
|
|
119
|
+
this.permit = undefined;
|
|
120
|
+
try {
|
|
121
|
+
this.shared.releaseJob();
|
|
122
|
+
}
|
|
123
|
+
finally {
|
|
124
|
+
permit.releaseStorage?.();
|
|
125
|
+
}
|
|
110
126
|
}
|
|
111
127
|
}
|
|
112
128
|
exports.ApplicationJobRecordLease = ApplicationJobRecordLease;
|
|
@@ -174,6 +190,7 @@ class SharedIngressRecordState {
|
|
|
174
190
|
this.initialPermit?.releaseAfterInternalProcessing();
|
|
175
191
|
}
|
|
176
192
|
finally {
|
|
193
|
+
this.initialPermit?.releaseStorage?.();
|
|
177
194
|
this.initialPermit = undefined;
|
|
178
195
|
this.record.close();
|
|
179
196
|
}
|
|
@@ -3,7 +3,8 @@ import type { ApplicationJobOrigin, ApplicationJobPermitPort } from './contracts
|
|
|
3
3
|
* Carries the host-owned queue permit through internal async dispatch without
|
|
4
4
|
* leaking capacity ownership into public handler contracts.
|
|
5
5
|
*/
|
|
6
|
-
export declare function runWithApplicationJobPermit<TResult>(permit: ApplicationJobPermitPort, callback: () => Promise<TResult>
|
|
6
|
+
export declare function runWithApplicationJobPermit<TResult>(permit: ApplicationJobPermitPort, callback: () => Promise<TResult>): Promise<TResult>;
|
|
7
|
+
export declare function runWithApplicationJobPermit<TResult, TFirst = undefined, TSecond = undefined>(permit: ApplicationJobPermitPort, callback: (first: TFirst, second: TSecond) => Promise<TResult> | TResult, first?: TFirst, second?: TSecond): TResult | Promise<TResult>;
|
|
7
8
|
/** Releases the current job permit immediately before the first user callback. */
|
|
8
9
|
export declare function releaseApplicationJobPermitBeforeHandler(): void;
|
|
9
10
|
/** True while dispatch already owns the host-wide application job permit. */
|
|
@@ -9,29 +9,45 @@ exports.bindApplicationJobPermit = bindApplicationJobPermit;
|
|
|
9
9
|
exports.detachApplicationJobPermit = detachApplicationJobPermit;
|
|
10
10
|
const node_async_hooks_1 = require("node:async_hooks");
|
|
11
11
|
const applicationJobPermitScope = new node_async_hooks_1.AsyncLocalStorage();
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
12
|
+
function releasePermitTurn() {
|
|
13
|
+
const permit = applicationJobPermitScope.getStore();
|
|
14
|
+
if (permit !== undefined && !permit.detachedForHandlerTurn)
|
|
15
|
+
permit.releaseAfterInternalProcessing();
|
|
16
|
+
}
|
|
17
|
+
function releasePermitSuccess(value) {
|
|
18
|
+
releasePermitTurn();
|
|
19
|
+
return value;
|
|
20
|
+
}
|
|
21
|
+
function releasePermitFailure(error) {
|
|
22
|
+
releasePermitTurn();
|
|
23
|
+
throw error;
|
|
24
|
+
}
|
|
25
|
+
function runWithApplicationJobPermit(permit, callback, first, second) {
|
|
26
|
+
const previous = applicationJobPermitScope.getStore();
|
|
27
|
+
applicationJobPermitScope.enterWith(permit);
|
|
28
|
+
try {
|
|
29
|
+
const result = callback(first, second);
|
|
30
|
+
if (result !== null && (typeof result === 'object' || typeof result === 'function')) {
|
|
31
|
+
return Promise.resolve(result).then(releasePermitSuccess, releasePermitFailure);
|
|
25
32
|
}
|
|
26
|
-
|
|
33
|
+
releasePermitTurn();
|
|
34
|
+
return result;
|
|
35
|
+
}
|
|
36
|
+
catch (error) {
|
|
37
|
+
releasePermitTurn();
|
|
38
|
+
return Promise.reject(error);
|
|
39
|
+
}
|
|
40
|
+
finally {
|
|
41
|
+
applicationJobPermitScope.enterWith(previous);
|
|
42
|
+
}
|
|
27
43
|
}
|
|
28
44
|
/** Releases the current job permit immediately before the first user callback. */
|
|
29
45
|
function releaseApplicationJobPermitBeforeHandler() {
|
|
30
|
-
applicationJobPermitScope.getStore()?.
|
|
46
|
+
applicationJobPermitScope.getStore()?.releaseBeforeHandler();
|
|
31
47
|
}
|
|
32
48
|
/** @internal Returns an ingress permit after a durable queue takes record ownership. */
|
|
33
49
|
function releaseApplicationJobPermitForDurableHandoff() {
|
|
34
|
-
applicationJobPermitScope.getStore()?.
|
|
50
|
+
applicationJobPermitScope.getStore()?.releaseAfterInternalProcessing();
|
|
35
51
|
}
|
|
36
52
|
/** True while dispatch already owns the host-wide application job permit. */
|
|
37
53
|
function hasApplicationJobPermit() {
|
|
@@ -39,7 +55,7 @@ function hasApplicationJobPermit() {
|
|
|
39
55
|
}
|
|
40
56
|
/** Keeps the ingress origin when a durable record later reacquires its permit. */
|
|
41
57
|
function currentApplicationJobOrigin() {
|
|
42
|
-
return applicationJobPermitScope.getStore().
|
|
58
|
+
return applicationJobPermitScope.getStore().origin;
|
|
43
59
|
}
|
|
44
60
|
/** Re-enters the captured permit scope when a serial executor runs later. */
|
|
45
61
|
function bindApplicationJobPermit(callback) {
|
|
@@ -53,10 +69,9 @@ function bindApplicationJobPermit(callback) {
|
|
|
53
69
|
* detached owner must release it at handler entry or at a pre-start terminal.
|
|
54
70
|
*/
|
|
55
71
|
function detachApplicationJobPermit() {
|
|
56
|
-
const
|
|
57
|
-
if (
|
|
72
|
+
const permit = applicationJobPermitScope.getStore();
|
|
73
|
+
if (permit === undefined)
|
|
58
74
|
return undefined;
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
return scope.permit;
|
|
75
|
+
permit.detachForHandlerTurn();
|
|
76
|
+
return permit;
|
|
62
77
|
}
|
|
@@ -1,13 +1,22 @@
|
|
|
1
1
|
export type ApplicationJobOrigin = 'local' | 'remote';
|
|
2
2
|
export interface ApplicationJobPermitPort {
|
|
3
3
|
readonly origin: ApplicationJobOrigin;
|
|
4
|
+
readonly detachedForHandlerTurn: boolean;
|
|
4
5
|
markApplicationQueued(): void;
|
|
5
6
|
/** Transfers ingress-record cleanup to a detached exact-target handler turn. */
|
|
6
|
-
detachForHandlerTurn
|
|
7
|
+
detachForHandlerTurn(): void;
|
|
7
8
|
releaseBeforeHandler(): void;
|
|
8
9
|
releaseAfterInternalProcessing(): void;
|
|
10
|
+
/** Returns reusable reservation storage only after its ingress lifetime ends. */
|
|
11
|
+
releaseStorage?(): void;
|
|
12
|
+
}
|
|
13
|
+
export interface ApplicationJobReceiveRotationPort {
|
|
14
|
+
reserve(): void;
|
|
15
|
+
take(): ApplicationJobPermitPort | undefined;
|
|
16
|
+
releaseUnused(): void;
|
|
9
17
|
}
|
|
10
18
|
export interface ApplicationJobQueuePort {
|
|
19
|
+
createReceiveRotation(capacity: number, origin: ApplicationJobOrigin): ApplicationJobReceiveRotationPort;
|
|
11
20
|
acquire(signal: AbortSignal | undefined, origin: ApplicationJobOrigin): Promise<ApplicationJobPermitPort>;
|
|
12
21
|
/** Returns a grant now, or registers one FIFO waiter that later calls resume. */
|
|
13
22
|
acquireOrResume(resume: (permit: ApplicationJobPermitPort) => void, reject: (reason: unknown) => void, signal: AbortSignal | undefined, origin: ApplicationJobOrigin): ApplicationJobPermitPort | undefined;
|
|
@@ -33,6 +33,7 @@ export type ZLinkBackendObjectPlacement = {
|
|
|
33
33
|
readonly kind: 'unavailable';
|
|
34
34
|
};
|
|
35
35
|
export interface ZLinkBackendMeshNode {
|
|
36
|
+
readonly routingId?: RoutingId;
|
|
36
37
|
completeClosedInstance?(spotId: string, objectGeneration: bigint): void;
|
|
37
38
|
setDispatchErrorReporter?(reporter: import('../../channels/dispatch-error-reporter').ZLinkDispatchErrorReporter, meshName: string): void;
|
|
38
39
|
setRoutingId(routingId: unknown): void;
|
|
@@ -68,9 +69,9 @@ export interface ZLinkBackendMeshNode {
|
|
|
68
69
|
selectObjectPlacement(stableType: string): ZLinkBackendObjectPlacement;
|
|
69
70
|
instanceSpotPlacementTypes?(): readonly string[];
|
|
70
71
|
sendToMissingInstanceSpot(target: ServiceInstanceColdActivationTarget, parts: ZLinkBackendMessageLike | readonly ZLinkBackendMessageLike[], deadlineUnixMs: bigint, sourceSpotId?: string, metadata?: ReadonlyMap<string, string>): Promise<SubmitResult>;
|
|
71
|
-
requestToMissingInstanceSpot(target: ServiceInstanceColdActivationTarget, parts: ZLinkBackendMessageLike | readonly ZLinkBackendMessageLike[], deadlineUnixMs: bigint, sourceSpotId?: string, metadata?: ReadonlyMap<string, string
|
|
72
|
+
requestToMissingInstanceSpot(target: ServiceInstanceColdActivationTarget, parts: ZLinkBackendMessageLike | readonly ZLinkBackendMessageLike[], deadlineUnixMs: bigint, sourceSpotId?: string, metadata?: ReadonlyMap<string, string>, onAdmitted?: () => void): MeshOperationId;
|
|
72
73
|
sendToInstanceSpot(route: ServiceInstanceRouteFence, parts: MessageLike | readonly MessageLike[], sourceSpotId?: string, metadata?: ReadonlyMap<string, string>, instanceIntent?: boolean): Promise<SubmitResult>;
|
|
73
|
-
requestInstanceSpot(route: ServiceInstanceRouteFence, parts: MessageLike | readonly MessageLike[], timeoutMs?: number, sourceSpotId?: string, metadata?: ReadonlyMap<string, string>, instanceIntent?: boolean): MeshOperationId;
|
|
74
|
+
requestInstanceSpot(route: ServiceInstanceRouteFence, parts: MessageLike | readonly MessageLike[], timeoutMs?: number, sourceSpotId?: string, metadata?: ReadonlyMap<string, string>, instanceIntent?: boolean, onAdmitted?: () => void): MeshOperationId;
|
|
74
75
|
registerUserSpotOperationHandler(handler: ServiceUserSpotOperationHandler): void;
|
|
75
76
|
requestUserSpotCreate(targetNodeRid: string, request: Omit<ServiceUserSpotCreateRecord, 'kind' | 'correlation' | 'operation'>, timeoutMs: number): Promise<ServiceUserSpotOperationResult>;
|
|
76
77
|
requestUserSpotClose(targetNodeRid: string, request: Omit<ServiceUserSpotCloseRecord, 'kind' | 'correlation' | 'operation'>, timeoutMs: number): Promise<ServiceUserSpotOperationResult>;
|
|
@@ -97,10 +98,12 @@ export interface ZLinkBackendMeshNode {
|
|
|
97
98
|
readonly lifecycleGeneration: bigint;
|
|
98
99
|
}): void;
|
|
99
100
|
isObjectClientNodeDirectTarget?(targetRid: unknown): boolean;
|
|
101
|
+
observePeerRoute?(targetRid: unknown): import('../../foundation/durable-service-request').PeerRouteObservation;
|
|
102
|
+
hasPeerRouteOrConnectionIntent?(targetRid: unknown, endpoint: string): boolean;
|
|
100
103
|
isPeerRouteReady?(targetRid: unknown, lifecycleGeneration?: bigint): boolean;
|
|
101
104
|
sendToNode(targetRid: unknown, parts: MessageLike | readonly MessageLike[], options?: {
|
|
102
105
|
flags?: number;
|
|
103
|
-
}): Promise<SubmitResult>;
|
|
106
|
+
}): SubmitResult | Promise<SubmitResult>;
|
|
104
107
|
/**
|
|
105
108
|
* Sends service-wire infrastructure frames directly to a peer. Relocation
|
|
106
109
|
* Prepare may add NODE-INTERNAL sideband frames after its canonical frame.
|
|
@@ -114,11 +117,14 @@ export interface ZLinkBackendMeshNode {
|
|
|
114
117
|
*/
|
|
115
118
|
requestInfrastructureControlFrames?(targetRid: unknown, frames: readonly Uint8Array[], options?: {
|
|
116
119
|
readonly timeoutMs?: number;
|
|
120
|
+
readonly signal?: AbortSignal;
|
|
121
|
+
readonly onSubmitted?: (signal: AbortSignal) => Promise<void>;
|
|
117
122
|
}): Promise<readonly Uint8Array[]>;
|
|
118
123
|
requestToNode(targetRid: unknown, parts: MessageLike | readonly MessageLike[], options?: {
|
|
119
124
|
flags?: number;
|
|
120
125
|
timeoutMs?: number;
|
|
121
126
|
applicationMetadata?: Buffer;
|
|
127
|
+
onAdmitted?: () => void;
|
|
122
128
|
}): MeshOperationId;
|
|
123
129
|
sendToChannel(channelName: string, parts: MessageLike | readonly MessageLike[], options?: {
|
|
124
130
|
flags?: number;
|
|
@@ -127,6 +133,7 @@ export interface ZLinkBackendMeshNode {
|
|
|
127
133
|
flags?: number;
|
|
128
134
|
timeoutMs?: number;
|
|
129
135
|
applicationMetadata?: Buffer;
|
|
136
|
+
onAdmitted?: () => void;
|
|
130
137
|
}): MeshOperationId;
|
|
131
138
|
status(): MeshNodeStatus;
|
|
132
139
|
peers(): MeshPeerEntry[];
|
|
@@ -191,6 +198,7 @@ export interface ZLinkBackendMeshNode {
|
|
|
191
198
|
flags?: number;
|
|
192
199
|
timeoutMs?: number;
|
|
193
200
|
applicationMetadata?: Buffer;
|
|
201
|
+
onAdmitted?: () => void;
|
|
194
202
|
}): MeshOperationId;
|
|
195
203
|
actorSendToActor(source: ZLinkBackendActorRef, target: ZLinkBackendActorRef, parts: MessageLike | readonly MessageLike[], options?: {
|
|
196
204
|
flags?: number;
|
|
@@ -199,6 +207,7 @@ export interface ZLinkBackendMeshNode {
|
|
|
199
207
|
flags?: number;
|
|
200
208
|
timeoutMs?: number;
|
|
201
209
|
applicationMetadata?: Buffer;
|
|
210
|
+
onAdmitted?: () => void;
|
|
202
211
|
}): MeshOperationId;
|
|
203
212
|
sendActorBoundSession(actor: ZLinkBackendActorRef, expectedBindingGeneration: bigint, parts: MessageLike | readonly MessageLike[], flags?: number): Promise<SubmitResult>;
|
|
204
213
|
closeActorBoundSession(actor: ZLinkBackendActorRef, expectedBindingGeneration: bigint, timeoutMs?: number): MeshOperationId;
|
|
@@ -283,7 +292,7 @@ export interface ZLinkBackendDealerSocket extends ZLinkBackendConnectableSocket
|
|
|
283
292
|
receiveTimeoutMs: number;
|
|
284
293
|
maxMessageSize: number;
|
|
285
294
|
send(message: Message | readonly Message[]): Promise<void>;
|
|
286
|
-
request(message: Message | readonly Message[], timeoutMs?: number): Promise<readonly Message[]>;
|
|
295
|
+
request(message: Message | readonly Message[], timeoutMs?: number, onAdmitted?: () => void): Promise<readonly Message[]>;
|
|
287
296
|
recv(flags?: ZLinkBackendRecvFlags): Received | undefined;
|
|
288
297
|
}
|
|
289
298
|
export interface ZLinkBackendReplyOperation {
|
|
@@ -297,7 +306,7 @@ export interface ZLinkBackendSendOperation {
|
|
|
297
306
|
export interface ZLinkBackendRequestOperation {
|
|
298
307
|
message(message: MessageLike): ZLinkBackendRequestOperation;
|
|
299
308
|
timeout(timeoutMs: number): ZLinkBackendRequestOperation;
|
|
300
|
-
submit(): Promise<readonly Message[]>;
|
|
309
|
+
submit(onAdmitted?: () => void): Promise<readonly Message[]>;
|
|
301
310
|
}
|
|
302
311
|
export interface ZLinkBackendRouterSocket extends ZLinkBackendConnectableSocket {
|
|
303
312
|
setReceiveFlowState(state: ReceiveFlowState): void;
|
|
@@ -311,9 +320,9 @@ export interface ZLinkBackendRouterSocket extends ZLinkBackendConnectableSocket
|
|
|
311
320
|
setRoutingId(routingId: RoutingId): void;
|
|
312
321
|
recv(flags?: ZLinkBackendRecvFlags): Received | undefined;
|
|
313
322
|
send(routingId: RoutingId, message: Message | readonly Message[]): Promise<void>;
|
|
314
|
-
request(routingId: RoutingId, message: Message | readonly Message[], timeoutMs?: number): Promise<readonly Message[]>;
|
|
323
|
+
request(routingId: RoutingId, message: Message | readonly Message[], timeoutMs?: number, onAdmitted?: () => void): Promise<readonly Message[]>;
|
|
315
324
|
sendToSpot(targetNodeRid: RoutingId, targetSpotId: RoutingId, parts: readonly Message[], flags?: ZLinkBackendSendFlags): Promise<void>;
|
|
316
|
-
requestToSpot(targetNodeRid: RoutingId, targetSpotId: RoutingId, parts: readonly Message[], timeoutMs?: number): Promise<readonly Message[]>;
|
|
325
|
+
requestToSpot(targetNodeRid: RoutingId, targetSpotId: RoutingId, parts: readonly Message[], timeoutMs?: number, onAdmitted?: () => void): Promise<readonly Message[]>;
|
|
317
326
|
disconnectPeer(routingId: RoutingId): void;
|
|
318
327
|
reply(routingId: RoutingId, replyToken: unknown): ZLinkBackendReplyOperation;
|
|
319
328
|
reply(routingId: RoutingId, replyToken: unknown, message: Message | readonly Message[]): void;
|
|
@@ -413,11 +422,11 @@ export interface ZLinkBackendSpot extends ZLinkBackendObject {
|
|
|
413
422
|
drainReply(): number;
|
|
414
423
|
drainChannelReply(subjectHandle: bigint): number;
|
|
415
424
|
setDispatchHandler(handler: (info: ZLinkBackendSpotDispatchInfo) => void): void;
|
|
416
|
-
requestToChannel(channelName: string, payload: Message | readonly Message[], timeoutMs?: number): Promise<readonly Message[]>;
|
|
425
|
+
requestToChannel(channelName: string, payload: Message | readonly Message[], timeoutMs?: number, onAdmitted?: () => void): Promise<readonly Message[]>;
|
|
417
426
|
sendToChannel(channelName: string, payload: Message | readonly Message[]): Promise<void>;
|
|
418
427
|
publish(topic: string, payload: Message | readonly Message[], flags: ZLinkBackendSendFlags): boolean;
|
|
419
428
|
sendToSpot(targetRid: RoutingId, spotId: RoutingId, payload: Message | readonly Message[]): Promise<void>;
|
|
420
|
-
requestToSpot(targetRid: RoutingId, spotId: RoutingId, payload: Message | readonly Message[], timeoutMs?: number): Promise<readonly Message[]>;
|
|
429
|
+
requestToSpot(targetRid: RoutingId, spotId: RoutingId, payload: Message | readonly Message[], timeoutMs?: number, onAdmitted?: () => void): Promise<readonly Message[]>;
|
|
421
430
|
dispose(): Promise<void>;
|
|
422
431
|
}
|
|
423
432
|
export interface ZLinkChannelBackendAdapter {
|
|
@@ -16,9 +16,17 @@ export type ZLinkMeshCompletionTerminal = Pick<ReceiveRecord, 'operationId' | 't
|
|
|
16
16
|
export type ZLinkMeshCompletionHandler = (terminal: ZLinkMeshCompletionTerminal, materialize: () => ReceiveRecord) => void;
|
|
17
17
|
export declare class ZLinkMeshCompletionTable {
|
|
18
18
|
private readonly onDiagnostic?;
|
|
19
|
-
private
|
|
19
|
+
private buckets;
|
|
20
|
+
private readonly slots;
|
|
21
|
+
private free;
|
|
22
|
+
private activeCount;
|
|
20
23
|
private disposed;
|
|
21
24
|
constructor(onDiagnostic?: ((diagnostic: ZLinkMeshCompletionDiagnostic) => void) | undefined);
|
|
25
|
+
private prepareSlots;
|
|
26
|
+
private bucket;
|
|
27
|
+
private indexSlot;
|
|
28
|
+
private findSlot;
|
|
29
|
+
private releaseSlot;
|
|
22
30
|
/**
|
|
23
31
|
* Reserves the dispatcher slot before transport submission. The backend
|
|
24
32
|
* observes native terminals through Promises, so identity binding finishes
|