@zlink-systems/framework 0.30.0 → 0.30.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +150 -68
- package/dist/.tsbuildinfo +1 -1
- package/dist/contracts/Actors/ZLinkActorClient.d.ts +2 -1
- package/dist/contracts/Channels/Calls.d.ts +2 -1
- package/dist/contracts/Common/ZLinkEncodedPayload.d.ts +6 -0
- package/dist/contracts/Common/ZLinkEncodedPayload.js +18 -3
- package/dist/contracts/Common/ZLinkMessageMetadata.js +11 -5
- 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/Handlers/Attributes.d.ts +5 -13
- package/dist/contracts/Handlers/Attributes.js +7 -11
- package/dist/contracts/Handlers/JsonContract.d.ts +2 -46
- package/dist/contracts/Handlers/JsonContract.js +4 -153
- package/dist/contracts/Locations/Rows.d.ts +2 -0
- package/dist/contracts/Spots/Contracts.d.ts +6 -1
- package/dist/contracts/Spots/ZLinkSpot.d.ts +3 -3
- package/dist/nest-integration.d.ts +1 -1
- package/dist/nest-integration.js +2 -1
- 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 +1 -2
- package/dist/runtime/actors/actor-client.js +52 -57
- 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 +8 -4
- package/dist/runtime/actors/actor-handoff.js +219 -92
- package/dist/runtime/actors/actor-join-relocation.d.ts +3 -0
- package/dist/runtime/actors/actor-local-native-join.js +13 -12
- package/dist/runtime/actors/actor-mailbox.js +27 -1
- package/dist/runtime/actors/actor-remote-joiner.js +3 -1
- package/dist/runtime/actors/actor-remote-wire.js +15 -0
- package/dist/runtime/actors/actor-reply.d.ts +4 -0
- package/dist/runtime/actors/actor-reply.js +29 -0
- package/dist/runtime/actors/actor-routed-join-transport.d.ts +6 -2
- package/dist/runtime/actors/actor-routed-json-request.d.ts +2 -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 +8 -3
- package/dist/runtime/actors/index.js +55 -27
- package/dist/runtime/actors/session-disconnected-wire.d.ts +8 -0
- package/dist/runtime/actors/session-disconnected-wire.js +48 -0
- package/dist/runtime/actors/spot-actor-dispatch.js +2 -2
- package/dist/runtime/admission.d.ts +9 -1
- package/dist/runtime/admission.js +56 -23
- package/dist/runtime/application-jobs/application-ingress-record-owner.d.ts +6 -8
- package/dist/runtime/application-jobs/application-ingress-record-owner.js +39 -22
- package/dist/runtime/application-jobs/application-job-queue-scope.d.ts +15 -1
- package/dist/runtime/application-jobs/application-job-queue-scope.js +61 -20
- package/dist/runtime/application-jobs/contracts.d.ts +12 -1
- package/dist/runtime/backend/contracts/index.d.ts +37 -12
- package/dist/runtime/backend/mesh-actor-session-node-adapter.js +2 -2
- package/dist/runtime/backend/mesh-completion-table.d.ts +9 -1
- package/dist/runtime/backend/mesh-completion-table.js +154 -49
- package/dist/runtime/backend/mesh-dispatch-pump.d.ts +28 -1
- package/dist/runtime/backend/mesh-dispatch-pump.js +208 -101
- package/dist/runtime/backend/node/node-backend-adapter-support.d.ts +2 -2
- package/dist/runtime/backend/node/node-backend-adapter-support.js +16 -9
- package/dist/runtime/backend/node/node-dealer-channel-client-transport.d.ts +1 -1
- package/dist/runtime/backend/node/node-dealer-channel-client-transport.js +5 -2
- package/dist/runtime/backend/node/node-raw-binding-port.js +124 -72
- package/dist/runtime/backend/node/node-raw-mesh-backend.d.ts +46 -13
- package/dist/runtime/backend/node/node-raw-mesh-backend.js +181 -164
- package/dist/runtime/backend/node/node-socket-backend-adapter.d.ts +1 -1
- package/dist/runtime/backend/node/node-socket-backend-adapter.js +11 -11
- package/dist/runtime/backend/raw-binding-port.d.ts +2 -2
- package/dist/runtime/backend/runtime-message.d.ts +1 -0
- package/dist/runtime/backend/runtime-message.js +5 -0
- package/dist/runtime/backend/runtime-values.d.ts +1 -0
- package/dist/runtime/backend/runtime-values.js +2 -1
- package/dist/runtime/channels/channel-clients.d.ts +2 -0
- package/dist/runtime/channels/channel-clients.js +75 -23
- package/dist/runtime/channels/channel-dispatch-pipeline.d.ts +25 -5
- package/dist/runtime/channels/channel-dispatch-pipeline.js +111 -56
- package/dist/runtime/channels/channel-dispatch-services.d.ts +1 -0
- package/dist/runtime/channels/channel-dispatch-services.js +45 -0
- package/dist/runtime/channels/channel-dispatchers.d.ts +4 -3
- package/dist/runtime/channels/channel-dispatchers.js +62 -54
- package/dist/runtime/channels/channel-envelope-inspection.d.ts +1 -2
- package/dist/runtime/channels/channel-envelope-inspection.js +1 -16
- package/dist/runtime/channels/channel-envelope.d.ts +2 -0
- package/dist/runtime/channels/channel-envelope.js +146 -28
- package/dist/runtime/channels/channel-outbound-operations.d.ts +2 -2
- package/dist/runtime/channels/channel-outbound-operations.js +8 -8
- 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 +9 -8
- package/dist/runtime/channels/channel-runtime-manager.js +16 -16
- package/dist/runtime/channels/channel-transports.d.ts +18 -16
- package/dist/runtime/channels/channel-transports.js +77 -58
- 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/channels/local-spot-route-transport.d.ts +1 -1
- package/dist/runtime/channels/local-spot-route-transport.js +2 -1
- package/dist/runtime/channels/router-socket-spot-route-transport.d.ts +2 -2
- package/dist/runtime/channels/router-socket-spot-route-transport.js +4 -4
- package/dist/runtime/channels/source-spot-router.d.ts +2 -2
- package/dist/runtime/channels/source-spot-router.js +4 -4
- package/dist/runtime/channels/spot-node-route-transport.d.ts +2 -2
- package/dist/runtime/channels/spot-node-route-transport.js +4 -4
- package/dist/runtime/channels/spot-route-bridge-transport.d.ts +2 -2
- package/dist/runtime/channels/spot-route-bridge-transport.js +4 -4
- package/dist/runtime/channels/spot-route-dispatch-strategy.d.ts +5 -4
- package/dist/runtime/channels/spot-route-dispatch-strategy.js +18 -18
- package/dist/runtime/diagnostics/flow-context.js +19 -7
- package/dist/runtime/diagnostics/index.js +4 -9
- package/dist/runtime/diagnostics/message-flow.d.ts +8 -0
- package/dist/runtime/diagnostics/message-flow.js +35 -5
- package/dist/runtime/diagnostics/runtime-metrics.d.ts +2 -2
- package/dist/runtime/diagnostics/runtime-metrics.js +10 -8
- package/dist/runtime/execution/index.d.ts +4 -2
- package/dist/runtime/execution/index.js +33 -10
- package/dist/runtime/execution/serial-execution-queue.d.ts +5 -0
- package/dist/runtime/execution/serial-execution-queue.js +22 -2
- package/dist/runtime/execution/state-lane.d.ts +2 -0
- package/dist/runtime/execution/state-lane.js +5 -0
- package/dist/runtime/foundation/actor-join-recovery-codec.js +2 -2
- package/dist/runtime/foundation/durable-service-request.d.ts +14 -0
- package/dist/runtime/foundation/durable-service-request.js +98 -0
- package/dist/runtime/foundation/operation-identity.d.ts +1 -0
- package/dist/runtime/foundation/operation-identity.js +5 -1
- 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 +61 -8
- package/dist/runtime/foundation/raw-service-mesh-runtime.js +486 -266
- 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 +3 -3
- package/dist/runtime/foundation/service-relocation-object-owner.js +48 -34
- package/dist/runtime/foundation/service-relocation-runtime.d.ts +2 -0
- package/dist/runtime/foundation/service-relocation-runtime.js +20 -4
- package/dist/runtime/foundation/service-runtime-contracts.d.ts +10 -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 +75 -9
- package/dist/runtime/foundation/service-stateful-runtime.js +486 -218
- package/dist/runtime/foundation/service-stateful-wire-codec.d.ts +14 -6
- package/dist/runtime/foundation/service-stateful-wire-codec.js +48 -27
- package/dist/runtime/foundation/service-topology-registry.d.ts +12 -2
- package/dist/runtime/foundation/service-topology-registry.js +61 -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 +13 -3
- package/dist/runtime/foundation/service-wire-m6a-codec.js +189 -78
- package/dist/runtime/handlers/handler-instance-scope.d.ts +8 -0
- package/dist/runtime/handlers/handler-instance-scope.js +54 -11
- 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-runtime-options-factory.js +2 -2
- 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 +40 -7
- package/dist/runtime/host/application-job-queue.js +137 -42
- package/dist/runtime/host/entry-actor-runtime.d.ts +1 -0
- package/dist/runtime/host/entry-actor-runtime.js +3 -0
- package/dist/runtime/host/index.d.ts +12 -2
- package/dist/runtime/host/index.js +300 -202
- 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 +73 -208
- package/dist/runtime/host/route-mesh-runtime.d.ts +2 -2
- package/dist/runtime/host/route-mesh-runtime.js +6 -4
- 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-control.d.ts +1 -0
- package/dist/runtime/host/service-relocation-control.js +10 -4
- package/dist/runtime/host/service-relocation-host-runtime.d.ts +22 -14
- package/dist/runtime/host/service-relocation-host-runtime.js +754 -599
- package/dist/runtime/host/spot-address-transport.js +3 -2
- package/dist/runtime/host/spot-runtime-options-factory.js +16 -7
- package/dist/runtime/host/user-spot-creation-coordinator.js +33 -84
- package/dist/runtime/locations/actor-location-claims.d.ts +2 -2
- package/dist/runtime/locations/actor-location-claims.js +34 -19
- package/dist/runtime/locations/auto-connect-loop.d.ts +2 -0
- package/dist/runtime/locations/auto-connect-loop.js +22 -14
- package/dist/runtime/locations/auto-connect-reconciler.js +0 -6
- package/dist/runtime/locations/auto-connect-types.d.ts +0 -1
- package/dist/runtime/locations/descriptor-publication.d.ts +4 -0
- package/dist/runtime/locations/descriptor-publication.js +11 -0
- package/dist/runtime/locations/domain-store-contract.d.ts +1 -0
- package/dist/runtime/locations/in-memory-authority-store.d.ts +7 -1
- package/dist/runtime/locations/in-memory-authority-store.js +56 -19
- package/dist/runtime/locations/in-memory-location-store.js +1 -10
- package/dist/runtime/locations/index.d.ts +1 -0
- package/dist/runtime/locations/index.js +1 -0
- package/dist/runtime/locations/lease-tracker.js +1 -6
- package/dist/runtime/locations/lifecycle.d.ts +1 -2
- package/dist/runtime/locations/lifecycle.js +2 -5
- 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 +7 -3
- package/dist/runtime/locations/runtime.js +61 -53
- package/dist/runtime/messaging/framework-json-v1.d.ts +4 -6
- package/dist/runtime/messaging/framework-json-v1.js +38 -294
- package/dist/runtime/messaging/packet-name.d.ts +1 -1
- package/dist/runtime/messaging/packet-name.js +8 -24
- 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.d.ts +2 -0
- package/dist/runtime/messaging/request-result.js +57 -0
- package/dist/runtime/messaging/submission-result.d.ts +1 -0
- package/dist/runtime/messaging/submission-result.js +5 -2
- package/dist/runtime/protocol/service_wire_codec.generated.d.ts +34 -1
- package/dist/runtime/protocol/service_wire_codec.generated.js +229 -0
- package/dist/runtime/protocol/service_wire_pilot_codec.generated.d.ts +16 -1
- package/dist/runtime/protocol/service_wire_pilot_codec.generated.js +37 -8
- package/dist/runtime/spots/formal-remote-actor-admission-registry.d.ts +7 -2
- package/dist/runtime/spots/formal-remote-actor-admission-registry.js +36 -21
- package/dist/runtime/spots/index.d.ts +21 -11
- package/dist/runtime/spots/index.js +243 -178
- 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 +7 -3
- package/dist/runtime/spots/spot-activation.js +140 -52
- 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 +20 -11
- package/dist/runtime/spots/spot-handler-registry.d.ts +7 -4
- package/dist/runtime/spots/spot-handler-registry.js +24 -10
- 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 +22 -42
- 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.d.ts +3 -0
- package/dist/runtime/spots/spot-outbound.js +27 -18
- package/dist/runtime/spots/spot-remote-codec.js +5 -1
- package/dist/runtime/spots/spot-routed-spot-packet-dispatch.d.ts +1 -0
- package/dist/runtime/spots/spot-routed-spot-packet-dispatch.js +1 -1
- package/dist/runtime/spots/spot-runtime-ports.d.ts +1 -1
- package/dist/runtime/spots/spot-serial-executor.d.ts +10 -0
- package/dist/runtime/spots/spot-serial-executor.js +61 -8
- package/dist/runtime/spots/spot-serial-turn-executor.js +19 -2
- package/dist/runtime/spots/spot-subscription-dispatch.js +1 -4
- package/dist/runtime/spots/spot-timer.d.ts +57 -5
- package/dist/runtime/spots/spot-timer.js +288 -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.d.ts +1 -1
- package/dist/runtime/streams/stream-session-runtime.js +14 -31
- package/dist/runtime/workers/index.js +1 -1
- package/package.json +3 -3
- package/src/contracts/Actors/ZLinkActorClient.ts +2 -1
- package/src/contracts/Channels/Calls.ts +2 -1
- package/src/contracts/Common/ZLinkEncodedPayload.ts +24 -4
- package/src/contracts/Common/ZLinkMessageMetadata.ts +13 -8
- 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/Handlers/Attributes.ts +14 -21
- package/src/contracts/Handlers/JsonContract.ts +8 -216
- package/src/contracts/Locations/Rows.ts +2 -0
- package/src/contracts/Spots/Contracts.ts +10 -1
- package/src/contracts/Spots/ZLinkSpot.ts +3 -3
- package/src/nest-integration.ts +1 -0
- package/src/runtime/abort.ts +12 -0
- package/src/runtime/actors/actor-authority-publication.ts +3 -2
- package/src/runtime/actors/actor-client.ts +100 -85
- package/src/runtime/actors/actor-context.ts +49 -9
- package/src/runtime/actors/actor-handoff.ts +291 -110
- package/src/runtime/actors/actor-join-relocation.ts +3 -0
- package/src/runtime/actors/actor-local-native-join.ts +21 -26
- package/src/runtime/actors/actor-mailbox.ts +40 -2
- package/src/runtime/actors/actor-remote-joiner.ts +6 -1
- package/src/runtime/actors/actor-remote-wire.ts +17 -0
- package/src/runtime/actors/actor-reply.ts +42 -0
- package/src/runtime/actors/actor-routed-join-transport.ts +14 -4
- package/src/runtime/actors/actor-routed-json-request.ts +10 -2
- 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 +60 -32
- package/src/runtime/actors/session-disconnected-wire.ts +66 -0
- package/src/runtime/actors/spot-actor-dispatch.ts +4 -2
- package/src/runtime/admission.ts +69 -21
- package/src/runtime/application-jobs/application-ingress-record-owner.ts +41 -25
- package/src/runtime/application-jobs/application-job-queue-scope.ts +83 -22
- package/src/runtime/application-jobs/contracts.ts +16 -1
- package/src/runtime/backend/contracts/index.ts +92 -18
- package/src/runtime/backend/mesh-actor-session-node-adapter.ts +5 -3
- package/src/runtime/backend/mesh-completion-table.ts +160 -57
- package/src/runtime/backend/mesh-dispatch-pump.ts +237 -108
- package/src/runtime/backend/node/node-backend-adapter-support.ts +17 -8
- package/src/runtime/backend/node/node-dealer-channel-client-transport.ts +12 -2
- package/src/runtime/backend/node/node-raw-binding-port.ts +148 -85
- package/src/runtime/backend/node/node-raw-mesh-backend.ts +315 -201
- package/src/runtime/backend/node/node-socket-backend-adapter.ts +26 -11
- package/src/runtime/backend/raw-binding-port.ts +7 -2
- package/src/runtime/backend/runtime-message.ts +6 -0
- package/src/runtime/backend/runtime-values.ts +1 -0
- package/src/runtime/channels/channel-clients.ts +132 -58
- package/src/runtime/channels/channel-dispatch-pipeline.ts +198 -114
- package/src/runtime/channels/channel-dispatch-services.ts +69 -1
- package/src/runtime/channels/channel-dispatchers.ts +136 -90
- package/src/runtime/channels/channel-envelope-inspection.ts +2 -16
- package/src/runtime/channels/channel-envelope.ts +225 -31
- package/src/runtime/channels/channel-outbound-operations.ts +22 -8
- package/src/runtime/channels/channel-runtime-lifecycle.ts +13 -13
- package/src/runtime/channels/channel-runtime-manager.ts +41 -17
- package/src/runtime/channels/channel-transports.ts +171 -112
- 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/channels/local-spot-route-transport.ts +3 -1
- package/src/runtime/channels/router-socket-spot-route-transport.ts +13 -4
- package/src/runtime/channels/source-spot-router.ts +8 -4
- package/src/runtime/channels/spot-node-route-transport.ts +8 -4
- package/src/runtime/channels/spot-route-bridge-transport.ts +6 -4
- package/src/runtime/channels/spot-route-dispatch-strategy.ts +47 -18
- package/src/runtime/diagnostics/flow-context.ts +20 -7
- package/src/runtime/diagnostics/index.ts +1 -7
- package/src/runtime/diagnostics/message-flow.ts +47 -9
- package/src/runtime/diagnostics/runtime-metrics.ts +12 -10
- package/src/runtime/execution/index.ts +40 -14
- package/src/runtime/execution/serial-execution-queue.ts +33 -4
- package/src/runtime/execution/state-lane.ts +7 -0
- package/src/runtime/foundation/actor-join-recovery-codec.ts +2 -2
- package/src/runtime/foundation/durable-service-request.ts +137 -0
- package/src/runtime/foundation/operation-identity.ts +5 -1
- package/src/runtime/foundation/operation-registry.ts +98 -20
- package/src/runtime/foundation/raw-service-mesh-runtime.ts +704 -336
- 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 +55 -36
- package/src/runtime/foundation/service-relocation-runtime.ts +25 -4
- package/src/runtime/foundation/service-runtime-contracts.ts +19 -2
- 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 +732 -275
- package/src/runtime/foundation/service-stateful-wire-codec.ts +49 -16
- package/src/runtime/foundation/service-topology-registry.ts +91 -36
- 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 +231 -76
- package/src/runtime/handlers/handler-instance-scope.ts +67 -16
- 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-runtime-options-factory.ts +13 -2
- package/src/runtime/host/actor-transfer-runtime.ts +104 -430
- package/src/runtime/host/application-job-queue.ts +160 -41
- package/src/runtime/host/entry-actor-runtime.ts +4 -0
- package/src/runtime/host/index.ts +473 -271
- 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 +88 -271
- package/src/runtime/host/route-mesh-runtime.ts +12 -6
- package/src/runtime/host/runtime-shutdown.ts +15 -4
- package/src/runtime/host/service-relocation-control.ts +11 -5
- package/src/runtime/host/service-relocation-host-runtime.ts +1092 -759
- package/src/runtime/host/spot-address-transport.ts +4 -2
- package/src/runtime/host/spot-runtime-options-factory.ts +20 -7
- package/src/runtime/host/user-spot-creation-coordinator.ts +41 -100
- package/src/runtime/locations/actor-location-claims.ts +52 -30
- package/src/runtime/locations/auto-connect-loop.ts +22 -14
- package/src/runtime/locations/auto-connect-reconciler.ts +0 -6
- package/src/runtime/locations/auto-connect-types.ts +0 -1
- package/src/runtime/locations/descriptor-publication.ts +7 -0
- package/src/runtime/locations/domain-store-contract.ts +5 -0
- package/src/runtime/locations/in-memory-authority-store.ts +85 -23
- package/src/runtime/locations/in-memory-location-store.ts +1 -12
- package/src/runtime/locations/index.ts +1 -0
- package/src/runtime/locations/lease-tracker.ts +2 -9
- package/src/runtime/locations/lifecycle.ts +8 -26
- 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 +98 -64
- package/src/runtime/messaging/framework-json-v1.ts +5 -325
- package/src/runtime/messaging/packet-name.ts +5 -25
- package/src/runtime/messaging/payload-codec.ts +8 -11
- package/src/runtime/messaging/request-result.ts +62 -0
- package/src/runtime/messaging/submission-result.ts +5 -1
- package/src/runtime/protocol/service_wire_codec.generated.ts +218 -5
- package/src/runtime/protocol/service_wire_pilot_codec.generated.ts +16 -13
- package/src/runtime/spots/formal-remote-actor-admission-registry.ts +46 -25
- package/src/runtime/spots/index.ts +389 -283
- 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 +198 -96
- 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 +33 -21
- package/src/runtime/spots/spot-handler-registry.ts +56 -12
- 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 +28 -47
- package/src/runtime/spots/spot-node-runtime-manager.ts +197 -67
- package/src/runtime/spots/spot-outbound.ts +39 -19
- package/src/runtime/spots/spot-remote-codec.ts +9 -2
- package/src/runtime/spots/spot-routed-spot-packet-dispatch.ts +2 -1
- package/src/runtime/spots/spot-runtime-ports.ts +1 -1
- package/src/runtime/spots/spot-serial-executor.ts +97 -25
- package/src/runtime/spots/spot-serial-turn-executor.ts +22 -3
- package/src/runtime/spots/spot-subscription-dispatch.ts +1 -4
- package/src/runtime/spots/spot-timer.ts +418 -158
- 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 +13 -34
- package/src/runtime/workers/index.ts +1 -1
|
@@ -35,9 +35,11 @@ export declare class ZLinkSpotActivationRegistry {
|
|
|
35
35
|
nextActiveActivationBatch(limit?: number): readonly ZLinkSpotActivation[];
|
|
36
36
|
closingOperation(meshName: string, spotId: RoutingId): ZLinkSpotCloseOperation | undefined;
|
|
37
37
|
whenEmpty(signal?: AbortSignal): Promise<void>;
|
|
38
|
-
|
|
38
|
+
registerPreparing(activation: ZLinkSpotActivation): void;
|
|
39
|
+
register(activation: ZLinkSpotActivation): ZLinkSpotActivation | undefined;
|
|
40
|
+
private registerIncarnation;
|
|
39
41
|
stage(meshName: string, spotId: RoutingId): void;
|
|
40
|
-
publish(meshName: string, spotId: RoutingId):
|
|
42
|
+
publish(meshName: string, spotId: RoutingId): ZLinkSpotActivation | undefined;
|
|
41
43
|
detachRelocated(meshName: string, spotId: RoutingId): ZLinkSpotActivation | undefined;
|
|
42
44
|
abandonStage(meshName: string, spotId: RoutingId): void;
|
|
43
45
|
startClose(meshName: string, spotId: RoutingId, close: (activation: ZLinkSpotActivation) => Promise<void>, resourcesReleased: (activation: ZLinkSpotActivation) => boolean, reason?: ZLinkSpotCloseReason): ZLinkSpotCloseOperation | undefined;
|
|
@@ -31,24 +31,22 @@ class ZLinkSpotActivationRegistry {
|
|
|
31
31
|
}
|
|
32
32
|
resolve(meshName, spotId) {
|
|
33
33
|
const key = spotActivationKey(meshName, spotId);
|
|
34
|
-
return this.staged.has(key) ? undefined : this.activations.get(key);
|
|
34
|
+
return this.staged.has(key) || this.pending.has(key) ? undefined : this.activations.get(key);
|
|
35
35
|
}
|
|
36
36
|
resolveUnique(spotId) {
|
|
37
37
|
const matches = [...this.activations.values()].filter((activation) => String(activation.spotId) === String(spotId) &&
|
|
38
|
-
|
|
38
|
+
this.has(activation.meshName, activation.spotId));
|
|
39
39
|
return matches.length === 1 ? matches[0] : undefined;
|
|
40
40
|
}
|
|
41
41
|
has(meshName, spotId) {
|
|
42
|
-
|
|
43
|
-
return !this.staged.has(key) && this.activations.has(key);
|
|
42
|
+
return this.resolve(meshName, spotId) !== undefined;
|
|
44
43
|
}
|
|
45
44
|
list(meshName) {
|
|
46
45
|
return [...this.activations.values()]
|
|
47
46
|
.filter((activation) => {
|
|
48
47
|
if (activation.meshName !== meshName)
|
|
49
48
|
return false;
|
|
50
|
-
|
|
51
|
-
return !this.staged.has(key);
|
|
49
|
+
return this.has(activation.meshName, activation.spotId);
|
|
52
50
|
})
|
|
53
51
|
.map((activation) => String(activation.spotId))
|
|
54
52
|
.sort((left, right) => left.localeCompare(right))
|
|
@@ -112,19 +110,31 @@ class ZLinkSpotActivationRegistry {
|
|
|
112
110
|
signal?.addEventListener('abort', abort, { once: true });
|
|
113
111
|
});
|
|
114
112
|
}
|
|
113
|
+
registerPreparing(activation) {
|
|
114
|
+
this.registerIncarnation(activation);
|
|
115
|
+
}
|
|
115
116
|
register(activation) {
|
|
117
|
+
return this.registerIncarnation(activation);
|
|
118
|
+
}
|
|
119
|
+
registerIncarnation(activation) {
|
|
116
120
|
const key = spotActivationKey(activation.meshName, activation.spotId);
|
|
117
|
-
|
|
121
|
+
const existing = this.activations.get(key);
|
|
122
|
+
if (existing !== undefined && existing !== activation) {
|
|
118
123
|
throw (0, framework_errors_internal_1.createInternalFrameworkException)(framework_errors_internal_1.ZLinkFrameworkInternalErrorKind.SpotTypeMismatch, `Spot '${activation.spotId}' was activated more than once.`);
|
|
119
124
|
}
|
|
120
|
-
|
|
121
|
-
|
|
125
|
+
if (existing === undefined) {
|
|
126
|
+
this.activations.set(key, activation);
|
|
127
|
+
this.lifecycleMetrics.opened('user');
|
|
128
|
+
}
|
|
129
|
+
return this.staged.has(key) ? undefined : activation;
|
|
122
130
|
}
|
|
123
131
|
stage(meshName, spotId) {
|
|
124
132
|
this.staged.add(spotActivationKey(meshName, spotId));
|
|
125
133
|
}
|
|
126
134
|
publish(meshName, spotId) {
|
|
127
|
-
|
|
135
|
+
const key = spotActivationKey(meshName, spotId);
|
|
136
|
+
this.staged.delete(key);
|
|
137
|
+
return this.activations.get(key);
|
|
128
138
|
}
|
|
129
139
|
detachRelocated(meshName, spotId) {
|
|
130
140
|
const key = spotActivationKey(meshName, spotId);
|
|
@@ -189,7 +199,7 @@ class ZLinkSpotActivationRegistry {
|
|
|
189
199
|
getOrBegin(meshName, spotType, spotId, create) {
|
|
190
200
|
const key = spotActivationKey(meshName, spotId);
|
|
191
201
|
const existing = this.activations.get(key);
|
|
192
|
-
if (existing !== undefined) {
|
|
202
|
+
if (existing !== undefined && !this.pending.has(key)) {
|
|
193
203
|
return {
|
|
194
204
|
owner: false,
|
|
195
205
|
ready: existing.serial.execute(() => {
|
|
@@ -71,7 +71,7 @@ export declare class ZLinkSpotActivation {
|
|
|
71
71
|
waitForRelocationBoundary(signal?: AbortSignal): Promise<boolean>;
|
|
72
72
|
completeConsumedRelocationBoundary(outcome: ZLinkSpotRelocationReadyOutcome): Promise<void>;
|
|
73
73
|
notifyRelocatedBoundary(): Promise<void>;
|
|
74
|
-
executeActor<T>(actorId: string, operation: (serial: ZLinkSpotSerialTurnExecutor) => Promise<T> | T): Promise<T>;
|
|
74
|
+
executeActor<T>(actorId: string, operation: (serial: ZLinkSpotSerialTurnExecutor) => Promise<T> | T, workOptions?: import('../execution/serial-execution-queue').ZLinkSerialWorkOptions): Promise<T>;
|
|
75
75
|
sealExecution(kind?: ZLinkExecutionBarrierSeal['kind']): ZLinkExecutionBarrierSeal;
|
|
76
76
|
waitForExecutionQuiescence(seal: ZLinkExecutionBarrierSeal, signal?: AbortSignal): Promise<void>;
|
|
77
77
|
abortExecutionSeal(seal: ZLinkExecutionBarrierSeal): boolean;
|
|
@@ -146,17 +146,17 @@ class ZLinkSpotActivation {
|
|
|
146
146
|
return;
|
|
147
147
|
this.relocationBoundaryConsumed = false;
|
|
148
148
|
this.relocationReadyDeferredTurnId = undefined;
|
|
149
|
-
await this.serial.
|
|
149
|
+
await this.serial.postBarrierTurn(() => this.notifyRelocationReadyCompleted(outcome));
|
|
150
150
|
}
|
|
151
151
|
async notifyRelocatedBoundary() {
|
|
152
|
-
await this.serial.
|
|
152
|
+
await this.serial.postBarrierTurn(() => this.notifyRelocationReadyCompleted(contracts_1.ZLinkSpotRelocationReadyOutcome.Relocated));
|
|
153
153
|
}
|
|
154
|
-
executeActor(actorId, operation) {
|
|
155
|
-
return this.serialExecutor.executeActor(actorId, operation);
|
|
154
|
+
executeActor(actorId, operation, workOptions) {
|
|
155
|
+
return this.serialExecutor.executeActor(actorId, operation, workOptions);
|
|
156
156
|
}
|
|
157
157
|
/** @internal Restores a non-executing durable prefix into one Actor FIFO. */
|
|
158
|
-
|
|
159
|
-
return this.serialExecutor.
|
|
158
|
+
admitActorPacketPrefix(actorId, records, dispatch) {
|
|
159
|
+
return this.serialExecutor.admitActorPacketPrefix(actorId, records, dispatch);
|
|
160
160
|
}
|
|
161
161
|
sealExecution(kind = 'relocation') {
|
|
162
162
|
return this.executionBarrier.seal(kind);
|
|
@@ -187,7 +187,7 @@ class ZLinkSpotActivation {
|
|
|
187
187
|
abortRelocation(capture) {
|
|
188
188
|
if (!this.executionBarrier.isCurrent(capture.seal))
|
|
189
189
|
return false;
|
|
190
|
-
this.timers.abortRelocation(
|
|
190
|
+
this.timers.abortRelocation();
|
|
191
191
|
return this.abortExecutionSeal(capture.seal);
|
|
192
192
|
}
|
|
193
193
|
async commitRelocation(capture) {
|
|
@@ -12,7 +12,7 @@ import { ZLinkDispatchErrorReporter } from '../channels';
|
|
|
12
12
|
import { type ZLinkRemoteBoundSessionTarget } from '../actors';
|
|
13
13
|
import { ZLinkWorkerRuntime } from '../workers';
|
|
14
14
|
import { type ZLinkSpotAddressTransport, type ZLinkSpotRoutedTransport } from './spot-outbound';
|
|
15
|
-
import { type ZLinkTimerClock } from './spot-timer';
|
|
15
|
+
import { type ZLinkTimerClock, type ZLinkTimerRelocationState } from './spot-timer';
|
|
16
16
|
import type { ZLinkDetachedTaskRunner } from './spot-actor-join-dispatch';
|
|
17
17
|
import type { ZLinkRouteToActorJoinPrewarm } from './spot-actor-packet-dispatch';
|
|
18
18
|
import { ZLinkSpotActivation } from './spot-activation-state';
|
|
@@ -29,6 +29,7 @@ export interface ZLinkSpotActivationLifecycleOptions {
|
|
|
29
29
|
readonly nodeRid?: RoutingId;
|
|
30
30
|
readonly nodeRidProvider?: (meshName: string) => RoutingId | undefined;
|
|
31
31
|
readonly actorCountProvider?: (spotId: RoutingId) => number;
|
|
32
|
+
readonly releaseActorMembers?: (meshName: string, spotId: RoutingId) => Promise<void>;
|
|
32
33
|
readonly userSpotExecutionMode?: (meshName: string, spotType: Type<ZLinkSpot>) => ZLinkUserSpotExecutionMode;
|
|
33
34
|
readonly userSpotRelocationCoordinationMode?: (meshName: string, spotType: Type<ZLinkSpot>) => ZLinkSpotRelocationCoordinationMode;
|
|
34
35
|
readonly channelClient?: ZLinkChannelClient;
|
|
@@ -57,7 +58,9 @@ export interface ZLinkSpotActivationLifecycleOptions {
|
|
|
57
58
|
readonly leaveActor: (spotId: RoutingId, actor: ZLinkActor, signal?: AbortSignal, meshName?: string) => Promise<void>;
|
|
58
59
|
/** Starts a context Close request after its calling turn has ended. */
|
|
59
60
|
readonly requestContextClose: (activation: ZLinkSpotActivation, objectGeneration: bigint, signal?: AbortSignal) => Promise<boolean>;
|
|
60
|
-
readonly registerActivation: (activation: ZLinkSpotActivation) => void
|
|
61
|
+
readonly registerActivation: (activation: ZLinkSpotActivation) => void | Promise<void>;
|
|
62
|
+
readonly stageActivation?: (activation: ZLinkSpotActivation) => void;
|
|
63
|
+
readonly discardActivation?: (activation: ZLinkSpotActivation) => void;
|
|
61
64
|
readonly routeToActorJoinPrewarm?: ZLinkRouteToActorJoinPrewarm;
|
|
62
65
|
readonly releaseLocation: (activation: ZLinkSpotActivation, meshName: string, spotId: RoutingId) => Promise<void>;
|
|
63
66
|
readonly metrics?: import('../diagnostics').ZLinkRuntimeMetrics;
|
|
@@ -73,7 +76,7 @@ export declare class ZLinkSpotActivationLifecycle {
|
|
|
73
76
|
private readonly actorAdmission;
|
|
74
77
|
private readonly cleanupStates;
|
|
75
78
|
constructor(options: ZLinkSpotActivationLifecycleOptions);
|
|
76
|
-
materializeRelocation<TSpot extends ZLinkSpot | ZLinkInstanceSpot>(meshName: string, objectKind: 'user_spot' | 'instance_spot', stableType: string, implementation: Type<TSpot>, spotId: RoutingId, objectGeneration: bigint, authorityOwnerGeneration: bigint, signal?: AbortSignal): Promise<ZLinkSpotActivation>;
|
|
79
|
+
materializeRelocation<TSpot extends ZLinkSpot | ZLinkInstanceSpot>(meshName: string, objectKind: 'user_spot' | 'instance_spot', stableType: string, implementation: Type<TSpot>, spotId: RoutingId, objectGeneration: bigint, authorityOwnerGeneration: bigint, restoredTimers: readonly ZLinkTimerRelocationState[], signal?: AbortSignal): Promise<ZLinkSpotActivation>;
|
|
77
80
|
materializeInstance<TSpot extends ZLinkInstanceSpot>(meshName: string, instanceType: string, implementation: Type<TSpot>, spotId: RoutingId, objectGeneration: bigint, signal?: AbortSignal, serialOwner?: ZLinkSpotActivation): Promise<ZLinkSpotActivation>;
|
|
78
81
|
discardInstance(activation: ZLinkSpotActivation): Promise<void>;
|
|
79
82
|
create<TSpot extends ZLinkSpot>(meshName: string, spotType: Type<TSpot>, spotId: RoutingId, request: Message, signal?: AbortSignal, authority?: ZLinkNativeSpotAuthority): Promise<ZLinkLocalSpotCreateResult>;
|
|
@@ -86,6 +89,7 @@ export declare class ZLinkSpotActivationLifecycle {
|
|
|
86
89
|
dispatchActorPacket(origin: ApplicationJobOrigin, activation: ZLinkSpotActivation, actorId: string, parts: readonly Message[], returnResponse?: boolean, remoteBoundSessionTarget?: ZLinkRemoteBoundSessionTarget, fallbackActorRef?: ActorRef, requestTerminal?: (response: unknown) => Promise<void> | void, messageFollowOrigin?: ZLinkMessageFollowOrigin): Promise<unknown>;
|
|
87
90
|
private runCreateLifecycle;
|
|
88
91
|
private cleanupActivation;
|
|
92
|
+
discardPreparation(activation: ZLinkSpotActivation): Promise<void>;
|
|
89
93
|
private runCleanup;
|
|
90
94
|
private decodeCreateReply;
|
|
91
95
|
}
|
|
@@ -29,14 +29,14 @@ class ZLinkSpotActivationLifecycle {
|
|
|
29
29
|
}
|
|
30
30
|
this.actorAdmission = new spot_actor_admission_coordinator_1.ZLinkSpotActorAdmissionCoordinator(options);
|
|
31
31
|
}
|
|
32
|
-
async materializeRelocation(meshName, objectKind, stableType, implementation, spotId, objectGeneration, authorityOwnerGeneration, signal) {
|
|
32
|
+
async materializeRelocation(meshName, objectKind, stableType, implementation, spotId, objectGeneration, authorityOwnerGeneration, restoredTimers, signal) {
|
|
33
33
|
const executionMode = objectKind === 'user_spot'
|
|
34
34
|
? (this.options.userSpotExecutionMode?.(meshName, implementation) ?? contracts_1.ZLinkUserSpotExecutionMode.SpotWide)
|
|
35
35
|
: contracts_1.ZLinkUserSpotExecutionMode.SpotWide;
|
|
36
36
|
const serial = new spot_serial_turn_executor_1.ZLinkSpotSerialTurnExecutor(executionMode === contracts_1.ZLinkUserSpotExecutionMode.SpotWide, spotId);
|
|
37
37
|
const serialExecutor = new spot_serial_executor_1.ZLinkSpotSerialExecutor(serial, executionMode, spotId);
|
|
38
38
|
const actorHandlers = new actors_1.ZLinkSpotActorHandlerRegistryRuntime();
|
|
39
|
-
const handlers = new spot_handler_registry_1.DefaultZLinkSpotHandlerRegistry(actorHandlers);
|
|
39
|
+
const handlers = new spot_handler_registry_1.DefaultZLinkSpotHandlerRegistry(actorHandlers, this.options.providerResolver);
|
|
40
40
|
(0, spot_handler_registry_1.applySpotHandlerRegistrations)(handlers, implementation, objectKind === 'user_spot'
|
|
41
41
|
? {
|
|
42
42
|
actorSendHandlers: this.options.spotActorSendHandlers,
|
|
@@ -46,6 +46,9 @@ class ZLinkSpotActivationLifecycle {
|
|
|
46
46
|
}
|
|
47
47
|
: { packetHandlers: this.options.spotPacketHandlers });
|
|
48
48
|
const timers = new spot_timer_1.ZLinkSpotTimerRegistry(this.options.metrics, () => this.options.dispatchErrors?.flow.flowCreationEnabled() ?? true, undefined, this.options.statefulExecutionAllowed, (name, operation) => serialExecutor.executeTimer(name, operation), (name) => serialExecutor.isTimerExecuting(name), this.options.timerClock);
|
|
49
|
+
// Spot timer §1: the source schedule exists before Configure so its
|
|
50
|
+
// registrations reattach to the restored keys.
|
|
51
|
+
timers.stageRelocation(restoredTimers);
|
|
49
52
|
const outbound = new spot_outbound_1.DefaultZLinkSpotOutbound({
|
|
50
53
|
serial,
|
|
51
54
|
channelClient: this.options.channelClient,
|
|
@@ -102,12 +105,6 @@ class ZLinkSpotActivationLifecycle {
|
|
|
102
105
|
enumerable: false,
|
|
103
106
|
value: context
|
|
104
107
|
});
|
|
105
|
-
await instance.configure?.();
|
|
106
|
-
await (0, spot_timer_1.addSpotTimerRegistrations)(timers, implementation, spotId, instance, serial, { timerHandlers: this.options.spotTimerHandlers }, {
|
|
107
|
-
providerResolver: this.options.providerResolver,
|
|
108
|
-
runtimeEventPublisher: this.options.runtimeEventPublisher,
|
|
109
|
-
signal
|
|
110
|
-
});
|
|
111
108
|
activation = new spot_activation_state_1.ZLinkSpotActivation({
|
|
112
109
|
meshName,
|
|
113
110
|
spotId,
|
|
@@ -130,10 +127,27 @@ class ZLinkSpotActivationLifecycle {
|
|
|
130
127
|
nativeSpot,
|
|
131
128
|
metrics: this.options.metrics
|
|
132
129
|
});
|
|
133
|
-
|
|
130
|
+
serialExecutor.beginPreparation('relocation');
|
|
131
|
+
const configured = instance;
|
|
132
|
+
await serial.postBarrierTurn(() => timers.runRelocationInitialization(async () => {
|
|
133
|
+
await configured.configure?.();
|
|
134
|
+
await (0, spot_timer_1.addSpotTimerRegistrations)(timers, implementation, spotId, configured, serial, { timerHandlers: this.options.spotTimerHandlers }, {
|
|
135
|
+
providerResolver: this.options.providerResolver,
|
|
136
|
+
runtimeEventPublisher: this.options.runtimeEventPublisher,
|
|
137
|
+
signal
|
|
138
|
+
});
|
|
139
|
+
// Node timer relocation: restored handlers resolve by name among the
|
|
140
|
+
// constructors announced in Configure (addTimer or addTimerHandler).
|
|
141
|
+
await timers.resolveRelocationHandlers(handlers
|
|
142
|
+
.snapshot()
|
|
143
|
+
.filter((entry) => entry.kind === 'timer')
|
|
144
|
+
.map((entry) => entry.handlerType), (name, periodMs, handlerType) => context.addTimer(name, periodMs, handlerType, undefined, signal));
|
|
145
|
+
}));
|
|
146
|
+
await this.options.registerActivation(activation);
|
|
134
147
|
return activation;
|
|
135
148
|
}
|
|
136
149
|
catch (error) {
|
|
150
|
+
const preparation = await Promise.allSettled(activation === undefined ? [] : [this.discardPreparation(activation)]);
|
|
137
151
|
const cleanup = await Promise.allSettled([
|
|
138
152
|
timers.dispose(),
|
|
139
153
|
...(instance === undefined
|
|
@@ -141,7 +155,7 @@ class ZLinkSpotActivationLifecycle {
|
|
|
141
155
|
: [(0, handler_instance_scope_1.disposeLifecycleHandlers)(instance, this.options.detachedTaskRunner)]),
|
|
142
156
|
...(nativeSpot === undefined ? [] : [Promise.resolve().then(() => nativeSpot.dispose())])
|
|
143
157
|
]);
|
|
144
|
-
const cleanupErrors = cleanup
|
|
158
|
+
const cleanupErrors = [...preparation, ...cleanup]
|
|
145
159
|
.filter((result) => result.status === 'rejected')
|
|
146
160
|
.map((result) => result.reason);
|
|
147
161
|
if (cleanupErrors.length > 0) {
|
|
@@ -151,10 +165,11 @@ class ZLinkSpotActivationLifecycle {
|
|
|
151
165
|
}
|
|
152
166
|
}
|
|
153
167
|
async materializeInstance(meshName, instanceType, implementation, spotId, objectGeneration, signal, serialOwner) {
|
|
168
|
+
(0, abort_1.throwIfAborted)(signal);
|
|
154
169
|
const serial = serialOwner?.serial ?? new spot_serial_turn_executor_1.ZLinkSpotSerialTurnExecutor(true, spotId);
|
|
155
170
|
const serialExecutor = new spot_serial_executor_1.ZLinkSpotSerialExecutor(serial, contracts_1.ZLinkUserSpotExecutionMode.SpotWide, spotId);
|
|
156
171
|
const actorHandlers = new actors_1.ZLinkSpotActorHandlerRegistryRuntime();
|
|
157
|
-
const handlers = new spot_handler_registry_1.DefaultZLinkSpotHandlerRegistry(actorHandlers);
|
|
172
|
+
const handlers = new spot_handler_registry_1.DefaultZLinkSpotHandlerRegistry(actorHandlers, this.options.providerResolver);
|
|
158
173
|
const instanceHandlers = new spot_handler_registry_1.DefaultZLinkInstanceSpotHandlerRegistry(handlers);
|
|
159
174
|
(0, spot_handler_registry_1.applySpotHandlerRegistrations)(handlers, implementation, {
|
|
160
175
|
packetHandlers: this.options.spotPacketHandlers
|
|
@@ -207,31 +222,56 @@ class ZLinkSpotActivationLifecycle {
|
|
|
207
222
|
externalActorCount: () => this.options.actorCountProvider?.(spotId) ?? 0
|
|
208
223
|
});
|
|
209
224
|
try {
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
225
|
+
if (serialOwner === undefined)
|
|
226
|
+
serialExecutor.beginPreparation();
|
|
227
|
+
await serial.postBarrierTurn(async () => {
|
|
228
|
+
(0, abort_1.throwIfAborted)(signal);
|
|
229
|
+
await instance.configure?.();
|
|
230
|
+
await (0, spot_timer_1.addSpotTimerRegistrations)(timers, implementation, spotId, instance, serial, { timerHandlers: this.options.spotTimerHandlers }, {
|
|
231
|
+
providerResolver: this.options.providerResolver,
|
|
232
|
+
runtimeEventPublisher: this.options.runtimeEventPublisher,
|
|
233
|
+
signal
|
|
234
|
+
});
|
|
235
|
+
(0, abort_1.throwIfAborted)(signal);
|
|
236
|
+
await instance.onInitialize?.(signal);
|
|
215
237
|
});
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
: serial.postBarrierTurn(() => instance.onInitialize?.()));
|
|
219
|
-
this.options.registerActivation(activation);
|
|
238
|
+
(0, abort_1.throwIfAborted)(signal);
|
|
239
|
+
await this.options.registerActivation(activation);
|
|
220
240
|
return activation;
|
|
221
241
|
}
|
|
222
242
|
catch (error) {
|
|
223
|
-
const
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
const cleanupErrors =
|
|
228
|
-
|
|
229
|
-
.
|
|
230
|
-
|
|
243
|
+
const failure = signal?.aborted === true ? (0, abort_1.createAbortError)() : error;
|
|
244
|
+
const cancelled = (0, abort_1.isAbortError)(failure);
|
|
245
|
+
if (cancelled && serialOwner === undefined)
|
|
246
|
+
serial.closeAdmission();
|
|
247
|
+
const cleanupErrors = [];
|
|
248
|
+
try {
|
|
249
|
+
await serialExecutor.finishPreparation(async () => {
|
|
250
|
+
const cleanup = await Promise.allSettled([
|
|
251
|
+
timers.dispose(),
|
|
252
|
+
(0, handler_instance_scope_1.disposeLifecycleHandlers)(instance, this.options.detachedTaskRunner)
|
|
253
|
+
]);
|
|
254
|
+
cleanupErrors.push(...cleanup
|
|
255
|
+
.filter((result) => result.status === 'rejected')
|
|
256
|
+
.map((result) => result.reason));
|
|
257
|
+
});
|
|
258
|
+
}
|
|
259
|
+
catch (cleanupError) {
|
|
260
|
+
cleanupErrors.push(cleanupError);
|
|
261
|
+
}
|
|
262
|
+
if (cancelled && cleanupErrors.length === 0)
|
|
263
|
+
throw failure;
|
|
264
|
+
throw new AggregateError([failure, ...cleanupErrors], `Instance Spot '${instanceType}' materialization failed for '${String(spotId)}'.`);
|
|
231
265
|
}
|
|
232
266
|
}
|
|
233
267
|
async discardInstance(activation) {
|
|
234
268
|
const errors = [];
|
|
269
|
+
try {
|
|
270
|
+
await this.discardPreparation(activation);
|
|
271
|
+
}
|
|
272
|
+
catch (error) {
|
|
273
|
+
errors.push(error);
|
|
274
|
+
}
|
|
235
275
|
try {
|
|
236
276
|
await activation.serial.execute(() => (0, spot_closing_1.invokeSpotClosing)(activation.spot.onClosing?.bind(activation.spot), contracts_1.ZLinkSpotCloseReason.ExplicitClose));
|
|
237
277
|
}
|
|
@@ -263,12 +303,13 @@ class ZLinkSpotActivationLifecycle {
|
|
|
263
303
|
}
|
|
264
304
|
}
|
|
265
305
|
async create(meshName, spotType, spotId, request, signal, authority) {
|
|
306
|
+
(0, abort_1.throwIfAborted)(signal);
|
|
266
307
|
const executionMode = this.options.userSpotExecutionMode?.(meshName, spotType) ??
|
|
267
308
|
contracts_1.ZLinkUserSpotExecutionMode.SpotWide;
|
|
268
309
|
const serial = new spot_serial_turn_executor_1.ZLinkSpotSerialTurnExecutor(executionMode === contracts_1.ZLinkUserSpotExecutionMode.SpotWide, spotId);
|
|
269
310
|
const serialExecutor = new spot_serial_executor_1.ZLinkSpotSerialExecutor(serial, executionMode, spotId);
|
|
270
311
|
const actorHandlers = new actors_1.ZLinkSpotActorHandlerRegistryRuntime();
|
|
271
|
-
const handlers = new spot_handler_registry_1.DefaultZLinkSpotHandlerRegistry(actorHandlers);
|
|
312
|
+
const handlers = new spot_handler_registry_1.DefaultZLinkSpotHandlerRegistry(actorHandlers, this.options.providerResolver);
|
|
272
313
|
(0, spot_handler_registry_1.applySpotHandlerRegistrations)(handlers, spotType, {
|
|
273
314
|
actorSendHandlers: this.options.spotActorSendHandlers,
|
|
274
315
|
actorRequestHandlers: this.options.spotActorRequestHandlers,
|
|
@@ -370,7 +411,8 @@ class ZLinkSpotActivationLifecycle {
|
|
|
370
411
|
const cleanupErrors = [];
|
|
371
412
|
try {
|
|
372
413
|
if (activation !== undefined) {
|
|
373
|
-
|
|
414
|
+
if (!lifecycleStarted)
|
|
415
|
+
await this.cleanupActivation(activation, locationClaim.meshName, false);
|
|
374
416
|
}
|
|
375
417
|
else {
|
|
376
418
|
const partialCleanup = await Promise.allSettled([
|
|
@@ -475,7 +517,7 @@ class ZLinkSpotActivationLifecycle {
|
|
|
475
517
|
return await this.cleanupActivation(activation, activation.meshName, true, undefined, reason, deadline, true);
|
|
476
518
|
}
|
|
477
519
|
async cleanupFailedIncarnation(activation) {
|
|
478
|
-
await this.cleanupActivation(activation, activation.meshName, false, undefined, contracts_1.ZLinkSpotCloseReason.ExplicitClose, undefined,
|
|
520
|
+
await this.cleanupActivation(activation, activation.meshName, false, undefined, contracts_1.ZLinkSpotCloseReason.ExplicitClose, undefined, !activation.serialExecutor.isPreparing);
|
|
479
521
|
}
|
|
480
522
|
async dispatchActorPacket(origin, activation, actorId, parts, returnResponse = false, remoteBoundSessionTarget, fallbackActorRef, requestTerminal, messageFollowOrigin) {
|
|
481
523
|
return await this.actorAdmission.dispatchActorPacket(origin, activation, actorId, parts, returnResponse, remoteBoundSessionTarget, fallbackActorRef, requestTerminal, messageFollowOrigin);
|
|
@@ -490,30 +532,36 @@ class ZLinkSpotActivationLifecycle {
|
|
|
490
532
|
}
|
|
491
533
|
async runCreateLifecycle(activation, spotType, request, locationClaim, nativeDispatch, signal) {
|
|
492
534
|
try {
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
await (0, spot_timer_1.addSpotTimerRegistrations)(activation.timers, spotType, activation.spotId, activation.spot, activation.serial, { timerHandlers: this.options.spotTimerHandlers }, {
|
|
496
|
-
providerResolver: this.options.providerResolver,
|
|
497
|
-
runtimeEventPublisher: this.options.runtimeEventPublisher,
|
|
498
|
-
signal
|
|
499
|
-
});
|
|
535
|
+
activation.serialExecutor.beginPreparation();
|
|
536
|
+
this.options.stageActivation?.(activation);
|
|
500
537
|
let createResponse;
|
|
501
|
-
await activation.serial.
|
|
502
|
-
|
|
538
|
+
await activation.serial.postBarrierTurn(async () => {
|
|
539
|
+
(0, abort_1.throwIfAborted)(signal);
|
|
540
|
+
await activation.spot.configure?.();
|
|
541
|
+
nativeDispatch?.configureSubscriptions(activation.handlers.snapshot());
|
|
542
|
+
await (0, spot_timer_1.addSpotTimerRegistrations)(activation.timers, spotType, activation.spotId, activation.spot, activation.serial, { timerHandlers: this.options.spotTimerHandlers }, {
|
|
543
|
+
providerResolver: this.options.providerResolver,
|
|
544
|
+
runtimeEventPublisher: this.options.runtimeEventPublisher,
|
|
545
|
+
signal
|
|
546
|
+
});
|
|
547
|
+
(0, abort_1.throwIfAborted)(signal);
|
|
548
|
+
createResponse = await activation.spot.onCreate?.((0, payload_codec_1.wrapFrameworkPayloadMessage)(request, this.options.messageSerializers, (0, payload_codec_1.frameworkPayloadContentType)(request)), signal);
|
|
503
549
|
if (createResponse?.accepted === false) {
|
|
504
550
|
return;
|
|
505
551
|
}
|
|
506
|
-
|
|
552
|
+
(0, abort_1.throwIfAborted)(signal);
|
|
553
|
+
await activation.spot.onInitialize?.(signal);
|
|
507
554
|
});
|
|
555
|
+
(0, abort_1.throwIfAborted)(signal);
|
|
508
556
|
if (createResponse?.accepted === false) {
|
|
509
|
-
await this.cleanupActivation(activation, locationClaim.meshName, false
|
|
557
|
+
await this.cleanupActivation(activation, locationClaim.meshName, false);
|
|
510
558
|
return {
|
|
511
559
|
spotId: activation.spotId,
|
|
512
560
|
state: contracts_1.ZLinkSpotCreateState.Rejected,
|
|
513
561
|
reply: this.decodeCreateReply(createResponse.reply)
|
|
514
562
|
};
|
|
515
563
|
}
|
|
516
|
-
this.options.registerActivation(activation);
|
|
564
|
+
await this.options.registerActivation(activation);
|
|
517
565
|
return {
|
|
518
566
|
spotId: activation.spotId,
|
|
519
567
|
state: contracts_1.ZLinkSpotCreateState.Created,
|
|
@@ -521,13 +569,17 @@ class ZLinkSpotActivationLifecycle {
|
|
|
521
569
|
};
|
|
522
570
|
}
|
|
523
571
|
catch (error) {
|
|
572
|
+
const failure = signal?.aborted === true ? (0, abort_1.createAbortError)() : error;
|
|
573
|
+
const cancelled = (0, abort_1.isAbortError)(failure);
|
|
574
|
+
if (cancelled)
|
|
575
|
+
activation.serial.closeAdmission();
|
|
524
576
|
try {
|
|
525
|
-
await this.cleanupActivation(activation, locationClaim.meshName,
|
|
577
|
+
await this.cleanupActivation(activation, locationClaim.meshName, !cancelled);
|
|
526
578
|
}
|
|
527
579
|
catch (cleanupError) {
|
|
528
|
-
throw new AggregateError([
|
|
580
|
+
throw new AggregateError([failure, cleanupError], `Spot '${activation.spotId}' creation cleanup failed.`);
|
|
529
581
|
}
|
|
530
|
-
throw
|
|
582
|
+
throw failure;
|
|
531
583
|
}
|
|
532
584
|
}
|
|
533
585
|
async cleanupActivation(activation, locationMeshName, notifyClosing, signal, reason = contracts_1.ZLinkSpotCloseReason.ExplicitClose, deadline, owningLifecycle = false) {
|
|
@@ -544,11 +596,38 @@ class ZLinkSpotActivationLifecycle {
|
|
|
544
596
|
this.cleanupStates.set(activation, state);
|
|
545
597
|
if (state.inFlight !== undefined)
|
|
546
598
|
return await state.inFlight;
|
|
547
|
-
|
|
599
|
+
let result;
|
|
600
|
+
const cleanup = async (ownsLifecycle) => {
|
|
601
|
+
try {
|
|
602
|
+
result = await this.runCleanup(activation, locationMeshName, notifyClosing, reason, state, deadline, ownsLifecycle);
|
|
603
|
+
}
|
|
604
|
+
finally {
|
|
605
|
+
if (activation.serialExecutor.isPreparing) {
|
|
606
|
+
activation.serial.closeAdmission();
|
|
607
|
+
// The receive pump releases retained payloads when these records finish.
|
|
608
|
+
activation.serial.visitPendingApplication((record) => {
|
|
609
|
+
record.operation = () => undefined;
|
|
610
|
+
});
|
|
611
|
+
this.options.discardActivation?.(activation);
|
|
612
|
+
}
|
|
613
|
+
}
|
|
614
|
+
};
|
|
615
|
+
state.inFlight = (!owningLifecycle && activation.serialExecutor.isPreparing
|
|
616
|
+
? activation.serialExecutor.finishPreparation(() => cleanup(true))
|
|
617
|
+
: cleanup(owningLifecycle))
|
|
618
|
+
.then(() => result)
|
|
619
|
+
.finally(() => {
|
|
548
620
|
state.inFlight = undefined;
|
|
549
621
|
});
|
|
550
622
|
return await state.inFlight;
|
|
551
623
|
}
|
|
624
|
+
async discardPreparation(activation) {
|
|
625
|
+
if (!activation.serialExecutor.isPreparing)
|
|
626
|
+
return;
|
|
627
|
+
// Clear timer generations before opening admission, so an already due
|
|
628
|
+
// dispatch can finish without invoking application code.
|
|
629
|
+
await activation.serialExecutor.finishPreparation(() => activation.timers.dispose());
|
|
630
|
+
}
|
|
552
631
|
async runCleanup(activation, locationMeshName, notifyClosing, reason, state, deadline, owningLifecycle = false) {
|
|
553
632
|
const errors = [];
|
|
554
633
|
let closingFailure;
|
|
@@ -571,7 +650,9 @@ class ZLinkSpotActivationLifecycle {
|
|
|
571
650
|
catch (error) {
|
|
572
651
|
// An OnClosing failure is diagnostic and cleanup continues. It is
|
|
573
652
|
// returned so host shutdown can classify its teardown outcome.
|
|
574
|
-
|
|
653
|
+
if (reason !== contracts_1.ZLinkSpotCloseReason.HostShutdown) {
|
|
654
|
+
this.options.closeErrorSink?.reportRuntimeTaskException(`spot ${String(activation.spotId)} onClosing`, error);
|
|
655
|
+
}
|
|
575
656
|
closingFailure = error;
|
|
576
657
|
}
|
|
577
658
|
}
|
|
@@ -598,7 +679,12 @@ class ZLinkSpotActivationLifecycle {
|
|
|
598
679
|
});
|
|
599
680
|
}
|
|
600
681
|
if (!state.nativeDisposed) {
|
|
601
|
-
await cleanup(
|
|
682
|
+
await cleanup(async () => {
|
|
683
|
+
if (reason === contracts_1.ZLinkSpotCloseReason.HostShutdown) {
|
|
684
|
+
await this.options.releaseActorMembers?.(locationMeshName, activation.spotId);
|
|
685
|
+
}
|
|
686
|
+
await activation.nativeSpot?.dispose();
|
|
687
|
+
}, () => {
|
|
602
688
|
state.nativeDisposed = true;
|
|
603
689
|
});
|
|
604
690
|
}
|
|
@@ -617,9 +703,11 @@ class ZLinkSpotActivationLifecycle {
|
|
|
617
703
|
state.locationReleased = true;
|
|
618
704
|
});
|
|
619
705
|
}
|
|
620
|
-
if (errors.length
|
|
621
|
-
|
|
622
|
-
|
|
706
|
+
if (errors.length > 0) {
|
|
707
|
+
if (closingFailure !== undefined)
|
|
708
|
+
errors.unshift(closingFailure);
|
|
709
|
+
if (errors.length === 1)
|
|
710
|
+
throw errors[0];
|
|
623
711
|
throw new AggregateError(errors, `Spot '${activation.spotId}' cleanup failed.`);
|
|
624
712
|
}
|
|
625
713
|
return closingFailure;
|
|
@@ -14,6 +14,7 @@ export declare class ZLinkSpotActorAdmissionCoordinator {
|
|
|
14
14
|
dispatchActorPacket(origin: ApplicationJobOrigin, activation: ZLinkSpotActivation, actorId: string, parts: readonly Message[], returnResponse?: boolean, remoteBoundSessionTarget?: ZLinkRemoteBoundSessionTarget, fallbackActorRef?: ActorRef, requestTerminal?: (response: unknown) => Promise<void> | void, messageFollowOrigin?: ZLinkMessageFollowOrigin): Promise<unknown>;
|
|
15
15
|
attachNativeActorJoinDispatch(activation: ZLinkSpotActivation, nativeSpot: ZLinkBackendSpot | undefined): ZLinkSpotActorJoinDispatch | undefined;
|
|
16
16
|
private dispatchActorPacketInActorTurn;
|
|
17
|
+
private resolveActor;
|
|
17
18
|
private commitTransferredActorTransaction;
|
|
18
19
|
private replayActorBacklog;
|
|
19
20
|
}
|
|
@@ -12,7 +12,7 @@ class ZLinkSpotActorAdmissionCoordinator {
|
|
|
12
12
|
this.options = options;
|
|
13
13
|
}
|
|
14
14
|
async dispatchActorPacket(origin, activation, actorId, parts, returnResponse = false, remoteBoundSessionTarget, fallbackActorRef, requestTerminal, messageFollowOrigin) {
|
|
15
|
-
const handoff = this.options.actorHandoffRuntime?.capture(origin, actorId, parts, returnResponse, remoteBoundSessionTarget, fallbackActorRef, undefined, messageFollowOrigin
|
|
15
|
+
const handoff = this.options.actorHandoffRuntime?.capture(origin, actorId, parts, returnResponse, remoteBoundSessionTarget, fallbackActorRef, undefined, messageFollowOrigin);
|
|
16
16
|
if (handoff !== undefined)
|
|
17
17
|
return await handoff;
|
|
18
18
|
return await this.dispatchActorPacketDirect(origin, activation, actorId, parts, returnResponse, remoteBoundSessionTarget, fallbackActorRef, requestTerminal);
|
|
@@ -25,9 +25,7 @@ class ZLinkSpotActorAdmissionCoordinator {
|
|
|
25
25
|
createTopicMessage: requireBackendValueFactory(this.options.createTopicMessage, 'TopicMessage'),
|
|
26
26
|
serial: activation.serial,
|
|
27
27
|
actors: {
|
|
28
|
-
resolveActor: (actorId) =>
|
|
29
|
-
? undefined
|
|
30
|
-
: (activation.resolveJoinedActor(actorId) ?? this.options.actorResolver?.(actorId)),
|
|
28
|
+
resolveActor: (actorId) => this.resolveActor(activation, actorId),
|
|
31
29
|
getTarget: () => activation.spot,
|
|
32
30
|
defaultAccept: false,
|
|
33
31
|
transfer: this.options.actorTransferRuntime === undefined
|
|
@@ -75,20 +73,7 @@ class ZLinkSpotActorAdmissionCoordinator {
|
|
|
75
73
|
* @internal
|
|
76
74
|
*/
|
|
77
75
|
admitActorPacketPrefix(activation, actorId, records) {
|
|
78
|
-
|
|
79
|
-
operation: (executeChild) => record.drain((parts, returnResponse, remoteBoundSessionTarget, fallbackActorRef) => executeChild((actorSerial) => this.dispatchActorPacketInActorTurn((0, application_job_queue_scope_1.currentApplicationJobOrigin)(), activation, actorSerial, actorId, parts, returnResponse, remoteBoundSessionTarget, fallbackActorRef))),
|
|
80
|
-
preparation: record.preparation,
|
|
81
|
-
workOptions: { payloadBytes: record.payloadBytes }
|
|
82
|
-
})));
|
|
83
|
-
const terminal = Promise.allSettled(terminals).then((outcomes) => {
|
|
84
|
-
const errors = outcomes.flatMap((outcome) => outcome.status === 'rejected' ? [outcome.reason] : []);
|
|
85
|
-
if (errors.length === 1)
|
|
86
|
-
throw errors[0];
|
|
87
|
-
if (errors.length > 1) {
|
|
88
|
-
throw new AggregateError(errors, `Actor '${actorId}' durable prefix replay failed.`);
|
|
89
|
-
}
|
|
90
|
-
});
|
|
91
|
-
return { terminal };
|
|
76
|
+
return activation.admitActorPacketPrefix(actorId, records, (actorSerial, parts, returnResponse, remoteBoundSessionTarget, fallbackActorRef) => this.dispatchActorPacketInActorTurn((0, application_job_queue_scope_1.currentApplicationJobOrigin)(), activation, actorSerial, actorId, parts, returnResponse, remoteBoundSessionTarget, fallbackActorRef));
|
|
92
77
|
}
|
|
93
78
|
dispatchActorPacketInActorTurn(origin, activation, actorSerial, actorId, parts, returnResponse = false, remoteBoundSessionTarget, fallbackActorRef, requestTerminal) {
|
|
94
79
|
return new spot_actor_packet_dispatch_1.ZLinkSpotActorPacketDispatch({
|
|
@@ -96,10 +81,7 @@ class ZLinkSpotActorAdmissionCoordinator {
|
|
|
96
81
|
spotId: () => String(activation.spotId),
|
|
97
82
|
registry: activation.actorHandlers,
|
|
98
83
|
serial: actorSerial,
|
|
99
|
-
resolveActor: (targetActorId) =>
|
|
100
|
-
? undefined
|
|
101
|
-
: (activation.resolveJoinedActor(targetActorId) ??
|
|
102
|
-
this.options.actorResolver?.(targetActorId)),
|
|
84
|
+
resolveActor: (targetActorId) => this.resolveActor(activation, targetActorId),
|
|
103
85
|
actorLeft: (targetActorId) => activation.hasDepartedActor(targetActorId),
|
|
104
86
|
onDisconnectActor: (actor) => activation.serial.execute(() => activation.spot.onDisconnectActor?.(actor)),
|
|
105
87
|
actorResponseSender: this.options.boundSessionRuntime?.sendActorResponse.bind(this.options.boundSessionRuntime),
|
|
@@ -110,6 +92,15 @@ class ZLinkSpotActorAdmissionCoordinator {
|
|
|
110
92
|
routeToActorJoinPrewarm: this.options.routeToActorJoinPrewarm
|
|
111
93
|
}).dispatch(origin, actorId, parts, returnResponse, remoteBoundSessionTarget, fallbackActorRef, requestTerminal);
|
|
112
94
|
}
|
|
95
|
+
resolveActor(activation, actorId) {
|
|
96
|
+
if (activation.hasDepartedActor(actorId))
|
|
97
|
+
return undefined;
|
|
98
|
+
// The manager owns relocation visibility. Membership alone cannot publish
|
|
99
|
+
// a staged Actor; resolver absence supports standalone Spot runtimes.
|
|
100
|
+
return this.options.actorResolver === undefined
|
|
101
|
+
? activation.resolveJoinedActor(actorId)
|
|
102
|
+
: this.options.actorResolver(actorId);
|
|
103
|
+
}
|
|
113
104
|
async commitTransferredActorTransaction(activation, actor, backlog, sealedSession) {
|
|
114
105
|
const transfer = this.options.actorTransferRuntime;
|
|
115
106
|
let routeSwitchStarted = false;
|
|
@@ -31,7 +31,6 @@ export declare class ZLinkSpotActorMembership {
|
|
|
31
31
|
notifyActorLeftAfterTransfer(spotId: RoutingId, actor: ZLinkActor, signal?: AbortSignal): Promise<void>;
|
|
32
32
|
prepareActorLeaveForTransfer(spotId: RoutingId, actor: ZLinkActor, signal?: AbortSignal): Promise<void>;
|
|
33
33
|
commitActorLeaveAfterTransfer(spotId: RoutingId, actorId: string): Promise<void>;
|
|
34
|
-
restoreActorAfterFailedTransfer(spotId: RoutingId, actor: ZLinkActor, signal?: AbortSignal): Promise<void>;
|
|
35
34
|
beginActorTransfer(spotId: RoutingId, actorId: string): Promise<void>;
|
|
36
35
|
cancelActorTransfer(spotId: RoutingId, actorId: string): Promise<void>;
|
|
37
36
|
notifyJoinedActorDisconnected(spotId: RoutingId, actor: ZLinkActor, signal?: AbortSignal): Promise<boolean>;
|
|
@@ -113,14 +113,6 @@ class ZLinkSpotActorMembership {
|
|
|
113
113
|
const activation = this.requireActivation(spotId);
|
|
114
114
|
await this.runLifecycleOperation(activation, () => activation.serial.execute(() => activation.commitActorDeparture(actorId)));
|
|
115
115
|
}
|
|
116
|
-
async restoreActorAfterFailedTransfer(spotId, actor, signal) {
|
|
117
|
-
(0, abort_1.throwIfAborted)(signal);
|
|
118
|
-
const activation = this.requireActivation(spotId);
|
|
119
|
-
await this.runLifecycleOperation(activation, () => activation.serial.execute(async () => {
|
|
120
|
-
activation.cancelActorTransfer(actor.context.actorId);
|
|
121
|
-
await activation.spot.onJoinedActor(actor);
|
|
122
|
-
}));
|
|
123
|
-
}
|
|
124
116
|
async beginActorTransfer(spotId, actorId) {
|
|
125
117
|
const activation = this.requireActivation(spotId);
|
|
126
118
|
await this.runLifecycleOperation(activation, () => activation.serial.execute(() => activation.beginActorTransfer(actorId)));
|