@zlink-systems/framework 0.30.1 → 0.30.2
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 +33 -10
- 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 +5 -0
- 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 +2 -0
- package/dist/runtime/locations/auto-connect-loop.js +22 -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 -176
- 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 +19 -2
- 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 +40 -14
- package/src/runtime/execution/serial-execution-queue.ts +31 -4
- package/src/runtime/execution/state-lane.ts +7 -0
- 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 +22 -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 -281
- 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 +22 -3
- 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);
|
|
@@ -849,9 +896,6 @@ class DefaultZLinkSpotManager {
|
|
|
849
896
|
async commitActorLeaveAfterTransfer(spotId, actorId) {
|
|
850
897
|
await this.actorMembership.commitActorLeaveAfterTransfer(spotId, actorId);
|
|
851
898
|
}
|
|
852
|
-
async restoreActorAfterFailedTransfer(spotId, actor, signal) {
|
|
853
|
-
await this.actorMembership.restoreActorAfterFailedTransfer(spotId, actor, signal);
|
|
854
|
-
}
|
|
855
899
|
async beginActorTransfer(spotId, actorId) {
|
|
856
900
|
await this.actorMembership.beginActorTransfer(spotId, actorId);
|
|
857
901
|
}
|
|
@@ -884,26 +928,41 @@ class DefaultZLinkSpotManager {
|
|
|
884
928
|
}
|
|
885
929
|
return this.activationLifecycle.admitActorPacketPrefix(activation, actorId, records);
|
|
886
930
|
}
|
|
931
|
+
/** Resolves the current Actor FIFO owner for both Entry and User membership. */
|
|
932
|
+
admitSourceActorPacketPrefix(actorId, records) {
|
|
933
|
+
const owner = this.options.actorDispatchOwnerResolver?.(actorId);
|
|
934
|
+
if (owner?.actorRef === undefined) {
|
|
935
|
+
throw new configuration_1.ZLinkConfigurationException(`Actor '${actorId}' has no local FIFO owner.`);
|
|
936
|
+
}
|
|
937
|
+
if (owner.spotId === undefined) {
|
|
938
|
+
if (this.options.admitEntryActorPacketPrefix === undefined) {
|
|
939
|
+
throw new configuration_1.ZLinkConfigurationException(`Actor '${actorId}' has no Entry FIFO port.`);
|
|
940
|
+
}
|
|
941
|
+
return this.options.admitEntryActorPacketPrefix(owner.actorRef.meshName, actorId, records);
|
|
942
|
+
}
|
|
943
|
+
return this.admitRoutedActorPacketPrefix(owner.spotId, actorId, records);
|
|
944
|
+
}
|
|
887
945
|
async dispatchRoutedSpotSend(spotId, packetName, message, context) {
|
|
888
946
|
await this.routedSpotPackets.send(spotId, packetName, message, context);
|
|
889
947
|
}
|
|
890
948
|
async dispatchRoutedSpotRequest(spotId, packetName, request, context) {
|
|
891
949
|
return await this.routedSpotPackets.request(spotId, packetName, request, context);
|
|
892
950
|
}
|
|
893
|
-
async dispatchMeshSpot(meshName, owner, record) {
|
|
951
|
+
async dispatchMeshSpot(meshName, owner, record, admit) {
|
|
894
952
|
const spotId = owner.spotId;
|
|
895
953
|
if (spotId === null) {
|
|
896
954
|
throw new configuration_1.ZLinkConfigurationException('MeshNode Spot record is missing the owner Spot RID.');
|
|
897
955
|
}
|
|
898
956
|
if (record.kind === service_runtime_contracts_1.ReceiveKind.SpotMulticast) {
|
|
899
|
-
const activation = this.activations.
|
|
957
|
+
const activation = this.activations.activationForClose(meshName, spotId);
|
|
900
958
|
if (activation?.actorDispatch === undefined) {
|
|
901
959
|
throw new configuration_1.ZLinkConfigurationException(`MeshNode Spot multicast target '${String(spotId)}' is not active.`);
|
|
902
960
|
}
|
|
903
961
|
if (record.topic === null || record.topic.length === 0) {
|
|
904
962
|
throw new configuration_1.ZLinkConfigurationException('MeshNode Spot multicast record is missing its topic.');
|
|
905
963
|
}
|
|
906
|
-
|
|
964
|
+
const dispatch = () => activation.actorDispatch.dispatchSubscriptionRecord(record.topic, record.parts, record.sourceNodeRid);
|
|
965
|
+
await (admit === undefined ? dispatch() : admit(dispatch));
|
|
907
966
|
return;
|
|
908
967
|
}
|
|
909
968
|
const envelope = (0, channel_envelope_1.decodeChannelEnvelope)(record.parts, undefined, this.options.dispatchErrors?.flow.flowCreationEnabled() ?? true);
|
|
@@ -917,20 +976,25 @@ class DefaultZLinkSpotManager {
|
|
|
917
976
|
contentType: envelope.header.contentType,
|
|
918
977
|
workOptions: (0, serial_work_size_1.zlinkSerialWorkOptions)(envelope.payload.byteLength, record.applicationMetadata?.byteLength ?? (0, serial_work_size_1.zlinkMetadataByteLength)(envelope.header.metadata))
|
|
919
978
|
};
|
|
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
979
|
try {
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
980
|
+
const dispatch = async () => {
|
|
981
|
+
if (record.kind === service_runtime_contracts_1.ReceiveKind.SpotSend) {
|
|
982
|
+
await this.ensureInstanceApplicationActivation(meshName, spotId);
|
|
983
|
+
await this.routedSpotPackets.sendEncoded(spotId, packetName, decodePayload, context);
|
|
984
|
+
return;
|
|
985
|
+
}
|
|
986
|
+
if (record.kind !== service_runtime_contracts_1.ReceiveKind.SpotRequest) {
|
|
987
|
+
throw new configuration_1.ZLinkConfigurationException(`Unsupported MeshNode Spot record kind '${record.kind}'.`);
|
|
988
|
+
}
|
|
989
|
+
await this.ensureInstanceApplicationActivation(meshName, spotId);
|
|
990
|
+
const response = await this.routedSpotPackets.requestEncoded(spotId, packetName, decodePayload, context);
|
|
991
|
+
requireMeshSpotReply(record.reply((0, channel_envelope_1.encodeChannelReplyParts)(envelope.header, response, codecs)));
|
|
992
|
+
};
|
|
993
|
+
await (admit === undefined ? dispatch() : admit(dispatch));
|
|
932
994
|
}
|
|
933
995
|
catch (error) {
|
|
996
|
+
if (record.kind !== service_runtime_contracts_1.ReceiveKind.SpotRequest)
|
|
997
|
+
throw error;
|
|
934
998
|
requireMeshSpotReply(record.reply((0, channel_envelope_1.encodeChannelErrorReplyParts)(envelope.header, error)));
|
|
935
999
|
}
|
|
936
1000
|
}
|
|
@@ -954,7 +1018,7 @@ class DefaultZLinkSpotManager {
|
|
|
954
1018
|
target = latest;
|
|
955
1019
|
}
|
|
956
1020
|
}
|
|
957
|
-
async dispatchMeshInstance(meshName, owner, record) {
|
|
1021
|
+
async dispatchMeshInstance(meshName, owner, record, admit) {
|
|
958
1022
|
const spotId = owner.spotId;
|
|
959
1023
|
if (spotId === null) {
|
|
960
1024
|
throw new configuration_1.ZLinkConfigurationException('MeshNode Instance Spot record is missing the owner Spot RID.');
|
|
@@ -965,55 +1029,58 @@ class DefaultZLinkSpotManager {
|
|
|
965
1029
|
const request = record.operationKind === service_runtime_contracts_1.OperationKind.InstanceSpotRequest;
|
|
966
1030
|
this.traceInstanceMessage(ZLinkDispatchOptions_1.ZLinkRuntimeMessageFlowOutcome.Received, meshName, spotId, record, envelope, 'activating');
|
|
967
1031
|
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
|
-
|
|
1032
|
+
const dispatch = async () => {
|
|
1033
|
+
await this.ensureInstanceApplicationActivation(meshName, spotId);
|
|
1034
|
+
const activation = this.resolveApplicationActivation(spotId, meshName);
|
|
1035
|
+
if (activation === undefined || activation.domain.kind !== 'instance') {
|
|
1036
|
+
throw new configuration_1.ZLinkConfigurationException(`MeshNode Instance Spot target '${String(spotId)}' is not active.`);
|
|
1037
|
+
}
|
|
1038
|
+
const target = this.options.instanceSpotApplicationTargetProvider?.(meshName, spotId);
|
|
1039
|
+
if (target !== undefined &&
|
|
1040
|
+
activation.domain.objectGeneration !== target.objectGeneration) {
|
|
1041
|
+
throw (0, framework_errors_internal_1.createInternalFrameworkException)(framework_errors_internal_1.ZLinkFrameworkInternalErrorKind.SpotGenerationStale, `Instance Spot target '${String(spotId)}' application generation is stale.`);
|
|
1042
|
+
}
|
|
1043
|
+
const codecs = this.options.messageSerializers === undefined
|
|
1044
|
+
? undefined
|
|
1045
|
+
: { serializers: this.options.messageSerializers };
|
|
1046
|
+
const decodePayload = () => (0, channel_envelope_1.decodeChannelPayload)(envelope, codecs);
|
|
1047
|
+
const context = {
|
|
1048
|
+
channelName: envelope.header.channelName,
|
|
1049
|
+
contentType: envelope.header.contentType,
|
|
1050
|
+
awaitFirstHandlerTurn: record.kind === service_runtime_contracts_1.ReceiveKind.InstanceSpotActivation,
|
|
1051
|
+
activationRecord: record,
|
|
1052
|
+
onOneWayError: this.options.dispatchErrors?.captureEnabled() === true
|
|
1053
|
+
? (error) => this.reportInstanceDispatchFailure(meshName, spotId, record, envelope, false, error)
|
|
1054
|
+
: undefined,
|
|
1055
|
+
workOptions: (0, serial_work_size_1.zlinkSerialWorkOptions)(envelope.payload.byteLength, record.applicationMetadata?.byteLength ??
|
|
1056
|
+
(0, serial_work_size_1.zlinkMetadataByteLength)(envelope.header.metadata))
|
|
1057
|
+
};
|
|
1058
|
+
// Spot messaging §7 step 3: an Instance intent request that reaches an
|
|
1059
|
+
// incarnation whose Close ended admission is refused before admission
|
|
1060
|
+
// with the owner fence terminal, so its caller re-reads authority.
|
|
1061
|
+
const instanceIntent = record.activationRecord?.activation === 'missing' ||
|
|
1062
|
+
(record.activationRecord?.activation === 'ready' &&
|
|
1063
|
+
record.activationRecord.instanceIntent);
|
|
1064
|
+
const refusal = activation.serial.applicationAdmissionRefusal(instanceIntent === true);
|
|
1065
|
+
if (request && refusal !== undefined && record.replyFailure !== undefined) {
|
|
1066
|
+
this.reportInstanceDispatchFailure(meshName, spotId, record, envelope, request, refusal);
|
|
1067
|
+
const terminal = (0, framework_errors_internal_1.internalFrameworkWireReply)(refusal);
|
|
1068
|
+
requireMeshSpotReply(record.replyFailure(terminal.terminalResult, terminal.failureCode));
|
|
1069
|
+
return;
|
|
1070
|
+
}
|
|
1071
|
+
this.traceInstanceMessage(ZLinkDispatchOptions_1.ZLinkRuntimeMessageFlowOutcome.Admitted, meshName, spotId, record, envelope, 'ready', target?.stableType);
|
|
1072
|
+
if (!request) {
|
|
1073
|
+
this.traceInstanceMessage(ZLinkDispatchOptions_1.ZLinkRuntimeMessageFlowOutcome.Dispatched, meshName, spotId, record, envelope, 'ready', target?.stableType);
|
|
1074
|
+
await this.routedSpotPackets.sendEncoded(spotId, envelope.packetName, decodePayload, context);
|
|
1075
|
+
this.traceInstanceMessage(ZLinkDispatchOptions_1.ZLinkRuntimeMessageFlowOutcome.Completed, meshName, spotId, record, envelope, 'ready', target?.stableType);
|
|
1076
|
+
return;
|
|
1077
|
+
}
|
|
1008
1078
|
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);
|
|
1079
|
+
const response = await this.routedSpotPackets.requestEncoded(spotId, envelope.packetName, decodePayload, context);
|
|
1080
|
+
requireMeshSpotReply(record.reply((0, channel_envelope_1.encodeChannelReplyParts)(envelope.header, response, codecs)));
|
|
1081
|
+
this.traceInstanceMessage(ZLinkDispatchOptions_1.ZLinkRuntimeMessageFlowOutcome.Replied, meshName, spotId, record, envelope, 'ready', target?.stableType);
|
|
1082
|
+
};
|
|
1083
|
+
await (admit === undefined ? dispatch() : admit(dispatch));
|
|
1017
1084
|
}
|
|
1018
1085
|
catch (error) {
|
|
1019
1086
|
this.reportInstanceDispatchFailure(meshName, spotId, record, envelope, request, error);
|
|
@@ -1072,7 +1139,7 @@ class DefaultZLinkSpotManager {
|
|
|
1072
1139
|
errorReason
|
|
1073
1140
|
});
|
|
1074
1141
|
}
|
|
1075
|
-
async dispatchMeshActor(origin, meshName, owner, record) {
|
|
1142
|
+
async dispatchMeshActor(origin, meshName, owner, record, admit) {
|
|
1076
1143
|
const spotId = owner.spotId;
|
|
1077
1144
|
const entrySpotId = this.options.entryNodeRidProvider?.() ?? this.options.entryNodeRid;
|
|
1078
1145
|
const targetsEntrySpot = spotId === null || (entrySpotId !== undefined && spotId === entrySpotId);
|
|
@@ -1081,12 +1148,15 @@ class DefaultZLinkSpotManager {
|
|
|
1081
1148
|
throw new configuration_1.ZLinkConfigurationException('MeshNode Actor record is missing its Actor owner.');
|
|
1082
1149
|
}
|
|
1083
1150
|
const request = record.kind === service_runtime_contracts_1.ReceiveKind.ActorRequest;
|
|
1084
|
-
const
|
|
1085
|
-
const
|
|
1086
|
-
|
|
1087
|
-
|
|
1151
|
+
const nativeTarget = record.messageFollowOrigin?.target;
|
|
1152
|
+
const ingressActor = nativeTarget?.actor ?? actor;
|
|
1153
|
+
const resolvedActorRef = (nativeTarget === undefined
|
|
1154
|
+
? this.options.actorDispatchOwnerResolver?.(actor.actorId).actorRef
|
|
1155
|
+
: undefined) ?? {
|
|
1156
|
+
actorId: ingressActor.actorId,
|
|
1157
|
+
objectGeneration: ingressActor.generation,
|
|
1088
1158
|
meshName,
|
|
1089
|
-
nodeRid:
|
|
1159
|
+
nodeRid: ingressActor.nodeRid
|
|
1090
1160
|
};
|
|
1091
1161
|
const responseActorRef = record.sourceBindingGeneration > 0n
|
|
1092
1162
|
? {
|
|
@@ -1112,18 +1182,23 @@ class DefaultZLinkSpotManager {
|
|
|
1112
1182
|
})
|
|
1113
1183
|
: undefined;
|
|
1114
1184
|
try {
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1185
|
+
const dispatch = async () => {
|
|
1186
|
+
if (this.formalRemoteTransfers.has(actor.actorId)) {
|
|
1187
|
+
throw new Error(`Actor '${actor.actorId}' target transfer reconciliation is not complete.`);
|
|
1188
|
+
}
|
|
1189
|
+
const response = targetsEntrySpot
|
|
1190
|
+
? await this.options.dispatchEntryActorPacket?.(origin, actor.actorId, record.parts, request, undefined, ownerActorRef, requestTerminal, record.messageFollowOrigin)
|
|
1191
|
+
: await this.dispatchMeshActorPacket(origin, meshName, spotId, actor.actorId, record.parts, request, ownerActorRef, requestTerminal, record.messageFollowOrigin);
|
|
1192
|
+
if (targetsEntrySpot && this.options.dispatchEntryActorPacket === undefined) {
|
|
1193
|
+
throw new configuration_1.ZLinkConfigurationException('MeshNode Entry Spot Actor dispatch is not configured.');
|
|
1194
|
+
}
|
|
1195
|
+
if (response === actor_handoff_1.RELOCATED_REQUEST_OWNED_BY_REQUESTER)
|
|
1196
|
+
return;
|
|
1197
|
+
if (request && !requestTerminalState.submitted) {
|
|
1198
|
+
requireMeshSpotReply(record.reply(this.encodeMeshActorReply(record.parts[0], protocol_1.ZLinkStreamMessageKind.Response, response)));
|
|
1199
|
+
}
|
|
1200
|
+
};
|
|
1201
|
+
await (admit === undefined ? dispatch() : admit(dispatch));
|
|
1127
1202
|
}
|
|
1128
1203
|
catch (error) {
|
|
1129
1204
|
if (!request) {
|
|
@@ -1132,10 +1207,7 @@ class DefaultZLinkSpotManager {
|
|
|
1132
1207
|
if (requestTerminalState.prepared || requestTerminalState.submitted) {
|
|
1133
1208
|
throw error;
|
|
1134
1209
|
}
|
|
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
|
-
})));
|
|
1210
|
+
requireMeshSpotReply(record.reply(this.encodeMeshActorReply(record.parts[0], protocol_1.ZLinkStreamMessageKind.Error, (0, bound_session_response_target_1.boundSessionErrorPayload)(error))));
|
|
1139
1211
|
}
|
|
1140
1212
|
}
|
|
1141
1213
|
async dispatchMeshActorJoin(meshName, owner, record) {
|
|
@@ -1628,7 +1700,7 @@ class DefaultZLinkSpotManager {
|
|
|
1628
1700
|
if (!sourceLeaveSubmitted) {
|
|
1629
1701
|
throw new Error(`Actor '${entryActor.context.actorId}' source authority commit failed before leave submission.`);
|
|
1630
1702
|
}
|
|
1631
|
-
const handoffResults = await (0,
|
|
1703
|
+
const handoffResults = await (0, actor_handoff_2.replayActorHandoffBacklog)(pendingTransfer.handoffBacklog, async (parts, returnResponse, remoteBoundSessionTarget, fallbackActorRef) => {
|
|
1632
1704
|
if (this.options.dispatchEntryActorPacket === undefined) {
|
|
1633
1705
|
throw new Error('Entry Spot saved handoff replay requires its Actor packet runtime.');
|
|
1634
1706
|
}
|
|
@@ -1745,12 +1817,7 @@ class DefaultZLinkSpotManager {
|
|
|
1745
1817
|
const callback = async () => {
|
|
1746
1818
|
await this.options.entrySpotCallbacks?.onLeaveActor(actor, undefined, actorRef, control.previousMembershipEpoch);
|
|
1747
1819
|
};
|
|
1748
|
-
|
|
1749
|
-
await callback();
|
|
1750
|
-
}
|
|
1751
|
-
else {
|
|
1752
|
-
await this.options.actorTransferRuntime.notifyCoreSourceLeave(actor, callback);
|
|
1753
|
-
}
|
|
1820
|
+
await callback();
|
|
1754
1821
|
return;
|
|
1755
1822
|
}
|
|
1756
1823
|
if (spotId === null) {
|
|
@@ -1791,7 +1858,7 @@ class DefaultZLinkSpotManager {
|
|
|
1791
1858
|
};
|
|
1792
1859
|
const completeTargetReady = async () => {
|
|
1793
1860
|
if (pendingTransfer !== undefined) {
|
|
1794
|
-
const handoffResults = await (0,
|
|
1861
|
+
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
1862
|
sourceName: 'zlink.framework.actor-handoff',
|
|
1796
1863
|
timestamp: new Date(),
|
|
1797
1864
|
marker: 'backlog_enqueued',
|
|
@@ -1808,7 +1875,7 @@ class DefaultZLinkSpotManager {
|
|
|
1808
1875
|
// ingress hold) migrate into the real Actor queue next, in the
|
|
1809
1876
|
// order they parked — after the relayed backlog above, before
|
|
1810
1877
|
// regular ingress opens.
|
|
1811
|
-
|
|
1878
|
+
this.migrateActorJoinPrewarm(activation, actor, pendingTransfer.transferId);
|
|
1812
1879
|
// This registry owns target lifecycle and saved backlog
|
|
1813
1880
|
// reconciliation only. Session route readiness is enforced by
|
|
1814
1881
|
// the Session binding aggregate after this boundary.
|
|
@@ -1871,7 +1938,7 @@ class DefaultZLinkSpotManager {
|
|
|
1871
1938
|
if (sourceJoinedActor === undefined && pendingTransfer === undefined) {
|
|
1872
1939
|
return;
|
|
1873
1940
|
}
|
|
1874
|
-
await
|
|
1941
|
+
await activation.spot.onLeaveActor(actor);
|
|
1875
1942
|
}
|
|
1876
1943
|
activation.commitActorDeparture(actor.context.actorId);
|
|
1877
1944
|
return;
|
|
@@ -1917,6 +1984,19 @@ class DefaultZLinkSpotManager {
|
|
|
1917
1984
|
}
|
|
1918
1985
|
catch (error) {
|
|
1919
1986
|
lifecycleFailure = { error };
|
|
1987
|
+
const reporter = this.options.dispatchErrors;
|
|
1988
|
+
if (reporter?.captureEnabled() === true) {
|
|
1989
|
+
reporter.report({
|
|
1990
|
+
surface: ZLinkDispatchOptions_1.ZLinkDispatchErrorSurface.ActorRelocation,
|
|
1991
|
+
messageKind: ZLinkDispatchOptions_1.ZLinkDispatchMessageKind.Control,
|
|
1992
|
+
reason: (0, dispatch_error_details_1.dispatchReasonFromError)(error),
|
|
1993
|
+
action: ZLinkDispatchOptions_1.ZLinkRuntimeDispatchErrorAction.FailCaller,
|
|
1994
|
+
packetName: 'OnJoinedActor',
|
|
1995
|
+
meshName,
|
|
1996
|
+
actorId: actor.context.actorId,
|
|
1997
|
+
error
|
|
1998
|
+
});
|
|
1999
|
+
}
|
|
1920
2000
|
}
|
|
1921
2001
|
if (lifecycleFailure === undefined) {
|
|
1922
2002
|
const sourceLeave = submitSourceLeave(admission.admission.actorRef.nodeRid);
|
|
@@ -1930,7 +2010,7 @@ class DefaultZLinkSpotManager {
|
|
|
1930
2010
|
if (activation === undefined) {
|
|
1931
2011
|
throw new Error(`Actor Join relocation '${relocationId}' target mailbox is missing.`);
|
|
1932
2012
|
}
|
|
1933
|
-
return activation.executeActor(actor.context.actorId, operation);
|
|
2013
|
+
return activation.executeActor(actor.context.actorId, operation, { lane: 'lifecycle' });
|
|
1934
2014
|
};
|
|
1935
2015
|
await this.options.actorTransferRuntime.deliverDeferredJoinCompletion(lifecycleFailure === undefined
|
|
1936
2016
|
? outcome.deferredJoinCompletion
|
|
@@ -1949,6 +2029,16 @@ class DefaultZLinkSpotManager {
|
|
|
1949
2029
|
this.formalRemoteActorAdmissions.beginRestore(relocationId);
|
|
1950
2030
|
return () => this.formalRemoteActorAdmissions.finishRestore(relocationId);
|
|
1951
2031
|
}
|
|
2032
|
+
/** @internal Transfers accepted ingress after the target Actor becomes visible. */
|
|
2033
|
+
openActorJoinRelocation(meshName, relocationId, actor) {
|
|
2034
|
+
const admission = this.formalRemoteActorAdmissions.get(relocationId);
|
|
2035
|
+
if (admission === undefined)
|
|
2036
|
+
return;
|
|
2037
|
+
const activation = this.activations.resolve(meshName, admission.admission.spotId);
|
|
2038
|
+
if (activation !== undefined) {
|
|
2039
|
+
this.migrateActorJoinPrewarm(activation, actor, relocationId);
|
|
2040
|
+
}
|
|
2041
|
+
}
|
|
1952
2042
|
async restoreCanonicalActorJoinRecovery(recovery, signal) {
|
|
1953
2043
|
(0, abort_1.throwIfAborted)(signal);
|
|
1954
2044
|
const admission = this.formalRemoteActorAdmissions.get(recovery.request.handoffId);
|
|
@@ -1965,7 +2055,7 @@ class DefaultZLinkSpotManager {
|
|
|
1965
2055
|
if (admitted.sourceActorNodeRid === undefined) {
|
|
1966
2056
|
throw new Error(`Actor Join recovery '${recovery.request.handoffId}' lost its command-28 source route.`);
|
|
1967
2057
|
}
|
|
1968
|
-
const admittedNodeBytes = Buffer.from((0,
|
|
2058
|
+
const admittedNodeBytes = Buffer.from((0, routing_id_2.encodeRoutingIdStorageHex)(admitted.sourceActorNodeRid), 'hex');
|
|
1969
2059
|
if (admitted.actorId !== recovery.request.actorId ||
|
|
1970
2060
|
admitted.actorType !== recovery.request.actorType ||
|
|
1971
2061
|
admitted.requestFingerprint !== recovery.request.request.toString('base64') ||
|
|
@@ -2003,33 +2093,7 @@ class DefaultZLinkSpotManager {
|
|
|
2003
2093
|
this.formalRemoteActorAdmissions.attachDeferredJoinCompletion(recovery.request.handoffId, deferred);
|
|
2004
2094
|
}
|
|
2005
2095
|
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
|
-
}
|
|
2096
|
+
return (0, actor_reply_1.encodeActorReply)(requestHeaderPart.data(), kind, payload, this.options.messageSerializers, this.options.dispatchErrors?.flow.flowCreationEnabled() ?? true);
|
|
2033
2097
|
}
|
|
2034
2098
|
async createActivation(meshName, spotType, spotId, request, signal, authority) {
|
|
2035
2099
|
this.requireRegisteredFactory(spotType);
|
|
@@ -2053,9 +2117,11 @@ class DefaultZLinkSpotManager {
|
|
|
2053
2117
|
* either lands in the snapshot or resolves the Actor directly through
|
|
2054
2118
|
* ordinary ingress — never both, never neither.
|
|
2055
2119
|
*/
|
|
2056
|
-
|
|
2120
|
+
migrateActorJoinPrewarm(activation, actor, transferId) {
|
|
2057
2121
|
const drained = this.formalRemoteActorAdmissions.completeMigration(transferId);
|
|
2058
|
-
|
|
2122
|
+
if (drained.length === 0)
|
|
2123
|
+
return;
|
|
2124
|
+
const terminals = drained.map(async (arrival) => {
|
|
2059
2125
|
try {
|
|
2060
2126
|
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
2127
|
arrival.resolve(response);
|
|
@@ -2063,7 +2129,13 @@ class DefaultZLinkSpotManager {
|
|
|
2063
2129
|
catch (error) {
|
|
2064
2130
|
arrival.reject(error);
|
|
2065
2131
|
}
|
|
2066
|
-
}
|
|
2132
|
+
});
|
|
2133
|
+
// Reserve every retained arrival's FIFO position before ordinary ingress
|
|
2134
|
+
// can resume. Handler terminals must not hold the relocation finalize that
|
|
2135
|
+
// releases an earlier saved-work prefix.
|
|
2136
|
+
this.options.detachedTaskRunner.runDetached(`actor Join ingress migration ${actor.context.actorId}`, async () => {
|
|
2137
|
+
await Promise.all(terminals);
|
|
2138
|
+
});
|
|
2067
2139
|
}
|
|
2068
2140
|
async dispatchMeshActorPacket(origin, meshName, spotId, actorId, parts, returnResponse, fallbackActorRef, requestTerminal, messageFollowOrigin) {
|
|
2069
2141
|
const activation = this.activations.resolve(meshName, spotId);
|
|
@@ -2119,7 +2191,7 @@ function decodeFormalRemoteTransferRequestBytes(bytes) {
|
|
|
2119
2191
|
? payload.requestContentType
|
|
2120
2192
|
: 'application/json',
|
|
2121
2193
|
actorEntryNodeRid: typeof payload.actorEntryNodeRid === 'string'
|
|
2122
|
-
? (0,
|
|
2194
|
+
? (0, routing_id_2.decodeRoutingId)(payload.actorEntryNodeRid, payload.actorEntryNodeRidHex)
|
|
2123
2195
|
: undefined,
|
|
2124
2196
|
sourceSpotId: typeof payload.sourceSpotId === 'string' ? payload.sourceSpotId : undefined,
|
|
2125
2197
|
actorRef: decodeFormalRemoteActorRef(payload),
|
|
@@ -2176,7 +2248,7 @@ function validateRemoteAdmissionCommit(admission, request, actorId, control) {
|
|
|
2176
2248
|
expected.targetSpotGeneration !== (control.currentSpotGeneration ?? 0n) ||
|
|
2177
2249
|
actorRef === undefined ||
|
|
2178
2250
|
actorRef.actorId !== expected.actorRef.actorId ||
|
|
2179
|
-
|
|
2251
|
+
!(0, routing_id_1.routingIdsEqual)(actorRef.nodeRid, expected.actorRef.nodeRid) ||
|
|
2180
2252
|
actorRef.objectGeneration !== expected.actorRef.objectGeneration) {
|
|
2181
2253
|
throw new configuration_1.ZLinkConfigurationException(`Remote Actor '${actorId}' commit does not match its target admission.`);
|
|
2182
2254
|
}
|
|
@@ -2204,17 +2276,3 @@ function isAbortSignal(value) {
|
|
|
2204
2276
|
typeof value.aborted === 'boolean' &&
|
|
2205
2277
|
typeof value.addEventListener === 'function');
|
|
2206
2278
|
}
|
|
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
|
-
}
|