@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,3 +1,7 @@
|
|
|
1
|
+
import { encodeActorReply } from '../actors/actor-reply';
|
|
2
|
+
import { boundSessionErrorPayload } from '../streams/bound-session-response-target';
|
|
3
|
+
import { RELOCATED_REQUEST_OWNED_BY_REQUESTER } from '../actors/actor-handoff';
|
|
4
|
+
import { routingIdsEqual } from '../routing-id';
|
|
1
5
|
import type { ApplicationJobOrigin } from '../application-jobs/contracts';
|
|
2
6
|
import { dispatchReasonFromError } from '../diagnostics/dispatch-error-details';
|
|
3
7
|
import type {
|
|
@@ -29,7 +33,7 @@ export { ZLinkSpotActorAdmissionCoordinator } from './spot-actor-admission-coord
|
|
|
29
33
|
import type { ZLinkSpotRouteResolver, ZLinkSpotRouteTarget } from './spot-routing-internal';
|
|
30
34
|
import type { Message } from '../../contracts/Common/Message';
|
|
31
35
|
import type { ZLinkMessageFollowOrigin } from '../foundation/service-runtime-contracts';
|
|
32
|
-
import { awaitWithAbort,
|
|
36
|
+
import { awaitWithAbort, throwIfAborted } from '../abort';
|
|
33
37
|
import {
|
|
34
38
|
ZLinkMessage,
|
|
35
39
|
ZLinkFrameworkException,
|
|
@@ -81,7 +85,6 @@ import {
|
|
|
81
85
|
} from '../actors';
|
|
82
86
|
import type { ZLinkLocationLifecycle } from '../locations';
|
|
83
87
|
import {
|
|
84
|
-
encodeFrameworkPayload,
|
|
85
88
|
encodeFrameworkPayloadMessage,
|
|
86
89
|
frameworkPayloadContentType,
|
|
87
90
|
wrapFrameworkPayloadMessage
|
|
@@ -92,13 +95,7 @@ import {
|
|
|
92
95
|
encodeChannelErrorReplyParts,
|
|
93
96
|
encodeChannelReplyParts
|
|
94
97
|
} from '../channels/channel-envelope';
|
|
95
|
-
import {
|
|
96
|
-
decodeStreamHeader,
|
|
97
|
-
encodeStreamHeader,
|
|
98
|
-
streamCodecForContentType,
|
|
99
|
-
ZLinkStreamHeaderFlags,
|
|
100
|
-
ZLinkStreamMessageKind
|
|
101
|
-
} from '../streams/protocol';
|
|
98
|
+
import { ZLinkStreamMessageKind } from '../streams/protocol';
|
|
102
99
|
import {
|
|
103
100
|
REMOTE_ACTOR_JOIN_PACKET,
|
|
104
101
|
REMOTE_ACTOR_JOIN_ABORT,
|
|
@@ -135,6 +132,7 @@ export {
|
|
|
135
132
|
export { ZLinkRuntimeSpotPublisherTransport } from './spot-publisher-transport';
|
|
136
133
|
import { ZLinkSpotActivationRegistry } from './spot-activation-registry';
|
|
137
134
|
import type { ZLinkSpotActivation } from './spot-activation-state';
|
|
135
|
+
import type { ZLinkSpotPreparationCompletion } from './spot-serial-executor';
|
|
138
136
|
import { ZLinkSpotActivationLifecycle, type ZLinkNativeSpotAuthority } from './spot-activation';
|
|
139
137
|
import { ZLinkSpotActorMembership } from './spot-actor-membership';
|
|
140
138
|
import { ZLinkFormalRemoteActorTransferRegistry } from './formal-remote-actor-transfer-registry';
|
|
@@ -148,7 +146,7 @@ import type {
|
|
|
148
146
|
ZLinkSpotActorTransferRuntime,
|
|
149
147
|
ZLinkSpotBoundSessionRuntime
|
|
150
148
|
} from './spot-runtime-ports';
|
|
151
|
-
import type { ZLinkRuntimeAdmissionGate } from '../admission';
|
|
149
|
+
import type { ZLinkRuntimeAdmissionGate, ZLinkMeshDispatchAdmission } from '../admission';
|
|
152
150
|
import type { ZLinkActivationAdmission } from '../activation-admission';
|
|
153
151
|
import type { ZLinkDetachedTaskRunner } from './spot-actor-join-dispatch';
|
|
154
152
|
import type { ZLinkLocalSpotCreateResult } from './spot-manager-internal-contracts';
|
|
@@ -159,6 +157,7 @@ import { ZLinkRoutedSpotPacketDispatch } from './spot-routed-spot-packet-dispatc
|
|
|
159
157
|
export { ZLinkEntrySpotActivation } from './spot-entry-activation';
|
|
160
158
|
export {
|
|
161
159
|
createFrameworkEntrySpotId,
|
|
160
|
+
registrationAcceptsNewActor,
|
|
162
161
|
ZLinkSpotNodeRuntimeManager,
|
|
163
162
|
type ZLinkSpotNodeRuntimeManagerOptions
|
|
164
163
|
} from './spot-node-runtime-manager';
|
|
@@ -209,6 +208,11 @@ export interface ZLinkSpotManagerOptions {
|
|
|
209
208
|
actor: ZLinkActor,
|
|
210
209
|
handoffBacklog?: readonly ZLinkActorHandoffPacket[]
|
|
211
210
|
) => Promise<void>;
|
|
211
|
+
readonly admitEntryActorPacketPrefix?: (
|
|
212
|
+
meshName: string,
|
|
213
|
+
actorId: string,
|
|
214
|
+
records: readonly ZLinkActorHandoffPrefixRecord[]
|
|
215
|
+
) => ZLinkActorHandoffPrefixAdmission;
|
|
212
216
|
readonly executeEntryActor?: <T>(
|
|
213
217
|
meshName: string,
|
|
214
218
|
actorId: string,
|
|
@@ -439,9 +443,16 @@ export class DefaultZLinkSpotManager {
|
|
|
439
443
|
this.actorMembership.leaveActor(spotId, actor, signal, meshName),
|
|
440
444
|
requestContextClose: (activation, objectGeneration, signal) =>
|
|
441
445
|
this.closeFromContext(activation, objectGeneration, signal),
|
|
442
|
-
|
|
443
|
-
this.activations.
|
|
446
|
+
stageActivation: (activation) => {
|
|
447
|
+
this.activations.registerPreparing(activation);
|
|
448
|
+
},
|
|
449
|
+
discardActivation: (activation) => {
|
|
450
|
+
this.activations.finishClose(activation.meshName, activation.spotId);
|
|
451
|
+
},
|
|
452
|
+
registerActivation: async (activation) => {
|
|
453
|
+
const published = this.activations.register(activation);
|
|
444
454
|
this.scheduleIdleSweep();
|
|
455
|
+
if (published?.domain.kind === 'user') await published.serialExecutor.finishPreparation();
|
|
445
456
|
},
|
|
446
457
|
// Spec 15 §4.2 relocation temporary queue: production ingress
|
|
447
458
|
// consults the same admission attempts registered on Accepted
|
|
@@ -513,6 +524,7 @@ export class DefaultZLinkSpotManager {
|
|
|
513
524
|
spotId: RoutingId,
|
|
514
525
|
objectGeneration: bigint,
|
|
515
526
|
authorityOwnerGeneration: bigint,
|
|
527
|
+
restoredTimers: readonly import('./spot-timer').ZLinkTimerRelocationState[],
|
|
516
528
|
signal?: AbortSignal
|
|
517
529
|
): Promise<ZLinkSpotActivation> {
|
|
518
530
|
this.activations.stage(meshName, spotId);
|
|
@@ -525,6 +537,7 @@ export class DefaultZLinkSpotManager {
|
|
|
525
537
|
spotId,
|
|
526
538
|
objectGeneration,
|
|
527
539
|
authorityOwnerGeneration,
|
|
540
|
+
restoredTimers,
|
|
528
541
|
signal
|
|
529
542
|
);
|
|
530
543
|
} catch (error) {
|
|
@@ -537,12 +550,19 @@ export class DefaultZLinkSpotManager {
|
|
|
537
550
|
activation: ZLinkSpotActivation,
|
|
538
551
|
beforeAdmission?: () => Promise<void>
|
|
539
552
|
): Promise<void> {
|
|
540
|
-
|
|
553
|
+
// Spot timer §1: OnInitialize before Ready reattaches restored keys; the
|
|
554
|
+
// relocation-ready completion and later callbacks use the ordinary rule.
|
|
555
|
+
await activation.serial.postBarrierTurn(() =>
|
|
556
|
+
activation.timers.runRelocationInitialization(() => activation.spot.onInitialize?.())
|
|
557
|
+
);
|
|
541
558
|
await beforeAdmission?.();
|
|
542
559
|
this.activations.publish(activation.meshName, activation.spotId);
|
|
560
|
+
await activation.serialExecutor.finishPreparation();
|
|
561
|
+
await activation.timers.publishRelocation();
|
|
543
562
|
}
|
|
544
563
|
|
|
545
564
|
async abortRelocationSpot(activation: ZLinkSpotActivation): Promise<void> {
|
|
565
|
+
await this.activationLifecycle.discardPreparation(activation);
|
|
546
566
|
this.activations.detachRelocated(activation.meshName, activation.spotId);
|
|
547
567
|
await activation.timers.dispose();
|
|
548
568
|
await activation.nativeSpot?.dispose();
|
|
@@ -558,7 +578,8 @@ export class DefaultZLinkSpotManager {
|
|
|
558
578
|
instanceType: string,
|
|
559
579
|
spotId: RoutingId,
|
|
560
580
|
objectGeneration: bigint,
|
|
561
|
-
signal?: AbortSignal
|
|
581
|
+
signal?: AbortSignal,
|
|
582
|
+
completion: ZLinkSpotPreparationCompletion = 'publication'
|
|
562
583
|
): Promise<void> {
|
|
563
584
|
const readyTarget = this.options.instanceSpotApplicationTargetProvider?.(meshName, spotId);
|
|
564
585
|
const existing = this.pendingInstanceMaterializations.get(
|
|
@@ -576,7 +597,8 @@ export class DefaultZLinkSpotManager {
|
|
|
576
597
|
spotId,
|
|
577
598
|
objectGeneration,
|
|
578
599
|
readyTarget?.objectGeneration === objectGeneration,
|
|
579
|
-
signal
|
|
600
|
+
signal,
|
|
601
|
+
completion
|
|
580
602
|
);
|
|
581
603
|
} finally {
|
|
582
604
|
release?.();
|
|
@@ -589,7 +611,8 @@ export class DefaultZLinkSpotManager {
|
|
|
589
611
|
spotId: RoutingId,
|
|
590
612
|
objectGeneration: bigint,
|
|
591
613
|
requiresReadyTarget: boolean,
|
|
592
|
-
signal
|
|
614
|
+
signal: AbortSignal | undefined,
|
|
615
|
+
completion: ZLinkSpotPreparationCompletion
|
|
593
616
|
): Promise<void> {
|
|
594
617
|
const factory = this.requireInstanceFactory(meshName, instanceType);
|
|
595
618
|
const key = `${meshName}\0${String(spotId)}`;
|
|
@@ -622,7 +645,7 @@ export class DefaultZLinkSpotManager {
|
|
|
622
645
|
continue;
|
|
623
646
|
}
|
|
624
647
|
|
|
625
|
-
const current = this.activations.
|
|
648
|
+
const current = this.activations.activationForClose(meshName, spotId);
|
|
626
649
|
if (current !== undefined) {
|
|
627
650
|
if (current.spotType !== factory) {
|
|
628
651
|
throw new ZLinkConfigurationException(
|
|
@@ -668,16 +691,16 @@ export class DefaultZLinkSpotManager {
|
|
|
668
691
|
}
|
|
669
692
|
}
|
|
670
693
|
if (pending === undefined) {
|
|
671
|
-
|
|
694
|
+
if (completion === 'first-terminal') this.activations.stage(meshName, spotId);
|
|
672
695
|
pending = this.activationLifecycle
|
|
673
696
|
.materializeInstance(meshName, instanceType, factory, spotId, objectGeneration, signal)
|
|
674
697
|
.then(
|
|
675
|
-
(activation) => {
|
|
676
|
-
|
|
698
|
+
async (activation) => {
|
|
699
|
+
if (completion === 'publication') await activation.serialExecutor.finishPreparation();
|
|
677
700
|
return activation;
|
|
678
701
|
},
|
|
679
702
|
(error) => {
|
|
680
|
-
|
|
703
|
+
this.activations.abandonStage(meshName, spotId);
|
|
681
704
|
throw error;
|
|
682
705
|
}
|
|
683
706
|
);
|
|
@@ -725,10 +748,16 @@ export class DefaultZLinkSpotManager {
|
|
|
725
748
|
? this.activations.resolveUnique(spotId)
|
|
726
749
|
: this.activations.resolve(meshName, spotId);
|
|
727
750
|
if (current !== undefined) return current;
|
|
728
|
-
if (meshName !== undefined)
|
|
729
|
-
|
|
751
|
+
if (meshName !== undefined) {
|
|
752
|
+
const closing = this.closeOperations.get(`${meshName}\0${String(spotId)}`);
|
|
753
|
+
return closing?.authority === undefined ? undefined : closing.activation;
|
|
754
|
+
}
|
|
730
755
|
for (const operation of this.closeOperations.values()) {
|
|
731
|
-
if (
|
|
756
|
+
if (
|
|
757
|
+
operation.authority !== undefined &&
|
|
758
|
+
String(operation.activation.spotId) === String(spotId)
|
|
759
|
+
)
|
|
760
|
+
return operation.activation;
|
|
732
761
|
}
|
|
733
762
|
return undefined;
|
|
734
763
|
}
|
|
@@ -737,6 +766,7 @@ export class DefaultZLinkSpotManager {
|
|
|
737
766
|
const prefix = instanceMaterializationPrefix(meshName, spotId);
|
|
738
767
|
return (
|
|
739
768
|
(this.pendingInstanceMaterializationsByPrefix.get(prefix)?.size ?? 0) > 0 ||
|
|
769
|
+
this.activations.activationForClose(meshName, spotId)?.serialExecutor.isPreparing === true ||
|
|
740
770
|
this.closeOperations.get(`${meshName}\0${String(spotId)}`)?.authority !== undefined
|
|
741
771
|
);
|
|
742
772
|
}
|
|
@@ -753,7 +783,7 @@ export class DefaultZLinkSpotManager {
|
|
|
753
783
|
}
|
|
754
784
|
|
|
755
785
|
async discardInstance(meshName: string, spotId: RoutingId): Promise<void> {
|
|
756
|
-
const activation = this.activations.
|
|
786
|
+
const activation = this.activations.activationForClose(meshName, spotId);
|
|
757
787
|
if (activation === undefined) return;
|
|
758
788
|
activation.requestClose();
|
|
759
789
|
const operation = this.activations.startClose(
|
|
@@ -803,6 +833,9 @@ export class DefaultZLinkSpotManager {
|
|
|
803
833
|
objectGeneration: bigint
|
|
804
834
|
): Promise<boolean> {
|
|
805
835
|
const key = `${meshName}\0${String(spotId)}`;
|
|
836
|
+
const activation = this.activations.activationForClose(meshName, spotId);
|
|
837
|
+
if (activation?.objectGeneration === objectGeneration)
|
|
838
|
+
await activation.serialExecutor.finishPreparation();
|
|
806
839
|
const pending = this.pendingInstanceTerminals.get(key);
|
|
807
840
|
if (pending === undefined) return false;
|
|
808
841
|
this.removePendingInstanceTerminalGeneration(key, objectGeneration);
|
|
@@ -849,6 +882,17 @@ export class DefaultZLinkSpotManager {
|
|
|
849
882
|
this.pendingInstanceTerminalGenerations.set(key, generations);
|
|
850
883
|
}
|
|
851
884
|
|
|
885
|
+
publishInstance(
|
|
886
|
+
target: { readonly targetSpotId: string; readonly objectGeneration: bigint },
|
|
887
|
+
meshName: string
|
|
888
|
+
): void {
|
|
889
|
+
const activation = this.activations.activationForClose(meshName, target.targetSpotId);
|
|
890
|
+
if (activation?.objectGeneration === target.objectGeneration) {
|
|
891
|
+
const published = this.activations.publish(meshName, target.targetSpotId);
|
|
892
|
+
published?.serialExecutor.openPreparationAdmission();
|
|
893
|
+
}
|
|
894
|
+
}
|
|
895
|
+
|
|
852
896
|
private deferInstanceAuthorityRelease(key: string, objectGeneration: bigint): void {
|
|
853
897
|
const generations = this.deferredInstanceAuthorityReleases.get(key) ?? new Set<bigint>();
|
|
854
898
|
generations.add(objectGeneration);
|
|
@@ -1079,19 +1123,24 @@ export class DefaultZLinkSpotManager {
|
|
|
1079
1123
|
}
|
|
1080
1124
|
|
|
1081
1125
|
async drainForShutdown(meshName: string, signal?: AbortSignal, deadline?: Date): Promise<void> {
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
.
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1126
|
+
// The host bounds observation of the whole Close, including lifecycle admission.
|
|
1127
|
+
// The owned operation keeps the gate and scopes until its running turns settle.
|
|
1128
|
+
const results = await awaitWithAbort(
|
|
1129
|
+
Promise.allSettled(
|
|
1130
|
+
this.activations
|
|
1131
|
+
.activeActivations()
|
|
1132
|
+
.filter((activation) => activation.meshName === meshName)
|
|
1133
|
+
.map((activation) =>
|
|
1134
|
+
this.closeWithReason(
|
|
1135
|
+
meshName,
|
|
1136
|
+
activation.spotId,
|
|
1137
|
+
undefined,
|
|
1138
|
+
ZLinkSpotCloseReason.HostShutdown,
|
|
1139
|
+
deadline
|
|
1140
|
+
)
|
|
1093
1141
|
)
|
|
1094
|
-
|
|
1142
|
+
),
|
|
1143
|
+
signal
|
|
1095
1144
|
);
|
|
1096
1145
|
const errors = results
|
|
1097
1146
|
.filter((result): result is PromiseRejectedResult => result.status === 'rejected')
|
|
@@ -1129,7 +1178,10 @@ export class DefaultZLinkSpotManager {
|
|
|
1129
1178
|
): Promise<boolean> {
|
|
1130
1179
|
const { meshName, spotId } = activation;
|
|
1131
1180
|
const operation = this.closeOperations.get(`${meshName}\0${String(spotId)}`);
|
|
1132
|
-
const current =
|
|
1181
|
+
const current =
|
|
1182
|
+
operation?.activation ??
|
|
1183
|
+
this.activations.resolve(meshName, spotId) ??
|
|
1184
|
+
(activation.serialExecutor.isPreparing ? activation : undefined);
|
|
1133
1185
|
if (current === undefined) {
|
|
1134
1186
|
return Promise.resolve(false);
|
|
1135
1187
|
}
|
|
@@ -1152,7 +1204,8 @@ export class DefaultZLinkSpotManager {
|
|
|
1152
1204
|
signal,
|
|
1153
1205
|
ZLinkSpotCloseReason.ExplicitClose,
|
|
1154
1206
|
undefined,
|
|
1155
|
-
beginUserAuthority
|
|
1207
|
+
beginUserAuthority,
|
|
1208
|
+
activation
|
|
1156
1209
|
);
|
|
1157
1210
|
}
|
|
1158
1211
|
|
|
@@ -1166,13 +1219,14 @@ export class DefaultZLinkSpotManager {
|
|
|
1166
1219
|
onCommitted: () => void
|
|
1167
1220
|
) => Promise<
|
|
1168
1221
|
import('../locations/spot-location-claims').ZLinkInstanceClosingAuthority | undefined
|
|
1169
|
-
|
|
1222
|
+
>,
|
|
1223
|
+
contextActivation?: ZLinkSpotActivation
|
|
1170
1224
|
): Promise<boolean> {
|
|
1171
1225
|
requireMeshName(meshName);
|
|
1172
1226
|
const key = `${meshName}\0${String(spotId)}`;
|
|
1173
1227
|
let operation = this.closeOperations.get(key);
|
|
1174
1228
|
if (operation === undefined) {
|
|
1175
|
-
const activation = this.activations.resolve(meshName, spotId);
|
|
1229
|
+
const activation = this.activations.resolve(meshName, spotId) ?? contextActivation;
|
|
1176
1230
|
if (activation === undefined) return false;
|
|
1177
1231
|
if (
|
|
1178
1232
|
activation.domain.kind === 'user' &&
|
|
@@ -1245,10 +1299,11 @@ export class DefaultZLinkSpotManager {
|
|
|
1245
1299
|
signal?: AbortSignal,
|
|
1246
1300
|
deadline?: Date
|
|
1247
1301
|
): Promise<boolean> {
|
|
1302
|
+
if (this.activations.resolve(meshName, spotId) !== operation.activation) return false;
|
|
1248
1303
|
const seal = await this.beginCloseAuthority(meshName, spotId, operation, signal);
|
|
1249
1304
|
if (seal === undefined) return false;
|
|
1250
1305
|
if (seal !== true) {
|
|
1251
|
-
await this.activationLifecycle.sealForClose(operation.activation, seal);
|
|
1306
|
+
await this.activationLifecycle.sealForClose(operation.activation, seal, signal);
|
|
1252
1307
|
} else {
|
|
1253
1308
|
await operation.activation.executionBarrier.waitForStartedTurns(signal);
|
|
1254
1309
|
}
|
|
@@ -1420,12 +1475,19 @@ export class DefaultZLinkSpotManager {
|
|
|
1420
1475
|
this.activations.stage(meshName, spotId);
|
|
1421
1476
|
}
|
|
1422
1477
|
|
|
1423
|
-
publishUserSpot(meshName: string, spotId: RoutingId): void {
|
|
1424
|
-
this.activations.publish(meshName, spotId);
|
|
1478
|
+
async publishUserSpot(meshName: string, spotId: RoutingId): Promise<void> {
|
|
1479
|
+
const published = this.activations.publish(meshName, spotId);
|
|
1480
|
+
await published?.serialExecutor.finishPreparation();
|
|
1425
1481
|
}
|
|
1426
1482
|
|
|
1427
|
-
abortUserSpotPublication(meshName: string, spotId: RoutingId): void {
|
|
1483
|
+
async abortUserSpotPublication(meshName: string, spotId: RoutingId): Promise<void> {
|
|
1428
1484
|
this.activations.abandonStage(meshName, spotId);
|
|
1485
|
+
const activation = this.activations.activationForClose(meshName, spotId);
|
|
1486
|
+
if (activation?.serialExecutor.isPreparing === true) {
|
|
1487
|
+
await this.activationLifecycle.cleanupFailedIncarnation(activation);
|
|
1488
|
+
this.activations.finishClose(meshName, spotId);
|
|
1489
|
+
await activation.serialExecutor.close();
|
|
1490
|
+
}
|
|
1429
1491
|
}
|
|
1430
1492
|
|
|
1431
1493
|
resolveLocalSpotRoute(spotId: RoutingId): ZLinkSpotRouteTarget | undefined {
|
|
@@ -1459,12 +1521,6 @@ export class DefaultZLinkSpotManager {
|
|
|
1459
1521
|
): Promise<ZLinkSpotActorJoinResult> {
|
|
1460
1522
|
const meshName = this.activations.resolveUnique(spotId)?.meshName;
|
|
1461
1523
|
this.options.admission?.requireRequest('Actor join admission', meshName);
|
|
1462
|
-
if (meshName !== undefined && this.isSpotClosing(meshName, spotId)) {
|
|
1463
|
-
throw createInternalFrameworkException(
|
|
1464
|
-
ZLinkFrameworkInternalErrorKind.RequestRejected,
|
|
1465
|
-
`Spot '${String(spotId)}' is closing.`
|
|
1466
|
-
);
|
|
1467
|
-
}
|
|
1468
1524
|
return await this.actorMembership.admitActorJoin(
|
|
1469
1525
|
spotId,
|
|
1470
1526
|
actor,
|
|
@@ -1511,14 +1567,6 @@ export class DefaultZLinkSpotManager {
|
|
|
1511
1567
|
await this.actorMembership.commitActorLeaveAfterTransfer(spotId, actorId);
|
|
1512
1568
|
}
|
|
1513
1569
|
|
|
1514
|
-
async restoreActorAfterFailedTransfer(
|
|
1515
|
-
spotId: RoutingId,
|
|
1516
|
-
actor: ZLinkActor,
|
|
1517
|
-
signal?: AbortSignal
|
|
1518
|
-
): Promise<void> {
|
|
1519
|
-
await this.actorMembership.restoreActorAfterFailedTransfer(spotId, actor, signal);
|
|
1520
|
-
}
|
|
1521
|
-
|
|
1522
1570
|
async beginActorTransfer(spotId: RoutingId, actorId: string): Promise<void> {
|
|
1523
1571
|
await this.actorMembership.beginActorTransfer(spotId, actorId);
|
|
1524
1572
|
}
|
|
@@ -1597,6 +1645,24 @@ export class DefaultZLinkSpotManager {
|
|
|
1597
1645
|
return this.activationLifecycle.admitActorPacketPrefix(activation, actorId, records);
|
|
1598
1646
|
}
|
|
1599
1647
|
|
|
1648
|
+
/** Resolves the current Actor FIFO owner for both Entry and User membership. */
|
|
1649
|
+
admitSourceActorPacketPrefix(
|
|
1650
|
+
actorId: string,
|
|
1651
|
+
records: readonly ZLinkActorHandoffPrefixRecord[]
|
|
1652
|
+
): ZLinkActorHandoffPrefixAdmission {
|
|
1653
|
+
const owner = this.options.actorDispatchOwnerResolver?.(actorId);
|
|
1654
|
+
if (owner?.actorRef === undefined) {
|
|
1655
|
+
throw new ZLinkConfigurationException(`Actor '${actorId}' has no local FIFO owner.`);
|
|
1656
|
+
}
|
|
1657
|
+
if (owner.spotId === undefined) {
|
|
1658
|
+
if (this.options.admitEntryActorPacketPrefix === undefined) {
|
|
1659
|
+
throw new ZLinkConfigurationException(`Actor '${actorId}' has no Entry FIFO port.`);
|
|
1660
|
+
}
|
|
1661
|
+
return this.options.admitEntryActorPacketPrefix(owner.actorRef.meshName, actorId, records);
|
|
1662
|
+
}
|
|
1663
|
+
return this.admitRoutedActorPacketPrefix(owner.spotId, actorId, records);
|
|
1664
|
+
}
|
|
1665
|
+
|
|
1600
1666
|
async dispatchRoutedSpotSend(
|
|
1601
1667
|
spotId: RoutingId,
|
|
1602
1668
|
packetName: string | undefined,
|
|
@@ -1631,14 +1697,15 @@ export class DefaultZLinkSpotManager {
|
|
|
1631
1697
|
async dispatchMeshSpot(
|
|
1632
1698
|
meshName: string,
|
|
1633
1699
|
owner: ReadyRecord,
|
|
1634
|
-
record: ReceiveRecord
|
|
1700
|
+
record: ReceiveRecord,
|
|
1701
|
+
admit?: ZLinkMeshDispatchAdmission
|
|
1635
1702
|
): Promise<void> {
|
|
1636
1703
|
const spotId = owner.spotId as unknown as RoutingId | null;
|
|
1637
1704
|
if (spotId === null) {
|
|
1638
1705
|
throw new ZLinkConfigurationException('MeshNode Spot record is missing the owner Spot RID.');
|
|
1639
1706
|
}
|
|
1640
1707
|
if (record.kind === ReceiveKind.SpotMulticast) {
|
|
1641
|
-
const activation = this.activations.
|
|
1708
|
+
const activation = this.activations.activationForClose(meshName, spotId);
|
|
1642
1709
|
if (activation?.actorDispatch === undefined) {
|
|
1643
1710
|
throw new ZLinkConfigurationException(
|
|
1644
1711
|
`MeshNode Spot multicast target '${String(spotId)}' is not active.`
|
|
@@ -1649,11 +1716,13 @@ export class DefaultZLinkSpotManager {
|
|
|
1649
1716
|
'MeshNode Spot multicast record is missing its topic.'
|
|
1650
1717
|
);
|
|
1651
1718
|
}
|
|
1652
|
-
|
|
1653
|
-
|
|
1654
|
-
|
|
1655
|
-
|
|
1656
|
-
|
|
1719
|
+
const dispatch = () =>
|
|
1720
|
+
activation.actorDispatch!.dispatchSubscriptionRecord(
|
|
1721
|
+
record.topic!,
|
|
1722
|
+
record.parts,
|
|
1723
|
+
record.sourceNodeRid as unknown as RoutingId | null
|
|
1724
|
+
);
|
|
1725
|
+
await (admit === undefined ? dispatch() : admit(dispatch));
|
|
1657
1726
|
return;
|
|
1658
1727
|
}
|
|
1659
1728
|
const envelope = decodeChannelEnvelope(
|
|
@@ -1675,28 +1744,32 @@ export class DefaultZLinkSpotManager {
|
|
|
1675
1744
|
record.applicationMetadata?.byteLength ?? zlinkMetadataByteLength(envelope.header.metadata)
|
|
1676
1745
|
)
|
|
1677
1746
|
};
|
|
1678
|
-
if (record.kind === ReceiveKind.SpotSend) {
|
|
1679
|
-
await this.ensureInstanceApplicationActivation(meshName, spotId);
|
|
1680
|
-
await this.routedSpotPackets.sendEncoded(spotId, packetName, decodePayload, context);
|
|
1681
|
-
return;
|
|
1682
|
-
}
|
|
1683
|
-
if (record.kind !== ReceiveKind.SpotRequest) {
|
|
1684
|
-
throw new ZLinkConfigurationException(
|
|
1685
|
-
`Unsupported MeshNode Spot record kind '${record.kind}'.`
|
|
1686
|
-
);
|
|
1687
|
-
}
|
|
1688
1747
|
try {
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
|
|
1692
|
-
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
|
|
1748
|
+
const dispatch = async () => {
|
|
1749
|
+
if (record.kind === ReceiveKind.SpotSend) {
|
|
1750
|
+
await this.ensureInstanceApplicationActivation(meshName, spotId);
|
|
1751
|
+
await this.routedSpotPackets.sendEncoded(spotId, packetName, decodePayload, context);
|
|
1752
|
+
return;
|
|
1753
|
+
}
|
|
1754
|
+
if (record.kind !== ReceiveKind.SpotRequest) {
|
|
1755
|
+
throw new ZLinkConfigurationException(
|
|
1756
|
+
`Unsupported MeshNode Spot record kind '${record.kind}'.`
|
|
1757
|
+
);
|
|
1758
|
+
}
|
|
1759
|
+
await this.ensureInstanceApplicationActivation(meshName, spotId);
|
|
1760
|
+
const response = await this.routedSpotPackets.requestEncoded(
|
|
1761
|
+
spotId,
|
|
1762
|
+
packetName,
|
|
1763
|
+
decodePayload,
|
|
1764
|
+
context
|
|
1765
|
+
);
|
|
1766
|
+
requireMeshSpotReply(
|
|
1767
|
+
record.reply(encodeChannelReplyParts(envelope.header, response, codecs))
|
|
1768
|
+
);
|
|
1769
|
+
};
|
|
1770
|
+
await (admit === undefined ? dispatch() : admit(dispatch));
|
|
1699
1771
|
} catch (error) {
|
|
1772
|
+
if (record.kind !== ReceiveKind.SpotRequest) throw error;
|
|
1700
1773
|
requireMeshSpotReply(record.reply(encodeChannelErrorReplyParts(envelope.header, error)));
|
|
1701
1774
|
}
|
|
1702
1775
|
}
|
|
@@ -1731,7 +1804,8 @@ export class DefaultZLinkSpotManager {
|
|
|
1731
1804
|
async dispatchMeshInstance(
|
|
1732
1805
|
meshName: string,
|
|
1733
1806
|
owner: ReadyRecord,
|
|
1734
|
-
record: ReceiveRecord
|
|
1807
|
+
record: ReceiveRecord,
|
|
1808
|
+
admit?: ZLinkMeshDispatchAdmission
|
|
1735
1809
|
): Promise<void> {
|
|
1736
1810
|
const spotId = owner.spotId as unknown as RoutingId | null;
|
|
1737
1811
|
if (spotId === null) {
|
|
@@ -1761,75 +1835,111 @@ export class DefaultZLinkSpotManager {
|
|
|
1761
1835
|
'activating'
|
|
1762
1836
|
);
|
|
1763
1837
|
try {
|
|
1764
|
-
|
|
1765
|
-
|
|
1766
|
-
|
|
1767
|
-
|
|
1768
|
-
|
|
1769
|
-
|
|
1770
|
-
|
|
1771
|
-
|
|
1772
|
-
|
|
1773
|
-
|
|
1774
|
-
|
|
1775
|
-
|
|
1776
|
-
|
|
1777
|
-
|
|
1778
|
-
|
|
1838
|
+
const dispatch = async () => {
|
|
1839
|
+
await this.ensureInstanceApplicationActivation(meshName, spotId);
|
|
1840
|
+
const activation = this.resolveApplicationActivation(spotId, meshName);
|
|
1841
|
+
if (activation === undefined || activation.domain.kind !== 'instance') {
|
|
1842
|
+
throw new ZLinkConfigurationException(
|
|
1843
|
+
`MeshNode Instance Spot target '${String(spotId)}' is not active.`
|
|
1844
|
+
);
|
|
1845
|
+
}
|
|
1846
|
+
const target = this.options.instanceSpotApplicationTargetProvider?.(meshName, spotId);
|
|
1847
|
+
if (
|
|
1848
|
+
target !== undefined &&
|
|
1849
|
+
activation.domain.objectGeneration !== target.objectGeneration
|
|
1850
|
+
) {
|
|
1851
|
+
throw createInternalFrameworkException(
|
|
1852
|
+
ZLinkFrameworkInternalErrorKind.SpotGenerationStale,
|
|
1853
|
+
`Instance Spot target '${String(spotId)}' application generation is stale.`
|
|
1854
|
+
);
|
|
1855
|
+
}
|
|
1856
|
+
const codecs =
|
|
1857
|
+
this.options.messageSerializers === undefined
|
|
1858
|
+
? undefined
|
|
1859
|
+
: { serializers: this.options.messageSerializers };
|
|
1860
|
+
const decodePayload = () => decodeChannelPayload(envelope, codecs);
|
|
1861
|
+
const context = {
|
|
1862
|
+
channelName: envelope.header.channelName,
|
|
1863
|
+
contentType: envelope.header.contentType,
|
|
1864
|
+
awaitFirstHandlerTurn: record.kind === ReceiveKind.InstanceSpotActivation,
|
|
1865
|
+
activationRecord: record,
|
|
1866
|
+
onOneWayError:
|
|
1867
|
+
this.options.dispatchErrors?.captureEnabled() === true
|
|
1868
|
+
? (error: unknown) =>
|
|
1869
|
+
this.reportInstanceDispatchFailure(
|
|
1870
|
+
meshName,
|
|
1871
|
+
spotId,
|
|
1872
|
+
record,
|
|
1873
|
+
envelope,
|
|
1874
|
+
false,
|
|
1875
|
+
error
|
|
1876
|
+
)
|
|
1877
|
+
: undefined,
|
|
1878
|
+
workOptions: zlinkSerialWorkOptions(
|
|
1879
|
+
envelope.payload.byteLength,
|
|
1880
|
+
record.applicationMetadata?.byteLength ??
|
|
1881
|
+
zlinkMetadataByteLength(envelope.header.metadata)
|
|
1882
|
+
)
|
|
1883
|
+
};
|
|
1884
|
+
// Spot messaging §7 step 3: an Instance intent request that reaches an
|
|
1885
|
+
// incarnation whose Close ended admission is refused before admission
|
|
1886
|
+
// with the owner fence terminal, so its caller re-reads authority.
|
|
1887
|
+
const instanceIntent =
|
|
1888
|
+
record.activationRecord?.activation === 'missing' ||
|
|
1889
|
+
(record.activationRecord?.activation === 'ready' &&
|
|
1890
|
+
record.activationRecord.instanceIntent);
|
|
1891
|
+
const refusal = activation.serial.applicationAdmissionRefusal(instanceIntent === true);
|
|
1892
|
+
if (request && refusal !== undefined && record.replyFailure !== undefined) {
|
|
1893
|
+
this.reportInstanceDispatchFailure(
|
|
1894
|
+
meshName,
|
|
1895
|
+
spotId,
|
|
1896
|
+
record,
|
|
1897
|
+
envelope,
|
|
1898
|
+
request,
|
|
1899
|
+
refusal
|
|
1900
|
+
);
|
|
1901
|
+
const terminal = internalFrameworkWireReply(refusal);
|
|
1902
|
+
requireMeshSpotReply(
|
|
1903
|
+
record.replyFailure(terminal.terminalResult, terminal.failureCode)
|
|
1904
|
+
);
|
|
1905
|
+
return;
|
|
1906
|
+
}
|
|
1907
|
+
this.traceInstanceMessage(
|
|
1908
|
+
ZLinkMessageFlowOutcome.Admitted,
|
|
1909
|
+
meshName,
|
|
1910
|
+
spotId,
|
|
1911
|
+
record,
|
|
1912
|
+
envelope,
|
|
1913
|
+
'ready',
|
|
1914
|
+
target?.stableType
|
|
1779
1915
|
);
|
|
1780
|
-
|
|
1781
|
-
|
|
1782
|
-
|
|
1783
|
-
|
|
1784
|
-
|
|
1785
|
-
|
|
1786
|
-
|
|
1787
|
-
|
|
1788
|
-
|
|
1789
|
-
|
|
1790
|
-
|
|
1791
|
-
|
|
1792
|
-
|
|
1793
|
-
|
|
1794
|
-
|
|
1795
|
-
|
|
1796
|
-
|
|
1797
|
-
|
|
1798
|
-
|
|
1799
|
-
|
|
1800
|
-
|
|
1801
|
-
|
|
1802
|
-
|
|
1803
|
-
|
|
1804
|
-
|
|
1805
|
-
|
|
1806
|
-
|
|
1807
|
-
)
|
|
1808
|
-
};
|
|
1809
|
-
// Spot messaging §7 step 3: an Instance intent request that reaches an
|
|
1810
|
-
// incarnation whose Close ended admission is refused before admission
|
|
1811
|
-
// with the owner fence terminal, so its caller re-reads authority.
|
|
1812
|
-
const instanceIntent =
|
|
1813
|
-
record.activationRecord?.activation === 'missing' ||
|
|
1814
|
-
(record.activationRecord?.activation === 'ready' &&
|
|
1815
|
-
record.activationRecord.instanceIntent);
|
|
1816
|
-
const refusal = activation.serial.applicationAdmissionRefusal(instanceIntent === true);
|
|
1817
|
-
if (request && refusal !== undefined && record.replyFailure !== undefined) {
|
|
1818
|
-
this.reportInstanceDispatchFailure(meshName, spotId, record, envelope, request, refusal);
|
|
1819
|
-
const terminal = internalFrameworkWireReply(refusal);
|
|
1820
|
-
requireMeshSpotReply(record.replyFailure(terminal.terminalResult, terminal.failureCode));
|
|
1821
|
-
return;
|
|
1822
|
-
}
|
|
1823
|
-
this.traceInstanceMessage(
|
|
1824
|
-
ZLinkMessageFlowOutcome.Admitted,
|
|
1825
|
-
meshName,
|
|
1826
|
-
spotId,
|
|
1827
|
-
record,
|
|
1828
|
-
envelope,
|
|
1829
|
-
'ready',
|
|
1830
|
-
target?.stableType
|
|
1831
|
-
);
|
|
1832
|
-
if (!request) {
|
|
1916
|
+
if (!request) {
|
|
1917
|
+
this.traceInstanceMessage(
|
|
1918
|
+
ZLinkMessageFlowOutcome.Dispatched,
|
|
1919
|
+
meshName,
|
|
1920
|
+
spotId,
|
|
1921
|
+
record,
|
|
1922
|
+
envelope,
|
|
1923
|
+
'ready',
|
|
1924
|
+
target?.stableType
|
|
1925
|
+
);
|
|
1926
|
+
await this.routedSpotPackets.sendEncoded(
|
|
1927
|
+
spotId,
|
|
1928
|
+
envelope.packetName,
|
|
1929
|
+
decodePayload,
|
|
1930
|
+
context
|
|
1931
|
+
);
|
|
1932
|
+
this.traceInstanceMessage(
|
|
1933
|
+
ZLinkMessageFlowOutcome.Completed,
|
|
1934
|
+
meshName,
|
|
1935
|
+
spotId,
|
|
1936
|
+
record,
|
|
1937
|
+
envelope,
|
|
1938
|
+
'ready',
|
|
1939
|
+
target?.stableType
|
|
1940
|
+
);
|
|
1941
|
+
return;
|
|
1942
|
+
}
|
|
1833
1943
|
this.traceInstanceMessage(
|
|
1834
1944
|
ZLinkMessageFlowOutcome.Dispatched,
|
|
1835
1945
|
meshName,
|
|
@@ -1839,14 +1949,17 @@ export class DefaultZLinkSpotManager {
|
|
|
1839
1949
|
'ready',
|
|
1840
1950
|
target?.stableType
|
|
1841
1951
|
);
|
|
1842
|
-
await this.routedSpotPackets.
|
|
1952
|
+
const response = await this.routedSpotPackets.requestEncoded(
|
|
1843
1953
|
spotId,
|
|
1844
1954
|
envelope.packetName,
|
|
1845
1955
|
decodePayload,
|
|
1846
1956
|
context
|
|
1847
1957
|
);
|
|
1958
|
+
requireMeshSpotReply(
|
|
1959
|
+
record.reply(encodeChannelReplyParts(envelope.header, response, codecs))
|
|
1960
|
+
);
|
|
1848
1961
|
this.traceInstanceMessage(
|
|
1849
|
-
ZLinkMessageFlowOutcome.
|
|
1962
|
+
ZLinkMessageFlowOutcome.Replied,
|
|
1850
1963
|
meshName,
|
|
1851
1964
|
spotId,
|
|
1852
1965
|
record,
|
|
@@ -1854,35 +1967,8 @@ export class DefaultZLinkSpotManager {
|
|
|
1854
1967
|
'ready',
|
|
1855
1968
|
target?.stableType
|
|
1856
1969
|
);
|
|
1857
|
-
|
|
1858
|
-
|
|
1859
|
-
this.traceInstanceMessage(
|
|
1860
|
-
ZLinkMessageFlowOutcome.Dispatched,
|
|
1861
|
-
meshName,
|
|
1862
|
-
spotId,
|
|
1863
|
-
record,
|
|
1864
|
-
envelope,
|
|
1865
|
-
'ready',
|
|
1866
|
-
target?.stableType
|
|
1867
|
-
);
|
|
1868
|
-
const response = await this.routedSpotPackets.requestEncoded(
|
|
1869
|
-
spotId,
|
|
1870
|
-
envelope.packetName,
|
|
1871
|
-
decodePayload,
|
|
1872
|
-
context
|
|
1873
|
-
);
|
|
1874
|
-
requireMeshSpotReply(
|
|
1875
|
-
record.reply(encodeChannelReplyParts(envelope.header, response, codecs))
|
|
1876
|
-
);
|
|
1877
|
-
this.traceInstanceMessage(
|
|
1878
|
-
ZLinkMessageFlowOutcome.Replied,
|
|
1879
|
-
meshName,
|
|
1880
|
-
spotId,
|
|
1881
|
-
record,
|
|
1882
|
-
envelope,
|
|
1883
|
-
'ready',
|
|
1884
|
-
target?.stableType
|
|
1885
|
-
);
|
|
1970
|
+
};
|
|
1971
|
+
await (admit === undefined ? dispatch() : admit(dispatch));
|
|
1886
1972
|
} catch (error) {
|
|
1887
1973
|
this.reportInstanceDispatchFailure(meshName, spotId, record, envelope, request, error);
|
|
1888
1974
|
const reason = dispatchReasonFromError(error);
|
|
@@ -1977,7 +2063,8 @@ export class DefaultZLinkSpotManager {
|
|
|
1977
2063
|
origin: ApplicationJobOrigin,
|
|
1978
2064
|
meshName: string,
|
|
1979
2065
|
owner: ReadyRecord,
|
|
1980
|
-
record: ReceiveRecord
|
|
2066
|
+
record: ReceiveRecord,
|
|
2067
|
+
admit?: ZLinkMeshDispatchAdmission
|
|
1981
2068
|
): Promise<void> {
|
|
1982
2069
|
const spotId = owner.spotId as unknown as RoutingId | null;
|
|
1983
2070
|
const entrySpotId = this.options.entryNodeRidProvider?.() ?? this.options.entryNodeRid;
|
|
@@ -1988,12 +2075,15 @@ export class DefaultZLinkSpotManager {
|
|
|
1988
2075
|
throw new ZLinkConfigurationException('MeshNode Actor record is missing its Actor owner.');
|
|
1989
2076
|
}
|
|
1990
2077
|
const request = record.kind === ReceiveKind.ActorRequest;
|
|
1991
|
-
const
|
|
1992
|
-
const
|
|
1993
|
-
|
|
1994
|
-
|
|
2078
|
+
const nativeTarget = record.messageFollowOrigin?.target;
|
|
2079
|
+
const ingressActor = nativeTarget?.actor ?? actor;
|
|
2080
|
+
const resolvedActorRef = (nativeTarget === undefined
|
|
2081
|
+
? this.options.actorDispatchOwnerResolver?.(actor.actorId).actorRef
|
|
2082
|
+
: undefined) ?? {
|
|
2083
|
+
actorId: ingressActor.actorId,
|
|
2084
|
+
objectGeneration: ingressActor.generation,
|
|
1995
2085
|
meshName,
|
|
1996
|
-
nodeRid:
|
|
2086
|
+
nodeRid: ingressActor.nodeRid
|
|
1997
2087
|
};
|
|
1998
2088
|
const responseActorRef =
|
|
1999
2089
|
record.sourceBindingGeneration > 0n
|
|
@@ -2032,43 +2122,49 @@ export class DefaultZLinkSpotManager {
|
|
|
2032
2122
|
)
|
|
2033
2123
|
: undefined;
|
|
2034
2124
|
try {
|
|
2035
|
-
|
|
2036
|
-
|
|
2037
|
-
|
|
2038
|
-
|
|
2039
|
-
? await this.options.dispatchEntryActorPacket?.(
|
|
2040
|
-
origin,
|
|
2041
|
-
actor.actorId,
|
|
2042
|
-
record.parts,
|
|
2043
|
-
request,
|
|
2044
|
-
undefined,
|
|
2045
|
-
ownerActorRef,
|
|
2046
|
-
requestTerminal,
|
|
2047
|
-
record.messageFollowOrigin
|
|
2048
|
-
)
|
|
2049
|
-
: await this.dispatchMeshActorPacket(
|
|
2050
|
-
origin,
|
|
2051
|
-
meshName,
|
|
2052
|
-
spotId,
|
|
2053
|
-
actor.actorId,
|
|
2054
|
-
record.parts,
|
|
2055
|
-
request,
|
|
2056
|
-
ownerActorRef,
|
|
2057
|
-
requestTerminal,
|
|
2058
|
-
record.messageFollowOrigin
|
|
2125
|
+
const dispatch = async () => {
|
|
2126
|
+
if (this.formalRemoteTransfers.has(actor.actorId)) {
|
|
2127
|
+
throw new Error(
|
|
2128
|
+
`Actor '${actor.actorId}' target transfer reconciliation is not complete.`
|
|
2059
2129
|
);
|
|
2060
|
-
|
|
2061
|
-
|
|
2062
|
-
|
|
2063
|
-
|
|
2064
|
-
|
|
2065
|
-
|
|
2066
|
-
|
|
2067
|
-
|
|
2068
|
-
|
|
2069
|
-
|
|
2070
|
-
|
|
2071
|
-
|
|
2130
|
+
}
|
|
2131
|
+
const response = targetsEntrySpot
|
|
2132
|
+
? await this.options.dispatchEntryActorPacket?.(
|
|
2133
|
+
origin,
|
|
2134
|
+
actor.actorId,
|
|
2135
|
+
record.parts,
|
|
2136
|
+
request,
|
|
2137
|
+
undefined,
|
|
2138
|
+
ownerActorRef,
|
|
2139
|
+
requestTerminal,
|
|
2140
|
+
record.messageFollowOrigin
|
|
2141
|
+
)
|
|
2142
|
+
: await this.dispatchMeshActorPacket(
|
|
2143
|
+
origin,
|
|
2144
|
+
meshName,
|
|
2145
|
+
spotId,
|
|
2146
|
+
actor.actorId,
|
|
2147
|
+
record.parts,
|
|
2148
|
+
request,
|
|
2149
|
+
ownerActorRef,
|
|
2150
|
+
requestTerminal,
|
|
2151
|
+
record.messageFollowOrigin
|
|
2152
|
+
);
|
|
2153
|
+
if (targetsEntrySpot && this.options.dispatchEntryActorPacket === undefined) {
|
|
2154
|
+
throw new ZLinkConfigurationException(
|
|
2155
|
+
'MeshNode Entry Spot Actor dispatch is not configured.'
|
|
2156
|
+
);
|
|
2157
|
+
}
|
|
2158
|
+
if (response === RELOCATED_REQUEST_OWNED_BY_REQUESTER) return;
|
|
2159
|
+
if (request && !requestTerminalState.submitted) {
|
|
2160
|
+
requireMeshSpotReply(
|
|
2161
|
+
record.reply(
|
|
2162
|
+
this.encodeMeshActorReply(record.parts[0], ZLinkStreamMessageKind.Response, response)
|
|
2163
|
+
)
|
|
2164
|
+
);
|
|
2165
|
+
}
|
|
2166
|
+
};
|
|
2167
|
+
await (admit === undefined ? dispatch() : admit(dispatch));
|
|
2072
2168
|
} catch (error) {
|
|
2073
2169
|
if (!request) {
|
|
2074
2170
|
throw error;
|
|
@@ -2078,10 +2174,11 @@ export class DefaultZLinkSpotManager {
|
|
|
2078
2174
|
}
|
|
2079
2175
|
requireMeshSpotReply(
|
|
2080
2176
|
record.reply(
|
|
2081
|
-
this.encodeMeshActorReply(
|
|
2082
|
-
|
|
2083
|
-
|
|
2084
|
-
|
|
2177
|
+
this.encodeMeshActorReply(
|
|
2178
|
+
record.parts[0],
|
|
2179
|
+
ZLinkStreamMessageKind.Error,
|
|
2180
|
+
boundSessionErrorPayload(error)
|
|
2181
|
+
)
|
|
2085
2182
|
)
|
|
2086
2183
|
);
|
|
2087
2184
|
}
|
|
@@ -2869,11 +2966,7 @@ export class DefaultZLinkSpotManager {
|
|
|
2869
2966
|
control.previousMembershipEpoch
|
|
2870
2967
|
);
|
|
2871
2968
|
};
|
|
2872
|
-
|
|
2873
|
-
await callback();
|
|
2874
|
-
} else {
|
|
2875
|
-
await this.options.actorTransferRuntime.notifyCoreSourceLeave(actor, callback);
|
|
2876
|
-
}
|
|
2969
|
+
await callback();
|
|
2877
2970
|
return;
|
|
2878
2971
|
}
|
|
2879
2972
|
if (spotId === null) {
|
|
@@ -2964,7 +3057,7 @@ export class DefaultZLinkSpotManager {
|
|
|
2964
3057
|
// ingress hold) migrate into the real Actor queue next, in the
|
|
2965
3058
|
// order they parked — after the relayed backlog above, before
|
|
2966
3059
|
// regular ingress opens.
|
|
2967
|
-
|
|
3060
|
+
this.migrateActorJoinPrewarm(activation, actor, pendingTransfer.transferId);
|
|
2968
3061
|
// This registry owns target lifecycle and saved backlog
|
|
2969
3062
|
// reconciliation only. Session route readiness is enforced by
|
|
2970
3063
|
// the Session binding aggregate after this boundary.
|
|
@@ -3037,9 +3130,7 @@ export class DefaultZLinkSpotManager {
|
|
|
3037
3130
|
if (sourceJoinedActor === undefined && pendingTransfer === undefined) {
|
|
3038
3131
|
return;
|
|
3039
3132
|
}
|
|
3040
|
-
await
|
|
3041
|
-
activation.spot.onLeaveActor(actor)
|
|
3042
|
-
);
|
|
3133
|
+
await activation.spot.onLeaveActor(actor);
|
|
3043
3134
|
}
|
|
3044
3135
|
activation.commitActorDeparture(actor.context.actorId);
|
|
3045
3136
|
return;
|
|
@@ -3099,6 +3190,19 @@ export class DefaultZLinkSpotManager {
|
|
|
3099
3190
|
}
|
|
3100
3191
|
} catch (error) {
|
|
3101
3192
|
lifecycleFailure = { error };
|
|
3193
|
+
const reporter = this.options.dispatchErrors;
|
|
3194
|
+
if (reporter?.captureEnabled() === true) {
|
|
3195
|
+
reporter.report({
|
|
3196
|
+
surface: ZLinkDispatchErrorSurface.ActorRelocation,
|
|
3197
|
+
messageKind: ZLinkDispatchMessageKind.Control,
|
|
3198
|
+
reason: dispatchReasonFromError(error),
|
|
3199
|
+
action: ZLinkDispatchErrorAction.FailCaller,
|
|
3200
|
+
packetName: 'OnJoinedActor',
|
|
3201
|
+
meshName,
|
|
3202
|
+
actorId: actor.context.actorId,
|
|
3203
|
+
error
|
|
3204
|
+
});
|
|
3205
|
+
}
|
|
3102
3206
|
}
|
|
3103
3207
|
if (lifecycleFailure === undefined) {
|
|
3104
3208
|
const sourceLeave = submitSourceLeave(admission.admission.actorRef.nodeRid);
|
|
@@ -3117,7 +3221,7 @@ export class DefaultZLinkSpotManager {
|
|
|
3117
3221
|
if (activation === undefined) {
|
|
3118
3222
|
throw new Error(`Actor Join relocation '${relocationId}' target mailbox is missing.`);
|
|
3119
3223
|
}
|
|
3120
|
-
return activation.executeActor(actor.context.actorId, operation);
|
|
3224
|
+
return activation.executeActor(actor.context.actorId, operation, { lane: 'lifecycle' });
|
|
3121
3225
|
};
|
|
3122
3226
|
await this.options.actorTransferRuntime.deliverDeferredJoinCompletion(
|
|
3123
3227
|
lifecycleFailure === undefined
|
|
@@ -3143,6 +3247,16 @@ export class DefaultZLinkSpotManager {
|
|
|
3143
3247
|
return () => this.formalRemoteActorAdmissions.finishRestore(relocationId);
|
|
3144
3248
|
}
|
|
3145
3249
|
|
|
3250
|
+
/** @internal Transfers accepted ingress after the target Actor becomes visible. */
|
|
3251
|
+
openActorJoinRelocation(meshName: string, relocationId: string, actor: ZLinkActor): void {
|
|
3252
|
+
const admission = this.formalRemoteActorAdmissions.get(relocationId);
|
|
3253
|
+
if (admission === undefined) return;
|
|
3254
|
+
const activation = this.activations.resolve(meshName, admission.admission.spotId);
|
|
3255
|
+
if (activation !== undefined) {
|
|
3256
|
+
this.migrateActorJoinPrewarm(activation, actor, relocationId);
|
|
3257
|
+
}
|
|
3258
|
+
}
|
|
3259
|
+
|
|
3146
3260
|
async restoreCanonicalActorJoinRecovery(
|
|
3147
3261
|
recovery: CanonicalActorJoinRecovery,
|
|
3148
3262
|
signal?: AbortSignal
|
|
@@ -3237,35 +3351,13 @@ export class DefaultZLinkSpotManager {
|
|
|
3237
3351
|
kind: ZLinkStreamMessageKind.Response | ZLinkStreamMessageKind.Error,
|
|
3238
3352
|
payload: unknown
|
|
3239
3353
|
): readonly Buffer[] {
|
|
3240
|
-
|
|
3241
|
-
// Off (and skips its validation); when tracing is on the reply preserves
|
|
3242
|
-
// the request's flow pair alongside its correlation.
|
|
3243
|
-
const requestHeader = decodeStreamHeader(
|
|
3354
|
+
return encodeActorReply(
|
|
3244
3355
|
requestHeaderPart.data(),
|
|
3356
|
+
kind,
|
|
3357
|
+
payload,
|
|
3358
|
+
this.options.messageSerializers,
|
|
3245
3359
|
this.options.dispatchErrors?.flow.flowCreationEnabled() ?? true
|
|
3246
3360
|
);
|
|
3247
|
-
const encoded = encodeFrameworkPayload(payload, this.options.messageSerializers);
|
|
3248
|
-
try {
|
|
3249
|
-
// encodeStreamHeader returns a fresh, unaliased array; view it without
|
|
3250
|
-
// re-copying. The payload copy stays: encoded.message closes below.
|
|
3251
|
-
const replyHeader = encodeStreamHeader({
|
|
3252
|
-
kind,
|
|
3253
|
-
codec: streamCodecForContentType(encoded.contentType),
|
|
3254
|
-
flags: ZLinkStreamHeaderFlags.None,
|
|
3255
|
-
requestSeq: requestHeader.requestSeq,
|
|
3256
|
-
name: '',
|
|
3257
|
-
metadata: new Map(),
|
|
3258
|
-
correlationId: requestHeader.correlationId,
|
|
3259
|
-
flowId: requestHeader.flowId,
|
|
3260
|
-
flowOrigin: requestHeader.flowOrigin
|
|
3261
|
-
});
|
|
3262
|
-
return [
|
|
3263
|
-
Buffer.from(replyHeader.buffer, replyHeader.byteOffset, replyHeader.byteLength),
|
|
3264
|
-
Buffer.from(encoded.message.data())
|
|
3265
|
-
];
|
|
3266
|
-
} finally {
|
|
3267
|
-
encoded.message.close();
|
|
3268
|
-
}
|
|
3269
3361
|
}
|
|
3270
3362
|
|
|
3271
3363
|
private async createActivation<TSpot extends ZLinkSpot>(
|
|
@@ -3327,13 +3419,14 @@ export class DefaultZLinkSpotManager {
|
|
|
3327
3419
|
* either lands in the snapshot or resolves the Actor directly through
|
|
3328
3420
|
* ordinary ingress — never both, never neither.
|
|
3329
3421
|
*/
|
|
3330
|
-
private
|
|
3422
|
+
private migrateActorJoinPrewarm(
|
|
3331
3423
|
activation: ZLinkSpotActivation,
|
|
3332
3424
|
actor: ZLinkActor,
|
|
3333
3425
|
transferId: string
|
|
3334
|
-
):
|
|
3426
|
+
): void {
|
|
3335
3427
|
const drained = this.formalRemoteActorAdmissions.completeMigration(transferId);
|
|
3336
|
-
|
|
3428
|
+
if (drained.length === 0) return;
|
|
3429
|
+
const terminals = drained.map(async (arrival) => {
|
|
3337
3430
|
try {
|
|
3338
3431
|
const response = await this.dispatchActorPacket(
|
|
3339
3432
|
arrival.origin,
|
|
@@ -3349,7 +3442,16 @@ export class DefaultZLinkSpotManager {
|
|
|
3349
3442
|
} catch (error) {
|
|
3350
3443
|
arrival.reject(error);
|
|
3351
3444
|
}
|
|
3352
|
-
}
|
|
3445
|
+
});
|
|
3446
|
+
// Reserve every retained arrival's FIFO position before ordinary ingress
|
|
3447
|
+
// can resume. Handler terminals must not hold the relocation finalize that
|
|
3448
|
+
// releases an earlier saved-work prefix.
|
|
3449
|
+
this.options.detachedTaskRunner.runDetached(
|
|
3450
|
+
`actor Join ingress migration ${actor.context.actorId}`,
|
|
3451
|
+
async () => {
|
|
3452
|
+
await Promise.all(terminals);
|
|
3453
|
+
}
|
|
3454
|
+
);
|
|
3353
3455
|
}
|
|
3354
3456
|
|
|
3355
3457
|
private async dispatchMeshActorPacket(
|
|
@@ -3567,7 +3669,7 @@ function validateRemoteAdmissionCommit(
|
|
|
3567
3669
|
expected.targetSpotGeneration !== (control.currentSpotGeneration ?? 0n) ||
|
|
3568
3670
|
actorRef === undefined ||
|
|
3569
3671
|
actorRef.actorId !== expected.actorRef.actorId ||
|
|
3570
|
-
|
|
3672
|
+
!routingIdsEqual(actorRef.nodeRid, expected.actorRef.nodeRid) ||
|
|
3571
3673
|
actorRef.objectGeneration !== expected.actorRef.objectGeneration
|
|
3572
3674
|
) {
|
|
3573
3675
|
throw new ZLinkConfigurationException(
|
|
@@ -3615,17 +3717,3 @@ function isAbortSignal(value: unknown): value is AbortSignal {
|
|
|
3615
3717
|
typeof (value as { addEventListener?: unknown }).addEventListener === 'function'
|
|
3616
3718
|
);
|
|
3617
3719
|
}
|
|
3618
|
-
|
|
3619
|
-
function instanceActivationOutcome(error: unknown): string {
|
|
3620
|
-
if (isAbortError(error)) return 'shutdown';
|
|
3621
|
-
if (error instanceof ZLinkFrameworkException) {
|
|
3622
|
-
if (error.kind === ZLinkFrameworkErrorKind.DeadlineExceeded) return 'timed_out';
|
|
3623
|
-
if (error.kind === ZLinkFrameworkErrorKind.AlreadyExists) return 'conflict';
|
|
3624
|
-
if (
|
|
3625
|
-
error.kind === ZLinkFrameworkErrorKind.InvalidOperation ||
|
|
3626
|
-
error.kind === ZLinkFrameworkErrorKind.Unavailable
|
|
3627
|
-
)
|
|
3628
|
-
return 'fenced';
|
|
3629
|
-
}
|
|
3630
|
-
return 'failed';
|
|
3631
|
-
}
|