@zlink-systems/framework 0.29.1 → 0.30.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/.tsbuildinfo +1 -1
- package/dist/contracts/Configuration/Builders.d.ts +1 -2
- package/dist/contracts/Configuration/Configs.d.ts +0 -5
- package/dist/contracts/Configuration/RegistrationBuilders.js +6 -4
- package/dist/contracts/Configuration/RegistrationTypes.d.ts +1 -6
- package/dist/contracts/Configuration/RegistrationValidators.js +4 -4
- package/dist/contracts/Configuration/index.d.ts +1 -1
- package/dist/internal.d.ts +1 -0
- package/dist/internal.js +3 -1
- package/dist/runtime/actors/actor-handoff.d.ts +3 -2
- package/dist/runtime/actors/actor-handoff.js +9 -4
- package/dist/runtime/application-jobs/application-ingress-record-owner.d.ts +3 -1
- package/dist/runtime/application-jobs/application-ingress-record-owner.js +6 -1
- package/dist/runtime/application-jobs/application-job-queue-scope.d.ts +3 -1
- package/dist/runtime/application-jobs/application-job-queue-scope.js +5 -0
- package/dist/runtime/application-jobs/contracts.d.ts +5 -1
- package/dist/runtime/backend/contracts/index.d.ts +10 -19
- package/dist/runtime/backend/mesh-completion-table.d.ts +6 -4
- package/dist/runtime/backend/mesh-completion-table.js +28 -18
- package/dist/runtime/backend/mesh-dispatch-pump.js +21 -25
- package/dist/runtime/backend/node/node-backend-adapter-factory.js +6 -1
- package/dist/runtime/backend/node/node-backend-adapter-support.d.ts +3 -3
- package/dist/runtime/backend/node/node-backend-adapter-support.js +24 -29
- package/dist/runtime/backend/node/node-mesh-backend-adapter.d.ts +1 -9
- package/dist/runtime/backend/node/node-mesh-backend-adapter.js +1 -1
- package/dist/runtime/backend/node/node-raw-binding-port.js +11 -6
- package/dist/runtime/backend/node/node-raw-mesh-backend.d.ts +10 -12
- package/dist/runtime/backend/node/node-raw-mesh-backend.js +64 -98
- package/dist/runtime/backend/node/node-socket-backend-adapter.js +10 -5
- package/dist/runtime/backend/raw-binding-port.d.ts +9 -2
- package/dist/runtime/channels/channel-receive-loops.js +3 -3
- package/dist/runtime/channels/channel-runtime-lifecycle.js +2 -1
- package/dist/runtime/channels/channel-socket-registry.d.ts +10 -3
- package/dist/runtime/channels/channel-socket-registry.js +59 -82
- package/dist/runtime/diagnostics/message-flow.d.ts +1 -0
- package/dist/runtime/diagnostics/message-flow.js +3 -3
- package/dist/runtime/foundation/raw-service-mesh-runtime.d.ts +15 -1
- package/dist/runtime/foundation/raw-service-mesh-runtime.js +193 -64
- package/dist/runtime/foundation/service-liveness-registry.d.ts +20 -8
- package/dist/runtime/foundation/service-liveness-registry.js +57 -44
- package/dist/runtime/foundation/service-mailbox.d.ts +3 -0
- package/dist/runtime/foundation/service-mailbox.js +2 -1
- package/dist/runtime/foundation/service-stateful-runtime.d.ts +7 -6
- package/dist/runtime/foundation/service-stateful-runtime.js +34 -23
- package/dist/runtime/foundation/service-stateful-wire-codec.d.ts +5 -2
- package/dist/runtime/foundation/service-stateful-wire-codec.js +43 -61
- package/dist/runtime/foundation/service-topology-registry.d.ts +5 -3
- package/dist/runtime/foundation/service-topology-registry.js +9 -4
- package/dist/runtime/host/actor-packet-relay.js +7 -7
- package/dist/runtime/host/actor-runtime-options-factory.js +1 -1
- package/dist/runtime/host/application-job-queue.d.ts +11 -4
- package/dist/runtime/host/application-job-queue.js +66 -10
- package/dist/runtime/host/entry-actor-runtime.js +1 -1
- package/dist/runtime/host/index.js +15 -11
- package/dist/runtime/host/instance-activation-authority.d.ts +2 -1
- package/dist/runtime/host/instance-activation-authority.js +89 -25
- package/dist/runtime/host/service-relocation-host-runtime.js +2 -2
- package/dist/runtime/host/spot-address-transport.d.ts +1 -0
- package/dist/runtime/host/spot-address-transport.js +25 -12
- package/dist/runtime/host/spot-runtime-options-factory.js +2 -2
- package/dist/runtime/host/user-spot-creation-coordinator.d.ts +1 -0
- package/dist/runtime/host/user-spot-creation-coordinator.js +1 -0
- package/dist/runtime/locations/domain-store-contract.d.ts +2 -2
- package/dist/runtime/locations/in-memory-authority-store.d.ts +4 -2
- package/dist/runtime/locations/in-memory-authority-store.js +80 -8
- package/dist/runtime/locations/in-memory-location-store.d.ts +2 -2
- package/dist/runtime/locations/in-memory-location-store.js +19 -3
- package/dist/runtime/locations/internal-location-contracts.d.ts +3 -0
- package/dist/runtime/locations/location-store-repository.d.ts +3 -2
- package/dist/runtime/locations/location-store-repository.js +165 -22
- package/dist/runtime/locations/resolvers.d.ts +2 -1
- package/dist/runtime/locations/resolvers.js +10 -1
- package/dist/runtime/messaging/submission-result.d.ts +1 -1
- package/dist/runtime/messaging/submission-result.js +2 -2
- package/dist/runtime/spots/formal-remote-actor-admission-registry.d.ts +2 -0
- package/dist/runtime/spots/index.d.ts +4 -3
- package/dist/runtime/spots/index.js +14 -14
- package/dist/runtime/spots/spot-activation.d.ts +2 -1
- package/dist/runtime/spots/spot-activation.js +4 -4
- package/dist/runtime/spots/spot-actor-admission-coordinator.d.ts +2 -1
- package/dist/runtime/spots/spot-actor-admission-coordinator.js +11 -10
- package/dist/runtime/spots/spot-actor-packet-dispatch.d.ts +4 -1
- package/dist/runtime/spots/spot-actor-packet-dispatch.js +7 -5
- package/dist/runtime/spots/spot-actor-packet-drain.js +2 -0
- package/dist/runtime/spots/spot-actor-packet-relay-dispatch.js +1 -0
- package/dist/runtime/spots/spot-entry-activation.js +3 -1
- package/dist/runtime/spots/spot-node-runtime-manager.d.ts +2 -1
- package/dist/runtime/spots/spot-node-runtime-manager.js +4 -11
- package/dist/runtime/spots/spot-routing-internal.d.ts +6 -0
- package/dist/runtime/spots/spot-runtime-ports.d.ts +2 -1
- package/dist/runtime/streams/stream-session-runtime.js +1 -1
- package/package.json +3 -3
- package/src/contracts/Configuration/Builders.ts +1 -2
- package/src/contracts/Configuration/Configs.ts +0 -6
- package/src/contracts/Configuration/RegistrationBuilders.ts +8 -12
- package/src/contracts/Configuration/RegistrationTypes.ts +1 -6
- package/src/contracts/Configuration/RegistrationValidators.ts +9 -10
- package/src/contracts/Configuration/index.ts +1 -6
- package/src/internal.ts +1 -0
- package/src/runtime/actors/actor-handoff.ts +13 -4
- package/src/runtime/application-jobs/application-ingress-record-owner.ts +12 -2
- package/src/runtime/application-jobs/application-job-queue-scope.ts +6 -1
- package/src/runtime/application-jobs/contracts.ts +14 -1
- package/src/runtime/backend/contracts/index.ts +10 -18
- package/src/runtime/backend/mesh-completion-table.ts +36 -19
- package/src/runtime/backend/mesh-dispatch-pump.ts +19 -22
- package/src/runtime/backend/node/node-backend-adapter-factory.ts +12 -5
- package/src/runtime/backend/node/node-backend-adapter-support.ts +31 -29
- package/src/runtime/backend/node/node-mesh-backend-adapter.ts +3 -10
- package/src/runtime/backend/node/node-raw-binding-port.ts +19 -10
- package/src/runtime/backend/node/node-raw-mesh-backend.ts +81 -111
- package/src/runtime/backend/node/node-socket-backend-adapter.ts +12 -8
- package/src/runtime/backend/raw-binding-port.ts +12 -2
- package/src/runtime/channels/channel-receive-loops.ts +3 -3
- package/src/runtime/channels/channel-runtime-lifecycle.ts +7 -1
- package/src/runtime/channels/channel-socket-registry.ts +84 -130
- package/src/runtime/diagnostics/message-flow.ts +1 -1
- package/src/runtime/foundation/raw-service-mesh-runtime.ts +268 -70
- package/src/runtime/foundation/service-liveness-registry.ts +68 -59
- package/src/runtime/foundation/service-mailbox.ts +7 -1
- package/src/runtime/foundation/service-stateful-runtime.ts +61 -35
- package/src/runtime/foundation/service-stateful-wire-codec.ts +55 -79
- package/src/runtime/foundation/service-topology-registry.ts +13 -7
- package/src/runtime/host/actor-packet-relay.ts +7 -0
- package/src/runtime/host/actor-runtime-options-factory.ts +1 -0
- package/src/runtime/host/application-job-queue.ts +77 -10
- package/src/runtime/host/entry-actor-runtime.ts +1 -0
- package/src/runtime/host/index.ts +24 -5
- package/src/runtime/host/instance-activation-authority.ts +132 -27
- package/src/runtime/host/service-relocation-host-runtime.ts +2 -0
- package/src/runtime/host/spot-address-transport.ts +45 -22
- package/src/runtime/host/spot-runtime-options-factory.ts +2 -0
- package/src/runtime/host/user-spot-creation-coordinator.ts +8 -0
- package/src/runtime/locations/domain-store-contract.ts +6 -2
- package/src/runtime/locations/in-memory-authority-store.ts +113 -9
- package/src/runtime/locations/in-memory-location-store.ts +25 -3
- package/src/runtime/locations/internal-location-contracts.ts +4 -0
- package/src/runtime/locations/location-store-repository.ts +220 -15
- package/src/runtime/locations/resolvers.ts +25 -2
- package/src/runtime/messaging/submission-result.ts +2 -2
- package/src/runtime/spots/formal-remote-actor-admission-registry.ts +2 -0
- package/src/runtime/spots/index.ts +16 -0
- package/src/runtime/spots/spot-activation.ts +5 -0
- package/src/runtime/spots/spot-actor-admission-coordinator.ts +13 -0
- package/src/runtime/spots/spot-actor-packet-dispatch.ts +10 -0
- package/src/runtime/spots/spot-actor-packet-drain.ts +2 -0
- package/src/runtime/spots/spot-actor-packet-relay-dispatch.ts +1 -0
- package/src/runtime/spots/spot-entry-activation.ts +3 -0
- package/src/runtime/spots/spot-node-runtime-manager.ts +7 -12
- package/src/runtime/spots/spot-routing-internal.ts +14 -0
- package/src/runtime/spots/spot-runtime-ports.ts +2 -0
- package/src/runtime/streams/stream-session-runtime.ts +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { ActorRef, RoutingId, SpotId } from '../../contracts/Common';
|
|
2
2
|
import { type SpotHandle, type ZLinkActorSpotHandleResolver, type ZLinkSpotHandleResolver, type ResolvedSpotHandle } from '../spots/spot-handle';
|
|
3
|
-
import type { ZLinkSpotRouteResolver, ZLinkSpotRouteTarget } from '../spots/spot-routing-internal';
|
|
3
|
+
import type { ZLinkSpotRouteResolver, ZLinkSpotRouteTarget, ZLinkInstanceReactivationRoute } from '../spots/spot-routing-internal';
|
|
4
4
|
import { ZLinkFrameworkRuntimeState, ZLinkLocationRole, type ZLinkActorLocation, type ZLinkActorLocationKey, type ZLinkLocationReadiness, type ZLinkLocationRuntimeQuery, type ZLinkPeerLocation, type ZLinkPeerLocationFilter, type ZLinkPeerLocationResolver, type ZLinkRouteLocation, type ZLinkRouteLocationKey, type ZLinkSpotLocation, type ZLinkSpotLocationKey } from './internal-location-contracts';
|
|
5
5
|
import type { ZLinkActorLocationStore, ZLinkAuthorityStore, ZLinkMeshNodeLocationStore, ZLinkPeerLocationStore, ZLinkRouteLocationStore, ZLinkSpotLocationStore } from './internal-store-contracts';
|
|
6
6
|
import { ZLinkOwnerLeaseTracker } from './lease-tracker';
|
|
@@ -135,6 +135,7 @@ export declare class ZLinkAuthoritySpotRouteResolver implements ZLinkSpotRouteRe
|
|
|
135
135
|
private readonly routeEpochs;
|
|
136
136
|
private readonly activeResolutions;
|
|
137
137
|
constructor(store: ZLinkAuthorityStore, routerChannelIdForMesh: (meshName: string) => string, fallback?: ZLinkSpotRouteResolver | undefined, leaseTracker?: ZLinkOwnerLeaseTracker | undefined, routeCacheMaxAgeMs?: number, monotonicNowMs?: () => number, targetNodeStateResolver?: ((meshName: string, nodeRid: RoutingId, expectedLifecycleGeneration: bigint, signal?: AbortSignal) => Promise<ZLinkFrameworkRuntimeState | undefined>) | undefined);
|
|
138
|
+
resolve(spotId: RoutingId, signal: AbortSignal | undefined, instanceIntent: true): Promise<ZLinkSpotRouteTarget | ZLinkInstanceReactivationRoute>;
|
|
138
139
|
resolve(spotId: RoutingId, signal?: AbortSignal): Promise<ZLinkSpotRouteTarget>;
|
|
139
140
|
invalidate(spotId: RoutingId): void;
|
|
140
141
|
private invalidateCore;
|
|
@@ -583,7 +583,7 @@ class ZLinkAuthoritySpotRouteResolver {
|
|
|
583
583
|
this.monotonicNowMs = monotonicNowMs;
|
|
584
584
|
this.targetNodeStateResolver = targetNodeStateResolver;
|
|
585
585
|
}
|
|
586
|
-
async resolve(spotId, signal) {
|
|
586
|
+
async resolve(spotId, signal, instanceIntent) {
|
|
587
587
|
const key = String(spotId);
|
|
588
588
|
const prepared = await this.lane.run(() => this.beginResolutionCore(key));
|
|
589
589
|
try {
|
|
@@ -606,6 +606,15 @@ class ZLinkAuthoritySpotRouteResolver {
|
|
|
606
606
|
leaseGeneration: current.ownerLeaseGeneration
|
|
607
607
|
}, signal);
|
|
608
608
|
if (remainingLeaseMs !== undefined && remainingLeaseMs <= 0) {
|
|
609
|
+
if (instanceIntent === true && ready?.kind === 'instance_spot') {
|
|
610
|
+
return {
|
|
611
|
+
kind: 'coldActivation',
|
|
612
|
+
spotId,
|
|
613
|
+
spotKind: Spots_1.ZLinkSpotKind.Instance,
|
|
614
|
+
meshName: ready.ownerMeshName,
|
|
615
|
+
stableType: ready.stableType
|
|
616
|
+
};
|
|
617
|
+
}
|
|
609
618
|
throw new Errors_1.ZLinkFrameworkException(Errors_1.ZLinkFrameworkErrorKind.Unavailable, `SPOT '${spotId}' Ready authority owner lease is unavailable.`);
|
|
610
619
|
}
|
|
611
620
|
const target = {
|
|
@@ -10,7 +10,7 @@ export declare enum ZLinkSubmitStatus {
|
|
|
10
10
|
export interface ZLinkSubmitResult {
|
|
11
11
|
readonly status: ZLinkSubmitStatus;
|
|
12
12
|
}
|
|
13
|
-
/** Projects
|
|
13
|
+
/** Projects typed submit failure; capacity refusal has no admission wait token. */
|
|
14
14
|
export declare function submitToRequestResult(result: number, phase: 'submit' | 'completion'): number;
|
|
15
15
|
export declare function classifySubmitResult(result: number, operation: string, phase?: 'submit' | 'completion'): ZLinkSubmitResult;
|
|
16
16
|
export declare function requireOneWayCompletion(result: ZLinkSubmitResult, operation: string, notFoundKind?: ZLinkFrameworkInternalErrorKind): void;
|
|
@@ -19,13 +19,13 @@ var ZLinkSubmitStatus;
|
|
|
19
19
|
ZLinkSubmitStatus["RouteNotConnected"] = "routeNotConnected";
|
|
20
20
|
ZLinkSubmitStatus["Shutdown"] = "shutdown";
|
|
21
21
|
})(ZLinkSubmitStatus || (exports.ZLinkSubmitStatus = ZLinkSubmitStatus = {}));
|
|
22
|
-
/** Projects
|
|
22
|
+
/** Projects typed submit failure; capacity refusal has no admission wait token. */
|
|
23
23
|
function submitToRequestResult(result, phase) {
|
|
24
24
|
switch (result) {
|
|
25
25
|
case runtime_values_1.SubmitResult.Ok:
|
|
26
26
|
return runtime_values_1.RequestResult.Ok;
|
|
27
27
|
case runtime_values_1.SubmitResult.Backpressured:
|
|
28
|
-
return
|
|
28
|
+
return runtime_values_1.RequestResult.NotConnected;
|
|
29
29
|
case runtime_values_1.SubmitResult.NotConnected:
|
|
30
30
|
return runtime_values_1.RequestResult.NotConnected;
|
|
31
31
|
case runtime_values_1.SubmitResult.NotFound:
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { ApplicationJobOrigin } from '../application-jobs/contracts';
|
|
1
2
|
import type { ActorRef, RoutingId, ZLinkActor, ZLinkActorJoinOperationId } from '../../contracts';
|
|
2
3
|
import type { ZLinkRemoteBoundSessionTarget } from '../actors/actor-runtime-state';
|
|
3
4
|
import type { ZLinkDeferredJoinCompletion } from '../actors/deferred-join-completion';
|
|
@@ -10,6 +11,7 @@ import type { ZLinkActorRequestTerminal } from './spot-actor-packet-dispatch';
|
|
|
10
11
|
* how long the underlying buffer stays valid.
|
|
11
12
|
*/
|
|
12
13
|
export interface ZLinkParkedActorArrival {
|
|
14
|
+
readonly origin: ApplicationJobOrigin;
|
|
13
15
|
readonly header: Buffer;
|
|
14
16
|
readonly payload: Buffer;
|
|
15
17
|
readonly returnResponse: boolean;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { ApplicationJobOrigin } from '../application-jobs/contracts';
|
|
1
2
|
import type { ActorRef, RoutingId, Type, ZLinkMessageSerializer, ZLinkInstanceSpot, ZLinkActor, ZLinkChannelClient, ZLinkFanoutClient, ZLinkSpot, ZLinkSpotActorJoinResult, ZLinkSpotInfo, ZLinkSpotPublisherClient } from '../../contracts';
|
|
2
3
|
import type { ZLinkProviderResolver } from '../../contracts/Common/ZLinkProviderResolver';
|
|
3
4
|
import type { ZLinkSpotActorRequestHandlerRegistration, ZLinkSpotActorSendHandlerRegistration, ZLinkSpotPacketHandlerRegistration, ZLinkSpotSubscriptionHandlerRegistration, ZLinkSpotTimerHandlerRegistration } from '../../contracts/Configuration/RegistrationTypes';
|
|
@@ -55,7 +56,7 @@ export interface ZLinkSpotManagerOptions {
|
|
|
55
56
|
readonly entrySpotCallbacks?: {
|
|
56
57
|
onLeaveActor(actor: ZLinkActor, signal?: AbortSignal, actorRef?: ActorRef, membershipEpoch?: bigint): Promise<void>;
|
|
57
58
|
};
|
|
58
|
-
readonly dispatchEntryActorPacket?: (actorId: string, parts: readonly Message[], returnResponse?: boolean, remoteBoundSessionTarget?: ZLinkRemoteBoundSessionTarget, fallbackActorRef?: ActorRef, requestTerminal?: (response: unknown) => Promise<void> | void, messageFollowOrigin?: ZLinkMessageFollowOrigin) => Promise<unknown>;
|
|
59
|
+
readonly dispatchEntryActorPacket?: (origin: ApplicationJobOrigin, actorId: string, parts: readonly Message[], returnResponse?: boolean, remoteBoundSessionTarget?: ZLinkRemoteBoundSessionTarget, fallbackActorRef?: ActorRef, requestTerminal?: (response: unknown) => Promise<void> | void, messageFollowOrigin?: ZLinkMessageFollowOrigin) => Promise<unknown>;
|
|
59
60
|
/**
|
|
60
61
|
* Commits a stateful MeshNode Actor return to the Entry Spot after the
|
|
61
62
|
* stateful reply has committed Core membership.
|
|
@@ -200,7 +201,7 @@ export declare class DefaultZLinkSpotManager {
|
|
|
200
201
|
beginActorTransfer(spotId: RoutingId, actorId: string): Promise<void>;
|
|
201
202
|
cancelActorTransfer(spotId: RoutingId, actorId: string): Promise<void>;
|
|
202
203
|
notifyJoinedSpotActorDisconnected(spotId: RoutingId, actor: ZLinkActor, signal?: AbortSignal): Promise<boolean>;
|
|
203
|
-
dispatchRoutedActorPacket(spotId: RoutingId, actorId: string, parts: readonly Message[], returnResponse?: boolean, remoteBoundSessionTarget?: ZLinkRemoteBoundSessionTarget, fallbackActorRef?: ActorRef): Promise<unknown>;
|
|
204
|
+
dispatchRoutedActorPacket(origin: ApplicationJobOrigin, spotId: RoutingId, actorId: string, parts: readonly Message[], returnResponse?: boolean, remoteBoundSessionTarget?: ZLinkRemoteBoundSessionTarget, fallbackActorRef?: ActorRef): Promise<unknown>;
|
|
204
205
|
dispatchRoutedSpotSend(spotId: RoutingId, packetName: string | undefined, message: unknown, context: {
|
|
205
206
|
readonly channelName: string;
|
|
206
207
|
readonly contentType?: string;
|
|
@@ -220,7 +221,7 @@ export declare class DefaultZLinkSpotManager {
|
|
|
220
221
|
dispatchMeshInstance(meshName: string, owner: ReadyRecord, record: ReceiveRecord): Promise<void>;
|
|
221
222
|
private reportInstanceDispatchFailure;
|
|
222
223
|
private traceInstanceMessage;
|
|
223
|
-
dispatchMeshActor(meshName: string, owner: ReadyRecord, record: ReceiveRecord): Promise<void>;
|
|
224
|
+
dispatchMeshActor(origin: ApplicationJobOrigin, meshName: string, owner: ReadyRecord, record: ReceiveRecord): Promise<void>;
|
|
224
225
|
dispatchMeshActorJoin(meshName: string, owner: ReadyRecord, record: ReceiveRecord): Promise<void>;
|
|
225
226
|
private dispatchMeshActorJoinCore;
|
|
226
227
|
dispatchMeshSpotControl(meshName: string, owner: ReadyRecord, record: ReceiveRecord): Promise<void>;
|
|
@@ -860,20 +860,20 @@ class DefaultZLinkSpotManager {
|
|
|
860
860
|
async notifyJoinedSpotActorDisconnected(spotId, actor, signal) {
|
|
861
861
|
return await this.actorMembership.notifyJoinedActorDisconnected(spotId, actor, signal);
|
|
862
862
|
}
|
|
863
|
-
dispatchRoutedActorPacket(spotId, actorId, parts, returnResponse = false, remoteBoundSessionTarget, fallbackActorRef) {
|
|
863
|
+
dispatchRoutedActorPacket(origin, spotId, actorId, parts, returnResponse = false, remoteBoundSessionTarget, fallbackActorRef) {
|
|
864
864
|
const activation = this.activations.resolveUnique(spotId);
|
|
865
865
|
if (activation === undefined) {
|
|
866
866
|
throw new configuration_1.ZLinkConfigurationException(`Spot '${spotId}' is not active.`);
|
|
867
867
|
}
|
|
868
|
-
return this.dispatchActorPacket(activation, actorId, parts, returnResponse, remoteBoundSessionTarget, fallbackActorRef);
|
|
868
|
+
return this.dispatchActorPacket(origin, activation, actorId, parts, returnResponse, remoteBoundSessionTarget, fallbackActorRef);
|
|
869
869
|
}
|
|
870
870
|
/** @internal Replays a record already owned by the Actor handoff queue. */
|
|
871
|
-
dispatchRoutedActorPacketDirect(spotId, actorId, parts, returnResponse = false, remoteBoundSessionTarget, fallbackActorRef) {
|
|
871
|
+
dispatchRoutedActorPacketDirect(origin, spotId, actorId, parts, returnResponse = false, remoteBoundSessionTarget, fallbackActorRef) {
|
|
872
872
|
const activation = this.activations.resolveUnique(spotId);
|
|
873
873
|
if (activation === undefined) {
|
|
874
874
|
throw new configuration_1.ZLinkConfigurationException(`Spot '${spotId}' is not active.`);
|
|
875
875
|
}
|
|
876
|
-
return this.activationLifecycle.dispatchActorPacketDirect(activation, actorId, parts, returnResponse, remoteBoundSessionTarget, fallbackActorRef);
|
|
876
|
+
return this.activationLifecycle.dispatchActorPacketDirect(origin, activation, actorId, parts, returnResponse, remoteBoundSessionTarget, fallbackActorRef);
|
|
877
877
|
}
|
|
878
878
|
/** @internal Atomically restores one durable packet prefix to an Actor FIFO. */
|
|
879
879
|
admitRoutedActorPacketPrefix(spotId, actorId, records) {
|
|
@@ -1071,7 +1071,7 @@ class DefaultZLinkSpotManager {
|
|
|
1071
1071
|
errorReason
|
|
1072
1072
|
});
|
|
1073
1073
|
}
|
|
1074
|
-
async dispatchMeshActor(meshName, owner, record) {
|
|
1074
|
+
async dispatchMeshActor(origin, meshName, owner, record) {
|
|
1075
1075
|
const spotId = owner.spotId;
|
|
1076
1076
|
const entrySpotId = this.options.entryNodeRidProvider?.() ?? this.options.entryNodeRid;
|
|
1077
1077
|
const targetsEntrySpot = spotId === null || (entrySpotId !== undefined && spotId === entrySpotId);
|
|
@@ -1115,8 +1115,8 @@ class DefaultZLinkSpotManager {
|
|
|
1115
1115
|
throw new Error(`Actor '${actor.actorId}' target transfer reconciliation is not complete.`);
|
|
1116
1116
|
}
|
|
1117
1117
|
const response = targetsEntrySpot
|
|
1118
|
-
? await this.options.dispatchEntryActorPacket?.(actor.actorId, record.parts, request, undefined, ownerActorRef, requestTerminal, record.messageFollowOrigin)
|
|
1119
|
-
: await this.dispatchMeshActorPacket(meshName, spotId, actor.actorId, record.parts, request, ownerActorRef, requestTerminal, record.messageFollowOrigin);
|
|
1118
|
+
? await this.options.dispatchEntryActorPacket?.(origin, actor.actorId, record.parts, request, undefined, ownerActorRef, requestTerminal, record.messageFollowOrigin)
|
|
1119
|
+
: await this.dispatchMeshActorPacket(origin, meshName, spotId, actor.actorId, record.parts, request, ownerActorRef, requestTerminal, record.messageFollowOrigin);
|
|
1120
1120
|
if (targetsEntrySpot && this.options.dispatchEntryActorPacket === undefined) {
|
|
1121
1121
|
throw new configuration_1.ZLinkConfigurationException('MeshNode Entry Spot Actor dispatch is not configured.');
|
|
1122
1122
|
}
|
|
@@ -1631,7 +1631,7 @@ class DefaultZLinkSpotManager {
|
|
|
1631
1631
|
if (this.options.dispatchEntryActorPacket === undefined) {
|
|
1632
1632
|
throw new Error('Entry Spot saved handoff replay requires its Actor packet runtime.');
|
|
1633
1633
|
}
|
|
1634
|
-
return await this.options.dispatchEntryActorPacket(entryActor.context.actorId, parts, returnResponse, remoteBoundSessionTarget, fallbackActorRef);
|
|
1634
|
+
return await this.options.dispatchEntryActorPacket('remote', entryActor.context.actorId, parts, returnResponse, remoteBoundSessionTarget, fallbackActorRef);
|
|
1635
1635
|
}, (index) => this.options.runtimeEventPublisher?.publish({
|
|
1636
1636
|
sourceName: 'zlink.framework.actor-handoff',
|
|
1637
1637
|
timestamp: new Date(),
|
|
@@ -1790,7 +1790,7 @@ class DefaultZLinkSpotManager {
|
|
|
1790
1790
|
};
|
|
1791
1791
|
const completeTargetReady = async () => {
|
|
1792
1792
|
if (pendingTransfer !== undefined) {
|
|
1793
|
-
const handoffResults = await (0, actor_handoff_1.replayActorHandoffBacklog)(pendingTransfer.handoffBacklog, (parts, returnResponse, remoteBoundSessionTarget, _fallbackActorRef) => this.dispatchActorPacket(activation, actor.context.actorId, parts, returnResponse, remoteBoundSessionTarget, undefined), (index) => this.options.runtimeEventPublisher?.publish({
|
|
1793
|
+
const handoffResults = await (0, actor_handoff_1.replayActorHandoffBacklog)(pendingTransfer.handoffBacklog, (parts, returnResponse, remoteBoundSessionTarget, _fallbackActorRef) => this.dispatchActorPacket('remote', activation, actor.context.actorId, parts, returnResponse, remoteBoundSessionTarget, undefined), (index) => this.options.runtimeEventPublisher?.publish({
|
|
1794
1794
|
sourceName: 'zlink.framework.actor-handoff',
|
|
1795
1795
|
timestamp: new Date(),
|
|
1796
1796
|
marker: 'backlog_enqueued',
|
|
@@ -2033,8 +2033,8 @@ class DefaultZLinkSpotManager {
|
|
|
2033
2033
|
throw new configuration_1.ZLinkConfigurationException('Spot type is not registered as a spot factory.');
|
|
2034
2034
|
}
|
|
2035
2035
|
}
|
|
2036
|
-
async dispatchActorPacket(activation, actorId, parts, returnResponse = false, remoteBoundSessionTarget, fallbackActorRef, requestTerminal, messageFollowOrigin) {
|
|
2037
|
-
return await this.activationLifecycle.dispatchActorPacket(activation, actorId, parts, returnResponse, remoteBoundSessionTarget, fallbackActorRef, requestTerminal, messageFollowOrigin);
|
|
2036
|
+
async dispatchActorPacket(origin, activation, actorId, parts, returnResponse = false, remoteBoundSessionTarget, fallbackActorRef, requestTerminal, messageFollowOrigin) {
|
|
2037
|
+
return await this.activationLifecycle.dispatchActorPacket(origin, activation, actorId, parts, returnResponse, remoteBoundSessionTarget, fallbackActorRef, requestTerminal, messageFollowOrigin);
|
|
2038
2038
|
}
|
|
2039
2039
|
/**
|
|
2040
2040
|
* Spec 15 §4.2 relocation temporary queue: drains every arrival parked
|
|
@@ -2050,7 +2050,7 @@ class DefaultZLinkSpotManager {
|
|
|
2050
2050
|
const drained = this.formalRemoteActorAdmissions.completeMigration(transferId);
|
|
2051
2051
|
for (const arrival of drained) {
|
|
2052
2052
|
try {
|
|
2053
|
-
const response = await this.dispatchActorPacket(activation, actor.context.actorId, [runtime_message_1.ZLinkBufferMessage.from(arrival.header), runtime_message_1.ZLinkBufferMessage.from(arrival.payload)], arrival.returnResponse, arrival.remoteBoundSessionTarget, arrival.fallbackActorRef, arrival.requestTerminal);
|
|
2053
|
+
const response = await this.dispatchActorPacket(arrival.origin, activation, actor.context.actorId, [runtime_message_1.ZLinkBufferMessage.from(arrival.header), runtime_message_1.ZLinkBufferMessage.from(arrival.payload)], arrival.returnResponse, arrival.remoteBoundSessionTarget, arrival.fallbackActorRef, arrival.requestTerminal);
|
|
2054
2054
|
arrival.resolve(response);
|
|
2055
2055
|
}
|
|
2056
2056
|
catch (error) {
|
|
@@ -2058,12 +2058,12 @@ class DefaultZLinkSpotManager {
|
|
|
2058
2058
|
}
|
|
2059
2059
|
}
|
|
2060
2060
|
}
|
|
2061
|
-
async dispatchMeshActorPacket(meshName, spotId, actorId, parts, returnResponse, fallbackActorRef, requestTerminal, messageFollowOrigin) {
|
|
2061
|
+
async dispatchMeshActorPacket(origin, meshName, spotId, actorId, parts, returnResponse, fallbackActorRef, requestTerminal, messageFollowOrigin) {
|
|
2062
2062
|
const activation = this.activations.resolve(meshName, spotId);
|
|
2063
2063
|
if (activation === undefined) {
|
|
2064
2064
|
throw new configuration_1.ZLinkConfigurationException(`Spot '${String(spotId)}' is not active in mesh '${meshName}'.`);
|
|
2065
2065
|
}
|
|
2066
|
-
return await this.dispatchActorPacket(activation, actorId, parts, returnResponse, undefined, fallbackActorRef, requestTerminal, messageFollowOrigin);
|
|
2066
|
+
return await this.dispatchActorPacket(origin, activation, actorId, parts, returnResponse, undefined, fallbackActorRef, requestTerminal, messageFollowOrigin);
|
|
2067
2067
|
}
|
|
2068
2068
|
}
|
|
2069
2069
|
exports.DefaultZLinkSpotManager = DefaultZLinkSpotManager;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { ApplicationJobOrigin } from '../application-jobs/contracts';
|
|
1
2
|
import type { ActorRef, RoutingId, Type, ZLinkActor, ZLinkChannelClient, ZLinkFanoutClient, ZLinkMessageSerializer, ZLinkInstanceSpot, ZLinkSpot, ZLinkSpotPublisherClient } from '../../contracts';
|
|
2
3
|
import type { ZLinkProviderResolver } from '../../contracts/Common/ZLinkProviderResolver';
|
|
3
4
|
import type { ZLinkRuntimeAdmissionGate } from '../admission';
|
|
@@ -82,7 +83,7 @@ export declare class ZLinkSpotActivationLifecycle {
|
|
|
82
83
|
/** Returns the OnClosing failure, which cleanup records and does not rethrow. */
|
|
83
84
|
cleanupClosedActivation(activation: ZLinkSpotActivation, reason?: ZLinkSpotCloseReason, deadline?: Date): Promise<unknown>;
|
|
84
85
|
cleanupFailedIncarnation(activation: ZLinkSpotActivation): Promise<void>;
|
|
85
|
-
dispatchActorPacket(activation: ZLinkSpotActivation, actorId: string, parts: readonly Message[], returnResponse?: boolean, remoteBoundSessionTarget?: ZLinkRemoteBoundSessionTarget, fallbackActorRef?: ActorRef, requestTerminal?: (response: unknown) => Promise<void> | void, messageFollowOrigin?: ZLinkMessageFollowOrigin): Promise<unknown>;
|
|
86
|
+
dispatchActorPacket(origin: ApplicationJobOrigin, activation: ZLinkSpotActivation, actorId: string, parts: readonly Message[], returnResponse?: boolean, remoteBoundSessionTarget?: ZLinkRemoteBoundSessionTarget, fallbackActorRef?: ActorRef, requestTerminal?: (response: unknown) => Promise<void> | void, messageFollowOrigin?: ZLinkMessageFollowOrigin): Promise<unknown>;
|
|
86
87
|
private runCreateLifecycle;
|
|
87
88
|
private cleanupActivation;
|
|
88
89
|
private runCleanup;
|
|
@@ -477,12 +477,12 @@ class ZLinkSpotActivationLifecycle {
|
|
|
477
477
|
async cleanupFailedIncarnation(activation) {
|
|
478
478
|
await this.cleanupActivation(activation, activation.meshName, false, undefined, contracts_1.ZLinkSpotCloseReason.ExplicitClose, undefined, true);
|
|
479
479
|
}
|
|
480
|
-
async dispatchActorPacket(activation, actorId, parts, returnResponse = false, remoteBoundSessionTarget, fallbackActorRef, requestTerminal, messageFollowOrigin) {
|
|
481
|
-
return await this.actorAdmission.dispatchActorPacket(activation, actorId, parts, returnResponse, remoteBoundSessionTarget, fallbackActorRef, requestTerminal, messageFollowOrigin);
|
|
480
|
+
async dispatchActorPacket(origin, activation, actorId, parts, returnResponse = false, remoteBoundSessionTarget, fallbackActorRef, requestTerminal, messageFollowOrigin) {
|
|
481
|
+
return await this.actorAdmission.dispatchActorPacket(origin, activation, actorId, parts, returnResponse, remoteBoundSessionTarget, fallbackActorRef, requestTerminal, messageFollowOrigin);
|
|
482
482
|
}
|
|
483
483
|
/** @internal Dispatches a held Actor record after its handoff owner releases it. */
|
|
484
|
-
dispatchActorPacketDirect(activation, actorId, parts, returnResponse = false, remoteBoundSessionTarget, fallbackActorRef) {
|
|
485
|
-
return this.actorAdmission.dispatchActorPacketDirect(activation, actorId, parts, returnResponse, remoteBoundSessionTarget, fallbackActorRef);
|
|
484
|
+
dispatchActorPacketDirect(origin, activation, actorId, parts, returnResponse = false, remoteBoundSessionTarget, fallbackActorRef) {
|
|
485
|
+
return this.actorAdmission.dispatchActorPacketDirect(origin, activation, actorId, parts, returnResponse, remoteBoundSessionTarget, fallbackActorRef);
|
|
486
486
|
}
|
|
487
487
|
/** @internal Atomically restores one durable Actor packet prefix. */
|
|
488
488
|
admitActorPacketPrefix(activation, actorId, records) {
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { ApplicationJobOrigin } from '../application-jobs/contracts';
|
|
1
2
|
import type { ActorRef } from '../../contracts';
|
|
2
3
|
import type { Message } from '../../contracts/Common/Message';
|
|
3
4
|
import type { ZLinkMessageFollowOrigin } from '../foundation/service-runtime-contracts';
|
|
@@ -10,7 +11,7 @@ type AdmissionOptions = Pick<ZLinkSpotActivationLifecycleOptions, 'actorHandoffR
|
|
|
10
11
|
export declare class ZLinkSpotActorAdmissionCoordinator {
|
|
11
12
|
private readonly options;
|
|
12
13
|
constructor(options: AdmissionOptions);
|
|
13
|
-
dispatchActorPacket(activation: ZLinkSpotActivation, actorId: string, parts: readonly Message[], returnResponse?: boolean, remoteBoundSessionTarget?: ZLinkRemoteBoundSessionTarget, fallbackActorRef?: ActorRef, requestTerminal?: (response: unknown) => Promise<void> | void, messageFollowOrigin?: ZLinkMessageFollowOrigin): Promise<unknown>;
|
|
14
|
+
dispatchActorPacket(origin: ApplicationJobOrigin, activation: ZLinkSpotActivation, actorId: string, parts: readonly Message[], returnResponse?: boolean, remoteBoundSessionTarget?: ZLinkRemoteBoundSessionTarget, fallbackActorRef?: ActorRef, requestTerminal?: (response: unknown) => Promise<void> | void, messageFollowOrigin?: ZLinkMessageFollowOrigin): Promise<unknown>;
|
|
14
15
|
attachNativeActorJoinDispatch(activation: ZLinkSpotActivation, nativeSpot: ZLinkBackendSpot | undefined): ZLinkSpotActorJoinDispatch | undefined;
|
|
15
16
|
private dispatchActorPacketInActorTurn;
|
|
16
17
|
private commitTransferredActorTransaction;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ZLinkSpotActorAdmissionCoordinator = void 0;
|
|
4
|
+
const application_job_queue_scope_1 = require("../application-jobs/application-job-queue-scope");
|
|
4
5
|
const actor_handoff_1 = require("../actors/actor-handoff");
|
|
5
6
|
const routing_id_1 = require("../routing-id");
|
|
6
7
|
const spot_actor_join_dispatch_1 = require("./spot-actor-join-dispatch");
|
|
@@ -10,11 +11,11 @@ class ZLinkSpotActorAdmissionCoordinator {
|
|
|
10
11
|
constructor(options) {
|
|
11
12
|
this.options = options;
|
|
12
13
|
}
|
|
13
|
-
async dispatchActorPacket(activation, actorId, parts, returnResponse = false, remoteBoundSessionTarget, fallbackActorRef, requestTerminal, messageFollowOrigin) {
|
|
14
|
-
const handoff = this.options.actorHandoffRuntime?.capture(actorId, parts, returnResponse, remoteBoundSessionTarget, fallbackActorRef, undefined, messageFollowOrigin, (replayedParts, replayReturnResponse, replayRemoteBoundSessionTarget, replayFallbackActorRef) => this.dispatchActorPacketDirect(activation, actorId, replayedParts, replayReturnResponse, replayRemoteBoundSessionTarget, replayFallbackActorRef));
|
|
14
|
+
async dispatchActorPacket(origin, activation, actorId, parts, returnResponse = false, remoteBoundSessionTarget, fallbackActorRef, requestTerminal, messageFollowOrigin) {
|
|
15
|
+
const handoff = this.options.actorHandoffRuntime?.capture(origin, actorId, parts, returnResponse, remoteBoundSessionTarget, fallbackActorRef, undefined, messageFollowOrigin, (replayedParts, replayReturnResponse, replayRemoteBoundSessionTarget, replayFallbackActorRef) => this.dispatchActorPacketDirect(origin, activation, actorId, replayedParts, replayReturnResponse, replayRemoteBoundSessionTarget, replayFallbackActorRef));
|
|
15
16
|
if (handoff !== undefined)
|
|
16
17
|
return await handoff;
|
|
17
|
-
return await this.dispatchActorPacketDirect(activation, actorId, parts, returnResponse, remoteBoundSessionTarget, fallbackActorRef, requestTerminal);
|
|
18
|
+
return await this.dispatchActorPacketDirect(origin, activation, actorId, parts, returnResponse, remoteBoundSessionTarget, fallbackActorRef, requestTerminal);
|
|
18
19
|
}
|
|
19
20
|
attachNativeActorJoinDispatch(activation, nativeSpot) {
|
|
20
21
|
if (nativeSpot === undefined)
|
|
@@ -39,7 +40,7 @@ class ZLinkSpotActorAdmissionCoordinator {
|
|
|
39
40
|
commitTransferredActor: (actor, backlog, sealedSession) => this.commitTransferredActorTransaction(activation, actor, backlog, sealedSession)
|
|
40
41
|
},
|
|
41
42
|
packets: {
|
|
42
|
-
handle: (delivery) => this.dispatchActorPacket(activation, delivery.actorId, delivery.parts, delivery.returnResponse, delivery.remoteBoundSessionTarget, delivery.fallbackActorRef),
|
|
43
|
+
handle: (delivery) => this.dispatchActorPacket('remote', activation, delivery.actorId, delivery.parts, delivery.returnResponse, delivery.remoteBoundSessionTarget, delivery.fallbackActorRef),
|
|
43
44
|
bindRemoteSession: (actor, sourceNodeRid, sourceSessionRid) => {
|
|
44
45
|
const node = this.options.nativeSpotNodeProvider?.(activation.meshName);
|
|
45
46
|
if (node === undefined || (0, routing_id_1.routingIdsEqual)(sourceNodeRid, node.routingId))
|
|
@@ -63,8 +64,8 @@ class ZLinkSpotActorAdmissionCoordinator {
|
|
|
63
64
|
return nativeDispatch;
|
|
64
65
|
}
|
|
65
66
|
/** @internal Dispatches a coordinator-owned replay without recapturing it. */
|
|
66
|
-
dispatchActorPacketDirect(activation, actorId, parts, returnResponse = false, remoteBoundSessionTarget, fallbackActorRef, requestTerminal) {
|
|
67
|
-
return activation.executeActor(actorId, (actorSerial) => this.dispatchActorPacketInActorTurn(activation, actorSerial, actorId, parts, returnResponse, remoteBoundSessionTarget, fallbackActorRef, requestTerminal));
|
|
67
|
+
dispatchActorPacketDirect(origin, activation, actorId, parts, returnResponse = false, remoteBoundSessionTarget, fallbackActorRef, requestTerminal) {
|
|
68
|
+
return activation.executeActor(actorId, (actorSerial) => this.dispatchActorPacketInActorTurn(origin, activation, actorSerial, actorId, parts, returnResponse, remoteBoundSessionTarget, fallbackActorRef, requestTerminal));
|
|
68
69
|
}
|
|
69
70
|
/**
|
|
70
71
|
* Atomically restores one durable packet prefix at the Actor FIFO tail.
|
|
@@ -75,7 +76,7 @@ class ZLinkSpotActorAdmissionCoordinator {
|
|
|
75
76
|
*/
|
|
76
77
|
admitActorPacketPrefix(activation, actorId, records) {
|
|
77
78
|
const terminals = activation.admitActorDurablePrefix(actorId, records.map((record) => ({
|
|
78
|
-
operation: (executeChild) => record.drain((parts, returnResponse, remoteBoundSessionTarget, fallbackActorRef) => executeChild((actorSerial) => this.dispatchActorPacketInActorTurn(activation, actorSerial, actorId, parts, returnResponse, remoteBoundSessionTarget, fallbackActorRef))),
|
|
79
|
+
operation: (executeChild) => record.drain((parts, returnResponse, remoteBoundSessionTarget, fallbackActorRef) => executeChild((actorSerial) => this.dispatchActorPacketInActorTurn((0, application_job_queue_scope_1.currentApplicationJobOrigin)(), activation, actorSerial, actorId, parts, returnResponse, remoteBoundSessionTarget, fallbackActorRef))),
|
|
79
80
|
preparation: record.preparation,
|
|
80
81
|
workOptions: { payloadBytes: record.payloadBytes }
|
|
81
82
|
})));
|
|
@@ -89,7 +90,7 @@ class ZLinkSpotActorAdmissionCoordinator {
|
|
|
89
90
|
});
|
|
90
91
|
return { terminal };
|
|
91
92
|
}
|
|
92
|
-
dispatchActorPacketInActorTurn(activation, actorSerial, actorId, parts, returnResponse = false, remoteBoundSessionTarget, fallbackActorRef, requestTerminal) {
|
|
93
|
+
dispatchActorPacketInActorTurn(origin, activation, actorSerial, actorId, parts, returnResponse = false, remoteBoundSessionTarget, fallbackActorRef, requestTerminal) {
|
|
93
94
|
return new spot_actor_packet_dispatch_1.ZLinkSpotActorPacketDispatch({
|
|
94
95
|
spot: activation.spot,
|
|
95
96
|
spotId: () => String(activation.spotId),
|
|
@@ -107,7 +108,7 @@ class ZLinkSpotActorAdmissionCoordinator {
|
|
|
107
108
|
messageSerializers: this.options.messageSerializers,
|
|
108
109
|
dispatchErrors: this.options.dispatchErrors,
|
|
109
110
|
routeToActorJoinPrewarm: this.options.routeToActorJoinPrewarm
|
|
110
|
-
}).dispatch(actorId, parts, returnResponse, remoteBoundSessionTarget, fallbackActorRef, requestTerminal);
|
|
111
|
+
}).dispatch(origin, actorId, parts, returnResponse, remoteBoundSessionTarget, fallbackActorRef, requestTerminal);
|
|
111
112
|
}
|
|
112
113
|
async commitTransferredActorTransaction(activation, actor, backlog, sealedSession) {
|
|
113
114
|
const transfer = this.options.actorTransferRuntime;
|
|
@@ -140,7 +141,7 @@ class ZLinkSpotActorAdmissionCoordinator {
|
|
|
140
141
|
}
|
|
141
142
|
}
|
|
142
143
|
async replayActorBacklog(activation, actor, backlog) {
|
|
143
|
-
return await (0, actor_handoff_1.replayActorHandoffBacklog)(backlog, (parts, returnResponse, remoteBoundSessionTarget, fallbackActorRef) => this.dispatchActorPacketDirect(activation, actor.context.actorId, parts, returnResponse, remoteBoundSessionTarget, fallbackActorRef), (index) => this.options.runtimeEventPublisher?.publish({
|
|
144
|
+
return await (0, actor_handoff_1.replayActorHandoffBacklog)(backlog, (parts, returnResponse, remoteBoundSessionTarget, fallbackActorRef) => this.dispatchActorPacketDirect('remote', activation, actor.context.actorId, parts, returnResponse, remoteBoundSessionTarget, fallbackActorRef), (index) => this.options.runtimeEventPublisher?.publish({
|
|
144
145
|
sourceName: 'zlink.framework.actor-handoff',
|
|
145
146
|
timestamp: new Date(),
|
|
146
147
|
marker: 'backlog_enqueued',
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { ApplicationJobOrigin } from '../application-jobs/contracts';
|
|
1
2
|
import type { ActorRef, RoutingId, ZLinkActor, ZLinkMessageSerializer, ZLinkSpot } from '../../contracts';
|
|
2
3
|
import type { Message } from '../../contracts/Common/Message';
|
|
3
4
|
import type { ZLinkRemoteBoundSessionTarget } from '../actors';
|
|
@@ -17,6 +18,7 @@ export interface ZLinkActorRequestTerminal {
|
|
|
17
18
|
}
|
|
18
19
|
/** One admitted Actor packet and the routing context that must move with it. */
|
|
19
20
|
export interface ZLinkActorPacketDelivery {
|
|
21
|
+
readonly origin: ApplicationJobOrigin;
|
|
20
22
|
readonly actorId: string;
|
|
21
23
|
readonly parts: readonly Message[];
|
|
22
24
|
readonly returnResponse: boolean;
|
|
@@ -35,6 +37,7 @@ export interface ZLinkActorPacketDelivery {
|
|
|
35
37
|
* unchanged.
|
|
36
38
|
*/
|
|
37
39
|
export type ZLinkRouteToActorJoinPrewarm = (actorId: string, objectGeneration: bigint, arrival: {
|
|
40
|
+
readonly origin: ApplicationJobOrigin;
|
|
38
41
|
readonly header: Buffer;
|
|
39
42
|
readonly payload: Buffer;
|
|
40
43
|
readonly returnResponse: boolean;
|
|
@@ -69,7 +72,7 @@ interface ZLinkSpotActorPacketDispatchOptions {
|
|
|
69
72
|
export declare class ZLinkSpotActorPacketDispatch {
|
|
70
73
|
private readonly options;
|
|
71
74
|
constructor(options: ZLinkSpotActorPacketDispatchOptions);
|
|
72
|
-
dispatch(actorId: string, parts: readonly Message[], returnResponse?: boolean, remoteBoundSessionTarget?: ZLinkRemoteBoundSessionTarget, fallbackActorRef?: ActorRef, requestTerminal?: ZLinkActorRequestTerminal): Promise<unknown>;
|
|
75
|
+
dispatch(origin: ApplicationJobOrigin, actorId: string, parts: readonly Message[], returnResponse?: boolean, remoteBoundSessionTarget?: ZLinkRemoteBoundSessionTarget, fallbackActorRef?: ActorRef, requestTerminal?: ZLinkActorRequestTerminal): Promise<unknown>;
|
|
73
76
|
dispatchDelivery(delivery: ZLinkActorPacketDelivery): Promise<unknown>;
|
|
74
77
|
private handleMissingActor;
|
|
75
78
|
/**
|
|
@@ -17,8 +17,9 @@ class ZLinkSpotActorPacketDispatch {
|
|
|
17
17
|
constructor(options) {
|
|
18
18
|
this.options = options;
|
|
19
19
|
}
|
|
20
|
-
dispatch(actorId, parts, returnResponse = false, remoteBoundSessionTarget, fallbackActorRef, requestTerminal) {
|
|
20
|
+
dispatch(origin, actorId, parts, returnResponse = false, remoteBoundSessionTarget, fallbackActorRef, requestTerminal) {
|
|
21
21
|
return this.dispatchDelivery({
|
|
22
|
+
origin,
|
|
22
23
|
actorId,
|
|
23
24
|
parts,
|
|
24
25
|
returnResponse,
|
|
@@ -71,7 +72,7 @@ class ZLinkSpotActorPacketDispatch {
|
|
|
71
72
|
}
|
|
72
73
|
const actor = this.options.resolveActor(actorId);
|
|
73
74
|
if (actor === undefined) {
|
|
74
|
-
return this.handleMissingActor(actorId, parts, header, messageKind, action, returnResponse, remoteBoundSessionTarget, fallbackActorRef, requestTerminal);
|
|
75
|
+
return this.handleMissingActor(delivery.origin, actorId, parts, header, messageKind, action, returnResponse, remoteBoundSessionTarget, fallbackActorRef, requestTerminal);
|
|
75
76
|
}
|
|
76
77
|
if (header.name === actors_1.ZLINK_REMOTE_ACTOR_SESSION_DISCONNECTED_PACKET) {
|
|
77
78
|
await this.options.onDisconnectActor(actor);
|
|
@@ -81,7 +82,7 @@ class ZLinkSpotActorPacketDispatch {
|
|
|
81
82
|
return this.dispatchActorPacket(actor, actorId, decodePayload, header, messageKind, action, returnResponse, remoteBoundSessionTarget, fallbackActorRef, requestTerminal, requestDeadlineUnixMs, (0, serial_work_size_1.zlinkSerialWorkOptions)(parts[1].data().byteLength, (0, serial_work_size_1.zlinkMetadataByteLength)(header.metadata)));
|
|
82
83
|
});
|
|
83
84
|
}
|
|
84
|
-
async handleMissingActor(actorId, parts, header, messageKind, action, returnResponse, fallbackBoundSessionTarget, fallbackActorRef, requestTerminal) {
|
|
85
|
+
async handleMissingActor(origin, actorId, parts, header, messageKind, action, returnResponse, fallbackBoundSessionTarget, fallbackActorRef, requestTerminal) {
|
|
85
86
|
if (this.options.routeToActorJoinPrewarm !== undefined &&
|
|
86
87
|
fallbackActorRef !== undefined &&
|
|
87
88
|
parts.length >= 2 &&
|
|
@@ -90,7 +91,7 @@ class ZLinkSpotActorPacketDispatch {
|
|
|
90
91
|
// forever with no reply route. Fall through to the existing
|
|
91
92
|
// missing-actor handling for that shape instead.
|
|
92
93
|
(messageKind !== ZLinkDispatchOptions_1.ZLinkDispatchMessageKind.ActorRequest || requestTerminal !== undefined)) {
|
|
93
|
-
const parked = this.parkForActorJoinPrewarm(actorId, parts, messageKind, returnResponse, fallbackBoundSessionTarget, fallbackActorRef, requestTerminal);
|
|
94
|
+
const parked = this.parkForActorJoinPrewarm(origin, actorId, parts, messageKind, returnResponse, fallbackBoundSessionTarget, fallbackActorRef, requestTerminal);
|
|
94
95
|
if (parked !== undefined)
|
|
95
96
|
return parked;
|
|
96
97
|
}
|
|
@@ -126,7 +127,7 @@ class ZLinkSpotActorPacketDispatch {
|
|
|
126
127
|
* arrival survives independently of the original {@link Message}
|
|
127
128
|
* lifetime.
|
|
128
129
|
*/
|
|
129
|
-
parkForActorJoinPrewarm(actorId, parts, messageKind, returnResponse, remoteBoundSessionTarget, fallbackActorRef, requestTerminal) {
|
|
130
|
+
parkForActorJoinPrewarm(origin, actorId, parts, messageKind, returnResponse, remoteBoundSessionTarget, fallbackActorRef, requestTerminal) {
|
|
130
131
|
const isRequest = messageKind === ZLinkDispatchOptions_1.ZLinkDispatchMessageKind.ActorRequest;
|
|
131
132
|
let resolve = () => undefined;
|
|
132
133
|
let reject = () => undefined;
|
|
@@ -154,6 +155,7 @@ class ZLinkSpotActorPacketDispatch {
|
|
|
154
155
|
}
|
|
155
156
|
}, { prepare: requestTerminal.prepare });
|
|
156
157
|
const route = this.options.routeToActorJoinPrewarm(actorId, fallbackActorRef.objectGeneration, {
|
|
158
|
+
origin,
|
|
157
159
|
header: Buffer.from(parts[0].data()),
|
|
158
160
|
payload: Buffer.from(parts[1].data()),
|
|
159
161
|
returnResponse,
|
|
@@ -83,6 +83,7 @@ class ZLinkSpotActorPacketDrain {
|
|
|
83
83
|
}
|
|
84
84
|
else {
|
|
85
85
|
await this.options.actorPacketHandler({
|
|
86
|
+
origin: 'remote',
|
|
86
87
|
actorId,
|
|
87
88
|
parts,
|
|
88
89
|
returnResponse: false,
|
|
@@ -131,6 +132,7 @@ class ZLinkSpotActorPacketDrain {
|
|
|
131
132
|
async dispatchNoBindActorRequest(info, actorId, parts, actorRef) {
|
|
132
133
|
try {
|
|
133
134
|
const response = await this.options.actorPacketHandler?.({
|
|
135
|
+
origin: 'remote',
|
|
134
136
|
actorId,
|
|
135
137
|
parts,
|
|
136
138
|
returnResponse: true,
|
|
@@ -69,6 +69,7 @@ class ZLinkSpotActorPacketRelayDispatch {
|
|
|
69
69
|
actorPacketRelay.messageFollowContext !== undefined &&
|
|
70
70
|
remoteBoundSessionTarget !== undefined;
|
|
71
71
|
const response = await this.options.actorPacketHandler({
|
|
72
|
+
origin: 'remote',
|
|
72
73
|
actorId: actorPacketRelay.actorId,
|
|
73
74
|
parts: [header, payload],
|
|
74
75
|
returnResponse: !followedBoundSessionReply,
|
|
@@ -287,7 +287,8 @@ class ZLinkEntrySpotActivation {
|
|
|
287
287
|
}
|
|
288
288
|
async dispatchActorPacket(delivery) {
|
|
289
289
|
const { actorId, parts, returnResponse, remoteBoundSessionTarget, fallbackActorRef, messageFollowOrigin } = delivery;
|
|
290
|
-
const handoff = this.options.actorHandoffRuntime?.capture(actorId, parts, returnResponse, remoteBoundSessionTarget, fallbackActorRef, undefined, messageFollowOrigin, (replayedParts, replayReturnResponse, replayRemoteBoundSessionTarget, replayFallbackActorRef) => this.spotSerialExecutor.executeActor(actorId, () => this.dispatchActorPacketInsideMailbox({
|
|
290
|
+
const handoff = this.options.actorHandoffRuntime?.capture(delivery.origin, actorId, parts, returnResponse, remoteBoundSessionTarget, fallbackActorRef, undefined, messageFollowOrigin, (replayedParts, replayReturnResponse, replayRemoteBoundSessionTarget, replayFallbackActorRef) => this.spotSerialExecutor.executeActor(actorId, () => this.dispatchActorPacketInsideMailbox({
|
|
291
|
+
origin: delivery.origin,
|
|
291
292
|
actorId,
|
|
292
293
|
parts: replayedParts,
|
|
293
294
|
returnResponse: replayReturnResponse,
|
|
@@ -300,6 +301,7 @@ class ZLinkEntrySpotActivation {
|
|
|
300
301
|
}
|
|
301
302
|
async replayActorBacklog(actor, backlog) {
|
|
302
303
|
return await (0, actor_handoff_1.replayActorHandoffBacklog)(backlog, (parts, returnResponse, remoteBoundSessionTarget, fallbackActorRef) => this.spotSerialExecutor.executeActor(actor.context.actorId, () => this.dispatchActorPacketInsideMailbox({
|
|
304
|
+
origin: 'remote',
|
|
303
305
|
actorId: actor.context.actorId,
|
|
304
306
|
parts,
|
|
305
307
|
returnResponse,
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { ApplicationJobOrigin } from '../application-jobs/contracts';
|
|
1
2
|
import { type ActorRef, type RoutingId, type ZLinkActor, type ZLinkChannelClient, type ZLinkFanoutClient, type ZLinkMeshNodeDescriptor, type ZLinkMessage, type ZLinkMessageSerializer, type ZLinkSpotPublisherClient, ZLinkFrameworkRuntimeState } from '../../contracts';
|
|
2
3
|
import type { Message } from '../../contracts/Common/Message';
|
|
3
4
|
import type { ZLinkProviderResolver } from '../../contracts/Common/ZLinkProviderResolver';
|
|
@@ -116,7 +117,7 @@ export declare class ZLinkSpotNodeRuntimeManager {
|
|
|
116
117
|
private ensureEntryActivation;
|
|
117
118
|
private initializeEntrySpot;
|
|
118
119
|
private primaryEntryActivation;
|
|
119
|
-
dispatchEntryActorPacket(actorId: string, parts: readonly Message[], returnResponse?: boolean, remoteBoundSessionTarget?: ZLinkRemoteBoundSessionTarget, fallbackActorRef?: ActorRef, requestTerminal?: (response: unknown) => Promise<void> | void, messageFollowOrigin?: ZLinkMessageFollowOrigin): Promise<unknown>;
|
|
120
|
+
dispatchEntryActorPacket(origin: ApplicationJobOrigin, actorId: string, parts: readonly Message[], returnResponse?: boolean, remoteBoundSessionTarget?: ZLinkRemoteBoundSessionTarget, fallbackActorRef?: ActorRef, requestTerminal?: (response: unknown) => Promise<void> | void, messageFollowOrigin?: ZLinkMessageFollowOrigin): Promise<unknown>;
|
|
120
121
|
dispatchEntryActorJoin(meshName: string, actor: ZLinkActor, handoffBacklog?: readonly ZLinkActorHandoffPacket[]): Promise<void>;
|
|
121
122
|
executeEntryActor<T>(meshName: string, actorId: string, operation: () => Promise<T>): Promise<T>;
|
|
122
123
|
publish(meshName: string, channelName: string, topic: string, packetName: string | undefined, event: Message, signal?: AbortSignal, metadata?: ReadonlyMap<string, string>): Promise<ZLinkSubmitResult>;
|
|
@@ -17,7 +17,6 @@ const channel_clients_1 = require("../channels/channel-clients");
|
|
|
17
17
|
const channel_envelope_1 = require("../channels/channel-envelope");
|
|
18
18
|
const configuration_1 = require("../configuration");
|
|
19
19
|
const flow_context_1 = require("../diagnostics/flow-context");
|
|
20
|
-
const execution_1 = require("../execution");
|
|
21
20
|
const service_runtime_contracts_1 = require("../foundation/service-runtime-contracts");
|
|
22
21
|
const framework_errors_internal_1 = require("../framework-errors-internal");
|
|
23
22
|
const application_job_queue_1 = require("../host/application-job-queue");
|
|
@@ -146,6 +145,7 @@ class ZLinkSpotNodeRuntimeManager {
|
|
|
146
145
|
routingId,
|
|
147
146
|
receiveTimeoutMs: spotNode.router?.receiveTimeoutMs,
|
|
148
147
|
applicationJobQueue: this.applicationJobQueue,
|
|
148
|
+
infrastructureTaskRunner: this.options.detachedTaskRunner,
|
|
149
149
|
applicationJobReceiveFlowFailureSink: this.options.applicationJobReceiveFlowFailureSink,
|
|
150
150
|
peerAdmissionSealed: () => this.options.peerAdmissionSealed?.(spotNodeName) ?? false
|
|
151
151
|
});
|
|
@@ -177,6 +177,7 @@ class ZLinkSpotNodeRuntimeManager {
|
|
|
177
177
|
let pump;
|
|
178
178
|
const completions = new mesh_completion_table_1.ZLinkMeshCompletionTable();
|
|
179
179
|
try {
|
|
180
|
+
node.setCompletionHandler((terminal, materialize) => completions.complete(terminal, materialize));
|
|
180
181
|
node.setBind(bind);
|
|
181
182
|
if (spotNode.router?.advertiseHost !== undefined) {
|
|
182
183
|
node.setAdvertiseHost(spotNode.router.advertiseHost);
|
|
@@ -604,15 +605,6 @@ class ZLinkSpotNodeRuntimeManager {
|
|
|
604
605
|
this.meshCompletions.clear();
|
|
605
606
|
}
|
|
606
607
|
async dispatchMeshRecord(meshName, owner, record) {
|
|
607
|
-
if (record.kind === service_runtime_contracts_1.ReceiveKind.Completion) {
|
|
608
|
-
(0, execution_1.requireZLinkInfrastructureExecutionArea)();
|
|
609
|
-
const completions = this.meshCompletions.get(meshName);
|
|
610
|
-
if (completions === undefined) {
|
|
611
|
-
throw new configuration_1.ZLinkConfigurationException(`MeshNode '${meshName}' received a completion before its completion table was registered.`);
|
|
612
|
-
}
|
|
613
|
-
completions.complete(record);
|
|
614
|
-
return;
|
|
615
|
-
}
|
|
616
608
|
const node = this.meshNodes.get(meshName);
|
|
617
609
|
const targetsEntrySpot = owner.spotId === null ||
|
|
618
610
|
(node !== undefined &&
|
|
@@ -745,7 +737,7 @@ class ZLinkSpotNodeRuntimeManager {
|
|
|
745
737
|
primaryEntryActivation() {
|
|
746
738
|
return this.entryActivations.values().next().value;
|
|
747
739
|
}
|
|
748
|
-
async dispatchEntryActorPacket(actorId, parts, returnResponse = false, remoteBoundSessionTarget, fallbackActorRef, requestTerminal, messageFollowOrigin) {
|
|
740
|
+
async dispatchEntryActorPacket(origin, actorId, parts, returnResponse = false, remoteBoundSessionTarget, fallbackActorRef, requestTerminal, messageFollowOrigin) {
|
|
749
741
|
let activation = this.primaryEntryActivation();
|
|
750
742
|
if (activation === undefined) {
|
|
751
743
|
const candidates = this.options.primaryMeshName === undefined
|
|
@@ -774,6 +766,7 @@ class ZLinkSpotNodeRuntimeManager {
|
|
|
774
766
|
throw new configuration_1.ZLinkConfigurationException('Entry Spot actor packet dispatch requires an Entry Spot.');
|
|
775
767
|
}
|
|
776
768
|
return await activation.dispatchActorPacket({
|
|
769
|
+
origin,
|
|
777
770
|
actorId,
|
|
778
771
|
parts,
|
|
779
772
|
returnResponse,
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { RoutingId } from '../../contracts/Common';
|
|
2
2
|
import type { ZLinkFrameworkRuntimeState, ZLinkSpotKind } from '../../contracts';
|
|
3
3
|
export interface ZLinkSpotRouteResolver {
|
|
4
|
+
resolve(spotId: RoutingId, signal: AbortSignal | undefined, instanceIntent: true): Promise<ZLinkSpotRouteTarget | ZLinkInstanceReactivationRoute>;
|
|
4
5
|
resolve(spotId: RoutingId, signal?: AbortSignal): Promise<ZLinkSpotRouteTarget>;
|
|
5
6
|
invalidate?(spotId: RoutingId): void;
|
|
6
7
|
}
|
|
@@ -26,3 +27,8 @@ export interface ZLinkSpotRouteTarget {
|
|
|
26
27
|
/** Current state of the owning MeshNode, when the route was resolved from Location Store. */
|
|
27
28
|
readonly targetNodeState?: ZLinkFrameworkRuntimeState;
|
|
28
29
|
}
|
|
30
|
+
export interface ZLinkInstanceReactivationRoute extends Pick<ZLinkSpotRouteTarget, 'spotId' | 'spotKind' | 'stableType'> {
|
|
31
|
+
readonly kind: 'coldActivation';
|
|
32
|
+
readonly meshName: string;
|
|
33
|
+
readonly stableType: string;
|
|
34
|
+
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { ApplicationJobOrigin } from '../application-jobs/contracts';
|
|
1
2
|
import type { ActorRef, RoutingId, ZLinkActor, ZLinkActorJoinOperationId, ZLinkSpot } from '../../contracts';
|
|
2
3
|
import type { Message } from '../../contracts/Common/Message';
|
|
3
4
|
import type { ZLinkMessageFollowOrigin } from '../foundation/service-runtime-contracts';
|
|
@@ -44,5 +45,5 @@ export interface ZLinkSpotBoundSessionRuntime {
|
|
|
44
45
|
sendActorError(actorId: string, packetName: string, requestSeq: bigint, error: unknown, metadata: ReadonlyMap<string, string>, fallbackBoundSessionTarget?: ZLinkRemoteBoundSessionTarget, actorRef?: ActorRef, signal?: AbortSignal): Promise<void>;
|
|
45
46
|
}
|
|
46
47
|
export interface ZLinkSpotActorHandoffRuntime {
|
|
47
|
-
capture(actorId: string, parts: readonly Message[], returnResponse?: boolean, remoteBoundSessionTarget?: ZLinkRemoteBoundSessionTarget, fallbackActorRef?: ActorRef, deadlineUnixMs?: number, messageFollowOrigin?: ZLinkMessageFollowOrigin, provisionalReplay?: ZLinkActorHandoffDispatch): Promise<unknown> | undefined;
|
|
48
|
+
capture(origin: ApplicationJobOrigin, actorId: string, parts: readonly Message[], returnResponse?: boolean, remoteBoundSessionTarget?: ZLinkRemoteBoundSessionTarget, fallbackActorRef?: ActorRef, deadlineUnixMs?: number, messageFollowOrigin?: ZLinkMessageFollowOrigin, provisionalReplay?: ZLinkActorHandoffDispatch): Promise<unknown> | undefined;
|
|
48
49
|
}
|
|
@@ -759,7 +759,7 @@ class ZLinkStreamSessionNodeRuntime {
|
|
|
759
759
|
let packet;
|
|
760
760
|
let packetTransferred = false;
|
|
761
761
|
try {
|
|
762
|
-
permit = await this.options.applicationJobQueue.acquire(signal);
|
|
762
|
+
permit = await this.options.applicationJobQueue.acquire(signal, 'remote');
|
|
763
763
|
if (this.isReceiveStopped(signal)) {
|
|
764
764
|
permit.releaseAfterInternalProcessing();
|
|
765
765
|
break;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zlink-systems/framework",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.30.0",
|
|
4
4
|
"license": "SEE LICENSE IN LICENSE",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
"dependencies": {
|
|
20
20
|
"@opentelemetry/api": "^1.9.1",
|
|
21
21
|
"@opentelemetry/api-logs": "^0.221.0",
|
|
22
|
-
"@zlink-systems/stream-wire": "0.
|
|
23
|
-
"@zlink-systems/zlink": "1.
|
|
22
|
+
"@zlink-systems/stream-wire": "0.30.0",
|
|
23
|
+
"@zlink-systems/zlink": "1.19.0"
|
|
24
24
|
}
|
|
25
25
|
}
|