@zlink-systems/framework 0.26.0 → 0.27.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/.tsbuildinfo +1 -1
- package/dist/contracts/Common/CoreTypes.d.ts +6 -0
- package/dist/contracts/Common/CoreTypes.js +7 -0
- package/dist/contracts/Common/index.d.ts +1 -1
- package/dist/contracts/Common/index.js +0 -1
- package/dist/contracts/Configuration/InternalDefaults.d.ts +8 -0
- package/dist/contracts/Configuration/InternalDefaults.js +9 -1
- package/dist/contracts/Configuration/Registration.d.ts +13 -2
- package/dist/contracts/Configuration/Registration.js +58 -36
- package/dist/contracts/Configuration/RegistrationBuilderPolicy.d.ts +13 -1
- package/dist/contracts/Configuration/RegistrationBuilderPolicy.js +38 -1
- package/dist/contracts/Configuration/RegistrationBuilders.d.ts +2 -3
- package/dist/contracts/Configuration/RegistrationBuilders.js +27 -32
- package/dist/contracts/Configuration/RegistrationTypes.d.ts +1 -0
- package/dist/contracts/Configuration/RegistrationValidators.js +15 -12
- package/dist/contracts/Configuration/TimerRegistrationValidator.js +3 -2
- package/dist/contracts/Dispatch/ZLinkDispatchOptions.d.ts +1 -1
- package/dist/contracts/Handlers/JsonContract.js +10 -4
- package/dist/contracts/Locations/Authority.d.ts +1 -1
- package/dist/contracts/Locations/Authority.js +3 -2
- package/dist/contracts/Locations/Options.js +1 -1
- package/dist/contracts/Locations/Stores.d.ts +12 -0
- package/dist/contracts/Locations/Stores.js +9 -0
- package/dist/contracts/Spots/Contracts.d.ts +1 -1
- package/dist/internal.d.ts +4 -0
- package/dist/internal.js +15 -1
- package/dist/nest-integration.d.ts +4 -2
- package/dist/nest-integration.js +14 -4
- package/dist/runtime/abort.d.ts +1 -0
- package/dist/runtime/abort.js +8 -5
- package/dist/runtime/activation-admission.d.ts +1 -2
- package/dist/runtime/activation-admission.js +2 -6
- package/dist/runtime/actors/actor-authority-payload-codec.d.ts +1 -2
- package/dist/runtime/actors/actor-authority-payload-codec.js +34 -18
- package/dist/runtime/actors/actor-client.d.ts +2 -2
- package/dist/runtime/actors/actor-client.js +42 -143
- package/dist/runtime/actors/actor-context.d.ts +3 -5
- package/dist/runtime/actors/actor-context.js +13 -11
- package/dist/runtime/actors/actor-handoff.d.ts +4 -4
- package/dist/runtime/actors/actor-handoff.js +8 -8
- package/dist/runtime/actors/actor-lifecycle-snapshot.js +2 -1
- package/dist/runtime/actors/actor-local-native-join.d.ts +11 -6
- package/dist/runtime/actors/actor-local-native-join.js +83 -105
- package/dist/runtime/actors/actor-native-lookup.js +2 -8
- package/dist/runtime/actors/actor-packet-relay-wire.d.ts +3 -3
- package/dist/runtime/actors/actor-packet-relay-wire.js +5 -3
- package/dist/runtime/actors/actor-remote-joiner.d.ts +1 -1
- package/dist/runtime/actors/actor-remote-joiner.js +5 -9
- package/dist/runtime/actors/actor-remote-wire.js +5 -3
- package/dist/runtime/actors/actor-request-deadline.d.ts +3 -0
- package/dist/runtime/actors/actor-request-deadline.js +31 -0
- package/dist/runtime/actors/actor-retry-delay.js +2 -1
- package/dist/runtime/actors/actor-runtime-state.d.ts +9 -21
- package/dist/runtime/actors/actor-runtime-state.js +70 -187
- package/dist/runtime/actors/bound-session-wire.js +2 -7
- package/dist/runtime/actors/deferred-join-completion.d.ts +11 -6
- package/dist/runtime/actors/deferred-join-completion.js +1 -0
- package/dist/runtime/actors/index.d.ts +9 -7
- package/dist/runtime/actors/index.js +87 -69
- package/dist/runtime/actors/spot-actor-dispatch.d.ts +3 -3
- package/dist/runtime/actors/spot-actor-dispatch.js +25 -10
- package/dist/runtime/actors/transferred-actor-rollback.d.ts +3 -5
- package/dist/runtime/actors/transferred-actor-rollback.js +9 -42
- package/dist/runtime/admission.d.ts +2 -0
- package/dist/runtime/admission.js +7 -1
- package/dist/runtime/application-jobs/application-job-queue-scope.d.ts +1 -1
- package/dist/runtime/application-jobs/application-job-queue-scope.js +1 -1
- package/dist/runtime/backend/contracts/index.d.ts +6 -23
- package/dist/runtime/backend/mesh-actor-session-node-adapter.js +1 -17
- package/dist/runtime/backend/mesh-dispatch-pump.d.ts +1 -2
- package/dist/runtime/backend/mesh-dispatch-pump.js +95 -107
- package/dist/runtime/backend/node/node-backend-adapter-support.d.ts +1 -1
- package/dist/runtime/backend/node/node-backend-adapter-support.js +16 -6
- package/dist/runtime/backend/node/node-event-loop-poller.d.ts +2 -2
- package/dist/runtime/backend/node/node-event-loop-poller.js +6 -7
- package/dist/runtime/backend/node/node-monitor-backend-adapter.js +1 -0
- package/dist/runtime/backend/node/node-raw-binding-port.js +40 -16
- package/dist/runtime/backend/node/node-raw-mesh-backend.d.ts +14 -15
- package/dist/runtime/backend/node/node-raw-mesh-backend.js +146 -118
- package/dist/runtime/backend/node/node-socket-backend-adapter.js +3 -2
- package/dist/runtime/backend/raw-binding-port.d.ts +1 -1
- package/dist/runtime/backend/runtime-values.d.ts +4 -1
- package/dist/runtime/backend/runtime-values.js +2 -0
- package/dist/runtime/channels/channel-clients.d.ts +20 -8
- package/dist/runtime/channels/channel-clients.js +68 -52
- package/dist/runtime/channels/channel-envelope-inspection.js +2 -1
- package/dist/runtime/channels/channel-envelope.js +47 -29
- package/dist/runtime/channels/channel-outbound-operations.d.ts +3 -0
- package/dist/runtime/channels/channel-outbound-operations.js +9 -10
- package/dist/runtime/channels/channel-receive-loops.d.ts +8 -3
- package/dist/runtime/channels/channel-receive-loops.js +27 -6
- package/dist/runtime/channels/channel-runtime-lifecycle.d.ts +12 -1
- package/dist/runtime/channels/channel-runtime-lifecycle.js +48 -28
- package/dist/runtime/channels/channel-runtime-manager.js +5 -2
- package/dist/runtime/channels/channel-socket-options.js +3 -2
- package/dist/runtime/channels/channel-socket-registry.d.ts +14 -29
- package/dist/runtime/channels/channel-socket-registry.js +248 -174
- package/dist/runtime/channels/channel-transports.d.ts +11 -17
- package/dist/runtime/channels/channel-transports.js +68 -47
- package/dist/runtime/channels/client-server-location-runtime.d.ts +1 -1
- package/dist/runtime/channels/client-server-location-runtime.js +10 -11
- package/dist/runtime/channels/client-server-service-wire.d.ts +7 -2
- package/dist/runtime/channels/client-server-service-wire.js +32 -11
- package/dist/runtime/channels/dispatch-error-reporter.d.ts +1 -2
- package/dist/runtime/channels/dispatch-error-reporter.js +2 -1
- package/dist/runtime/channels/fanout-location-runtime.d.ts +16 -3
- package/dist/runtime/channels/fanout-location-runtime.js +130 -72
- package/dist/runtime/channels/spot-direct-envelope.d.ts +1 -0
- package/dist/runtime/channels/spot-direct-envelope.js +4 -3
- package/dist/runtime/channels/spot-node-route-transport.js +3 -2
- package/dist/runtime/diagnostics/diagnostic-text.d.ts +2 -0
- package/dist/runtime/diagnostics/diagnostic-text.js +7 -0
- package/dist/runtime/diagnostics/dispatch-error-details.d.ts +3 -0
- package/dist/runtime/diagnostics/dispatch-error-details.js +30 -2
- package/dist/runtime/diagnostics/flow-context.d.ts +6 -0
- package/dist/runtime/diagnostics/flow-context.js +16 -2
- package/dist/runtime/diagnostics/index.d.ts +4 -2
- package/dist/runtime/diagnostics/index.js +14 -4
- package/dist/runtime/diagnostics/message-flow.d.ts +1 -1
- package/dist/runtime/diagnostics/message-flow.js +10 -19
- package/dist/runtime/diagnostics/runtime-metrics.d.ts +94 -31
- package/dist/runtime/diagnostics/runtime-metrics.js +168 -105
- package/dist/runtime/diagnostics/runtime-observation-queue.js +3 -2
- package/dist/runtime/diagnostics/topology-runtime-projections.d.ts +2 -4
- package/dist/runtime/diagnostics/topology-runtime-projections.js +135 -154
- package/dist/runtime/disposal.d.ts +5 -0
- package/dist/runtime/disposal.js +22 -0
- package/dist/runtime/execution/index.d.ts +12 -9
- package/dist/runtime/execution/index.js +58 -14
- package/dist/runtime/execution/serial-execution-queue.d.ts +8 -2
- package/dist/runtime/execution/serial-execution-queue.js +54 -15
- package/dist/runtime/execution/state-lane.d.ts +8 -1
- package/dist/runtime/execution/state-lane.js +118 -3
- package/dist/runtime/foundation/actor-join-recovery-codec.d.ts +3 -0
- package/dist/runtime/foundation/actor-join-recovery-codec.js +15 -11
- package/dist/runtime/foundation/event-loop-resources.d.ts +2 -24
- package/dist/runtime/foundation/event-loop-resources.js +6 -119
- package/dist/runtime/foundation/operation-identity.d.ts +2 -0
- package/dist/runtime/foundation/operation-identity.js +9 -5
- package/dist/runtime/foundation/operation-registry.d.ts +5 -7
- package/dist/runtime/foundation/operation-registry.js +34 -44
- package/dist/runtime/foundation/raw-service-mesh-runtime.d.ts +8 -5
- package/dist/runtime/foundation/raw-service-mesh-runtime.js +62 -83
- package/dist/runtime/foundation/runtime-state-projections.d.ts +3 -1
- package/dist/runtime/foundation/runtime-state-projections.js +8 -0
- package/dist/runtime/foundation/service-authority-payload-codec.js +22 -12
- package/dist/runtime/foundation/service-discovery-registry.d.ts +4 -0
- package/dist/runtime/foundation/service-discovery-registry.js +22 -3
- package/dist/runtime/foundation/service-instance-activation-recovery-codec.js +8 -4
- package/dist/runtime/foundation/service-liveness-registry.js +2 -1
- package/dist/runtime/foundation/service-maintenance-runtime.d.ts +0 -1
- package/dist/runtime/foundation/service-maintenance-runtime.js +0 -6
- package/dist/runtime/foundation/service-metadata-codec.js +3 -3
- package/dist/runtime/foundation/service-relocation-aggregate-committer.d.ts +2 -5
- package/dist/runtime/foundation/service-relocation-aggregate-committer.js +1 -48
- package/dist/runtime/foundation/service-relocation-object-owner.js +3 -2
- package/dist/runtime/foundation/service-relocation-runtime.js +43 -32
- package/dist/runtime/foundation/service-runtime-contracts.d.ts +40 -8
- package/dist/runtime/foundation/service-runtime-contracts.js +25 -1
- package/dist/runtime/foundation/service-session-binding-ingress-port.d.ts +0 -12
- package/dist/runtime/foundation/service-stateful-registry.d.ts +2 -0
- package/dist/runtime/foundation/service-stateful-registry.js +10 -2
- package/dist/runtime/foundation/service-stateful-runtime.d.ts +26 -25
- package/dist/runtime/foundation/service-stateful-runtime.js +217 -204
- package/dist/runtime/foundation/service-stateful-wire-codec.d.ts +3 -3
- package/dist/runtime/foundation/service-stateful-wire-codec.js +89 -55
- package/dist/runtime/foundation/service-topology-registry.d.ts +0 -1
- package/dist/runtime/foundation/service-topology-registry.js +17 -32
- package/dist/runtime/foundation/service-wire-binary-primitives.d.ts +5 -0
- package/dist/runtime/foundation/service-wire-binary-primitives.js +6 -0
- package/dist/runtime/foundation/service-wire-codec.js +10 -8
- package/dist/runtime/foundation/service-wire-constants.generated.d.ts +1 -0
- package/dist/runtime/foundation/service-wire-constants.generated.js +2 -1
- package/dist/runtime/foundation/service-wire-m6a-codec.d.ts +2 -0
- package/dist/runtime/foundation/service-wire-m6a-codec.js +23 -13
- package/dist/runtime/framework-errors-internal.d.ts +2 -1
- package/dist/runtime/framework-errors-internal.js +343 -122
- package/dist/runtime/handlers/handler-instance-scope.d.ts +3 -1
- package/dist/runtime/handlers/handler-instance-scope.js +61 -74
- package/dist/runtime/host/actor-packet-relay.d.ts +9 -6
- package/dist/runtime/host/actor-packet-relay.js +48 -91
- package/dist/runtime/host/actor-placement-coordinator.js +7 -5
- package/dist/runtime/host/actor-runtime-options-factory.d.ts +2 -0
- package/dist/runtime/host/actor-runtime-options-factory.js +17 -4
- package/dist/runtime/host/actor-transfer-runtime.d.ts +16 -18
- package/dist/runtime/host/actor-transfer-runtime.js +143 -176
- package/dist/runtime/host/application-job-queue.js +16 -33
- package/dist/runtime/host/bound-session-relay.js +1 -1
- package/dist/runtime/host/channel-runtime-options-factory.js +1 -1
- package/dist/runtime/host/index.d.ts +14 -13
- package/dist/runtime/host/index.js +190 -157
- package/dist/runtime/host/instance-activation-authority.d.ts +2 -3
- package/dist/runtime/host/instance-activation-authority.js +17 -45
- package/dist/runtime/host/location-runtime-owner.d.ts +1 -1
- package/dist/runtime/host/location-runtime-owner.js +2 -2
- package/dist/runtime/host/remote-actor-join-receiver.d.ts +2 -2
- package/dist/runtime/host/remote-actor-join-receiver.js +1 -14
- package/dist/runtime/host/remote-actor-packet-target-store.d.ts +3 -2
- package/dist/runtime/host/remote-actor-packet-target-store.js +8 -47
- package/dist/runtime/host/remote-bound-session-relay.d.ts +2 -3
- package/dist/runtime/host/remote-bound-session-relay.js +7 -20
- package/dist/runtime/host/route-mesh-runtime.d.ts +13 -11
- package/dist/runtime/host/route-mesh-runtime.js +171 -252
- package/dist/runtime/host/runtime-shutdown.d.ts +2 -0
- package/dist/runtime/host/runtime-shutdown.js +18 -21
- package/dist/runtime/host/service-relocation-control.js +6 -1
- package/dist/runtime/host/service-relocation-host-runtime.d.ts +21 -30
- package/dist/runtime/host/service-relocation-host-runtime.js +508 -416
- package/dist/runtime/host/spot-address-transport.d.ts +2 -3
- package/dist/runtime/host/spot-address-transport.js +34 -136
- package/dist/runtime/host/spot-node-runtime-options-factory.d.ts +1 -1
- package/dist/runtime/host/spot-node-runtime-options-factory.js +3 -2
- package/dist/runtime/host/spot-runtime-options-factory.d.ts +4 -10
- package/dist/runtime/host/spot-runtime-options-factory.js +50 -14
- package/dist/runtime/host/user-spot-creation-coordinator.d.ts +3 -3
- package/dist/runtime/host/user-spot-creation-coordinator.js +11 -8
- package/dist/runtime/locations/aggregate-inventory-store.js +13 -10
- package/dist/runtime/locations/authority-key-codec.js +4 -3
- package/dist/runtime/locations/auto-connect-reconciler.d.ts +4 -0
- package/dist/runtime/locations/auto-connect-reconciler.js +37 -25
- package/dist/runtime/locations/creation-operation-id.js +6 -4
- package/dist/runtime/locations/domain-store-contract.d.ts +3 -3
- package/dist/runtime/locations/in-memory-authority-store.js +31 -15
- package/dist/runtime/locations/in-memory-location-store.d.ts +2 -2
- package/dist/runtime/locations/in-memory-location-store.js +17 -14
- package/dist/runtime/locations/in-memory-provider-location-store.d.ts +1 -0
- package/dist/runtime/locations/in-memory-provider-location-store.js +72 -22
- package/dist/runtime/locations/key-codec.js +3 -2
- package/dist/runtime/locations/lease-tracker.d.ts +3 -5
- package/dist/runtime/locations/lease-tracker.js +7 -11
- package/dist/runtime/locations/lifecycle.d.ts +4 -9
- package/dist/runtime/locations/lifecycle.js +2 -31
- package/dist/runtime/locations/location-store-failure.d.ts +2 -0
- package/dist/runtime/locations/location-store-failure.js +7 -0
- package/dist/runtime/locations/location-store-pages.d.ts +3 -0
- package/dist/runtime/locations/location-store-pages.js +13 -0
- package/dist/runtime/locations/location-store-repository.d.ts +5 -7
- package/dist/runtime/locations/location-store-repository.js +303 -332
- package/dist/runtime/locations/relocation-blob.js +18 -5
- package/dist/runtime/locations/resolvers.d.ts +5 -5
- package/dist/runtime/locations/resolvers.js +37 -28
- package/dist/runtime/locations/runtime.d.ts +5 -4
- package/dist/runtime/locations/runtime.js +123 -92
- package/dist/runtime/locations/spot-location-claims.d.ts +6 -0
- package/dist/runtime/locations/spot-location-claims.js +42 -1
- package/dist/runtime/messaging/payload-codec.js +26 -20
- package/dist/runtime/messaging/submission-result.d.ts +3 -0
- package/dist/runtime/messaging/submission-result.js +48 -0
- package/dist/runtime/protocol/service_wire_codec.generated.d.ts +1 -0
- package/dist/runtime/protocol/service_wire_codec.generated.js +12 -7
- package/dist/runtime/spots/formal-remote-actor-transfer-registry.d.ts +4 -1
- package/dist/runtime/spots/index.d.ts +14 -20
- package/dist/runtime/spots/index.js +302 -176
- package/dist/runtime/spots/spot-activation-registry.d.ts +3 -5
- package/dist/runtime/spots/spot-activation-registry.js +14 -50
- package/dist/runtime/spots/spot-activation-state.d.ts +1 -1
- package/dist/runtime/spots/spot-activation-state.js +2 -2
- package/dist/runtime/spots/spot-activation.d.ts +3 -4
- package/dist/runtime/spots/spot-activation.js +49 -32
- package/dist/runtime/spots/spot-actor-admission-coordinator.d.ts +1 -2
- package/dist/runtime/spots/spot-actor-admission-coordinator.js +3 -40
- package/dist/runtime/spots/spot-actor-join-dispatch.d.ts +10 -18
- package/dist/runtime/spots/spot-actor-join-dispatch.js +4 -52
- package/dist/runtime/spots/spot-actor-membership.d.ts +4 -6
- package/dist/runtime/spots/spot-actor-membership.js +22 -45
- package/dist/runtime/spots/spot-actor-packet-dispatch.d.ts +0 -1
- package/dist/runtime/spots/spot-actor-packet-dispatch.js +0 -9
- package/dist/runtime/spots/spot-actor-packet-relay-dispatch.d.ts +2 -2
- package/dist/runtime/spots/spot-actor-packet-relay-dispatch.js +1 -7
- package/dist/runtime/spots/spot-context.d.ts +2 -2
- package/dist/runtime/spots/spot-entry-activation.d.ts +2 -2
- package/dist/runtime/spots/spot-entry-activation.js +9 -20
- package/dist/runtime/spots/spot-lifecycle-metrics.js +3 -2
- package/dist/runtime/spots/spot-manager-public.d.ts +5 -6
- package/dist/runtime/spots/spot-manager-public.js +5 -4
- package/dist/runtime/spots/spot-node-autoconnect.js +22 -31
- package/dist/runtime/spots/spot-node-runtime-manager.d.ts +19 -18
- package/dist/runtime/spots/spot-node-runtime-manager.js +67 -72
- package/dist/runtime/spots/spot-outbound.d.ts +4 -3
- package/dist/runtime/spots/spot-outbound.js +9 -8
- package/dist/runtime/spots/spot-remote-codec.js +5 -3
- package/dist/runtime/spots/spot-route-packet-dispatch.d.ts +2 -2
- package/dist/runtime/spots/spot-route-packet-dispatch.js +8 -8
- package/dist/runtime/spots/spot-route-replies.d.ts +2 -2
- package/dist/runtime/spots/spot-route-replies.js +3 -1
- package/dist/runtime/spots/spot-routed-actor-admission.d.ts +3 -3
- package/dist/runtime/spots/spot-routed-actor-admission.js +3 -12
- package/dist/runtime/spots/spot-routed-frame-dispatch.d.ts +1 -2
- package/dist/runtime/spots/spot-routed-frame-dispatch.js +0 -1
- package/dist/runtime/spots/spot-routed-spot-packet-dispatch.d.ts +4 -0
- package/dist/runtime/spots/spot-routed-spot-packet-dispatch.js +65 -15
- package/dist/runtime/spots/spot-runtime-ports.d.ts +2 -16
- package/dist/runtime/spots/spot-serial-executor.js +2 -2
- package/dist/runtime/spots/spot-serial-turn-executor.d.ts +27 -7
- package/dist/runtime/spots/spot-serial-turn-executor.js +83 -11
- package/dist/runtime/spots/spot-timer.d.ts +3 -2
- package/dist/runtime/streams/actor-session-binding-registry.d.ts +16 -29
- package/dist/runtime/streams/actor-session-binding-registry.js +142 -212
- package/dist/runtime/streams/actor-session-binding-runtime-owner.d.ts +1 -4
- package/dist/runtime/streams/bound-actor-relay-sender.d.ts +6 -2
- package/dist/runtime/streams/bound-actor-relay-sender.js +57 -33
- package/dist/runtime/streams/bound-session-service.d.ts +7 -0
- package/dist/runtime/streams/bound-session-service.js +11 -1
- package/dist/runtime/streams/index.d.ts +14 -15
- package/dist/runtime/streams/index.js +20 -21
- package/dist/runtime/streams/managed-stream.d.ts +3 -0
- package/dist/runtime/streams/managed-stream.js +17 -8
- package/dist/runtime/streams/native-fallback-bound-session.js +1 -3
- package/dist/runtime/streams/protocol.d.ts +6 -33
- package/dist/runtime/streams/protocol.js +38 -110
- package/dist/runtime/streams/session-actor-coordinator.d.ts +2 -3
- package/dist/runtime/streams/session-actor-coordinator.js +12 -4
- package/dist/runtime/streams/session-calls.d.ts +1 -1
- package/dist/runtime/streams/session-calls.js +5 -4
- package/dist/runtime/streams/session-context.d.ts +6 -6
- package/dist/runtime/streams/session-context.js +22 -4
- package/dist/runtime/streams/session-requests.js +2 -1
- package/dist/runtime/streams/stream-binding-runtime-ports.d.ts +16 -1
- package/dist/runtime/streams/stream-frame-factory.js +2 -2
- package/dist/runtime/streams/stream-session-runtime.d.ts +10 -11
- package/dist/runtime/streams/stream-session-runtime.js +25 -33
- package/dist/runtime/workers/index.d.ts +2 -2
- package/dist/runtime/workers/index.js +5 -4
- package/package.json +3 -3
- package/src/contracts/Common/CoreTypes.ts +7 -0
- package/src/contracts/Common/index.ts +1 -1
- package/src/contracts/Configuration/InternalDefaults.ts +12 -0
- package/src/contracts/Configuration/Registration.ts +92 -48
- package/src/contracts/Configuration/RegistrationBuilderPolicy.ts +44 -2
- package/src/contracts/Configuration/RegistrationBuilders.ts +77 -68
- package/src/contracts/Configuration/RegistrationTypes.ts +1 -0
- package/src/contracts/Configuration/RegistrationValidators.ts +19 -13
- package/src/contracts/Configuration/TimerRegistrationValidator.ts +4 -2
- package/src/contracts/Dispatch/ZLinkDispatchOptions.ts +1 -0
- package/src/contracts/Handlers/JsonContract.ts +14 -4
- package/src/contracts/Locations/Authority.ts +7 -3
- package/src/contracts/Locations/Options.ts +1 -1
- package/src/contracts/Locations/Stores.ts +14 -0
- package/src/contracts/Spots/Contracts.ts +1 -1
- package/src/internal.ts +14 -0
- package/src/nest-integration.ts +28 -10
- package/src/runtime/abort.ts +6 -5
- package/src/runtime/activation-admission.ts +2 -8
- package/src/runtime/actors/actor-authority-payload-codec.ts +58 -20
- package/src/runtime/actors/actor-client.ts +77 -204
- package/src/runtime/actors/actor-context.ts +39 -33
- package/src/runtime/actors/actor-handoff.ts +24 -22
- package/src/runtime/actors/actor-lifecycle-snapshot.ts +2 -1
- package/src/runtime/actors/actor-local-native-join.ts +172 -174
- package/src/runtime/actors/actor-native-lookup.ts +2 -9
- package/src/runtime/actors/actor-packet-relay-wire.ts +18 -12
- package/src/runtime/actors/actor-remote-joiner.ts +9 -11
- package/src/runtime/actors/actor-remote-wire.ts +5 -3
- package/src/runtime/actors/actor-request-deadline.ts +49 -0
- package/src/runtime/actors/actor-retry-delay.ts +2 -1
- package/src/runtime/actors/actor-runtime-state.ts +85 -247
- package/src/runtime/actors/bound-session-wire.ts +2 -8
- package/src/runtime/actors/deferred-join-completion.ts +10 -6
- package/src/runtime/actors/index.ts +100 -79
- package/src/runtime/actors/spot-actor-dispatch.ts +60 -29
- package/src/runtime/actors/transferred-actor-rollback.ts +11 -62
- package/src/runtime/admission.ts +8 -1
- package/src/runtime/application-jobs/application-job-queue-scope.ts +4 -4
- package/src/runtime/backend/contracts/index.ts +13 -29
- package/src/runtime/backend/mesh-actor-session-node-adapter.ts +2 -18
- package/src/runtime/backend/mesh-dispatch-pump.ts +111 -117
- package/src/runtime/backend/node/node-backend-adapter-support.ts +23 -6
- package/src/runtime/backend/node/node-event-loop-poller.ts +8 -12
- package/src/runtime/backend/node/node-monitor-backend-adapter.ts +1 -0
- package/src/runtime/backend/node/node-raw-binding-port.ts +41 -20
- package/src/runtime/backend/node/node-raw-mesh-backend.ts +227 -170
- package/src/runtime/backend/node/node-socket-backend-adapter.ts +3 -2
- package/src/runtime/backend/raw-binding-port.ts +1 -1
- package/src/runtime/backend/runtime-values.ts +4 -1
- package/src/runtime/channels/channel-clients.ts +132 -85
- package/src/runtime/channels/channel-envelope-inspection.ts +2 -1
- package/src/runtime/channels/channel-envelope.ts +58 -29
- package/src/runtime/channels/channel-outbound-operations.ts +10 -23
- package/src/runtime/channels/channel-receive-loops.ts +39 -7
- package/src/runtime/channels/channel-runtime-lifecycle.ts +60 -27
- package/src/runtime/channels/channel-runtime-manager.ts +6 -2
- package/src/runtime/channels/channel-socket-options.ts +8 -2
- package/src/runtime/channels/channel-socket-registry.ts +301 -192
- package/src/runtime/channels/channel-transports.ts +161 -112
- package/src/runtime/channels/client-server-location-runtime.ts +17 -17
- package/src/runtime/channels/client-server-service-wire.ts +40 -12
- package/src/runtime/channels/dispatch-error-reporter.ts +7 -5
- package/src/runtime/channels/fanout-location-runtime.ts +172 -91
- package/src/runtime/channels/spot-direct-envelope.ts +1 -1
- package/src/runtime/channels/spot-node-route-transport.ts +5 -2
- package/src/runtime/diagnostics/diagnostic-text.ts +4 -0
- package/src/runtime/diagnostics/dispatch-error-details.ts +36 -1
- package/src/runtime/diagnostics/flow-context.ts +16 -2
- package/src/runtime/diagnostics/index.ts +27 -17
- package/src/runtime/diagnostics/message-flow.ts +15 -25
- package/src/runtime/diagnostics/runtime-metrics.ts +181 -113
- package/src/runtime/diagnostics/runtime-observation-queue.ts +3 -2
- package/src/runtime/diagnostics/topology-runtime-projections.ts +194 -162
- package/src/runtime/disposal.ts +19 -0
- package/src/runtime/execution/index.ts +60 -20
- package/src/runtime/execution/serial-execution-queue.ts +131 -18
- package/src/runtime/execution/state-lane.ts +142 -4
- package/src/runtime/foundation/actor-join-recovery-codec.ts +13 -8
- package/src/runtime/foundation/event-loop-resources.ts +5 -122
- package/src/runtime/foundation/operation-identity.ts +11 -5
- package/src/runtime/foundation/operation-registry.ts +33 -50
- package/src/runtime/foundation/raw-service-mesh-runtime.ts +110 -111
- package/src/runtime/foundation/runtime-state-projections.ts +9 -1
- package/src/runtime/foundation/service-authority-payload-codec.ts +31 -13
- package/src/runtime/foundation/service-discovery-registry.ts +32 -3
- package/src/runtime/foundation/service-instance-activation-recovery-codec.ts +12 -4
- package/src/runtime/foundation/service-liveness-registry.ts +2 -1
- package/src/runtime/foundation/service-maintenance-runtime.ts +0 -10
- package/src/runtime/foundation/service-metadata-codec.ts +2 -2
- package/src/runtime/foundation/service-relocation-aggregate-committer.ts +3 -66
- package/src/runtime/foundation/service-relocation-object-owner.ts +5 -2
- package/src/runtime/foundation/service-relocation-runtime.ts +57 -35
- package/src/runtime/foundation/service-runtime-contracts.ts +46 -10
- package/src/runtime/foundation/service-session-binding-ingress-port.ts +0 -17
- package/src/runtime/foundation/service-stateful-registry.ts +14 -2
- package/src/runtime/foundation/service-stateful-runtime.ts +322 -276
- package/src/runtime/foundation/service-stateful-wire-codec.ts +128 -80
- package/src/runtime/foundation/service-topology-registry.ts +23 -32
- package/src/runtime/foundation/service-wire-binary-primitives.ts +6 -0
- package/src/runtime/foundation/service-wire-codec.ts +15 -8
- package/src/runtime/foundation/service-wire-constants.generated.ts +1 -0
- package/src/runtime/foundation/service-wire-m6a-codec.ts +29 -15
- package/src/runtime/framework-errors-internal.ts +380 -134
- package/src/runtime/handlers/handler-instance-scope.ts +68 -95
- package/src/runtime/host/actor-packet-relay.ts +57 -147
- package/src/runtime/host/actor-placement-coordinator.ts +8 -5
- package/src/runtime/host/actor-runtime-options-factory.ts +27 -8
- package/src/runtime/host/actor-transfer-runtime.ts +180 -260
- package/src/runtime/host/application-job-queue.ts +28 -34
- package/src/runtime/host/bound-session-relay.ts +1 -2
- package/src/runtime/host/channel-runtime-options-factory.ts +1 -2
- package/src/runtime/host/index.ts +327 -296
- package/src/runtime/host/instance-activation-authority.ts +89 -109
- package/src/runtime/host/location-runtime-owner.ts +4 -2
- package/src/runtime/host/remote-actor-join-receiver.ts +3 -31
- package/src/runtime/host/remote-actor-packet-target-store.ts +17 -58
- package/src/runtime/host/remote-bound-session-relay.ts +8 -41
- package/src/runtime/host/route-mesh-runtime.ts +228 -271
- package/src/runtime/host/runtime-shutdown.ts +17 -21
- package/src/runtime/host/service-relocation-control.ts +14 -1
- package/src/runtime/host/service-relocation-host-runtime.ts +699 -561
- package/src/runtime/host/spot-address-transport.ts +73 -195
- package/src/runtime/host/spot-node-runtime-options-factory.ts +6 -3
- package/src/runtime/host/spot-runtime-options-factory.ts +73 -22
- package/src/runtime/host/user-spot-creation-coordinator.ts +36 -22
- package/src/runtime/locations/aggregate-inventory-store.ts +16 -13
- package/src/runtime/locations/authority-key-codec.ts +7 -3
- package/src/runtime/locations/auto-connect-reconciler.ts +39 -26
- package/src/runtime/locations/creation-operation-id.ts +6 -3
- package/src/runtime/locations/domain-store-contract.ts +12 -3
- package/src/runtime/locations/in-memory-authority-store.ts +44 -15
- package/src/runtime/locations/in-memory-location-store.ts +50 -39
- package/src/runtime/locations/in-memory-provider-location-store.ts +100 -25
- package/src/runtime/locations/key-codec.ts +3 -2
- package/src/runtime/locations/lease-tracker.ts +8 -14
- package/src/runtime/locations/lifecycle.ts +13 -43
- package/src/runtime/locations/location-store-failure.ts +4 -0
- package/src/runtime/locations/location-store-pages.ts +18 -0
- package/src/runtime/locations/location-store-repository.ts +450 -478
- package/src/runtime/locations/relocation-blob.ts +17 -6
- package/src/runtime/locations/resolvers.ts +75 -49
- package/src/runtime/locations/runtime.ts +220 -110
- package/src/runtime/locations/spot-location-claims.ts +58 -1
- package/src/runtime/messaging/payload-codec.ts +35 -24
- package/src/runtime/messaging/submission-result.ts +57 -1
- package/src/runtime/protocol/service_wire_codec.generated.ts +18 -8
- package/src/runtime/protocol/service_wire_pilot_codec.generated.ts +1 -1
- package/src/runtime/spots/formal-remote-actor-transfer-registry.ts +4 -1
- package/src/runtime/spots/index.ts +433 -229
- package/src/runtime/spots/spot-activation-registry.ts +30 -69
- package/src/runtime/spots/spot-activation-state.ts +2 -2
- package/src/runtime/spots/spot-activation.ts +67 -37
- package/src/runtime/spots/spot-actor-admission-coordinator.ts +5 -57
- package/src/runtime/spots/spot-actor-join-dispatch.ts +24 -77
- package/src/runtime/spots/spot-actor-membership.ts +40 -72
- package/src/runtime/spots/spot-actor-packet-dispatch.ts +0 -16
- package/src/runtime/spots/spot-actor-packet-relay-dispatch.ts +3 -15
- package/src/runtime/spots/spot-context.ts +3 -3
- package/src/runtime/spots/spot-entry-activation.ts +13 -30
- package/src/runtime/spots/spot-lifecycle-metrics.ts +3 -2
- package/src/runtime/spots/spot-manager-public.ts +21 -17
- package/src/runtime/spots/spot-node-autoconnect.ts +20 -26
- package/src/runtime/spots/spot-node-runtime-manager.ts +136 -125
- package/src/runtime/spots/spot-outbound.ts +45 -23
- package/src/runtime/spots/spot-remote-codec.ts +7 -3
- package/src/runtime/spots/spot-route-packet-dispatch.ts +25 -24
- package/src/runtime/spots/spot-route-replies.ts +6 -4
- package/src/runtime/spots/spot-routed-actor-admission.ts +13 -26
- package/src/runtime/spots/spot-routed-frame-dispatch.ts +2 -3
- package/src/runtime/spots/spot-routed-spot-packet-dispatch.ts +95 -22
- package/src/runtime/spots/spot-runtime-ports.ts +5 -27
- package/src/runtime/spots/spot-serial-executor.ts +2 -2
- package/src/runtime/spots/spot-serial-turn-executor.ts +112 -11
- package/src/runtime/spots/spot-timer.ts +3 -2
- package/src/runtime/streams/actor-session-binding-registry.ts +179 -269
- package/src/runtime/streams/actor-session-binding-runtime-owner.ts +0 -8
- package/src/runtime/streams/bound-actor-relay-sender.ts +89 -43
- package/src/runtime/streams/bound-session-service.ts +21 -1
- package/src/runtime/streams/index.ts +76 -64
- package/src/runtime/streams/managed-stream.ts +29 -10
- package/src/runtime/streams/native-fallback-bound-session.ts +1 -3
- package/src/runtime/streams/protocol.ts +34 -88
- package/src/runtime/streams/session-actor-coordinator.ts +17 -5
- package/src/runtime/streams/session-calls.ts +6 -5
- package/src/runtime/streams/session-context.ts +54 -10
- package/src/runtime/streams/session-requests.ts +2 -1
- package/src/runtime/streams/stream-binding-runtime-ports.ts +22 -1
- package/src/runtime/streams/stream-frame-factory.ts +2 -3
- package/src/runtime/streams/stream-session-runtime.ts +57 -59
- package/src/runtime/workers/index.ts +13 -12
- package/dist/runtime/actors/post-commit-actor-location.d.ts +0 -19
- package/dist/runtime/actors/post-commit-actor-location.js +0 -72
- package/dist/runtime/spots/spot-native-actor-join-admission.d.ts +0 -26
- package/dist/runtime/spots/spot-native-actor-join-admission.js +0 -106
- package/src/runtime/actors/post-commit-actor-location.ts +0 -121
- package/src/runtime/spots/spot-native-actor-join-admission.ts +0 -155
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { dispatchReasonFromError } from '../diagnostics/dispatch-error-details';
|
|
1
2
|
import type {
|
|
2
3
|
ActorRef,
|
|
3
4
|
RoutingId,
|
|
@@ -32,6 +33,7 @@ import {
|
|
|
32
33
|
ZLinkMessage,
|
|
33
34
|
ZLinkFrameworkException,
|
|
34
35
|
ZLinkFrameworkErrorKind,
|
|
36
|
+
ZLinkFrameworkRuntimeState,
|
|
35
37
|
ZLinkSpotCloseReason,
|
|
36
38
|
ZLinkSpotKind
|
|
37
39
|
} from '../../contracts';
|
|
@@ -48,6 +50,7 @@ import {
|
|
|
48
50
|
runWithFlow,
|
|
49
51
|
type ZLinkRuntimeEventPublisher
|
|
50
52
|
} from '../diagnostics';
|
|
53
|
+
import { diagnosticTextOrAbsent } from '../diagnostics/diagnostic-text';
|
|
51
54
|
import { ZLinkBufferMessage as RuntimeMessage } from '../backend/runtime-message';
|
|
52
55
|
import { SubmitResult } from '../backend/runtime-values';
|
|
53
56
|
import {
|
|
@@ -59,10 +62,10 @@ import {
|
|
|
59
62
|
} from '../foundation/service-runtime-contracts';
|
|
60
63
|
import { zlinkMetadataByteLength, zlinkSerialWorkOptions } from '../execution/serial-work-size';
|
|
61
64
|
import { ZLinkConfigurationException } from '../configuration';
|
|
65
|
+
import { releaseApplicationJobPermitBeforeHandler } from '../application-jobs/application-job-queue-scope';
|
|
62
66
|
import {
|
|
63
67
|
ZLinkFrameworkInternalErrorKind,
|
|
64
68
|
createInternalFrameworkException,
|
|
65
|
-
internalFrameworkErrorKind,
|
|
66
69
|
internalFrameworkWireReply
|
|
67
70
|
} from '../framework-errors-internal';
|
|
68
71
|
import type { ZLinkBackendSpot, ZLinkBackendSpotNode } from '../backend/contracts';
|
|
@@ -132,7 +135,7 @@ export { ZLinkRuntimeSpotPublisherTransport } from './spot-publisher-transport';
|
|
|
132
135
|
import { ZLinkSpotActivationRegistry } from './spot-activation-registry';
|
|
133
136
|
import type { ZLinkSpotActivation } from './spot-activation-state';
|
|
134
137
|
import { ZLinkSpotActivationLifecycle, type ZLinkNativeSpotAuthority } from './spot-activation';
|
|
135
|
-
import { ZLinkSpotActorMembership
|
|
138
|
+
import { ZLinkSpotActorMembership } from './spot-actor-membership';
|
|
136
139
|
import { ZLinkFormalRemoteActorTransferRegistry } from './formal-remote-actor-transfer-registry';
|
|
137
140
|
import {
|
|
138
141
|
ZLinkFormalRemoteActorAdmissionRegistry,
|
|
@@ -204,6 +207,11 @@ export interface ZLinkSpotManagerOptions {
|
|
|
204
207
|
actor: ZLinkActor,
|
|
205
208
|
handoffBacklog?: readonly ZLinkActorHandoffPacket[]
|
|
206
209
|
) => Promise<void>;
|
|
210
|
+
readonly executeEntryActor?: <T>(
|
|
211
|
+
meshName: string,
|
|
212
|
+
actorId: string,
|
|
213
|
+
operation: () => Promise<T>
|
|
214
|
+
) => Promise<T>;
|
|
207
215
|
readonly actorCountProvider?: (spotId: RoutingId) => number;
|
|
208
216
|
readonly userSpotExecutionMode?: (
|
|
209
217
|
meshName: string,
|
|
@@ -217,7 +225,6 @@ export interface ZLinkSpotManagerOptions {
|
|
|
217
225
|
readonly actorRef?: ActorRef;
|
|
218
226
|
readonly spotId?: RoutingId;
|
|
219
227
|
};
|
|
220
|
-
readonly actorBindingGenerationObserver?: (actorId: string, generation: bigint) => void;
|
|
221
228
|
readonly channelClient?: ZLinkChannelClient;
|
|
222
229
|
readonly fanoutClient?: ZLinkFanoutClient;
|
|
223
230
|
readonly spotPublisherClient?: ZLinkSpotPublisherClient;
|
|
@@ -225,7 +232,6 @@ export interface ZLinkSpotManagerOptions {
|
|
|
225
232
|
readonly routedTransport?: ZLinkSpotRoutedTransport;
|
|
226
233
|
readonly addressTransport?: import('./spot-outbound').ZLinkSpotAddressTransport;
|
|
227
234
|
readonly spotRouterChannelIdForMesh?: (meshName: string) => string;
|
|
228
|
-
readonly channelMeshNameForChannel?: (channelName: string) => string | undefined;
|
|
229
235
|
readonly providerResolver?: ZLinkProviderResolver;
|
|
230
236
|
readonly dispatchErrors?: ZLinkDispatchErrorReporter;
|
|
231
237
|
readonly closeErrorSink?: import('../diagnostics/dispatch-error-port').ZLinkDispatchErrorSink;
|
|
@@ -242,19 +248,26 @@ export interface ZLinkSpotManagerOptions {
|
|
|
242
248
|
meshName: string,
|
|
243
249
|
spotId: RoutingId,
|
|
244
250
|
onCommitted: () => void
|
|
245
|
-
) => Promise<
|
|
251
|
+
) => Promise<
|
|
252
|
+
import('../locations/spot-location-claims').ZLinkInstanceClosingAuthority | undefined
|
|
253
|
+
>;
|
|
246
254
|
readonly beginInstanceClosingAuthority?: (
|
|
247
255
|
meshName: string,
|
|
248
256
|
spotId: RoutingId,
|
|
249
|
-
onCommitted: () => void
|
|
250
|
-
|
|
257
|
+
onCommitted: () => void,
|
|
258
|
+
objectGeneration: bigint
|
|
259
|
+
) => Promise<
|
|
260
|
+
import('../locations/spot-location-claims').ZLinkInstanceClosingAuthority | undefined
|
|
261
|
+
>;
|
|
251
262
|
/** Moves a local User Spot incarnation's authority to Closing for a context Close. */
|
|
252
263
|
readonly beginUserClosingAuthority?: (
|
|
253
264
|
meshName: string,
|
|
254
265
|
spotId: RoutingId,
|
|
255
266
|
objectGeneration: bigint,
|
|
256
267
|
onCommitted: () => void
|
|
257
|
-
) => Promise<
|
|
268
|
+
) => Promise<
|
|
269
|
+
import('../locations/spot-location-claims').ZLinkInstanceClosingAuthority | undefined
|
|
270
|
+
>;
|
|
258
271
|
readonly instanceSpotApplicationTargetProvider?: (
|
|
259
272
|
meshName: string,
|
|
260
273
|
spotId: RoutingId
|
|
@@ -284,13 +297,16 @@ export interface ZLinkSpotManagerOptions {
|
|
|
284
297
|
readonly ownerLeaseGeneration: bigint;
|
|
285
298
|
}) => Promise<{ readonly actorType: string }>;
|
|
286
299
|
readonly actorLifecycleResolver?: (actorId: string) => ZLinkActor | undefined;
|
|
287
|
-
readonly detachedTaskRunner
|
|
300
|
+
readonly detachedTaskRunner: ZLinkDetachedTaskRunner;
|
|
288
301
|
readonly actorTransferRuntime?: ZLinkSpotActorTransferRuntime;
|
|
289
302
|
readonly boundSessionRuntime?: ZLinkSpotBoundSessionRuntime;
|
|
290
303
|
readonly actorHandoffRuntime?: ZLinkSpotActorHandoffRuntime;
|
|
291
304
|
readonly metrics?: import('../diagnostics').ZLinkRuntimeMetrics;
|
|
292
305
|
readonly admission?: ZLinkRuntimeAdmissionGate;
|
|
293
|
-
readonly
|
|
306
|
+
readonly statefulExecution?: {
|
|
307
|
+
readonly admissionOpen: () => boolean;
|
|
308
|
+
readonly hostState: () => ZLinkFrameworkRuntimeState;
|
|
309
|
+
};
|
|
294
310
|
readonly activationAdmission?: ZLinkActivationAdmission;
|
|
295
311
|
}
|
|
296
312
|
|
|
@@ -299,11 +315,15 @@ interface ZLinkTargetSpotCloseOperation {
|
|
|
299
315
|
readonly reason: ZLinkSpotCloseReason;
|
|
300
316
|
readonly beginAuthority: (
|
|
301
317
|
onCommitted: () => void
|
|
302
|
-
) => Promise<
|
|
303
|
-
|
|
304
|
-
|
|
318
|
+
) => Promise<
|
|
319
|
+
import('../locations/spot-location-claims').ZLinkInstanceClosingAuthority | undefined
|
|
320
|
+
>;
|
|
321
|
+
authority?: import('../locations/spot-location-claims').ZLinkInstanceClosingAuthority;
|
|
305
322
|
authorityDecision?: Promise<void>;
|
|
306
323
|
ready?: Promise<boolean>;
|
|
324
|
+
canExecuteApplication?(
|
|
325
|
+
record: import('../execution/serial-execution-queue').ZLinkSerialWorkRecord<unknown>
|
|
326
|
+
): boolean;
|
|
307
327
|
}
|
|
308
328
|
|
|
309
329
|
export class DefaultZLinkSpotManager {
|
|
@@ -338,9 +358,10 @@ export class DefaultZLinkSpotManager {
|
|
|
338
358
|
private readonly options: ZLinkSpotManagerOptions,
|
|
339
359
|
timerClock?: import('./spot-timer').ZLinkTimerClock
|
|
340
360
|
) {
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
361
|
+
if ((options.detachedTaskRunner as unknown) === undefined) {
|
|
362
|
+
throw new ZLinkConfigurationException('Spot manager requires a detached task runner.');
|
|
363
|
+
}
|
|
364
|
+
this.activations = new ZLinkSpotActivationRegistry(options.metrics);
|
|
344
365
|
this.factories = new Set(options.spotFactories);
|
|
345
366
|
this.workerRuntime = options.workerRuntime ?? new ZLinkWorkerRuntime();
|
|
346
367
|
this.locationClaim = new ZLinkSpotLocationClaim({
|
|
@@ -350,7 +371,7 @@ export class DefaultZLinkSpotManager {
|
|
|
350
371
|
nodeGenerationProvider: options.nodeGenerationProvider
|
|
351
372
|
});
|
|
352
373
|
this.routedSpotPackets = new ZLinkRoutedSpotPacketDispatch({
|
|
353
|
-
resolveActivation: (spotId) => this.
|
|
374
|
+
resolveActivation: (spotId) => this.resolveApplicationActivation(spotId),
|
|
354
375
|
claimApplicationWork:
|
|
355
376
|
options.admission === undefined
|
|
356
377
|
? undefined
|
|
@@ -359,9 +380,6 @@ export class DefaultZLinkSpotManager {
|
|
|
359
380
|
dispatchErrors: options.dispatchErrors
|
|
360
381
|
});
|
|
361
382
|
this.actorMembership = new ZLinkSpotActorMembership({
|
|
362
|
-
isSpotClosing: (activation) =>
|
|
363
|
-
this.isSpotClosing(activation.meshName, activation.spotId) ||
|
|
364
|
-
this.activations.resolve(activation.meshName, activation.spotId) !== activation,
|
|
365
383
|
resolveActivation: (spotId, meshName) =>
|
|
366
384
|
meshName === undefined
|
|
367
385
|
? this.activations.resolveUnique(spotId)
|
|
@@ -412,14 +430,11 @@ export class DefaultZLinkSpotManager {
|
|
|
412
430
|
boundSessionRuntime: options.boundSessionRuntime,
|
|
413
431
|
actorHandoffRuntime: options.actorHandoffRuntime,
|
|
414
432
|
admission: options.admission,
|
|
415
|
-
statefulExecutionAllowed: options.
|
|
433
|
+
statefulExecutionAllowed: options.statefulExecution?.admissionOpen,
|
|
416
434
|
leaveActor: (spotId, actor, signal, meshName) =>
|
|
417
435
|
this.actorMembership.leaveActor(spotId, actor, signal, meshName),
|
|
418
436
|
requestContextClose: (activation, objectGeneration, signal) =>
|
|
419
437
|
this.closeFromContext(activation, objectGeneration, signal),
|
|
420
|
-
isSpotClosing: (activation) =>
|
|
421
|
-
this.isSpotClosing(activation.meshName, activation.spotId) ||
|
|
422
|
-
this.activations.resolve(activation.meshName, activation.spotId) !== activation,
|
|
423
438
|
registerActivation: (activation) => {
|
|
424
439
|
this.activations.register(activation);
|
|
425
440
|
this.scheduleIdleSweep();
|
|
@@ -597,10 +612,6 @@ export class DefaultZLinkSpotManager {
|
|
|
597
612
|
await awaitWithAbort(pendingClose, signal);
|
|
598
613
|
continue;
|
|
599
614
|
}
|
|
600
|
-
if (closeOperation?.committed === true) {
|
|
601
|
-
await awaitWithAbort(this.closeWithReason(meshName, spotId), signal);
|
|
602
|
-
continue;
|
|
603
|
-
}
|
|
604
615
|
const closing = this.activations.closingOperation(meshName, spotId);
|
|
605
616
|
if (closing !== undefined) {
|
|
606
617
|
await awaitWithAbort(closing.ready, signal);
|
|
@@ -694,31 +705,49 @@ export class DefaultZLinkSpotManager {
|
|
|
694
705
|
}
|
|
695
706
|
|
|
696
707
|
isInstanceMaterialized(meshName: string, instanceType: string, spotId: RoutingId): boolean {
|
|
697
|
-
const activation = this.
|
|
708
|
+
const activation = this.resolveApplicationActivation(spotId, meshName);
|
|
698
709
|
return (
|
|
699
710
|
activation !== undefined &&
|
|
700
711
|
activation.spotType === this.requireInstanceFactory(meshName, instanceType)
|
|
701
712
|
);
|
|
702
713
|
}
|
|
703
714
|
|
|
715
|
+
private resolveApplicationActivation(
|
|
716
|
+
spotId: RoutingId,
|
|
717
|
+
meshName?: string
|
|
718
|
+
): ZLinkSpotActivation | undefined {
|
|
719
|
+
const current =
|
|
720
|
+
meshName === undefined
|
|
721
|
+
? this.activations.resolveUnique(spotId)
|
|
722
|
+
: this.activations.resolve(meshName, spotId);
|
|
723
|
+
if (current !== undefined) return current;
|
|
724
|
+
if (meshName !== undefined)
|
|
725
|
+
return this.closeOperations.get(`${meshName}\0${String(spotId)}`)?.activation;
|
|
726
|
+
for (const operation of this.closeOperations.values()) {
|
|
727
|
+
if (String(operation.activation.spotId) === String(spotId)) return operation.activation;
|
|
728
|
+
}
|
|
729
|
+
return undefined;
|
|
730
|
+
}
|
|
731
|
+
|
|
704
732
|
isInstanceMaterializing(meshName: string, spotId: RoutingId): boolean {
|
|
705
733
|
const prefix = instanceMaterializationPrefix(meshName, spotId);
|
|
706
|
-
return (
|
|
734
|
+
return (
|
|
735
|
+
(this.pendingInstanceMaterializationsByPrefix.get(prefix)?.size ?? 0) > 0 ||
|
|
736
|
+
this.closeOperations.get(`${meshName}\0${String(spotId)}`)?.authority !== undefined
|
|
737
|
+
);
|
|
707
738
|
}
|
|
708
739
|
|
|
709
740
|
isSpotClosing(meshName: string, spotId: RoutingId): boolean {
|
|
710
|
-
|
|
711
|
-
|
|
741
|
+
return (
|
|
742
|
+
this.closeOperations.get(`${meshName}\0${String(spotId)}`)?.authority !== undefined ||
|
|
743
|
+
this.activations.activationForClose(meshName, spotId)?.executionBarrier.isCloseSealed === true
|
|
744
|
+
);
|
|
712
745
|
}
|
|
713
746
|
|
|
714
747
|
pendingSpotCloseDecision(meshName: string, spotId: RoutingId): Promise<void> | undefined {
|
|
715
748
|
return this.closeOperations.get(`${meshName}\0${String(spotId)}`)?.authorityDecision;
|
|
716
749
|
}
|
|
717
750
|
|
|
718
|
-
isInstanceClosing(meshName: string, spotId: RoutingId): boolean {
|
|
719
|
-
return this.closeOperations.has(`${meshName}\0${String(spotId)}`);
|
|
720
|
-
}
|
|
721
|
-
|
|
722
751
|
async discardInstance(meshName: string, spotId: RoutingId): Promise<void> {
|
|
723
752
|
const activation = this.activations.resolve(meshName, spotId);
|
|
724
753
|
if (activation === undefined) return;
|
|
@@ -910,13 +939,10 @@ export class DefaultZLinkSpotManager {
|
|
|
910
939
|
throw error;
|
|
911
940
|
}
|
|
912
941
|
};
|
|
913
|
-
this.options.detachedTaskRunner
|
|
942
|
+
this.options.detachedTaskRunner.runDetached(
|
|
914
943
|
`instance idle eviction ${String(activation.spotId)}`,
|
|
915
944
|
run
|
|
916
945
|
);
|
|
917
|
-
if (this.options.detachedTaskRunner === undefined) {
|
|
918
|
-
void run().catch(() => undefined);
|
|
919
|
-
}
|
|
920
946
|
}
|
|
921
947
|
} finally {
|
|
922
948
|
this.idleSweepRunning = false;
|
|
@@ -1010,8 +1036,8 @@ export class DefaultZLinkSpotManager {
|
|
|
1010
1036
|
requireMeshName(meshName);
|
|
1011
1037
|
const args = normalizeSpotCreateArgs(requestOrSignal, signal);
|
|
1012
1038
|
throwIfAborted(args.signal);
|
|
1039
|
+
this.options.admission?.requireRequest('SPOT create', meshName);
|
|
1013
1040
|
const operation = this.activations.getOrBegin(meshName, spotType, spotId, async () => {
|
|
1014
|
-
this.options.admission?.requireRequest('SPOT create', meshName);
|
|
1015
1041
|
const release = await this.options.activationAdmission?.acquire(meshName, args.signal);
|
|
1016
1042
|
const ownedRequest =
|
|
1017
1043
|
args.request === undefined
|
|
@@ -1036,12 +1062,16 @@ export class DefaultZLinkSpotManager {
|
|
|
1036
1062
|
|
|
1037
1063
|
async find(meshName: string, spotId: RoutingId): Promise<ZLinkSpotInfo | null> {
|
|
1038
1064
|
requireMeshName(meshName);
|
|
1039
|
-
return this.activations.has(meshName, spotId)
|
|
1065
|
+
return this.activations.has(meshName, spotId) && !this.isSpotClosing(meshName, spotId)
|
|
1066
|
+
? { spotId }
|
|
1067
|
+
: null;
|
|
1040
1068
|
}
|
|
1041
1069
|
|
|
1042
1070
|
async list(meshName: string): Promise<readonly ZLinkSpotInfo[]> {
|
|
1043
1071
|
requireMeshName(meshName);
|
|
1044
|
-
return this.activations
|
|
1072
|
+
return this.activations
|
|
1073
|
+
.list(meshName)
|
|
1074
|
+
.filter(({ spotId }) => !this.isSpotClosing(meshName, spotId));
|
|
1045
1075
|
}
|
|
1046
1076
|
|
|
1047
1077
|
async drainForShutdown(meshName: string, signal?: AbortSignal, deadline?: Date): Promise<void> {
|
|
@@ -1073,7 +1103,9 @@ export class DefaultZLinkSpotManager {
|
|
|
1073
1103
|
async closeUserWithAuthority(
|
|
1074
1104
|
meshName: string,
|
|
1075
1105
|
spotId: RoutingId,
|
|
1076
|
-
beginAuthority: (
|
|
1106
|
+
beginAuthority: (
|
|
1107
|
+
onCommitted: () => void
|
|
1108
|
+
) => Promise<import('../locations/spot-location-claims').ZLinkInstanceClosingAuthority>,
|
|
1077
1109
|
signal?: AbortSignal
|
|
1078
1110
|
): Promise<boolean> {
|
|
1079
1111
|
return await this.closeWithReason(
|
|
@@ -1128,7 +1160,9 @@ export class DefaultZLinkSpotManager {
|
|
|
1128
1160
|
deadline?: Date,
|
|
1129
1161
|
beginUserAuthority?: (
|
|
1130
1162
|
onCommitted: () => void
|
|
1131
|
-
) => Promise<
|
|
1163
|
+
) => Promise<
|
|
1164
|
+
import('../locations/spot-location-claims').ZLinkInstanceClosingAuthority | undefined
|
|
1165
|
+
>
|
|
1132
1166
|
): Promise<boolean> {
|
|
1133
1167
|
requireMeshName(meshName);
|
|
1134
1168
|
const key = `${meshName}\0${String(spotId)}`;
|
|
@@ -1146,14 +1180,20 @@ export class DefaultZLinkSpotManager {
|
|
|
1146
1180
|
`User Spot '${String(spotId)}' Close requires its authority owner.`
|
|
1147
1181
|
);
|
|
1148
1182
|
}
|
|
1183
|
+
const domain = activation.domain;
|
|
1149
1184
|
const beginAuthority =
|
|
1150
1185
|
beginUserAuthority ??
|
|
1151
|
-
(
|
|
1186
|
+
(domain.kind === 'instance' &&
|
|
1152
1187
|
reason === ZLinkSpotCloseReason.ExplicitClose &&
|
|
1153
1188
|
this.options.beginInstanceClosingAuthority !== undefined
|
|
1154
1189
|
? (onCommitted) =>
|
|
1155
|
-
this.options.beginInstanceClosingAuthority!(
|
|
1156
|
-
|
|
1190
|
+
this.options.beginInstanceClosingAuthority!(
|
|
1191
|
+
meshName,
|
|
1192
|
+
spotId,
|
|
1193
|
+
onCommitted,
|
|
1194
|
+
domain.objectGeneration
|
|
1195
|
+
)
|
|
1196
|
+
: domain.kind === 'instance' &&
|
|
1157
1197
|
reason === ZLinkSpotCloseReason.IdleEvicted &&
|
|
1158
1198
|
this.options.beginInstanceIdleClosingAuthority !== undefined
|
|
1159
1199
|
? (onCommitted) =>
|
|
@@ -1165,15 +1205,24 @@ export class DefaultZLinkSpotManager {
|
|
|
1165
1205
|
operation = {
|
|
1166
1206
|
activation,
|
|
1167
1207
|
reason,
|
|
1168
|
-
beginAuthority
|
|
1169
|
-
committed: false
|
|
1208
|
+
beginAuthority
|
|
1170
1209
|
};
|
|
1210
|
+
if (reason === ZLinkSpotCloseReason.ExplicitClose) {
|
|
1211
|
+
operation.canExecuteApplication = (record) => {
|
|
1212
|
+
const context = record.context as
|
|
1213
|
+
import('./spot-serial-turn-executor').ZLinkSpotApplicationTurnContext | undefined;
|
|
1214
|
+
return context === undefined;
|
|
1215
|
+
};
|
|
1216
|
+
}
|
|
1171
1217
|
this.closeOperations.set(key, operation);
|
|
1172
1218
|
}
|
|
1173
1219
|
if (operation.ready === undefined) {
|
|
1174
1220
|
const active = operation;
|
|
1175
|
-
const run = active.activation.serial.
|
|
1176
|
-
this.runCloseOperation(meshName, spotId, active, signal, deadline)
|
|
1221
|
+
const run = active.activation.serial.executeControlLifecycleOperation(
|
|
1222
|
+
() => this.runCloseOperation(meshName, spotId, active, signal, deadline),
|
|
1223
|
+
active.canExecuteApplication === undefined
|
|
1224
|
+
? undefined
|
|
1225
|
+
: (active as import('../execution/serial-execution-queue').ZLinkSerialLifecycleContext)
|
|
1177
1226
|
);
|
|
1178
1227
|
active.ready = run.finally(() => {
|
|
1179
1228
|
active.ready = undefined;
|
|
@@ -1192,20 +1241,100 @@ export class DefaultZLinkSpotManager {
|
|
|
1192
1241
|
signal?: AbortSignal,
|
|
1193
1242
|
deadline?: Date
|
|
1194
1243
|
): Promise<boolean> {
|
|
1195
|
-
const
|
|
1196
|
-
if (
|
|
1197
|
-
|
|
1198
|
-
|
|
1244
|
+
const seal = await this.beginCloseAuthority(meshName, spotId, operation, signal);
|
|
1245
|
+
if (seal === undefined) return false;
|
|
1246
|
+
if (seal !== true) {
|
|
1247
|
+
await this.activationLifecycle.sealForClose(operation.activation, seal);
|
|
1248
|
+
} else {
|
|
1249
|
+
await operation.activation.executionBarrier.waitForStartedTurns(signal);
|
|
1250
|
+
}
|
|
1199
1251
|
const closingFailure = await this.activationLifecycle.cleanupClosedActivation(
|
|
1200
1252
|
operation.activation,
|
|
1201
1253
|
operation.reason,
|
|
1202
1254
|
deadline
|
|
1203
1255
|
);
|
|
1204
|
-
await operation.authority?.release();
|
|
1205
|
-
// The incarnation has no further lifecycle item once its authority is
|
|
1206
|
-
// released, so its lifecycle lane admission closes with this Close.
|
|
1207
|
-
operation.activation.serial.closeAdmission();
|
|
1208
1256
|
this.activations.finishClose(meshName, spotId);
|
|
1257
|
+
const intentRecords: unknown[] = [];
|
|
1258
|
+
operation.activation.serial.visitPendingApplication((record) => {
|
|
1259
|
+
const context = record.context as
|
|
1260
|
+
import('./spot-serial-turn-executor').ZLinkSpotApplicationTurnContext | undefined;
|
|
1261
|
+
if (context?.replay !== undefined) intentRecords.push(record);
|
|
1262
|
+
});
|
|
1263
|
+
const hasIntent = intentRecords.length > 0;
|
|
1264
|
+
// Spot messaging §7 step 3: with no Instance intent message waiting, the
|
|
1265
|
+
// release decision also ends this Instance incarnation's admission in this turn.
|
|
1266
|
+
if (!hasIntent && operation.activation.domain.kind === 'instance')
|
|
1267
|
+
operation.activation.serial.closeAdmission();
|
|
1268
|
+
const hostState = this.options.statefulExecution?.hostState();
|
|
1269
|
+
const intentFailure = !hasIntent
|
|
1270
|
+
? undefined
|
|
1271
|
+
: hostState === ZLinkFrameworkRuntimeState.Draining
|
|
1272
|
+
? createInternalFrameworkException(
|
|
1273
|
+
ZLinkFrameworkInternalErrorKind.RuntimeShutdown,
|
|
1274
|
+
'Instance intent cannot continue while the host is draining.'
|
|
1275
|
+
)
|
|
1276
|
+
: hostState === ZLinkFrameworkRuntimeState.Relocating ||
|
|
1277
|
+
hostState === ZLinkFrameworkRuntimeState.Relocated ||
|
|
1278
|
+
this.options.statefulExecution?.admissionOpen() === false ||
|
|
1279
|
+
(operation.activation.executionBarrier.isSealed &&
|
|
1280
|
+
!operation.activation.executionBarrier.isCloseSealed)
|
|
1281
|
+
? createInternalFrameworkException(
|
|
1282
|
+
ZLinkFrameworkInternalErrorKind.SpotMoving,
|
|
1283
|
+
'Instance intent cannot continue on an unavailable or relocating owner.'
|
|
1284
|
+
)
|
|
1285
|
+
: undefined;
|
|
1286
|
+
if (
|
|
1287
|
+
operation.reason === ZLinkSpotCloseReason.ExplicitClose &&
|
|
1288
|
+
hasIntent &&
|
|
1289
|
+
intentFailure === undefined &&
|
|
1290
|
+
operation.authority?.reincarnate !== undefined
|
|
1291
|
+
) {
|
|
1292
|
+
try {
|
|
1293
|
+
await operation.authority.reincarnate(async (authority) => {
|
|
1294
|
+
await this.activationLifecycle.materializeInstance(
|
|
1295
|
+
meshName,
|
|
1296
|
+
authority.stableType,
|
|
1297
|
+
operation.activation.spotType as Type<ZLinkInstanceSpot>,
|
|
1298
|
+
spotId,
|
|
1299
|
+
authority.objectGeneration,
|
|
1300
|
+
signal,
|
|
1301
|
+
operation.activation
|
|
1302
|
+
);
|
|
1303
|
+
});
|
|
1304
|
+
// The new incarnation shares this serial owner and admits membership work again.
|
|
1305
|
+
operation.activation.serial.setLifecycleAdmissionClosed(false);
|
|
1306
|
+
} catch (error) {
|
|
1307
|
+
const initialized = this.activations.resolve(meshName, spotId);
|
|
1308
|
+
if (initialized !== undefined && initialized !== operation.activation) {
|
|
1309
|
+
await this.activationLifecycle.cleanupFailedIncarnation(initialized);
|
|
1310
|
+
}
|
|
1311
|
+
this.activations.finishClose(meshName, spotId);
|
|
1312
|
+
operation.activation.serial.visitPendingApplication((record) => {
|
|
1313
|
+
const context = record.context as
|
|
1314
|
+
import('./spot-serial-turn-executor').ZLinkSpotApplicationTurnContext | undefined;
|
|
1315
|
+
if (context?.replay !== undefined) record.operation = () => context.replay!(error);
|
|
1316
|
+
});
|
|
1317
|
+
operation.activation.serial.closeAdmission();
|
|
1318
|
+
throw error;
|
|
1319
|
+
}
|
|
1320
|
+
} else {
|
|
1321
|
+
await operation.authority?.release();
|
|
1322
|
+
operation.activation.serial.closeAdmission();
|
|
1323
|
+
if (!operation.activation.executionBarrier.isSealed) {
|
|
1324
|
+
const closed = operation.activation.sealExecution('close');
|
|
1325
|
+
operation.activation.commitExecutionSeal(closed);
|
|
1326
|
+
}
|
|
1327
|
+
}
|
|
1328
|
+
if (operation.reason === ZLinkSpotCloseReason.ExplicitClose) {
|
|
1329
|
+
operation.activation.serial.visitPendingApplication((record) => {
|
|
1330
|
+
const context = record.context as
|
|
1331
|
+
import('./spot-serial-turn-executor').ZLinkSpotApplicationTurnContext | undefined;
|
|
1332
|
+
if (context?.replay !== undefined) {
|
|
1333
|
+
record.operation =
|
|
1334
|
+
intentFailure === undefined ? context.replay : () => context.replay!(intentFailure);
|
|
1335
|
+
}
|
|
1336
|
+
});
|
|
1337
|
+
}
|
|
1209
1338
|
this.closeOperations.delete(`${meshName}\0${String(spotId)}`);
|
|
1210
1339
|
// An OnClosing failure never changes a Close result; host shutdown alone
|
|
1211
1340
|
// reports it as its teardown outcome after cleanup has finished.
|
|
@@ -1220,9 +1349,11 @@ export class DefaultZLinkSpotManager {
|
|
|
1220
1349
|
spotId: RoutingId,
|
|
1221
1350
|
operation: ZLinkTargetSpotCloseOperation,
|
|
1222
1351
|
signal?: AbortSignal
|
|
1223
|
-
): Promise<
|
|
1352
|
+
): Promise<import('../execution').ZLinkExecutionBarrierSeal | true | undefined> {
|
|
1353
|
+
// Spot messaging §4 step 12 with §7 step 1: a Close of any reason begins its
|
|
1354
|
+
// Closing CAS only after the first terminal record of an activated message.
|
|
1224
1355
|
await this.options.instanceSpotApplicationQuiescenceProvider?.(meshName, spotId, signal);
|
|
1225
|
-
if (!operation.activation.canClose(operation.reason)) return
|
|
1356
|
+
if (!operation.activation.canClose(operation.reason)) return undefined;
|
|
1226
1357
|
if (operation.activation.executionBarrier.isSealed) {
|
|
1227
1358
|
throw createInternalFrameworkException(
|
|
1228
1359
|
ZLinkFrameworkInternalErrorKind.SpotMoving,
|
|
@@ -1230,9 +1361,15 @@ export class DefaultZLinkSpotManager {
|
|
|
1230
1361
|
true
|
|
1231
1362
|
);
|
|
1232
1363
|
}
|
|
1364
|
+
let seal: import('../execution').ZLinkExecutionBarrierSeal | true | undefined;
|
|
1233
1365
|
const authorityPromise = Promise.resolve().then(() =>
|
|
1234
1366
|
operation.beginAuthority(() => {
|
|
1235
|
-
operation.
|
|
1367
|
+
if (operation.reason === ZLinkSpotCloseReason.ExplicitClose) {
|
|
1368
|
+
operation.activation.serial.setLifecycleAdmissionClosed(true);
|
|
1369
|
+
seal = true;
|
|
1370
|
+
} else {
|
|
1371
|
+
seal = operation.activation.sealExecution('close');
|
|
1372
|
+
}
|
|
1236
1373
|
})
|
|
1237
1374
|
);
|
|
1238
1375
|
operation.authorityDecision = authorityPromise.then(
|
|
@@ -1240,12 +1377,12 @@ export class DefaultZLinkSpotManager {
|
|
|
1240
1377
|
() => undefined
|
|
1241
1378
|
);
|
|
1242
1379
|
const authority = await authorityPromise;
|
|
1243
|
-
if (authority === undefined) return
|
|
1380
|
+
if (authority === undefined) return undefined;
|
|
1244
1381
|
operation.authority = authority;
|
|
1245
|
-
if (
|
|
1382
|
+
if (seal === undefined) {
|
|
1246
1383
|
throw new Error(`Spot '${String(spotId)}' Closing authority did not confirm its commit.`);
|
|
1247
1384
|
}
|
|
1248
|
-
return
|
|
1385
|
+
return seal;
|
|
1249
1386
|
}
|
|
1250
1387
|
|
|
1251
1388
|
async executeOnSpot<TSpot extends ZLinkSpot, TResult>(
|
|
@@ -1311,15 +1448,19 @@ export class DefaultZLinkSpotManager {
|
|
|
1311
1448
|
spotId: RoutingId,
|
|
1312
1449
|
actor: ZLinkActor,
|
|
1313
1450
|
request: Message,
|
|
1314
|
-
commit: (
|
|
1315
|
-
spot: ZLinkSpot
|
|
1316
|
-
) => Promise<ZLinkActorJoinRollback | void> | ZLinkActorJoinRollback | void,
|
|
1451
|
+
commit: (spot: ZLinkSpot) => Promise<void> | void,
|
|
1317
1452
|
signal?: AbortSignal,
|
|
1318
1453
|
leaveSource?: () => Promise<void>,
|
|
1319
1454
|
contentType = 'application/json'
|
|
1320
1455
|
): Promise<ZLinkSpotActorJoinResult> {
|
|
1321
1456
|
const meshName = this.activations.resolveUnique(spotId)?.meshName;
|
|
1322
1457
|
this.options.admission?.requireRequest('Actor join admission', meshName);
|
|
1458
|
+
if (meshName !== undefined && this.isSpotClosing(meshName, spotId)) {
|
|
1459
|
+
throw createInternalFrameworkException(
|
|
1460
|
+
ZLinkFrameworkInternalErrorKind.RequestRejected,
|
|
1461
|
+
`Spot '${String(spotId)}' is closing.`
|
|
1462
|
+
);
|
|
1463
|
+
}
|
|
1323
1464
|
return await this.actorMembership.admitActorJoin(
|
|
1324
1465
|
spotId,
|
|
1325
1466
|
actor,
|
|
@@ -1558,7 +1699,7 @@ export class DefaultZLinkSpotManager {
|
|
|
1558
1699
|
let target = this.options.instanceSpotApplicationTargetProvider?.(meshName, spotId);
|
|
1559
1700
|
if (target === undefined) return;
|
|
1560
1701
|
for (;;) {
|
|
1561
|
-
const current = this.
|
|
1702
|
+
const current = this.resolveApplicationActivation(spotId, meshName);
|
|
1562
1703
|
if (
|
|
1563
1704
|
current !== undefined &&
|
|
1564
1705
|
current.objectGeneration === target.objectGeneration &&
|
|
@@ -1612,7 +1753,7 @@ export class DefaultZLinkSpotManager {
|
|
|
1612
1753
|
);
|
|
1613
1754
|
try {
|
|
1614
1755
|
await this.ensureInstanceApplicationActivation(meshName, spotId);
|
|
1615
|
-
const activation = this.
|
|
1756
|
+
const activation = this.resolveApplicationActivation(spotId, meshName);
|
|
1616
1757
|
if (activation === undefined || activation.domain.kind !== 'instance') {
|
|
1617
1758
|
throw new ZLinkConfigurationException(
|
|
1618
1759
|
`MeshNode Instance Spot target '${String(spotId)}' is not active.`
|
|
@@ -1637,12 +1778,39 @@ export class DefaultZLinkSpotManager {
|
|
|
1637
1778
|
channelName: envelope.header.channelName,
|
|
1638
1779
|
contentType: envelope.header.contentType,
|
|
1639
1780
|
awaitFirstHandlerTurn: record.kind === ReceiveKind.InstanceSpotActivation,
|
|
1781
|
+
activationRecord: record,
|
|
1782
|
+
onOneWayError:
|
|
1783
|
+
this.options.dispatchErrors?.captureEnabled() === true
|
|
1784
|
+
? (error: unknown) =>
|
|
1785
|
+
this.reportInstanceDispatchFailure(
|
|
1786
|
+
meshName,
|
|
1787
|
+
spotId,
|
|
1788
|
+
record,
|
|
1789
|
+
envelope,
|
|
1790
|
+
false,
|
|
1791
|
+
error
|
|
1792
|
+
)
|
|
1793
|
+
: undefined,
|
|
1640
1794
|
workOptions: zlinkSerialWorkOptions(
|
|
1641
1795
|
envelope.payload.byteLength,
|
|
1642
1796
|
record.applicationMetadata?.byteLength ??
|
|
1643
1797
|
zlinkMetadataByteLength(envelope.header.metadata)
|
|
1644
1798
|
)
|
|
1645
1799
|
};
|
|
1800
|
+
// Spot messaging §7 step 3: an Instance intent request that reaches an
|
|
1801
|
+
// incarnation whose Close ended admission is refused before admission
|
|
1802
|
+
// with the owner fence terminal, so its caller re-reads authority.
|
|
1803
|
+
const instanceIntent =
|
|
1804
|
+
record.activationRecord?.activation === 'missing' ||
|
|
1805
|
+
(record.activationRecord?.activation === 'ready' &&
|
|
1806
|
+
record.activationRecord.instanceIntent);
|
|
1807
|
+
const refusal = activation.serial.applicationAdmissionRefusal(instanceIntent === true);
|
|
1808
|
+
if (request && refusal !== undefined && record.replyFailure !== undefined) {
|
|
1809
|
+
this.reportInstanceDispatchFailure(meshName, spotId, record, envelope, request, refusal);
|
|
1810
|
+
const terminal = internalFrameworkWireReply(refusal);
|
|
1811
|
+
requireMeshSpotReply(record.replyFailure(terminal.terminalResult, terminal.failureCode));
|
|
1812
|
+
return;
|
|
1813
|
+
}
|
|
1646
1814
|
this.traceInstanceMessage(
|
|
1647
1815
|
ZLinkMessageFlowOutcome.Admitted,
|
|
1648
1816
|
meshName,
|
|
@@ -1707,7 +1875,8 @@ export class DefaultZLinkSpotManager {
|
|
|
1707
1875
|
target?.stableType
|
|
1708
1876
|
);
|
|
1709
1877
|
} catch (error) {
|
|
1710
|
-
|
|
1878
|
+
this.reportInstanceDispatchFailure(meshName, spotId, record, envelope, request, error);
|
|
1879
|
+
const reason = dispatchReasonFromError(error);
|
|
1711
1880
|
if (!request) {
|
|
1712
1881
|
this.traceInstanceMessage(
|
|
1713
1882
|
ZLinkMessageFlowOutcome.Dropped,
|
|
@@ -1721,29 +1890,42 @@ export class DefaultZLinkSpotManager {
|
|
|
1721
1890
|
);
|
|
1722
1891
|
return;
|
|
1723
1892
|
}
|
|
1724
|
-
|
|
1725
|
-
surface: ZLinkDispatchErrorSurface.InstanceSpot,
|
|
1726
|
-
messageKind: ZLinkDispatchMessageKind.Request,
|
|
1727
|
-
packetName: envelope.packetName,
|
|
1728
|
-
channelName: envelope.header.channelName,
|
|
1729
|
-
meshName,
|
|
1730
|
-
correlationId: envelope.header.correlationId ?? undefined,
|
|
1731
|
-
sourceRid: record.sourceNodeRid === null ? undefined : String(record.sourceNodeRid),
|
|
1732
|
-
spotId: String(spotId),
|
|
1733
|
-
instanceSpotType: this.options.instanceSpotApplicationTargetProvider?.(meshName, spotId)
|
|
1734
|
-
?.stableType,
|
|
1735
|
-
activationState: 'closing',
|
|
1736
|
-
flowId: envelope.header.flowId,
|
|
1737
|
-
flowOrigin: envelope.header.flowOrigin,
|
|
1738
|
-
reason,
|
|
1739
|
-
action: ZLinkDispatchErrorAction.ReplyError,
|
|
1740
|
-
error
|
|
1741
|
-
});
|
|
1893
|
+
|
|
1742
1894
|
requireMeshSpotReply(record.reply(encodeChannelErrorReplyParts(envelope.header, error)));
|
|
1743
1895
|
}
|
|
1744
1896
|
});
|
|
1745
1897
|
}
|
|
1746
1898
|
|
|
1899
|
+
private reportInstanceDispatchFailure(
|
|
1900
|
+
meshName: string,
|
|
1901
|
+
spotId: RoutingId,
|
|
1902
|
+
record: ReceiveRecord,
|
|
1903
|
+
envelope: ReturnType<typeof decodeChannelEnvelope>,
|
|
1904
|
+
request: boolean,
|
|
1905
|
+
error: unknown
|
|
1906
|
+
): void {
|
|
1907
|
+
const reporter = this.options.dispatchErrors;
|
|
1908
|
+
if (reporter?.captureEnabled() !== true) return;
|
|
1909
|
+
reporter.report({
|
|
1910
|
+
surface: ZLinkDispatchErrorSurface.InstanceSpot,
|
|
1911
|
+
messageKind: request ? ZLinkDispatchMessageKind.Request : ZLinkDispatchMessageKind.Send,
|
|
1912
|
+
packetName: envelope.packetName,
|
|
1913
|
+
channelName: envelope.header.channelName,
|
|
1914
|
+
meshName,
|
|
1915
|
+
correlationId: envelope.header.correlationId ?? undefined,
|
|
1916
|
+
sourceRid: record.sourceNodeRid === null ? undefined : String(record.sourceNodeRid),
|
|
1917
|
+
spotId: String(spotId),
|
|
1918
|
+
instanceSpotType: this.options.instanceSpotApplicationTargetProvider?.(meshName, spotId)
|
|
1919
|
+
?.stableType,
|
|
1920
|
+
activationState: 'closing',
|
|
1921
|
+
flowId: envelope.header.flowId,
|
|
1922
|
+
flowOrigin: envelope.header.flowOrigin,
|
|
1923
|
+
reason: dispatchReasonFromError(error),
|
|
1924
|
+
action: request ? ZLinkDispatchErrorAction.ReplyError : ZLinkDispatchErrorAction.Drop,
|
|
1925
|
+
error
|
|
1926
|
+
});
|
|
1927
|
+
}
|
|
1928
|
+
|
|
1747
1929
|
private traceInstanceMessage(
|
|
1748
1930
|
outcome: ZLinkMessageFlowOutcome,
|
|
1749
1931
|
meshName: string,
|
|
@@ -1796,9 +1978,6 @@ export class DefaultZLinkSpotManager {
|
|
|
1796
1978
|
throw new ZLinkConfigurationException('MeshNode Actor record is missing its Actor owner.');
|
|
1797
1979
|
}
|
|
1798
1980
|
const request = record.kind === ReceiveKind.ActorRequest;
|
|
1799
|
-
if (record.sourceBindingGeneration > 0n) {
|
|
1800
|
-
this.options.actorBindingGenerationObserver?.(actor.actorId, record.sourceBindingGeneration);
|
|
1801
|
-
}
|
|
1802
1981
|
const resolvedOwner = this.options.actorDispatchOwnerResolver?.(actor.actorId);
|
|
1803
1982
|
const resolvedActorRef = resolvedOwner?.actorRef ?? {
|
|
1804
1983
|
actorId: actor.actorId,
|
|
@@ -1889,10 +2068,7 @@ export class DefaultZLinkSpotManager {
|
|
|
1889
2068
|
record.reply(
|
|
1890
2069
|
this.encodeMeshActorReply(record.parts[0], ZLinkStreamMessageKind.Error, {
|
|
1891
2070
|
message: error instanceof Error ? error.message : String(error),
|
|
1892
|
-
kind:
|
|
1893
|
-
error instanceof ZLinkFrameworkException
|
|
1894
|
-
? error.kind
|
|
1895
|
-
: ZLinkFrameworkErrorKind.InternalFailure
|
|
2071
|
+
kind: spotActorFailureKind(error)
|
|
1896
2072
|
})
|
|
1897
2073
|
)
|
|
1898
2074
|
);
|
|
@@ -1906,37 +2082,51 @@ export class DefaultZLinkSpotManager {
|
|
|
1906
2082
|
): Promise<void> {
|
|
1907
2083
|
const spotId = owner.spotId as unknown as RoutingId | null;
|
|
1908
2084
|
const activation = spotId === null ? undefined : this.activations.resolve(meshName, spotId);
|
|
1909
|
-
|
|
1910
|
-
|
|
2085
|
+
const replyState = { targetCommitPublished: false };
|
|
2086
|
+
try {
|
|
2087
|
+
if (
|
|
2088
|
+
record.kindData?.kind === 'actorControl' &&
|
|
2089
|
+
record.kindData.canonicalActorJoin !== undefined
|
|
2090
|
+
) {
|
|
2091
|
+
const entrySpotId = this.options.entryNodeRidProvider?.() ?? this.options.entryNodeRid;
|
|
1911
2092
|
if (
|
|
1912
|
-
|
|
1913
|
-
|
|
2093
|
+
spotId !== null && entrySpotId !== undefined && String(spotId) === String(entrySpotId)
|
|
2094
|
+
? this.options.dispatchEntryActorJoin === undefined
|
|
2095
|
+
: activation === undefined
|
|
1914
2096
|
) {
|
|
1915
|
-
|
|
1916
|
-
ZLinkFrameworkInternalErrorKind.
|
|
1917
|
-
`
|
|
2097
|
+
throw createInternalFrameworkException(
|
|
2098
|
+
ZLinkFrameworkInternalErrorKind.RouteNotConnected,
|
|
2099
|
+
`Spot '${String(spotId)}' is not active on this node.`
|
|
1918
2100
|
);
|
|
1919
|
-
if (record.replyFailure !== undefined) {
|
|
1920
|
-
const terminal = internalFrameworkWireReply(rejection);
|
|
1921
|
-
requireMeshSpotReply(
|
|
1922
|
-
record.replyFailure(terminal.terminalResult, terminal.failureCode)
|
|
1923
|
-
);
|
|
1924
|
-
} else {
|
|
1925
|
-
requireMeshSpotReply(record.replyActorJoin(1, []));
|
|
1926
|
-
}
|
|
1927
|
-
return;
|
|
1928
2101
|
}
|
|
1929
|
-
|
|
1930
|
-
|
|
1931
|
-
|
|
2102
|
+
}
|
|
2103
|
+
if (activation?.domain.kind === 'user') {
|
|
2104
|
+
await activation.serial.executeLifecycleOperation(() =>
|
|
2105
|
+
this.dispatchMeshActorJoinCore(meshName, owner, record, replyState)
|
|
2106
|
+
);
|
|
2107
|
+
return;
|
|
2108
|
+
}
|
|
2109
|
+
await this.dispatchMeshActorJoinCore(meshName, owner, record, replyState);
|
|
2110
|
+
} catch (error) {
|
|
2111
|
+
if (replyState.targetCommitPublished || record.replyFailure === undefined) throw error;
|
|
2112
|
+
const failure =
|
|
2113
|
+
error instanceof ZLinkFrameworkException
|
|
2114
|
+
? error
|
|
2115
|
+
: createInternalFrameworkException(
|
|
2116
|
+
ZLinkFrameworkInternalErrorKind.RequestFailed,
|
|
2117
|
+
'Actor Join target admission failed.',
|
|
2118
|
+
error
|
|
2119
|
+
);
|
|
2120
|
+
const terminal = internalFrameworkWireReply(failure);
|
|
2121
|
+
requireMeshSpotReply(record.replyFailure(terminal.terminalResult, terminal.failureCode));
|
|
1932
2122
|
}
|
|
1933
|
-
await this.dispatchMeshActorJoinCore(meshName, owner, record);
|
|
1934
2123
|
}
|
|
1935
2124
|
|
|
1936
2125
|
private async dispatchMeshActorJoinCore(
|
|
1937
2126
|
meshName: string,
|
|
1938
2127
|
owner: ReadyRecord,
|
|
1939
|
-
record: ReceiveRecord
|
|
2128
|
+
record: ReceiveRecord,
|
|
2129
|
+
replyState: { targetCommitPublished: boolean }
|
|
1940
2130
|
): Promise<void> {
|
|
1941
2131
|
const spotId = owner.spotId as unknown as RoutingId | null;
|
|
1942
2132
|
const control = record.kindData;
|
|
@@ -2001,14 +2191,10 @@ export class DefaultZLinkSpotManager {
|
|
|
2001
2191
|
admissionRecord = provisional.record;
|
|
2002
2192
|
canonicalAdmissionCreated = provisional.created;
|
|
2003
2193
|
try {
|
|
2194
|
+
releaseApplicationJobPermitBeforeHandler();
|
|
2004
2195
|
canonicalActorType = (await resolver({ actorId, ...control.canonicalActorJoin })).actorType;
|
|
2005
2196
|
} catch (error) {
|
|
2006
2197
|
this.formalRemoteActorAdmissions.fail(control.canonicalActorJoin.handoffId, error);
|
|
2007
|
-
if (error instanceof ZLinkFrameworkException && record.replyFailure !== undefined) {
|
|
2008
|
-
const terminal = internalFrameworkWireReply(error);
|
|
2009
|
-
requireMeshSpotReply(record.replyFailure(terminal.terminalResult, terminal.failureCode));
|
|
2010
|
-
return;
|
|
2011
|
-
}
|
|
2012
2198
|
throw error;
|
|
2013
2199
|
}
|
|
2014
2200
|
}
|
|
@@ -2037,7 +2223,6 @@ export class DefaultZLinkSpotManager {
|
|
|
2037
2223
|
let admissionOutcome: ZLinkFormalRemoteActorAdmissionResult | undefined;
|
|
2038
2224
|
let accepted = false;
|
|
2039
2225
|
let committedAdmissionReplay = isRemoteCommit && admissionRecord?.state === 'committed';
|
|
2040
|
-
let targetCommitPublished: boolean | undefined;
|
|
2041
2226
|
const actorJoinIsCurrent = (): boolean =>
|
|
2042
2227
|
(record.deadlineUnixMs === undefined || record.deadlineUnixMs > BigInt(Date.now())) &&
|
|
2043
2228
|
(record.isPending?.() ?? true);
|
|
@@ -2098,14 +2283,12 @@ export class DefaultZLinkSpotManager {
|
|
|
2098
2283
|
if (canonicalAdmissionCreated) {
|
|
2099
2284
|
if (targetsEntrySpot) {
|
|
2100
2285
|
admissionOutcome = {
|
|
2101
|
-
accepted:
|
|
2286
|
+
accepted: true,
|
|
2102
2287
|
actorRef
|
|
2103
2288
|
};
|
|
2104
|
-
} else if (activation === undefined) {
|
|
2105
|
-
admissionOutcome = { accepted: false, actorRef };
|
|
2106
2289
|
} else {
|
|
2107
|
-
const response: ZLinkSpotActorJoinResult = await activation
|
|
2108
|
-
activation
|
|
2290
|
+
const response: ZLinkSpotActorJoinResult = await activation!.serial.execute(async () =>
|
|
2291
|
+
activation!.spot.onActorJoin(
|
|
2109
2292
|
actorRef.actorId,
|
|
2110
2293
|
wrapFrameworkPayloadMessage(
|
|
2111
2294
|
callbackRequest!,
|
|
@@ -2429,21 +2612,6 @@ export class DefaultZLinkSpotManager {
|
|
|
2429
2612
|
return;
|
|
2430
2613
|
}
|
|
2431
2614
|
}
|
|
2432
|
-
if (
|
|
2433
|
-
accepted &&
|
|
2434
|
-
transferRequest !== undefined &&
|
|
2435
|
-
this.options.actorTransferRuntime !== undefined &&
|
|
2436
|
-
!isRemoteAdmission
|
|
2437
|
-
) {
|
|
2438
|
-
// A lightweight Core actor-join notification can create the Actor
|
|
2439
|
-
// before the formal transfer request reaches this branch. Preserve
|
|
2440
|
-
// the full relocation fence in that race so a later Session bind
|
|
2441
|
-
// refresh cannot erase the seal.
|
|
2442
|
-
this.options.actorTransferRuntime.rememberRoutedActorTransferTarget(
|
|
2443
|
-
actorId,
|
|
2444
|
-
transferRequest.remoteBoundSessionTarget
|
|
2445
|
-
);
|
|
2446
|
-
}
|
|
2447
2615
|
if (
|
|
2448
2616
|
accepted &&
|
|
2449
2617
|
actor !== undefined &&
|
|
@@ -2456,7 +2624,8 @@ export class DefaultZLinkSpotManager {
|
|
|
2456
2624
|
spotId,
|
|
2457
2625
|
transferId: transferRequest.transferId,
|
|
2458
2626
|
handoffBacklog: transferRequest.handoffBacklog,
|
|
2459
|
-
deferredJoinCompletion
|
|
2627
|
+
deferredJoinCompletion,
|
|
2628
|
+
sealedSession: transferRequest.remoteBoundSessionTarget
|
|
2460
2629
|
});
|
|
2461
2630
|
if (isRemoteCommit && admissionRecord !== undefined) {
|
|
2462
2631
|
this.formalRemoteActorAdmissions.markCommitted(transferRequest.transferId, actor);
|
|
@@ -2476,7 +2645,7 @@ export class DefaultZLinkSpotManager {
|
|
|
2476
2645
|
// Core commits the target membership while it accepts this reply.
|
|
2477
2646
|
// From this call onward a later callback/transport failure is
|
|
2478
2647
|
// post-commit and must not roll the materialized Actor back.
|
|
2479
|
-
targetCommitPublished = true;
|
|
2648
|
+
replyState.targetCommitPublished = true;
|
|
2480
2649
|
}
|
|
2481
2650
|
requireMeshSpotReply(joinReplyResult);
|
|
2482
2651
|
return true;
|
|
@@ -2501,60 +2670,85 @@ export class DefaultZLinkSpotManager {
|
|
|
2501
2670
|
if (!replyActorJoin()) return;
|
|
2502
2671
|
const commitEntryTransfer = async (): Promise<void> => {
|
|
2503
2672
|
try {
|
|
2504
|
-
|
|
2505
|
-
|
|
2506
|
-
|
|
2507
|
-
|
|
2508
|
-
pendingTransfer.transferId
|
|
2509
|
-
);
|
|
2510
|
-
}
|
|
2511
|
-
const sourceLeaveSubmitted = await pendingTransfer.sourceLeaveSubmitted;
|
|
2512
|
-
if (!sourceLeaveSubmitted) {
|
|
2513
|
-
throw new Error(
|
|
2514
|
-
`Actor '${entryActor.context.actorId}' source authority commit failed before leave submission.`
|
|
2515
|
-
);
|
|
2516
|
-
}
|
|
2517
|
-
const handoffResults = await replayActorHandoffBacklog(
|
|
2518
|
-
pendingTransfer.handoffBacklog,
|
|
2519
|
-
async (parts, returnResponse, remoteBoundSessionTarget, fallbackActorRef) => {
|
|
2520
|
-
if (this.options.dispatchEntryActorPacket === undefined) {
|
|
2521
|
-
throw new Error(
|
|
2522
|
-
'Entry Spot saved handoff replay requires its Actor packet runtime.'
|
|
2523
|
-
);
|
|
2524
|
-
}
|
|
2525
|
-
return await this.options.dispatchEntryActorPacket(
|
|
2673
|
+
try {
|
|
2674
|
+
await this.options.dispatchEntryActorJoin?.(meshName, entryActor, []);
|
|
2675
|
+
} finally {
|
|
2676
|
+
this.formalRemoteTransfers.completeTargetLifecycle(
|
|
2526
2677
|
entryActor.context.actorId,
|
|
2527
|
-
|
|
2528
|
-
returnResponse,
|
|
2529
|
-
remoteBoundSessionTarget,
|
|
2530
|
-
fallbackActorRef
|
|
2678
|
+
pendingTransfer.transferId
|
|
2531
2679
|
);
|
|
2532
|
-
}
|
|
2533
|
-
|
|
2534
|
-
|
|
2535
|
-
|
|
2536
|
-
|
|
2537
|
-
|
|
2538
|
-
|
|
2539
|
-
|
|
2540
|
-
|
|
2541
|
-
|
|
2542
|
-
|
|
2543
|
-
|
|
2544
|
-
|
|
2545
|
-
|
|
2546
|
-
|
|
2680
|
+
}
|
|
2681
|
+
const sourceLeaveSubmitted = await pendingTransfer.sourceLeaveSubmitted;
|
|
2682
|
+
if (!sourceLeaveSubmitted) {
|
|
2683
|
+
throw new Error(
|
|
2684
|
+
`Actor '${entryActor.context.actorId}' source authority commit failed before leave submission.`
|
|
2685
|
+
);
|
|
2686
|
+
}
|
|
2687
|
+
const handoffResults = await replayActorHandoffBacklog(
|
|
2688
|
+
pendingTransfer.handoffBacklog,
|
|
2689
|
+
async (parts, returnResponse, remoteBoundSessionTarget, fallbackActorRef) => {
|
|
2690
|
+
if (this.options.dispatchEntryActorPacket === undefined) {
|
|
2691
|
+
throw new Error(
|
|
2692
|
+
'Entry Spot saved handoff replay requires its Actor packet runtime.'
|
|
2693
|
+
);
|
|
2694
|
+
}
|
|
2695
|
+
return await this.options.dispatchEntryActorPacket(
|
|
2696
|
+
entryActor.context.actorId,
|
|
2697
|
+
parts,
|
|
2698
|
+
returnResponse,
|
|
2699
|
+
remoteBoundSessionTarget,
|
|
2700
|
+
fallbackActorRef
|
|
2701
|
+
);
|
|
2702
|
+
},
|
|
2703
|
+
(index) =>
|
|
2704
|
+
this.options.runtimeEventPublisher?.publish({
|
|
2705
|
+
sourceName: 'zlink.framework.actor-handoff',
|
|
2706
|
+
timestamp: new Date(),
|
|
2707
|
+
marker: 'backlog_enqueued',
|
|
2708
|
+
actorId: entryActor.context.actorId,
|
|
2709
|
+
index
|
|
2710
|
+
})
|
|
2711
|
+
);
|
|
2712
|
+
const failedHandoff = handoffResults.find((result) => !result.ok);
|
|
2713
|
+
if (failedHandoff !== undefined) {
|
|
2714
|
+
throw new Error(
|
|
2715
|
+
`Actor '${entryActor.context.actorId}' saved Entry handoff packet ` +
|
|
2716
|
+
`${failedHandoff.index} failed: ${diagnosticTextOrAbsent(failedHandoff.error)}.`
|
|
2717
|
+
);
|
|
2718
|
+
}
|
|
2719
|
+
} catch (error) {
|
|
2720
|
+
const completion = pendingTransfer.deferredJoinCompletion;
|
|
2721
|
+
if (completion !== undefined) {
|
|
2722
|
+
await this.options.actorTransferRuntime?.deliverDeferredJoinCompletion(
|
|
2723
|
+
{
|
|
2724
|
+
...completion,
|
|
2725
|
+
status: 'failed',
|
|
2726
|
+
kind: spotActorFailureKind(error)
|
|
2727
|
+
},
|
|
2728
|
+
entryActor,
|
|
2729
|
+
completion.actor,
|
|
2730
|
+
(operation) =>
|
|
2731
|
+
this.options.executeEntryActor!(meshName, entryActor.context.actorId, operation)
|
|
2732
|
+
);
|
|
2733
|
+
}
|
|
2734
|
+
throw error;
|
|
2735
|
+
}
|
|
2736
|
+
const completion = pendingTransfer.deferredJoinCompletion;
|
|
2737
|
+
if (completion !== undefined) {
|
|
2738
|
+
await this.options.actorTransferRuntime?.deliverDeferredJoinCompletion(
|
|
2739
|
+
completion,
|
|
2740
|
+
entryActor,
|
|
2741
|
+
completion.actor,
|
|
2742
|
+
(operation) =>
|
|
2743
|
+
this.options.executeEntryActor!(meshName, entryActor.context.actorId, operation)
|
|
2547
2744
|
);
|
|
2548
2745
|
}
|
|
2549
2746
|
this.formalRemoteTransfers.delete(entryActor.context.actorId);
|
|
2550
2747
|
};
|
|
2551
|
-
this.options.detachedTaskRunner
|
|
2748
|
+
this.options.detachedTaskRunner.runDetached(
|
|
2552
2749
|
`actor Entry Spot transfer ${entryActor.context.actorId}`,
|
|
2553
2750
|
commitEntryTransfer
|
|
2554
2751
|
);
|
|
2555
|
-
if (this.options.detachedTaskRunner === undefined) {
|
|
2556
|
-
void commitEntryTransfer().catch(() => undefined);
|
|
2557
|
-
}
|
|
2558
2752
|
}
|
|
2559
2753
|
} else {
|
|
2560
2754
|
if (!replyActorJoin()) return;
|
|
@@ -2563,10 +2757,10 @@ export class DefaultZLinkSpotManager {
|
|
|
2563
2757
|
if (control.canonicalActorJoin !== undefined) {
|
|
2564
2758
|
this.formalRemoteActorAdmissions.fail(control.canonicalActorJoin.handoffId, error);
|
|
2565
2759
|
}
|
|
2566
|
-
if (targetCommitPublished
|
|
2760
|
+
if (!replyState.targetCommitPublished) {
|
|
2567
2761
|
this.formalRemoteTransfers.delete(actorId);
|
|
2568
2762
|
}
|
|
2569
|
-
if (materialized && targetCommitPublished
|
|
2763
|
+
if (materialized && !replyState.targetCommitPublished) {
|
|
2570
2764
|
await this.options.actorTransferRuntime?.rollbackRoutedActor(actor!);
|
|
2571
2765
|
}
|
|
2572
2766
|
throw error;
|
|
@@ -2601,11 +2795,10 @@ export class DefaultZLinkSpotManager {
|
|
|
2601
2795
|
actorId !== undefined &&
|
|
2602
2796
|
this.formalRemoteTransfers.get(actorId) !== undefined
|
|
2603
2797
|
) {
|
|
2604
|
-
this.options.detachedTaskRunner
|
|
2798
|
+
this.options.detachedTaskRunner.runDetached(
|
|
2605
2799
|
`actor transfer target commit ${actorId}`,
|
|
2606
2800
|
async () => await operation
|
|
2607
2801
|
);
|
|
2608
|
-
if (this.options.detachedTaskRunner === undefined) void operation.catch(() => undefined);
|
|
2609
2802
|
return;
|
|
2610
2803
|
}
|
|
2611
2804
|
await operation;
|
|
@@ -2714,7 +2907,7 @@ export class DefaultZLinkSpotManager {
|
|
|
2714
2907
|
`Actor '${actor.context.actorId}' has no target ref for deferred Join completion.`
|
|
2715
2908
|
);
|
|
2716
2909
|
}
|
|
2717
|
-
await this.options.actorTransferRuntime?.
|
|
2910
|
+
await this.options.actorTransferRuntime?.deliverDeferredJoinCompletion(
|
|
2718
2911
|
deferredJoinCompletion,
|
|
2719
2912
|
actor,
|
|
2720
2913
|
currentRef,
|
|
@@ -2749,7 +2942,7 @@ export class DefaultZLinkSpotManager {
|
|
|
2749
2942
|
if (failedHandoff !== undefined) {
|
|
2750
2943
|
throw new Error(
|
|
2751
2944
|
`Actor '${actor.context.actorId}' saved handoff packet ` +
|
|
2752
|
-
`${failedHandoff.index} failed: ${failedHandoff.error
|
|
2945
|
+
`${failedHandoff.index} failed: ${diagnosticTextOrAbsent(failedHandoff.error)}.`
|
|
2753
2946
|
);
|
|
2754
2947
|
}
|
|
2755
2948
|
// Spec 15 §4.2 relocation temporary queue: arrivals parked at
|
|
@@ -2763,13 +2956,17 @@ export class DefaultZLinkSpotManager {
|
|
|
2763
2956
|
// the Session binding aggregate after this boundary.
|
|
2764
2957
|
this.formalRemoteTransfers.delete(actor.context.actorId);
|
|
2765
2958
|
}
|
|
2959
|
+
const sealedSession = pendingTransfer?.sealedSession;
|
|
2766
2960
|
const updateBoundSessionRoute = async (): Promise<void> => {
|
|
2767
|
-
await this.options.actorTransferRuntime?.publishRoutedActorOwnership(
|
|
2961
|
+
await this.options.actorTransferRuntime?.publishRoutedActorOwnership(
|
|
2962
|
+
actor,
|
|
2963
|
+
sealedSession
|
|
2964
|
+
);
|
|
2768
2965
|
await this.options.actorTransferRuntime?.openRoutedActorSession(actor);
|
|
2769
2966
|
};
|
|
2770
|
-
// Session routing is an independent post-Ready branch.
|
|
2771
|
-
//
|
|
2772
|
-
if (pendingTransfer !== undefined
|
|
2967
|
+
// Session routing is an independent post-Ready branch. The Session
|
|
2968
|
+
// owner submits current-binding pushes while the route seal remains installed.
|
|
2969
|
+
if (pendingTransfer !== undefined) {
|
|
2773
2970
|
this.options.detachedTaskRunner.runDetached(
|
|
2774
2971
|
`actor transfer Session route ${actor.context.actorId}`,
|
|
2775
2972
|
updateBoundSessionRoute
|
|
@@ -2803,13 +3000,10 @@ export class DefaultZLinkSpotManager {
|
|
|
2803
3000
|
if (onDetachedTerminal !== undefined) {
|
|
2804
3001
|
onDetachedTerminal(terminal);
|
|
2805
3002
|
} else {
|
|
2806
|
-
this.options.detachedTaskRunner
|
|
3003
|
+
this.options.detachedTaskRunner.runDetached(
|
|
2807
3004
|
`actor transfer target commit ${actor.context.actorId}`,
|
|
2808
3005
|
async () => await terminal
|
|
2809
3006
|
);
|
|
2810
|
-
if (this.options.detachedTaskRunner === undefined) {
|
|
2811
|
-
void terminal.catch(() => undefined);
|
|
2812
|
-
}
|
|
2813
3007
|
}
|
|
2814
3008
|
return;
|
|
2815
3009
|
}
|
|
@@ -2876,16 +3070,29 @@ export class DefaultZLinkSpotManager {
|
|
|
2876
3070
|
const entrySpotId = this.options.entryNodeRidProvider?.() ?? this.options.entryNodeRid;
|
|
2877
3071
|
const targetsEntry =
|
|
2878
3072
|
entrySpotId !== undefined && String(admission.admission.spotId) === String(entrySpotId);
|
|
2879
|
-
|
|
2880
|
-
|
|
2881
|
-
|
|
2882
|
-
|
|
2883
|
-
|
|
2884
|
-
|
|
3073
|
+
const activation = targetsEntry
|
|
3074
|
+
? undefined
|
|
3075
|
+
: this.activations.resolve(meshName, admission.admission.spotId);
|
|
3076
|
+
let lifecycleFailure: { readonly error: unknown } | undefined;
|
|
3077
|
+
try {
|
|
3078
|
+
if (targetsEntry) {
|
|
3079
|
+
await this.options.dispatchEntryActorJoin?.(meshName, actor, []);
|
|
3080
|
+
} else {
|
|
3081
|
+
if (activation === undefined) {
|
|
3082
|
+
throw new Error(`Actor Join relocation '${relocationId}' target Spot is not active.`);
|
|
3083
|
+
}
|
|
3084
|
+
await activation.serial.execute(() => activation.spot.onJoinedActor(actor));
|
|
2885
3085
|
}
|
|
2886
|
-
|
|
3086
|
+
} catch (error) {
|
|
3087
|
+
lifecycleFailure = { error };
|
|
3088
|
+
}
|
|
3089
|
+
if (lifecycleFailure === undefined) {
|
|
3090
|
+
const sourceLeave = submitSourceLeave(admission.admission.actorRef.nodeRid);
|
|
3091
|
+
this.options.detachedTaskRunner.runDetached(
|
|
3092
|
+
`actor Join source leave ${actor.context.actorId}`,
|
|
3093
|
+
() => sourceLeave
|
|
3094
|
+
);
|
|
2887
3095
|
}
|
|
2888
|
-
await submitSourceLeave(admission.admission.actorRef.nodeRid);
|
|
2889
3096
|
if (
|
|
2890
3097
|
outcome.deferredJoinCompletion !== undefined &&
|
|
2891
3098
|
this.options.actorTransferRuntime !== undefined
|
|
@@ -2893,20 +3100,26 @@ export class DefaultZLinkSpotManager {
|
|
|
2893
3100
|
const submitMailbox = targetsEntry
|
|
2894
3101
|
? <T>(operation: () => Promise<T>): Promise<T> => operation()
|
|
2895
3102
|
: <T>(operation: () => Promise<T>): Promise<T> => {
|
|
2896
|
-
const activation = this.activations.resolve(meshName, admission.admission.spotId);
|
|
2897
3103
|
if (activation === undefined) {
|
|
2898
3104
|
throw new Error(`Actor Join relocation '${relocationId}' target mailbox is missing.`);
|
|
2899
3105
|
}
|
|
2900
3106
|
return activation.executeActor(actor.context.actorId, operation);
|
|
2901
3107
|
};
|
|
2902
|
-
await this.options.actorTransferRuntime.
|
|
2903
|
-
|
|
3108
|
+
await this.options.actorTransferRuntime.deliverDeferredJoinCompletion(
|
|
3109
|
+
lifecycleFailure === undefined
|
|
3110
|
+
? outcome.deferredJoinCompletion
|
|
3111
|
+
: {
|
|
3112
|
+
...outcome.deferredJoinCompletion,
|
|
3113
|
+
status: 'failed',
|
|
3114
|
+
kind: spotActorFailureKind(lifecycleFailure.error)
|
|
3115
|
+
},
|
|
2904
3116
|
actor,
|
|
2905
3117
|
actorRef,
|
|
2906
3118
|
submitMailbox,
|
|
2907
3119
|
signal
|
|
2908
3120
|
);
|
|
2909
3121
|
}
|
|
3122
|
+
if (lifecycleFailure !== undefined) throw lifecycleFailure.error;
|
|
2910
3123
|
this.formalRemoteActorAdmissions.markCommitted(relocationId, actor);
|
|
2911
3124
|
return true;
|
|
2912
3125
|
}
|
|
@@ -3142,19 +3355,10 @@ export class DefaultZLinkSpotManager {
|
|
|
3142
3355
|
}
|
|
3143
3356
|
}
|
|
3144
3357
|
|
|
3145
|
-
function
|
|
3146
|
-
|
|
3147
|
-
|
|
3148
|
-
|
|
3149
|
-
kind === ZLinkFrameworkInternalErrorKind.SpotGenerationStale ||
|
|
3150
|
-
kind === ZLinkFrameworkInternalErrorKind.SpotMoving ||
|
|
3151
|
-
kind === ZLinkFrameworkInternalErrorKind.SpotRouteNotFound ||
|
|
3152
|
-
kind === ZLinkFrameworkInternalErrorKind.RequestTargetNotFound
|
|
3153
|
-
) {
|
|
3154
|
-
return ZLinkDispatchErrorReason.StaleTarget;
|
|
3155
|
-
}
|
|
3156
|
-
}
|
|
3157
|
-
return ZLinkDispatchErrorReason.HandlerException;
|
|
3358
|
+
function spotActorFailureKind(error: unknown): ZLinkFrameworkErrorKind {
|
|
3359
|
+
return error instanceof ZLinkFrameworkException
|
|
3360
|
+
? error.kind
|
|
3361
|
+
: ZLinkFrameworkErrorKind.InternalFailure;
|
|
3158
3362
|
}
|
|
3159
3363
|
|
|
3160
3364
|
interface ZLinkFormalRemoteTransferRequest {
|