@zlink-systems/framework 0.30.1 → 0.30.3
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/Common/ZLinkEncodedPayload.d.ts +6 -0
- package/dist/contracts/Common/ZLinkEncodedPayload.js +18 -3
- package/dist/contracts/Common/encoded-payload-storage.d.ts +1 -1
- package/dist/contracts/Common/encoded-payload-storage.js +5 -2
- package/dist/contracts/Configuration/Builders.d.ts +1 -1
- package/dist/contracts/Configuration/RegistrationBuilderPolicy.d.ts +2 -1
- package/dist/contracts/Configuration/RegistrationBuilderPolicy.js +5 -1
- package/dist/contracts/Configuration/RegistrationBuilders.js +2 -2
- package/dist/contracts/Configuration/RegistrationTypes.d.ts +1 -0
- package/dist/contracts/Dispatch/ZLinkDispatchOptions.d.ts +2 -2
- package/dist/contracts/Locations/Rows.d.ts +2 -0
- package/dist/contracts/Spots/Contracts.d.ts +4 -0
- package/dist/contracts/Spots/ZLinkSpot.d.ts +3 -3
- package/dist/runtime/abort.d.ts +5 -0
- package/dist/runtime/abort.js +10 -0
- package/dist/runtime/actors/actor-authority-publication.js +3 -2
- package/dist/runtime/actors/actor-client.d.ts +0 -1
- package/dist/runtime/actors/actor-client.js +38 -45
- package/dist/runtime/actors/actor-context.d.ts +2 -0
- package/dist/runtime/actors/actor-context.js +46 -9
- package/dist/runtime/actors/actor-handoff.d.ts +7 -3
- package/dist/runtime/actors/actor-handoff.js +212 -88
- package/dist/runtime/actors/actor-join-relocation.d.ts +2 -0
- package/dist/runtime/actors/actor-local-native-join.js +4 -0
- package/dist/runtime/actors/actor-mailbox.js +27 -1
- package/dist/runtime/actors/actor-remote-joiner.js +3 -1
- package/dist/runtime/actors/actor-reply.d.ts +4 -0
- package/dist/runtime/actors/actor-reply.js +29 -0
- package/dist/runtime/actors/actor-runtime-contracts.d.ts +2 -0
- package/dist/runtime/actors/actor-runtime-state.js +2 -20
- package/dist/runtime/actors/actor-source-transfer.d.ts +1 -17
- package/dist/runtime/actors/index.d.ts +6 -2
- package/dist/runtime/actors/index.js +37 -21
- package/dist/runtime/actors/session-disconnected-wire.d.ts +8 -0
- package/dist/runtime/actors/session-disconnected-wire.js +48 -0
- package/dist/runtime/admission.d.ts +9 -1
- package/dist/runtime/admission.js +55 -32
- package/dist/runtime/application-jobs/application-job-queue-scope.d.ts +13 -0
- package/dist/runtime/application-jobs/application-job-queue-scope.js +27 -1
- package/dist/runtime/application-jobs/contracts.d.ts +2 -0
- package/dist/runtime/backend/contracts/index.d.ts +19 -3
- package/dist/runtime/backend/mesh-actor-session-node-adapter.js +2 -2
- package/dist/runtime/backend/mesh-completion-table.js +5 -0
- package/dist/runtime/backend/mesh-dispatch-pump.d.ts +26 -2
- package/dist/runtime/backend/mesh-dispatch-pump.js +193 -107
- package/dist/runtime/backend/node/node-raw-binding-port.js +90 -58
- package/dist/runtime/backend/node/node-raw-mesh-backend.d.ts +33 -8
- package/dist/runtime/backend/node/node-raw-mesh-backend.js +142 -143
- package/dist/runtime/backend/node/node-socket-backend-adapter.d.ts +1 -1
- package/dist/runtime/backend/node/node-socket-backend-adapter.js +5 -5
- package/dist/runtime/channels/channel-clients.d.ts +1 -0
- package/dist/runtime/channels/channel-clients.js +20 -5
- package/dist/runtime/channels/channel-dispatch-pipeline.d.ts +22 -3
- package/dist/runtime/channels/channel-dispatch-pipeline.js +103 -57
- package/dist/runtime/channels/channel-dispatchers.d.ts +3 -2
- package/dist/runtime/channels/channel-dispatchers.js +44 -37
- package/dist/runtime/channels/channel-envelope.d.ts +1 -0
- package/dist/runtime/channels/channel-envelope.js +74 -31
- package/dist/runtime/channels/channel-runtime-lifecycle.d.ts +4 -3
- package/dist/runtime/channels/channel-runtime-lifecycle.js +19 -24
- package/dist/runtime/channels/channel-runtime-manager.d.ts +3 -2
- package/dist/runtime/channels/channel-runtime-manager.js +4 -4
- package/dist/runtime/channels/channel-transports.d.ts +0 -1
- package/dist/runtime/channels/channel-transports.js +35 -33
- package/dist/runtime/channels/client-server-location-runtime.js +5 -4
- package/dist/runtime/channels/dispatch-error-reporter.d.ts +2 -1
- package/dist/runtime/channels/dispatch-error-reporter.js +2 -1
- package/dist/runtime/channels/fanout-location-runtime.d.ts +1 -1
- package/dist/runtime/channels/fanout-location-runtime.js +3 -3
- package/dist/runtime/diagnostics/flow-context.js +19 -7
- package/dist/runtime/diagnostics/index.js +4 -9
- package/dist/runtime/diagnostics/message-flow.d.ts +8 -0
- package/dist/runtime/diagnostics/message-flow.js +35 -5
- package/dist/runtime/diagnostics/runtime-metrics.d.ts +2 -2
- package/dist/runtime/diagnostics/runtime-metrics.js +10 -8
- package/dist/runtime/execution/index.d.ts +4 -2
- package/dist/runtime/execution/index.js +40 -19
- package/dist/runtime/execution/serial-execution-queue.d.ts +4 -0
- package/dist/runtime/execution/serial-execution-queue.js +21 -2
- package/dist/runtime/execution/state-lane.d.ts +2 -0
- package/dist/runtime/execution/state-lane.js +39 -11
- package/dist/runtime/foundation/operation-registry.d.ts +25 -1
- package/dist/runtime/foundation/operation-registry.js +86 -18
- package/dist/runtime/foundation/raw-service-mesh-runtime.d.ts +39 -3
- package/dist/runtime/foundation/raw-service-mesh-runtime.js +151 -55
- package/dist/runtime/foundation/service-liveness-registry.d.ts +12 -1
- package/dist/runtime/foundation/service-liveness-registry.js +38 -0
- package/dist/runtime/foundation/service-mailbox.d.ts +7 -0
- package/dist/runtime/foundation/service-maintenance-runtime.js +1 -6
- package/dist/runtime/foundation/service-relocation-object-owner.d.ts +2 -3
- package/dist/runtime/foundation/service-relocation-object-owner.js +48 -35
- package/dist/runtime/foundation/service-relocation-runtime.js +7 -3
- package/dist/runtime/foundation/service-runtime-contracts.d.ts +8 -1
- package/dist/runtime/foundation/service-session-binding-ingress-port.d.ts +2 -1
- package/dist/runtime/foundation/service-stateful-registry.d.ts +5 -4
- package/dist/runtime/foundation/service-stateful-registry.js +24 -26
- package/dist/runtime/foundation/service-stateful-runtime.d.ts +72 -6
- package/dist/runtime/foundation/service-stateful-runtime.js +444 -117
- package/dist/runtime/foundation/service-stateful-wire-codec.d.ts +14 -1
- package/dist/runtime/foundation/service-stateful-wire-codec.js +48 -27
- package/dist/runtime/foundation/service-wire-binary-primitives.d.ts +6 -1
- package/dist/runtime/foundation/service-wire-binary-primitives.js +27 -11
- package/dist/runtime/foundation/service-wire-constants.generated.d.ts +1 -0
- package/dist/runtime/foundation/service-wire-constants.generated.js +1 -0
- package/dist/runtime/foundation/service-wire-m6a-codec.d.ts +10 -0
- package/dist/runtime/foundation/service-wire-m6a-codec.js +166 -53
- package/dist/runtime/host/actor-packet-relay.d.ts +6 -4
- package/dist/runtime/host/actor-packet-relay.js +59 -72
- package/dist/runtime/host/actor-placement-coordinator.js +25 -8
- package/dist/runtime/host/actor-transfer-runtime.d.ts +7 -31
- package/dist/runtime/host/actor-transfer-runtime.js +85 -331
- package/dist/runtime/host/application-job-queue.d.ts +24 -3
- package/dist/runtime/host/application-job-queue.js +28 -41
- package/dist/runtime/host/index.d.ts +5 -1
- package/dist/runtime/host/index.js +171 -97
- package/dist/runtime/host/location-runtime-owner.js +2 -6
- package/dist/runtime/host/mesh-router-resolver.d.ts +4 -0
- package/dist/runtime/host/mesh-router-resolver.js +14 -6
- package/dist/runtime/host/remote-bound-session-relay.d.ts +2 -4
- package/dist/runtime/host/remote-bound-session-relay.js +71 -190
- package/dist/runtime/host/route-mesh-runtime.d.ts +2 -2
- package/dist/runtime/host/route-mesh-runtime.js +5 -3
- package/dist/runtime/host/runtime-shutdown.d.ts +1 -0
- package/dist/runtime/host/runtime-shutdown.js +3 -2
- package/dist/runtime/host/service-relocation-host-runtime.d.ts +17 -7
- package/dist/runtime/host/service-relocation-host-runtime.js +550 -367
- package/dist/runtime/host/spot-runtime-options-factory.js +15 -7
- package/dist/runtime/host/user-spot-creation-coordinator.js +33 -84
- package/dist/runtime/locations/auto-connect-loop.d.ts +4 -0
- package/dist/runtime/locations/auto-connect-loop.js +35 -14
- package/dist/runtime/locations/auto-connect-reconciler.js +0 -6
- package/dist/runtime/locations/auto-connect-types.d.ts +0 -1
- package/dist/runtime/locations/descriptor-publication.d.ts +4 -0
- package/dist/runtime/locations/descriptor-publication.js +11 -0
- package/dist/runtime/locations/domain-store-contract.d.ts +1 -0
- package/dist/runtime/locations/in-memory-authority-store.d.ts +7 -1
- package/dist/runtime/locations/in-memory-authority-store.js +56 -19
- package/dist/runtime/locations/in-memory-location-store.js +1 -10
- package/dist/runtime/locations/index.d.ts +1 -0
- package/dist/runtime/locations/index.js +1 -0
- package/dist/runtime/locations/lease-tracker.js +1 -6
- package/dist/runtime/locations/location-store-repository.d.ts +51 -1
- package/dist/runtime/locations/location-store-repository.js +363 -139
- package/dist/runtime/locations/relocation-blob.d.ts +18 -1
- package/dist/runtime/locations/relocation-blob.js +52 -1
- package/dist/runtime/locations/request-source-resolver.d.ts +37 -0
- package/dist/runtime/locations/request-source-resolver.js +80 -0
- package/dist/runtime/locations/resolvers.js +1 -1
- package/dist/runtime/locations/runtime.d.ts +6 -2
- package/dist/runtime/locations/runtime.js +37 -30
- package/dist/runtime/messaging/payload-codec.d.ts +7 -1
- package/dist/runtime/messaging/payload-codec.js +7 -6
- package/dist/runtime/messaging/request-result.js +29 -26
- package/dist/runtime/protocol/service_wire_codec.generated.d.ts +19 -1
- package/dist/runtime/protocol/service_wire_codec.generated.js +85 -0
- package/dist/runtime/protocol/service_wire_pilot_codec.generated.d.ts +7 -1
- package/dist/runtime/protocol/service_wire_pilot_codec.generated.js +23 -7
- package/dist/runtime/spots/formal-remote-actor-admission-registry.js +3 -2
- package/dist/runtime/spots/index.d.ts +18 -11
- package/dist/runtime/spots/index.js +234 -179
- package/dist/runtime/spots/spot-activation-registry.d.ts +4 -2
- package/dist/runtime/spots/spot-activation-registry.js +21 -11
- package/dist/runtime/spots/spot-activation-state.d.ts +1 -1
- package/dist/runtime/spots/spot-activation-state.js +7 -7
- package/dist/runtime/spots/spot-activation.d.ts +6 -3
- package/dist/runtime/spots/spot-activation.js +123 -44
- package/dist/runtime/spots/spot-actor-admission-coordinator.d.ts +1 -0
- package/dist/runtime/spots/spot-actor-admission-coordinator.js +13 -22
- package/dist/runtime/spots/spot-actor-membership.d.ts +0 -1
- package/dist/runtime/spots/spot-actor-membership.js +0 -8
- package/dist/runtime/spots/spot-actor-packet-dispatch.js +33 -8
- package/dist/runtime/spots/spot-actor-packet-drain.js +5 -33
- package/dist/runtime/spots/spot-entry-activation.d.ts +2 -0
- package/dist/runtime/spots/spot-entry-activation.js +14 -9
- package/dist/runtime/spots/spot-handler-registry.d.ts +4 -3
- package/dist/runtime/spots/spot-handler-registry.js +6 -2
- package/dist/runtime/spots/spot-manager-internal-contracts.d.ts +2 -2
- package/dist/runtime/spots/spot-manager-public.js +2 -2
- package/dist/runtime/spots/spot-node-autoconnect.d.ts +2 -1
- package/dist/runtime/spots/spot-node-autoconnect.js +18 -39
- package/dist/runtime/spots/spot-node-runtime-manager.d.ts +19 -2
- package/dist/runtime/spots/spot-node-runtime-manager.js +115 -50
- package/dist/runtime/spots/spot-outbound.js +3 -3
- package/dist/runtime/spots/spot-remote-codec.js +5 -1
- package/dist/runtime/spots/spot-runtime-ports.d.ts +0 -1
- package/dist/runtime/spots/spot-serial-executor.d.ts +10 -0
- package/dist/runtime/spots/spot-serial-executor.js +61 -8
- package/dist/runtime/spots/spot-serial-turn-executor.js +29 -6
- package/dist/runtime/spots/spot-subscription-dispatch.js +1 -1
- package/dist/runtime/spots/spot-timer.d.ts +57 -5
- package/dist/runtime/spots/spot-timer.js +287 -103
- package/dist/runtime/streams/actor-session-binding-registry.d.ts +42 -11
- package/dist/runtime/streams/actor-session-binding-registry.js +165 -48
- package/dist/runtime/streams/actor-session-binding-runtime-owner.d.ts +8 -4
- package/dist/runtime/streams/bound-actor-relay-sender.d.ts +2 -1
- package/dist/runtime/streams/bound-actor-relay-sender.js +15 -8
- package/dist/runtime/streams/bound-session-service.d.ts +1 -1
- package/dist/runtime/streams/bound-session-service.js +6 -11
- package/dist/runtime/streams/index.d.ts +3 -2
- package/dist/runtime/streams/index.js +6 -4
- package/dist/runtime/streams/managed-stream.js +3 -2
- package/dist/runtime/streams/native-fallback-bound-session.js +8 -73
- package/dist/runtime/streams/session-actor-coordinator.d.ts +2 -8
- package/dist/runtime/streams/session-actor-coordinator.js +15 -32
- package/dist/runtime/streams/stream-binding-runtime-ports.d.ts +3 -10
- package/dist/runtime/streams/stream-session-runtime.js +1 -4
- package/dist/runtime/workers/index.js +1 -1
- package/package.json +3 -3
- package/src/contracts/Common/ZLinkEncodedPayload.ts +24 -4
- package/src/contracts/Common/encoded-payload-storage.ts +6 -3
- package/src/contracts/Configuration/Builders.ts +4 -1
- package/src/contracts/Configuration/RegistrationBuilderPolicy.ts +7 -2
- package/src/contracts/Configuration/RegistrationBuilders.ts +6 -2
- package/src/contracts/Configuration/RegistrationTypes.ts +1 -0
- package/src/contracts/Dispatch/ZLinkDispatchOptions.ts +2 -1
- package/src/contracts/Locations/Rows.ts +2 -0
- package/src/contracts/Spots/Contracts.ts +8 -0
- package/src/contracts/Spots/ZLinkSpot.ts +3 -3
- package/src/runtime/abort.ts +12 -0
- package/src/runtime/actors/actor-authority-publication.ts +3 -2
- package/src/runtime/actors/actor-client.ts +61 -70
- package/src/runtime/actors/actor-context.ts +49 -9
- package/src/runtime/actors/actor-handoff.ts +282 -106
- package/src/runtime/actors/actor-join-relocation.ts +2 -0
- package/src/runtime/actors/actor-local-native-join.ts +4 -0
- package/src/runtime/actors/actor-mailbox.ts +40 -2
- package/src/runtime/actors/actor-remote-joiner.ts +6 -1
- package/src/runtime/actors/actor-reply.ts +42 -0
- package/src/runtime/actors/actor-runtime-contracts.ts +2 -0
- package/src/runtime/actors/actor-runtime-state.ts +2 -20
- package/src/runtime/actors/actor-source-transfer.ts +1 -34
- package/src/runtime/actors/index.ts +41 -27
- package/src/runtime/actors/session-disconnected-wire.ts +66 -0
- package/src/runtime/admission.ts +69 -34
- package/src/runtime/application-jobs/application-job-queue-scope.ts +33 -1
- package/src/runtime/application-jobs/contracts.ts +2 -0
- package/src/runtime/backend/contracts/index.ts +39 -4
- package/src/runtime/backend/mesh-actor-session-node-adapter.ts +5 -3
- package/src/runtime/backend/mesh-completion-table.ts +4 -0
- package/src/runtime/backend/mesh-dispatch-pump.ts +223 -124
- package/src/runtime/backend/node/node-raw-binding-port.ts +106 -70
- package/src/runtime/backend/node/node-raw-mesh-backend.ts +221 -170
- package/src/runtime/backend/node/node-socket-backend-adapter.ts +5 -5
- package/src/runtime/channels/channel-clients.ts +49 -24
- package/src/runtime/channels/channel-dispatch-pipeline.ts +173 -124
- package/src/runtime/channels/channel-dispatchers.ts +116 -72
- package/src/runtime/channels/channel-envelope.ts +105 -36
- package/src/runtime/channels/channel-runtime-lifecycle.ts +13 -13
- package/src/runtime/channels/channel-runtime-manager.ts +12 -5
- package/src/runtime/channels/channel-transports.ts +49 -58
- package/src/runtime/channels/client-server-location-runtime.ts +11 -10
- package/src/runtime/channels/dispatch-error-reporter.ts +4 -2
- package/src/runtime/channels/fanout-location-runtime.ts +17 -9
- package/src/runtime/diagnostics/flow-context.ts +20 -7
- package/src/runtime/diagnostics/index.ts +1 -7
- package/src/runtime/diagnostics/message-flow.ts +47 -9
- package/src/runtime/diagnostics/runtime-metrics.ts +12 -10
- package/src/runtime/execution/index.ts +56 -28
- package/src/runtime/execution/serial-execution-queue.ts +31 -4
- package/src/runtime/execution/state-lane.ts +60 -14
- package/src/runtime/foundation/operation-registry.ts +98 -20
- package/src/runtime/foundation/raw-service-mesh-runtime.ts +244 -67
- package/src/runtime/foundation/service-liveness-registry.ts +39 -0
- package/src/runtime/foundation/service-mailbox.ts +8 -0
- package/src/runtime/foundation/service-maintenance-runtime.ts +1 -8
- package/src/runtime/foundation/service-relocation-object-owner.ts +54 -37
- package/src/runtime/foundation/service-relocation-runtime.ts +7 -3
- package/src/runtime/foundation/service-runtime-contracts.ts +12 -1
- package/src/runtime/foundation/service-session-binding-ingress-port.ts +2 -1
- package/src/runtime/foundation/service-stateful-registry.ts +38 -35
- package/src/runtime/foundation/service-stateful-runtime.ts +667 -152
- package/src/runtime/foundation/service-stateful-wire-codec.ts +49 -11
- package/src/runtime/foundation/service-wire-binary-primitives.ts +35 -12
- package/src/runtime/foundation/service-wire-constants.generated.ts +1 -0
- package/src/runtime/foundation/service-wire-m6a-codec.ts +187 -51
- package/src/runtime/host/actor-packet-relay.ts +113 -94
- package/src/runtime/host/actor-placement-coordinator.ts +31 -8
- package/src/runtime/host/actor-transfer-runtime.ts +104 -430
- package/src/runtime/host/application-job-queue.ts +29 -44
- package/src/runtime/host/index.ts +286 -129
- package/src/runtime/host/location-runtime-owner.ts +2 -6
- package/src/runtime/host/mesh-router-resolver.ts +13 -5
- package/src/runtime/host/remote-bound-session-relay.ts +86 -248
- package/src/runtime/host/route-mesh-runtime.ts +11 -5
- package/src/runtime/host/runtime-shutdown.ts +15 -4
- package/src/runtime/host/service-relocation-host-runtime.ts +784 -475
- package/src/runtime/host/spot-runtime-options-factory.ts +18 -7
- package/src/runtime/host/user-spot-creation-coordinator.ts +41 -100
- package/src/runtime/locations/auto-connect-loop.ts +38 -14
- package/src/runtime/locations/auto-connect-reconciler.ts +0 -6
- package/src/runtime/locations/auto-connect-types.ts +0 -1
- package/src/runtime/locations/descriptor-publication.ts +7 -0
- package/src/runtime/locations/domain-store-contract.ts +5 -0
- package/src/runtime/locations/in-memory-authority-store.ts +85 -23
- package/src/runtime/locations/in-memory-location-store.ts +1 -12
- package/src/runtime/locations/index.ts +1 -0
- package/src/runtime/locations/lease-tracker.ts +2 -9
- package/src/runtime/locations/location-store-repository.ts +628 -152
- package/src/runtime/locations/relocation-blob.ts +75 -1
- package/src/runtime/locations/request-source-resolver.ts +138 -0
- package/src/runtime/locations/resolvers.ts +2 -2
- package/src/runtime/locations/runtime.ts +70 -40
- package/src/runtime/messaging/payload-codec.ts +8 -11
- package/src/runtime/messaging/request-result.ts +33 -29
- package/src/runtime/protocol/service_wire_codec.generated.ts +87 -4
- package/src/runtime/protocol/service_wire_pilot_codec.generated.ts +13 -10
- package/src/runtime/spots/formal-remote-actor-admission-registry.ts +3 -2
- package/src/runtime/spots/index.ts +375 -287
- package/src/runtime/spots/spot-activation-registry.ts +25 -13
- package/src/runtime/spots/spot-activation-state.ts +12 -19
- package/src/runtime/spots/spot-activation.ts +170 -86
- package/src/runtime/spots/spot-actor-admission-coordinator.ts +25 -55
- package/src/runtime/spots/spot-actor-membership.ts +0 -15
- package/src/runtime/spots/spot-actor-packet-dispatch.ts +56 -11
- package/src/runtime/spots/spot-actor-packet-drain.ts +9 -52
- package/src/runtime/spots/spot-entry-activation.ts +24 -19
- package/src/runtime/spots/spot-handler-registry.ts +15 -4
- package/src/runtime/spots/spot-manager-internal-contracts.ts +2 -2
- package/src/runtime/spots/spot-manager-public.ts +2 -2
- package/src/runtime/spots/spot-node-autoconnect.ts +22 -45
- package/src/runtime/spots/spot-node-runtime-manager.ts +197 -67
- package/src/runtime/spots/spot-outbound.ts +3 -3
- package/src/runtime/spots/spot-remote-codec.ts +9 -2
- package/src/runtime/spots/spot-runtime-ports.ts +0 -1
- package/src/runtime/spots/spot-serial-executor.ts +97 -25
- package/src/runtime/spots/spot-serial-turn-executor.ts +33 -8
- package/src/runtime/spots/spot-subscription-dispatch.ts +1 -1
- package/src/runtime/spots/spot-timer.ts +413 -157
- package/src/runtime/streams/actor-session-binding-registry.ts +236 -64
- package/src/runtime/streams/actor-session-binding-runtime-owner.ts +16 -8
- package/src/runtime/streams/bound-actor-relay-sender.ts +23 -9
- package/src/runtime/streams/bound-session-service.ts +7 -10
- package/src/runtime/streams/index.ts +12 -6
- package/src/runtime/streams/managed-stream.ts +4 -2
- package/src/runtime/streams/native-fallback-bound-session.ts +14 -103
- package/src/runtime/streams/session-actor-coordinator.ts +39 -88
- package/src/runtime/streams/stream-binding-runtime-ports.ts +3 -9
- package/src/runtime/streams/stream-session-runtime.ts +1 -5
- package/src/runtime/workers/index.ts +1 -1
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.DefaultZLinkSpotManager = exports.ZLinkPublicSpotManager = exports.ZLinkSpotNodeRuntimeManager = exports.createFrameworkEntrySpotId = exports.ZLinkEntrySpotActivation = exports.ZLinkRuntimeSpotPublisherTransport = exports.DefaultZLinkSpotHandlerRegistry = exports.DefaultZLinkSpotOutbound = exports.ZLinkSpotTimerRegistry = exports.ZLinkManagedTimer = exports.ZLinkSpotSerialExecutor = exports.ZLinkSpotSerialTurnExecutor = exports.ZLinkSpotActorAdmissionCoordinator = exports.ZLinkSpotRoutedBoundSessionDispatch = exports.sendToSpotHandle = exports.requestToSpotHandle = exports.resolveSpotHandle = exports.createSpotHandle = void 0;
|
|
3
|
+
exports.DefaultZLinkSpotManager = exports.ZLinkPublicSpotManager = exports.ZLinkSpotNodeRuntimeManager = exports.registrationAcceptsNewActor = exports.createFrameworkEntrySpotId = exports.ZLinkEntrySpotActivation = exports.ZLinkRuntimeSpotPublisherTransport = exports.DefaultZLinkSpotHandlerRegistry = exports.DefaultZLinkSpotOutbound = exports.ZLinkSpotTimerRegistry = exports.ZLinkManagedTimer = exports.ZLinkSpotSerialExecutor = exports.ZLinkSpotSerialTurnExecutor = exports.ZLinkSpotActorAdmissionCoordinator = exports.ZLinkSpotRoutedBoundSessionDispatch = exports.sendToSpotHandle = exports.requestToSpotHandle = exports.resolveSpotHandle = exports.createSpotHandle = void 0;
|
|
4
|
+
const actor_reply_1 = require("../actors/actor-reply");
|
|
5
|
+
const bound_session_response_target_1 = require("../streams/bound-session-response-target");
|
|
6
|
+
const actor_handoff_1 = require("../actors/actor-handoff");
|
|
7
|
+
const routing_id_1 = require("../routing-id");
|
|
4
8
|
const dispatch_error_details_1 = require("../diagnostics/dispatch-error-details");
|
|
5
9
|
var spot_handle_1 = require("./spot-handle");
|
|
6
10
|
Object.defineProperty(exports, "createSpotHandle", { enumerable: true, get: function () { return spot_handle_1.createSpotHandle; } });
|
|
@@ -29,9 +33,9 @@ const payload_codec_1 = require("../messaging/payload-codec");
|
|
|
29
33
|
const channel_envelope_1 = require("../channels/channel-envelope");
|
|
30
34
|
const protocol_1 = require("../streams/protocol");
|
|
31
35
|
const actor_remote_wire_1 = require("../actors/actor-remote-wire");
|
|
32
|
-
const
|
|
36
|
+
const actor_handoff_2 = require("../actors/actor-handoff");
|
|
33
37
|
const spot_remote_codec_1 = require("./spot-remote-codec");
|
|
34
|
-
const
|
|
38
|
+
const routing_id_2 = require("../routing-id");
|
|
35
39
|
const service_wire_constants_generated_1 = require("../foundation/service-wire-constants.generated");
|
|
36
40
|
var spot_serial_turn_executor_1 = require("./spot-serial-turn-executor");
|
|
37
41
|
Object.defineProperty(exports, "ZLinkSpotSerialTurnExecutor", { enumerable: true, get: function () { return spot_serial_turn_executor_1.ZLinkSpotSerialTurnExecutor; } });
|
|
@@ -57,6 +61,7 @@ var spot_entry_activation_1 = require("./spot-entry-activation");
|
|
|
57
61
|
Object.defineProperty(exports, "ZLinkEntrySpotActivation", { enumerable: true, get: function () { return spot_entry_activation_1.ZLinkEntrySpotActivation; } });
|
|
58
62
|
var spot_node_runtime_manager_1 = require("./spot-node-runtime-manager");
|
|
59
63
|
Object.defineProperty(exports, "createFrameworkEntrySpotId", { enumerable: true, get: function () { return spot_node_runtime_manager_1.createFrameworkEntrySpotId; } });
|
|
64
|
+
Object.defineProperty(exports, "registrationAcceptsNewActor", { enumerable: true, get: function () { return spot_node_runtime_manager_1.registrationAcceptsNewActor; } });
|
|
60
65
|
Object.defineProperty(exports, "ZLinkSpotNodeRuntimeManager", { enumerable: true, get: function () { return spot_node_runtime_manager_1.ZLinkSpotNodeRuntimeManager; } });
|
|
61
66
|
var spot_manager_public_1 = require("./spot-manager-public");
|
|
62
67
|
Object.defineProperty(exports, "ZLinkPublicSpotManager", { enumerable: true, get: function () { return spot_manager_public_1.ZLinkPublicSpotManager; } });
|
|
@@ -158,9 +163,17 @@ class DefaultZLinkSpotManager {
|
|
|
158
163
|
statefulExecutionAllowed: options.statefulExecution?.admissionOpen,
|
|
159
164
|
leaveActor: (spotId, actor, signal, meshName) => this.actorMembership.leaveActor(spotId, actor, signal, meshName),
|
|
160
165
|
requestContextClose: (activation, objectGeneration, signal) => this.closeFromContext(activation, objectGeneration, signal),
|
|
161
|
-
|
|
162
|
-
this.activations.
|
|
166
|
+
stageActivation: (activation) => {
|
|
167
|
+
this.activations.registerPreparing(activation);
|
|
168
|
+
},
|
|
169
|
+
discardActivation: (activation) => {
|
|
170
|
+
this.activations.finishClose(activation.meshName, activation.spotId);
|
|
171
|
+
},
|
|
172
|
+
registerActivation: async (activation) => {
|
|
173
|
+
const published = this.activations.register(activation);
|
|
163
174
|
this.scheduleIdleSweep();
|
|
175
|
+
if (published?.domain.kind === 'user')
|
|
176
|
+
await published.serialExecutor.finishPreparation();
|
|
164
177
|
},
|
|
165
178
|
// Spec 15 §4.2 relocation temporary queue: production ingress
|
|
166
179
|
// consults the same admission attempts registered on Accepted
|
|
@@ -207,10 +220,10 @@ class DefaultZLinkSpotManager {
|
|
|
207
220
|
resolveRelocationActivation(meshName, spotId) {
|
|
208
221
|
return this.activations.resolve(meshName, spotId);
|
|
209
222
|
}
|
|
210
|
-
async prepareRelocationSpot(meshName, objectKind, stableType, implementation, spotId, objectGeneration, authorityOwnerGeneration, signal) {
|
|
223
|
+
async prepareRelocationSpot(meshName, objectKind, stableType, implementation, spotId, objectGeneration, authorityOwnerGeneration, restoredTimers, signal) {
|
|
211
224
|
this.activations.stage(meshName, spotId);
|
|
212
225
|
try {
|
|
213
|
-
return await this.activationLifecycle.materializeRelocation(meshName, objectKind, stableType, implementation, spotId, objectGeneration, authorityOwnerGeneration, signal);
|
|
226
|
+
return await this.activationLifecycle.materializeRelocation(meshName, objectKind, stableType, implementation, spotId, objectGeneration, authorityOwnerGeneration, restoredTimers, signal);
|
|
214
227
|
}
|
|
215
228
|
catch (error) {
|
|
216
229
|
this.activations.abandonStage(meshName, spotId);
|
|
@@ -218,11 +231,16 @@ class DefaultZLinkSpotManager {
|
|
|
218
231
|
}
|
|
219
232
|
}
|
|
220
233
|
async publishRelocationSpot(activation, beforeAdmission) {
|
|
221
|
-
|
|
234
|
+
// Spot timer §1: OnInitialize before Ready reattaches restored keys; the
|
|
235
|
+
// relocation-ready completion and later callbacks use the ordinary rule.
|
|
236
|
+
await activation.serial.postBarrierTurn(() => activation.timers.runRelocationInitialization(() => activation.spot.onInitialize?.()));
|
|
222
237
|
await beforeAdmission?.();
|
|
223
238
|
this.activations.publish(activation.meshName, activation.spotId);
|
|
239
|
+
await activation.serialExecutor.finishPreparation();
|
|
240
|
+
await activation.timers.publishRelocation();
|
|
224
241
|
}
|
|
225
242
|
async abortRelocationSpot(activation) {
|
|
243
|
+
await this.activationLifecycle.discardPreparation(activation);
|
|
226
244
|
this.activations.detachRelocated(activation.meshName, activation.spotId);
|
|
227
245
|
await activation.timers.dispose();
|
|
228
246
|
await activation.nativeSpot?.dispose();
|
|
@@ -231,7 +249,7 @@ class DefaultZLinkSpotManager {
|
|
|
231
249
|
this.activations.detachRelocated(activation.meshName, activation.spotId);
|
|
232
250
|
await activation.nativeSpot?.dispose();
|
|
233
251
|
}
|
|
234
|
-
async materializeInstance(meshName, instanceType, spotId, objectGeneration, signal) {
|
|
252
|
+
async materializeInstance(meshName, instanceType, spotId, objectGeneration, signal, completion = 'publication') {
|
|
235
253
|
const readyTarget = this.options.instanceSpotApplicationTargetProvider?.(meshName, spotId);
|
|
236
254
|
const existing = this.pendingInstanceMaterializations.get(instanceMaterializationKey(meshName, spotId, objectGeneration));
|
|
237
255
|
if (existing !== undefined) {
|
|
@@ -240,13 +258,13 @@ class DefaultZLinkSpotManager {
|
|
|
240
258
|
}
|
|
241
259
|
const release = await this.options.activationAdmission?.acquire(meshName, signal);
|
|
242
260
|
try {
|
|
243
|
-
await this.materializeInstanceCore(meshName, instanceType, spotId, objectGeneration, readyTarget?.objectGeneration === objectGeneration, signal);
|
|
261
|
+
await this.materializeInstanceCore(meshName, instanceType, spotId, objectGeneration, readyTarget?.objectGeneration === objectGeneration, signal, completion);
|
|
244
262
|
}
|
|
245
263
|
finally {
|
|
246
264
|
release?.();
|
|
247
265
|
}
|
|
248
266
|
}
|
|
249
|
-
async materializeInstanceCore(meshName, instanceType, spotId, objectGeneration, requiresReadyTarget, signal) {
|
|
267
|
+
async materializeInstanceCore(meshName, instanceType, spotId, objectGeneration, requiresReadyTarget, signal, completion) {
|
|
250
268
|
const factory = this.requireInstanceFactory(meshName, instanceType);
|
|
251
269
|
const key = `${meshName}\0${String(spotId)}`;
|
|
252
270
|
const materializationKey = instanceMaterializationKey(meshName, spotId, objectGeneration);
|
|
@@ -272,7 +290,7 @@ class DefaultZLinkSpotManager {
|
|
|
272
290
|
await (0, abort_1.awaitWithAbort)(closing.ready, signal);
|
|
273
291
|
continue;
|
|
274
292
|
}
|
|
275
|
-
const current = this.activations.
|
|
293
|
+
const current = this.activations.activationForClose(meshName, spotId);
|
|
276
294
|
if (current !== undefined) {
|
|
277
295
|
if (current.spotType !== factory) {
|
|
278
296
|
throw new configuration_1.ZLinkConfigurationException(`Instance Spot '${String(spotId)}' is assigned to another type.`);
|
|
@@ -306,14 +324,16 @@ class DefaultZLinkSpotManager {
|
|
|
306
324
|
}
|
|
307
325
|
}
|
|
308
326
|
if (pending === undefined) {
|
|
309
|
-
|
|
327
|
+
if (completion === 'first-terminal')
|
|
328
|
+
this.activations.stage(meshName, spotId);
|
|
310
329
|
pending = this.activationLifecycle
|
|
311
330
|
.materializeInstance(meshName, instanceType, factory, spotId, objectGeneration, signal)
|
|
312
|
-
.then((activation) => {
|
|
313
|
-
|
|
331
|
+
.then(async (activation) => {
|
|
332
|
+
if (completion === 'publication')
|
|
333
|
+
await activation.serialExecutor.finishPreparation();
|
|
314
334
|
return activation;
|
|
315
335
|
}, (error) => {
|
|
316
|
-
|
|
336
|
+
this.activations.abandonStage(meshName, spotId);
|
|
317
337
|
throw error;
|
|
318
338
|
});
|
|
319
339
|
this.pendingInstanceMaterializations.set(materializationKey, pending);
|
|
@@ -353,10 +373,13 @@ class DefaultZLinkSpotManager {
|
|
|
353
373
|
: this.activations.resolve(meshName, spotId);
|
|
354
374
|
if (current !== undefined)
|
|
355
375
|
return current;
|
|
356
|
-
if (meshName !== undefined)
|
|
357
|
-
|
|
376
|
+
if (meshName !== undefined) {
|
|
377
|
+
const closing = this.closeOperations.get(`${meshName}\0${String(spotId)}`);
|
|
378
|
+
return closing?.authority === undefined ? undefined : closing.activation;
|
|
379
|
+
}
|
|
358
380
|
for (const operation of this.closeOperations.values()) {
|
|
359
|
-
if (
|
|
381
|
+
if (operation.authority !== undefined &&
|
|
382
|
+
String(operation.activation.spotId) === String(spotId))
|
|
360
383
|
return operation.activation;
|
|
361
384
|
}
|
|
362
385
|
return undefined;
|
|
@@ -364,6 +387,7 @@ class DefaultZLinkSpotManager {
|
|
|
364
387
|
isInstanceMaterializing(meshName, spotId) {
|
|
365
388
|
const prefix = instanceMaterializationPrefix(meshName, spotId);
|
|
366
389
|
return ((this.pendingInstanceMaterializationsByPrefix.get(prefix)?.size ?? 0) > 0 ||
|
|
390
|
+
this.activations.activationForClose(meshName, spotId)?.serialExecutor.isPreparing === true ||
|
|
367
391
|
this.closeOperations.get(`${meshName}\0${String(spotId)}`)?.authority !== undefined);
|
|
368
392
|
}
|
|
369
393
|
isSpotClosing(meshName, spotId) {
|
|
@@ -374,7 +398,7 @@ class DefaultZLinkSpotManager {
|
|
|
374
398
|
return this.closeOperations.get(`${meshName}\0${String(spotId)}`)?.authorityDecision;
|
|
375
399
|
}
|
|
376
400
|
async discardInstance(meshName, spotId) {
|
|
377
|
-
const activation = this.activations.
|
|
401
|
+
const activation = this.activations.activationForClose(meshName, spotId);
|
|
378
402
|
if (activation === undefined)
|
|
379
403
|
return;
|
|
380
404
|
activation.requestClose();
|
|
@@ -400,6 +424,9 @@ class DefaultZLinkSpotManager {
|
|
|
400
424
|
}
|
|
401
425
|
async completeInstanceTerminal(meshName, spotId, objectGeneration) {
|
|
402
426
|
const key = `${meshName}\0${String(spotId)}`;
|
|
427
|
+
const activation = this.activations.activationForClose(meshName, spotId);
|
|
428
|
+
if (activation?.objectGeneration === objectGeneration)
|
|
429
|
+
await activation.serialExecutor.finishPreparation();
|
|
403
430
|
const pending = this.pendingInstanceTerminals.get(key);
|
|
404
431
|
if (pending === undefined)
|
|
405
432
|
return false;
|
|
@@ -438,6 +465,13 @@ class DefaultZLinkSpotManager {
|
|
|
438
465
|
generations.set(generationKey, (generations.get(generationKey) ?? 0) + 1);
|
|
439
466
|
this.pendingInstanceTerminalGenerations.set(key, generations);
|
|
440
467
|
}
|
|
468
|
+
publishInstance(target, meshName) {
|
|
469
|
+
const activation = this.activations.activationForClose(meshName, target.targetSpotId);
|
|
470
|
+
if (activation?.objectGeneration === target.objectGeneration) {
|
|
471
|
+
const published = this.activations.publish(meshName, target.targetSpotId);
|
|
472
|
+
published?.serialExecutor.openPreparationAdmission();
|
|
473
|
+
}
|
|
474
|
+
}
|
|
441
475
|
deferInstanceAuthorityRelease(key, objectGeneration) {
|
|
442
476
|
const generations = this.deferredInstanceAuthorityReleases.get(key) ?? new Set();
|
|
443
477
|
generations.add(objectGeneration);
|
|
@@ -578,10 +612,12 @@ class DefaultZLinkSpotManager {
|
|
|
578
612
|
.filter(({ spotId }) => !this.isSpotClosing(meshName, spotId));
|
|
579
613
|
}
|
|
580
614
|
async drainForShutdown(meshName, signal, deadline) {
|
|
581
|
-
|
|
615
|
+
// The host bounds observation of the whole Close, including lifecycle admission.
|
|
616
|
+
// The owned operation keeps the gate and scopes until its running turns settle.
|
|
617
|
+
const results = await (0, abort_1.awaitWithAbort)(Promise.allSettled(this.activations
|
|
582
618
|
.activeActivations()
|
|
583
619
|
.filter((activation) => activation.meshName === meshName)
|
|
584
|
-
.map((activation) => this.closeWithReason(meshName, activation.spotId,
|
|
620
|
+
.map((activation) => this.closeWithReason(meshName, activation.spotId, undefined, contracts_1.ZLinkSpotCloseReason.HostShutdown, deadline))), signal);
|
|
585
621
|
const errors = results
|
|
586
622
|
.filter((result) => result.status === 'rejected')
|
|
587
623
|
.map((result) => result.reason);
|
|
@@ -599,7 +635,9 @@ class DefaultZLinkSpotManager {
|
|
|
599
635
|
closeFromContext(activation, objectGeneration, signal) {
|
|
600
636
|
const { meshName, spotId } = activation;
|
|
601
637
|
const operation = this.closeOperations.get(`${meshName}\0${String(spotId)}`);
|
|
602
|
-
const current = operation?.activation ??
|
|
638
|
+
const current = operation?.activation ??
|
|
639
|
+
this.activations.resolve(meshName, spotId) ??
|
|
640
|
+
(activation.serialExecutor.isPreparing ? activation : undefined);
|
|
603
641
|
if (current === undefined) {
|
|
604
642
|
return Promise.resolve(false);
|
|
605
643
|
}
|
|
@@ -609,14 +647,14 @@ class DefaultZLinkSpotManager {
|
|
|
609
647
|
const beginUserAuthority = activation.domain.kind === 'user' && this.options.beginUserClosingAuthority !== undefined
|
|
610
648
|
? (onCommitted) => this.options.beginUserClosingAuthority(meshName, spotId, objectGeneration, onCommitted)
|
|
611
649
|
: undefined;
|
|
612
|
-
return this.closeWithReason(meshName, spotId, signal, contracts_1.ZLinkSpotCloseReason.ExplicitClose, undefined, beginUserAuthority);
|
|
650
|
+
return this.closeWithReason(meshName, spotId, signal, contracts_1.ZLinkSpotCloseReason.ExplicitClose, undefined, beginUserAuthority, activation);
|
|
613
651
|
}
|
|
614
|
-
async closeWithReason(meshName, spotId, signal, reason = contracts_1.ZLinkSpotCloseReason.ExplicitClose, deadline, beginUserAuthority) {
|
|
652
|
+
async closeWithReason(meshName, spotId, signal, reason = contracts_1.ZLinkSpotCloseReason.ExplicitClose, deadline, beginUserAuthority, contextActivation) {
|
|
615
653
|
requireMeshName(meshName);
|
|
616
654
|
const key = `${meshName}\0${String(spotId)}`;
|
|
617
655
|
let operation = this.closeOperations.get(key);
|
|
618
656
|
if (operation === undefined) {
|
|
619
|
-
const activation = this.activations.resolve(meshName, spotId);
|
|
657
|
+
const activation = this.activations.resolve(meshName, spotId) ?? contextActivation;
|
|
620
658
|
if (activation === undefined)
|
|
621
659
|
return false;
|
|
622
660
|
if (activation.domain.kind === 'user' &&
|
|
@@ -666,11 +704,13 @@ class DefaultZLinkSpotManager {
|
|
|
666
704
|
return await operation.ready;
|
|
667
705
|
}
|
|
668
706
|
async runCloseOperation(meshName, spotId, operation, signal, deadline) {
|
|
707
|
+
if (this.activations.resolve(meshName, spotId) !== operation.activation)
|
|
708
|
+
return false;
|
|
669
709
|
const seal = await this.beginCloseAuthority(meshName, spotId, operation, signal);
|
|
670
710
|
if (seal === undefined)
|
|
671
711
|
return false;
|
|
672
712
|
if (seal !== true) {
|
|
673
|
-
await this.activationLifecycle.sealForClose(operation.activation, seal);
|
|
713
|
+
await this.activationLifecycle.sealForClose(operation.activation, seal, signal);
|
|
674
714
|
}
|
|
675
715
|
else {
|
|
676
716
|
await operation.activation.executionBarrier.waitForStartedTurns(signal);
|
|
@@ -800,11 +840,18 @@ class DefaultZLinkSpotManager {
|
|
|
800
840
|
beginUserSpotPublication(meshName, spotId) {
|
|
801
841
|
this.activations.stage(meshName, spotId);
|
|
802
842
|
}
|
|
803
|
-
publishUserSpot(meshName, spotId) {
|
|
804
|
-
this.activations.publish(meshName, spotId);
|
|
843
|
+
async publishUserSpot(meshName, spotId) {
|
|
844
|
+
const published = this.activations.publish(meshName, spotId);
|
|
845
|
+
await published?.serialExecutor.finishPreparation();
|
|
805
846
|
}
|
|
806
|
-
abortUserSpotPublication(meshName, spotId) {
|
|
847
|
+
async abortUserSpotPublication(meshName, spotId) {
|
|
807
848
|
this.activations.abandonStage(meshName, spotId);
|
|
849
|
+
const activation = this.activations.activationForClose(meshName, spotId);
|
|
850
|
+
if (activation?.serialExecutor.isPreparing === true) {
|
|
851
|
+
await this.activationLifecycle.cleanupFailedIncarnation(activation);
|
|
852
|
+
this.activations.finishClose(meshName, spotId);
|
|
853
|
+
await activation.serialExecutor.close();
|
|
854
|
+
}
|
|
808
855
|
}
|
|
809
856
|
resolveLocalSpotRoute(spotId) {
|
|
810
857
|
const activation = this.activations.resolveUnique(spotId);
|
|
@@ -827,9 +874,6 @@ class DefaultZLinkSpotManager {
|
|
|
827
874
|
async admitActorJoin(spotId, actor, request, commit, signal, leaveSource, contentType = 'application/json') {
|
|
828
875
|
const meshName = this.activations.resolveUnique(spotId)?.meshName;
|
|
829
876
|
this.options.admission?.requireRequest('Actor join admission', meshName);
|
|
830
|
-
if (meshName !== undefined && this.isSpotClosing(meshName, spotId)) {
|
|
831
|
-
throw (0, framework_errors_internal_1.createInternalFrameworkException)(framework_errors_internal_1.ZLinkFrameworkInternalErrorKind.RequestRejected, `Spot '${String(spotId)}' is closing.`);
|
|
832
|
-
}
|
|
833
877
|
return await this.actorMembership.admitActorJoin(spotId, actor, request, commit, signal, leaveSource, contentType);
|
|
834
878
|
}
|
|
835
879
|
async leaveActor(spotId, actor, signal) {
|
|
@@ -849,9 +893,6 @@ class DefaultZLinkSpotManager {
|
|
|
849
893
|
async commitActorLeaveAfterTransfer(spotId, actorId) {
|
|
850
894
|
await this.actorMembership.commitActorLeaveAfterTransfer(spotId, actorId);
|
|
851
895
|
}
|
|
852
|
-
async restoreActorAfterFailedTransfer(spotId, actor, signal) {
|
|
853
|
-
await this.actorMembership.restoreActorAfterFailedTransfer(spotId, actor, signal);
|
|
854
|
-
}
|
|
855
896
|
async beginActorTransfer(spotId, actorId) {
|
|
856
897
|
await this.actorMembership.beginActorTransfer(spotId, actorId);
|
|
857
898
|
}
|
|
@@ -884,26 +925,41 @@ class DefaultZLinkSpotManager {
|
|
|
884
925
|
}
|
|
885
926
|
return this.activationLifecycle.admitActorPacketPrefix(activation, actorId, records);
|
|
886
927
|
}
|
|
928
|
+
/** Resolves the current Actor FIFO owner for both Entry and User membership. */
|
|
929
|
+
admitSourceActorPacketPrefix(actorId, records) {
|
|
930
|
+
const owner = this.options.actorDispatchOwnerResolver?.(actorId);
|
|
931
|
+
if (owner?.actorRef === undefined) {
|
|
932
|
+
throw new configuration_1.ZLinkConfigurationException(`Actor '${actorId}' has no local FIFO owner.`);
|
|
933
|
+
}
|
|
934
|
+
if (owner.spotId === undefined) {
|
|
935
|
+
if (this.options.admitEntryActorPacketPrefix === undefined) {
|
|
936
|
+
throw new configuration_1.ZLinkConfigurationException(`Actor '${actorId}' has no Entry FIFO port.`);
|
|
937
|
+
}
|
|
938
|
+
return this.options.admitEntryActorPacketPrefix(owner.actorRef.meshName, actorId, records);
|
|
939
|
+
}
|
|
940
|
+
return this.admitRoutedActorPacketPrefix(owner.spotId, actorId, records);
|
|
941
|
+
}
|
|
887
942
|
async dispatchRoutedSpotSend(spotId, packetName, message, context) {
|
|
888
943
|
await this.routedSpotPackets.send(spotId, packetName, message, context);
|
|
889
944
|
}
|
|
890
945
|
async dispatchRoutedSpotRequest(spotId, packetName, request, context) {
|
|
891
946
|
return await this.routedSpotPackets.request(spotId, packetName, request, context);
|
|
892
947
|
}
|
|
893
|
-
async dispatchMeshSpot(meshName, owner, record) {
|
|
948
|
+
async dispatchMeshSpot(meshName, owner, record, admit) {
|
|
894
949
|
const spotId = owner.spotId;
|
|
895
950
|
if (spotId === null) {
|
|
896
951
|
throw new configuration_1.ZLinkConfigurationException('MeshNode Spot record is missing the owner Spot RID.');
|
|
897
952
|
}
|
|
898
953
|
if (record.kind === service_runtime_contracts_1.ReceiveKind.SpotMulticast) {
|
|
899
|
-
const activation = this.activations.
|
|
954
|
+
const activation = this.activations.activationForClose(meshName, spotId);
|
|
900
955
|
if (activation?.actorDispatch === undefined) {
|
|
901
956
|
throw new configuration_1.ZLinkConfigurationException(`MeshNode Spot multicast target '${String(spotId)}' is not active.`);
|
|
902
957
|
}
|
|
903
958
|
if (record.topic === null || record.topic.length === 0) {
|
|
904
959
|
throw new configuration_1.ZLinkConfigurationException('MeshNode Spot multicast record is missing its topic.');
|
|
905
960
|
}
|
|
906
|
-
|
|
961
|
+
const dispatch = () => activation.actorDispatch.dispatchSubscriptionRecord(record.topic, record.parts, record.sourceNodeRid);
|
|
962
|
+
await (admit === undefined ? dispatch() : admit(dispatch));
|
|
907
963
|
return;
|
|
908
964
|
}
|
|
909
965
|
const envelope = (0, channel_envelope_1.decodeChannelEnvelope)(record.parts, undefined, this.options.dispatchErrors?.flow.flowCreationEnabled() ?? true);
|
|
@@ -917,20 +973,25 @@ class DefaultZLinkSpotManager {
|
|
|
917
973
|
contentType: envelope.header.contentType,
|
|
918
974
|
workOptions: (0, serial_work_size_1.zlinkSerialWorkOptions)(envelope.payload.byteLength, record.applicationMetadata?.byteLength ?? (0, serial_work_size_1.zlinkMetadataByteLength)(envelope.header.metadata))
|
|
919
975
|
};
|
|
920
|
-
if (record.kind === service_runtime_contracts_1.ReceiveKind.SpotSend) {
|
|
921
|
-
await this.ensureInstanceApplicationActivation(meshName, spotId);
|
|
922
|
-
await this.routedSpotPackets.sendEncoded(spotId, packetName, decodePayload, context);
|
|
923
|
-
return;
|
|
924
|
-
}
|
|
925
|
-
if (record.kind !== service_runtime_contracts_1.ReceiveKind.SpotRequest) {
|
|
926
|
-
throw new configuration_1.ZLinkConfigurationException(`Unsupported MeshNode Spot record kind '${record.kind}'.`);
|
|
927
|
-
}
|
|
928
976
|
try {
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
977
|
+
const dispatch = async () => {
|
|
978
|
+
if (record.kind === service_runtime_contracts_1.ReceiveKind.SpotSend) {
|
|
979
|
+
await this.ensureInstanceApplicationActivation(meshName, spotId);
|
|
980
|
+
await this.routedSpotPackets.sendEncoded(spotId, packetName, decodePayload, context);
|
|
981
|
+
return;
|
|
982
|
+
}
|
|
983
|
+
if (record.kind !== service_runtime_contracts_1.ReceiveKind.SpotRequest) {
|
|
984
|
+
throw new configuration_1.ZLinkConfigurationException(`Unsupported MeshNode Spot record kind '${record.kind}'.`);
|
|
985
|
+
}
|
|
986
|
+
await this.ensureInstanceApplicationActivation(meshName, spotId);
|
|
987
|
+
const response = await this.routedSpotPackets.requestEncoded(spotId, packetName, decodePayload, context);
|
|
988
|
+
requireMeshSpotReply(record.reply((0, channel_envelope_1.encodeChannelReplyParts)(envelope.header, response, codecs)));
|
|
989
|
+
};
|
|
990
|
+
await (admit === undefined ? dispatch() : admit(dispatch));
|
|
932
991
|
}
|
|
933
992
|
catch (error) {
|
|
993
|
+
if (record.kind !== service_runtime_contracts_1.ReceiveKind.SpotRequest)
|
|
994
|
+
throw error;
|
|
934
995
|
requireMeshSpotReply(record.reply((0, channel_envelope_1.encodeChannelErrorReplyParts)(envelope.header, error)));
|
|
935
996
|
}
|
|
936
997
|
}
|
|
@@ -954,7 +1015,7 @@ class DefaultZLinkSpotManager {
|
|
|
954
1015
|
target = latest;
|
|
955
1016
|
}
|
|
956
1017
|
}
|
|
957
|
-
async dispatchMeshInstance(meshName, owner, record) {
|
|
1018
|
+
async dispatchMeshInstance(meshName, owner, record, admit) {
|
|
958
1019
|
const spotId = owner.spotId;
|
|
959
1020
|
if (spotId === null) {
|
|
960
1021
|
throw new configuration_1.ZLinkConfigurationException('MeshNode Instance Spot record is missing the owner Spot RID.');
|
|
@@ -965,55 +1026,58 @@ class DefaultZLinkSpotManager {
|
|
|
965
1026
|
const request = record.operationKind === service_runtime_contracts_1.OperationKind.InstanceSpotRequest;
|
|
966
1027
|
this.traceInstanceMessage(ZLinkDispatchOptions_1.ZLinkRuntimeMessageFlowOutcome.Received, meshName, spotId, record, envelope, 'activating');
|
|
967
1028
|
try {
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
(0, serial_work_size_1.
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
record.activationRecord
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1029
|
+
const dispatch = async () => {
|
|
1030
|
+
await this.ensureInstanceApplicationActivation(meshName, spotId);
|
|
1031
|
+
const activation = this.resolveApplicationActivation(spotId, meshName);
|
|
1032
|
+
if (activation === undefined || activation.domain.kind !== 'instance') {
|
|
1033
|
+
throw new configuration_1.ZLinkConfigurationException(`MeshNode Instance Spot target '${String(spotId)}' is not active.`);
|
|
1034
|
+
}
|
|
1035
|
+
const target = this.options.instanceSpotApplicationTargetProvider?.(meshName, spotId);
|
|
1036
|
+
if (target !== undefined &&
|
|
1037
|
+
activation.domain.objectGeneration !== target.objectGeneration) {
|
|
1038
|
+
throw (0, framework_errors_internal_1.createInternalFrameworkException)(framework_errors_internal_1.ZLinkFrameworkInternalErrorKind.SpotGenerationStale, `Instance Spot target '${String(spotId)}' application generation is stale.`);
|
|
1039
|
+
}
|
|
1040
|
+
const codecs = this.options.messageSerializers === undefined
|
|
1041
|
+
? undefined
|
|
1042
|
+
: { serializers: this.options.messageSerializers };
|
|
1043
|
+
const decodePayload = () => (0, channel_envelope_1.decodeChannelPayload)(envelope, codecs);
|
|
1044
|
+
const context = {
|
|
1045
|
+
channelName: envelope.header.channelName,
|
|
1046
|
+
contentType: envelope.header.contentType,
|
|
1047
|
+
awaitFirstHandlerTurn: record.kind === service_runtime_contracts_1.ReceiveKind.InstanceSpotActivation,
|
|
1048
|
+
activationRecord: record,
|
|
1049
|
+
onOneWayError: this.options.dispatchErrors?.captureEnabled() === true
|
|
1050
|
+
? (error) => this.reportInstanceDispatchFailure(meshName, spotId, record, envelope, false, error)
|
|
1051
|
+
: undefined,
|
|
1052
|
+
workOptions: (0, serial_work_size_1.zlinkSerialWorkOptions)(envelope.payload.byteLength, record.applicationMetadata?.byteLength ??
|
|
1053
|
+
(0, serial_work_size_1.zlinkMetadataByteLength)(envelope.header.metadata))
|
|
1054
|
+
};
|
|
1055
|
+
// Spot messaging §7 step 3: an Instance intent request that reaches an
|
|
1056
|
+
// incarnation whose Close ended admission is refused before admission
|
|
1057
|
+
// with the owner fence terminal, so its caller re-reads authority.
|
|
1058
|
+
const instanceIntent = record.activationRecord?.activation === 'missing' ||
|
|
1059
|
+
(record.activationRecord?.activation === 'ready' &&
|
|
1060
|
+
record.activationRecord.instanceIntent);
|
|
1061
|
+
const refusal = activation.serial.applicationAdmissionRefusal(instanceIntent === true);
|
|
1062
|
+
if (request && refusal !== undefined && record.replyFailure !== undefined) {
|
|
1063
|
+
this.reportInstanceDispatchFailure(meshName, spotId, record, envelope, request, refusal);
|
|
1064
|
+
const terminal = (0, framework_errors_internal_1.internalFrameworkWireReply)(refusal);
|
|
1065
|
+
requireMeshSpotReply(record.replyFailure(terminal.terminalResult, terminal.failureCode));
|
|
1066
|
+
return;
|
|
1067
|
+
}
|
|
1068
|
+
this.traceInstanceMessage(ZLinkDispatchOptions_1.ZLinkRuntimeMessageFlowOutcome.Admitted, meshName, spotId, record, envelope, 'ready', target?.stableType);
|
|
1069
|
+
if (!request) {
|
|
1070
|
+
this.traceInstanceMessage(ZLinkDispatchOptions_1.ZLinkRuntimeMessageFlowOutcome.Dispatched, meshName, spotId, record, envelope, 'ready', target?.stableType);
|
|
1071
|
+
await this.routedSpotPackets.sendEncoded(spotId, envelope.packetName, decodePayload, context);
|
|
1072
|
+
this.traceInstanceMessage(ZLinkDispatchOptions_1.ZLinkRuntimeMessageFlowOutcome.Completed, meshName, spotId, record, envelope, 'ready', target?.stableType);
|
|
1073
|
+
return;
|
|
1074
|
+
}
|
|
1008
1075
|
this.traceInstanceMessage(ZLinkDispatchOptions_1.ZLinkRuntimeMessageFlowOutcome.Dispatched, meshName, spotId, record, envelope, 'ready', target?.stableType);
|
|
1009
|
-
await this.routedSpotPackets.
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
}
|
|
1013
|
-
|
|
1014
|
-
const response = await this.routedSpotPackets.requestEncoded(spotId, envelope.packetName, decodePayload, context);
|
|
1015
|
-
requireMeshSpotReply(record.reply((0, channel_envelope_1.encodeChannelReplyParts)(envelope.header, response, codecs)));
|
|
1016
|
-
this.traceInstanceMessage(ZLinkDispatchOptions_1.ZLinkRuntimeMessageFlowOutcome.Replied, meshName, spotId, record, envelope, 'ready', target?.stableType);
|
|
1076
|
+
const response = await this.routedSpotPackets.requestEncoded(spotId, envelope.packetName, decodePayload, context);
|
|
1077
|
+
requireMeshSpotReply(record.reply((0, channel_envelope_1.encodeChannelReplyParts)(envelope.header, response, codecs)));
|
|
1078
|
+
this.traceInstanceMessage(ZLinkDispatchOptions_1.ZLinkRuntimeMessageFlowOutcome.Replied, meshName, spotId, record, envelope, 'ready', target?.stableType);
|
|
1079
|
+
};
|
|
1080
|
+
await (admit === undefined ? dispatch() : admit(dispatch));
|
|
1017
1081
|
}
|
|
1018
1082
|
catch (error) {
|
|
1019
1083
|
this.reportInstanceDispatchFailure(meshName, spotId, record, envelope, request, error);
|
|
@@ -1072,7 +1136,7 @@ class DefaultZLinkSpotManager {
|
|
|
1072
1136
|
errorReason
|
|
1073
1137
|
});
|
|
1074
1138
|
}
|
|
1075
|
-
async dispatchMeshActor(origin, meshName, owner, record) {
|
|
1139
|
+
async dispatchMeshActor(origin, meshName, owner, record, admit) {
|
|
1076
1140
|
const spotId = owner.spotId;
|
|
1077
1141
|
const entrySpotId = this.options.entryNodeRidProvider?.() ?? this.options.entryNodeRid;
|
|
1078
1142
|
const targetsEntrySpot = spotId === null || (entrySpotId !== undefined && spotId === entrySpotId);
|
|
@@ -1081,12 +1145,15 @@ class DefaultZLinkSpotManager {
|
|
|
1081
1145
|
throw new configuration_1.ZLinkConfigurationException('MeshNode Actor record is missing its Actor owner.');
|
|
1082
1146
|
}
|
|
1083
1147
|
const request = record.kind === service_runtime_contracts_1.ReceiveKind.ActorRequest;
|
|
1084
|
-
const
|
|
1085
|
-
const
|
|
1086
|
-
|
|
1087
|
-
|
|
1148
|
+
const nativeTarget = record.messageFollowOrigin?.target;
|
|
1149
|
+
const ingressActor = nativeTarget?.actor ?? actor;
|
|
1150
|
+
const resolvedActorRef = (nativeTarget === undefined
|
|
1151
|
+
? this.options.actorDispatchOwnerResolver?.(actor.actorId).actorRef
|
|
1152
|
+
: undefined) ?? {
|
|
1153
|
+
actorId: ingressActor.actorId,
|
|
1154
|
+
objectGeneration: ingressActor.generation,
|
|
1088
1155
|
meshName,
|
|
1089
|
-
nodeRid:
|
|
1156
|
+
nodeRid: ingressActor.nodeRid
|
|
1090
1157
|
};
|
|
1091
1158
|
const responseActorRef = record.sourceBindingGeneration > 0n
|
|
1092
1159
|
? {
|
|
@@ -1112,18 +1179,23 @@ class DefaultZLinkSpotManager {
|
|
|
1112
1179
|
})
|
|
1113
1180
|
: undefined;
|
|
1114
1181
|
try {
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1182
|
+
const dispatch = async () => {
|
|
1183
|
+
if (this.formalRemoteTransfers.has(actor.actorId)) {
|
|
1184
|
+
throw new Error(`Actor '${actor.actorId}' target transfer reconciliation is not complete.`);
|
|
1185
|
+
}
|
|
1186
|
+
const response = targetsEntrySpot
|
|
1187
|
+
? await this.options.dispatchEntryActorPacket?.(origin, actor.actorId, record.parts, request, undefined, ownerActorRef, requestTerminal, record.messageFollowOrigin)
|
|
1188
|
+
: await this.dispatchMeshActorPacket(origin, meshName, spotId, actor.actorId, record.parts, request, ownerActorRef, requestTerminal, record.messageFollowOrigin);
|
|
1189
|
+
if (targetsEntrySpot && this.options.dispatchEntryActorPacket === undefined) {
|
|
1190
|
+
throw new configuration_1.ZLinkConfigurationException('MeshNode Entry Spot Actor dispatch is not configured.');
|
|
1191
|
+
}
|
|
1192
|
+
if (response === actor_handoff_1.RELOCATED_REQUEST_OWNED_BY_REQUESTER)
|
|
1193
|
+
return;
|
|
1194
|
+
if (request && !requestTerminalState.submitted) {
|
|
1195
|
+
requireMeshSpotReply(record.reply(this.encodeMeshActorReply(record.parts[0], protocol_1.ZLinkStreamMessageKind.Response, response)));
|
|
1196
|
+
}
|
|
1197
|
+
};
|
|
1198
|
+
await (admit === undefined ? dispatch() : admit(dispatch));
|
|
1127
1199
|
}
|
|
1128
1200
|
catch (error) {
|
|
1129
1201
|
if (!request) {
|
|
@@ -1132,10 +1204,7 @@ class DefaultZLinkSpotManager {
|
|
|
1132
1204
|
if (requestTerminalState.prepared || requestTerminalState.submitted) {
|
|
1133
1205
|
throw error;
|
|
1134
1206
|
}
|
|
1135
|
-
requireMeshSpotReply(record.reply(this.encodeMeshActorReply(record.parts[0], protocol_1.ZLinkStreamMessageKind.Error,
|
|
1136
|
-
message: error instanceof Error ? error.message : String(error),
|
|
1137
|
-
kind: spotActorFailureKind(error)
|
|
1138
|
-
})));
|
|
1207
|
+
requireMeshSpotReply(record.reply(this.encodeMeshActorReply(record.parts[0], protocol_1.ZLinkStreamMessageKind.Error, (0, bound_session_response_target_1.boundSessionErrorPayload)(error))));
|
|
1139
1208
|
}
|
|
1140
1209
|
}
|
|
1141
1210
|
async dispatchMeshActorJoin(meshName, owner, record) {
|
|
@@ -1628,7 +1697,7 @@ class DefaultZLinkSpotManager {
|
|
|
1628
1697
|
if (!sourceLeaveSubmitted) {
|
|
1629
1698
|
throw new Error(`Actor '${entryActor.context.actorId}' source authority commit failed before leave submission.`);
|
|
1630
1699
|
}
|
|
1631
|
-
const handoffResults = await (0,
|
|
1700
|
+
const handoffResults = await (0, actor_handoff_2.replayActorHandoffBacklog)(pendingTransfer.handoffBacklog, async (parts, returnResponse, remoteBoundSessionTarget, fallbackActorRef) => {
|
|
1632
1701
|
if (this.options.dispatchEntryActorPacket === undefined) {
|
|
1633
1702
|
throw new Error('Entry Spot saved handoff replay requires its Actor packet runtime.');
|
|
1634
1703
|
}
|
|
@@ -1745,12 +1814,7 @@ class DefaultZLinkSpotManager {
|
|
|
1745
1814
|
const callback = async () => {
|
|
1746
1815
|
await this.options.entrySpotCallbacks?.onLeaveActor(actor, undefined, actorRef, control.previousMembershipEpoch);
|
|
1747
1816
|
};
|
|
1748
|
-
|
|
1749
|
-
await callback();
|
|
1750
|
-
}
|
|
1751
|
-
else {
|
|
1752
|
-
await this.options.actorTransferRuntime.notifyCoreSourceLeave(actor, callback);
|
|
1753
|
-
}
|
|
1817
|
+
await callback();
|
|
1754
1818
|
return;
|
|
1755
1819
|
}
|
|
1756
1820
|
if (spotId === null) {
|
|
@@ -1791,7 +1855,7 @@ class DefaultZLinkSpotManager {
|
|
|
1791
1855
|
};
|
|
1792
1856
|
const completeTargetReady = async () => {
|
|
1793
1857
|
if (pendingTransfer !== undefined) {
|
|
1794
|
-
const handoffResults = await (0,
|
|
1858
|
+
const handoffResults = await (0, actor_handoff_2.replayActorHandoffBacklog)(pendingTransfer.handoffBacklog, (parts, returnResponse, remoteBoundSessionTarget, _fallbackActorRef) => this.dispatchActorPacket('remote', activation, actor.context.actorId, parts, returnResponse, remoteBoundSessionTarget, undefined), (index) => this.options.runtimeEventPublisher?.publish({
|
|
1795
1859
|
sourceName: 'zlink.framework.actor-handoff',
|
|
1796
1860
|
timestamp: new Date(),
|
|
1797
1861
|
marker: 'backlog_enqueued',
|
|
@@ -1808,7 +1872,7 @@ class DefaultZLinkSpotManager {
|
|
|
1808
1872
|
// ingress hold) migrate into the real Actor queue next, in the
|
|
1809
1873
|
// order they parked — after the relayed backlog above, before
|
|
1810
1874
|
// regular ingress opens.
|
|
1811
|
-
|
|
1875
|
+
this.migrateActorJoinPrewarm(activation, actor, pendingTransfer.transferId);
|
|
1812
1876
|
// This registry owns target lifecycle and saved backlog
|
|
1813
1877
|
// reconciliation only. Session route readiness is enforced by
|
|
1814
1878
|
// the Session binding aggregate after this boundary.
|
|
@@ -1871,7 +1935,7 @@ class DefaultZLinkSpotManager {
|
|
|
1871
1935
|
if (sourceJoinedActor === undefined && pendingTransfer === undefined) {
|
|
1872
1936
|
return;
|
|
1873
1937
|
}
|
|
1874
|
-
await
|
|
1938
|
+
await activation.spot.onLeaveActor(actor);
|
|
1875
1939
|
}
|
|
1876
1940
|
activation.commitActorDeparture(actor.context.actorId);
|
|
1877
1941
|
return;
|
|
@@ -1917,6 +1981,19 @@ class DefaultZLinkSpotManager {
|
|
|
1917
1981
|
}
|
|
1918
1982
|
catch (error) {
|
|
1919
1983
|
lifecycleFailure = { error };
|
|
1984
|
+
const reporter = this.options.dispatchErrors;
|
|
1985
|
+
if (reporter?.captureEnabled() === true) {
|
|
1986
|
+
reporter.report({
|
|
1987
|
+
surface: ZLinkDispatchOptions_1.ZLinkDispatchErrorSurface.ActorRelocation,
|
|
1988
|
+
messageKind: ZLinkDispatchOptions_1.ZLinkDispatchMessageKind.Control,
|
|
1989
|
+
reason: (0, dispatch_error_details_1.dispatchReasonFromError)(error),
|
|
1990
|
+
action: ZLinkDispatchOptions_1.ZLinkRuntimeDispatchErrorAction.FailCaller,
|
|
1991
|
+
packetName: 'OnJoinedActor',
|
|
1992
|
+
meshName,
|
|
1993
|
+
actorId: actor.context.actorId,
|
|
1994
|
+
error
|
|
1995
|
+
});
|
|
1996
|
+
}
|
|
1920
1997
|
}
|
|
1921
1998
|
if (lifecycleFailure === undefined) {
|
|
1922
1999
|
const sourceLeave = submitSourceLeave(admission.admission.actorRef.nodeRid);
|
|
@@ -1930,7 +2007,7 @@ class DefaultZLinkSpotManager {
|
|
|
1930
2007
|
if (activation === undefined) {
|
|
1931
2008
|
throw new Error(`Actor Join relocation '${relocationId}' target mailbox is missing.`);
|
|
1932
2009
|
}
|
|
1933
|
-
return activation.executeActor(actor.context.actorId, operation);
|
|
2010
|
+
return activation.executeActor(actor.context.actorId, operation, { lane: 'lifecycle' });
|
|
1934
2011
|
};
|
|
1935
2012
|
await this.options.actorTransferRuntime.deliverDeferredJoinCompletion(lifecycleFailure === undefined
|
|
1936
2013
|
? outcome.deferredJoinCompletion
|
|
@@ -1949,6 +2026,16 @@ class DefaultZLinkSpotManager {
|
|
|
1949
2026
|
this.formalRemoteActorAdmissions.beginRestore(relocationId);
|
|
1950
2027
|
return () => this.formalRemoteActorAdmissions.finishRestore(relocationId);
|
|
1951
2028
|
}
|
|
2029
|
+
/** @internal Transfers accepted ingress after the target Actor becomes visible. */
|
|
2030
|
+
openActorJoinRelocation(meshName, relocationId, actor) {
|
|
2031
|
+
const admission = this.formalRemoteActorAdmissions.get(relocationId);
|
|
2032
|
+
if (admission === undefined)
|
|
2033
|
+
return;
|
|
2034
|
+
const activation = this.activations.resolve(meshName, admission.admission.spotId);
|
|
2035
|
+
if (activation !== undefined) {
|
|
2036
|
+
this.migrateActorJoinPrewarm(activation, actor, relocationId);
|
|
2037
|
+
}
|
|
2038
|
+
}
|
|
1952
2039
|
async restoreCanonicalActorJoinRecovery(recovery, signal) {
|
|
1953
2040
|
(0, abort_1.throwIfAborted)(signal);
|
|
1954
2041
|
const admission = this.formalRemoteActorAdmissions.get(recovery.request.handoffId);
|
|
@@ -1965,7 +2052,7 @@ class DefaultZLinkSpotManager {
|
|
|
1965
2052
|
if (admitted.sourceActorNodeRid === undefined) {
|
|
1966
2053
|
throw new Error(`Actor Join recovery '${recovery.request.handoffId}' lost its command-28 source route.`);
|
|
1967
2054
|
}
|
|
1968
|
-
const admittedNodeBytes = Buffer.from((0,
|
|
2055
|
+
const admittedNodeBytes = Buffer.from((0, routing_id_2.encodeRoutingIdStorageHex)(admitted.sourceActorNodeRid), 'hex');
|
|
1969
2056
|
if (admitted.actorId !== recovery.request.actorId ||
|
|
1970
2057
|
admitted.actorType !== recovery.request.actorType ||
|
|
1971
2058
|
admitted.requestFingerprint !== recovery.request.request.toString('base64') ||
|
|
@@ -2003,33 +2090,7 @@ class DefaultZLinkSpotManager {
|
|
|
2003
2090
|
this.formalRemoteActorAdmissions.attachDeferredJoinCompletion(recovery.request.handoffId, deferred);
|
|
2004
2091
|
}
|
|
2005
2092
|
encodeMeshActorReply(requestHeaderPart, kind, payload) {
|
|
2006
|
-
|
|
2007
|
-
// Off (and skips its validation); when tracing is on the reply preserves
|
|
2008
|
-
// the request's flow pair alongside its correlation.
|
|
2009
|
-
const requestHeader = (0, protocol_1.decodeStreamHeader)(requestHeaderPart.data(), this.options.dispatchErrors?.flow.flowCreationEnabled() ?? true);
|
|
2010
|
-
const encoded = (0, payload_codec_1.encodeFrameworkPayload)(payload, this.options.messageSerializers);
|
|
2011
|
-
try {
|
|
2012
|
-
// encodeStreamHeader returns a fresh, unaliased array; view it without
|
|
2013
|
-
// re-copying. The payload copy stays: encoded.message closes below.
|
|
2014
|
-
const replyHeader = (0, protocol_1.encodeStreamHeader)({
|
|
2015
|
-
kind,
|
|
2016
|
-
codec: (0, protocol_1.streamCodecForContentType)(encoded.contentType),
|
|
2017
|
-
flags: protocol_1.ZLinkStreamHeaderFlags.None,
|
|
2018
|
-
requestSeq: requestHeader.requestSeq,
|
|
2019
|
-
name: '',
|
|
2020
|
-
metadata: new Map(),
|
|
2021
|
-
correlationId: requestHeader.correlationId,
|
|
2022
|
-
flowId: requestHeader.flowId,
|
|
2023
|
-
flowOrigin: requestHeader.flowOrigin
|
|
2024
|
-
});
|
|
2025
|
-
return [
|
|
2026
|
-
Buffer.from(replyHeader.buffer, replyHeader.byteOffset, replyHeader.byteLength),
|
|
2027
|
-
Buffer.from(encoded.message.data())
|
|
2028
|
-
];
|
|
2029
|
-
}
|
|
2030
|
-
finally {
|
|
2031
|
-
encoded.message.close();
|
|
2032
|
-
}
|
|
2093
|
+
return (0, actor_reply_1.encodeActorReply)(requestHeaderPart.data(), kind, payload, this.options.messageSerializers, this.options.dispatchErrors?.flow.flowCreationEnabled() ?? true);
|
|
2033
2094
|
}
|
|
2034
2095
|
async createActivation(meshName, spotType, spotId, request, signal, authority) {
|
|
2035
2096
|
this.requireRegisteredFactory(spotType);
|
|
@@ -2053,9 +2114,11 @@ class DefaultZLinkSpotManager {
|
|
|
2053
2114
|
* either lands in the snapshot or resolves the Actor directly through
|
|
2054
2115
|
* ordinary ingress — never both, never neither.
|
|
2055
2116
|
*/
|
|
2056
|
-
|
|
2117
|
+
migrateActorJoinPrewarm(activation, actor, transferId) {
|
|
2057
2118
|
const drained = this.formalRemoteActorAdmissions.completeMigration(transferId);
|
|
2058
|
-
|
|
2119
|
+
if (drained.length === 0)
|
|
2120
|
+
return;
|
|
2121
|
+
const terminals = drained.map(async (arrival) => {
|
|
2059
2122
|
try {
|
|
2060
2123
|
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);
|
|
2061
2124
|
arrival.resolve(response);
|
|
@@ -2063,7 +2126,13 @@ class DefaultZLinkSpotManager {
|
|
|
2063
2126
|
catch (error) {
|
|
2064
2127
|
arrival.reject(error);
|
|
2065
2128
|
}
|
|
2066
|
-
}
|
|
2129
|
+
});
|
|
2130
|
+
// Reserve every retained arrival's FIFO position before ordinary ingress
|
|
2131
|
+
// can resume. Handler terminals must not hold the relocation finalize that
|
|
2132
|
+
// releases an earlier saved-work prefix.
|
|
2133
|
+
this.options.detachedTaskRunner.runDetached(`actor Join ingress migration ${actor.context.actorId}`, async () => {
|
|
2134
|
+
await Promise.all(terminals);
|
|
2135
|
+
});
|
|
2067
2136
|
}
|
|
2068
2137
|
async dispatchMeshActorPacket(origin, meshName, spotId, actorId, parts, returnResponse, fallbackActorRef, requestTerminal, messageFollowOrigin) {
|
|
2069
2138
|
const activation = this.activations.resolve(meshName, spotId);
|
|
@@ -2119,7 +2188,7 @@ function decodeFormalRemoteTransferRequestBytes(bytes) {
|
|
|
2119
2188
|
? payload.requestContentType
|
|
2120
2189
|
: 'application/json',
|
|
2121
2190
|
actorEntryNodeRid: typeof payload.actorEntryNodeRid === 'string'
|
|
2122
|
-
? (0,
|
|
2191
|
+
? (0, routing_id_2.decodeRoutingId)(payload.actorEntryNodeRid, payload.actorEntryNodeRidHex)
|
|
2123
2192
|
: undefined,
|
|
2124
2193
|
sourceSpotId: typeof payload.sourceSpotId === 'string' ? payload.sourceSpotId : undefined,
|
|
2125
2194
|
actorRef: decodeFormalRemoteActorRef(payload),
|
|
@@ -2176,7 +2245,7 @@ function validateRemoteAdmissionCommit(admission, request, actorId, control) {
|
|
|
2176
2245
|
expected.targetSpotGeneration !== (control.currentSpotGeneration ?? 0n) ||
|
|
2177
2246
|
actorRef === undefined ||
|
|
2178
2247
|
actorRef.actorId !== expected.actorRef.actorId ||
|
|
2179
|
-
|
|
2248
|
+
!(0, routing_id_1.routingIdsEqual)(actorRef.nodeRid, expected.actorRef.nodeRid) ||
|
|
2180
2249
|
actorRef.objectGeneration !== expected.actorRef.objectGeneration) {
|
|
2181
2250
|
throw new configuration_1.ZLinkConfigurationException(`Remote Actor '${actorId}' commit does not match its target admission.`);
|
|
2182
2251
|
}
|
|
@@ -2204,17 +2273,3 @@ function isAbortSignal(value) {
|
|
|
2204
2273
|
typeof value.aborted === 'boolean' &&
|
|
2205
2274
|
typeof value.addEventListener === 'function');
|
|
2206
2275
|
}
|
|
2207
|
-
function instanceActivationOutcome(error) {
|
|
2208
|
-
if ((0, abort_1.isAbortError)(error))
|
|
2209
|
-
return 'shutdown';
|
|
2210
|
-
if (error instanceof contracts_1.ZLinkFrameworkException) {
|
|
2211
|
-
if (error.kind === contracts_1.ZLinkFrameworkErrorKind.DeadlineExceeded)
|
|
2212
|
-
return 'timed_out';
|
|
2213
|
-
if (error.kind === contracts_1.ZLinkFrameworkErrorKind.AlreadyExists)
|
|
2214
|
-
return 'conflict';
|
|
2215
|
-
if (error.kind === contracts_1.ZLinkFrameworkErrorKind.InvalidOperation ||
|
|
2216
|
-
error.kind === contracts_1.ZLinkFrameworkErrorKind.Unavailable)
|
|
2217
|
-
return 'fenced';
|
|
2218
|
-
}
|
|
2219
|
-
return 'failed';
|
|
2220
|
-
}
|