@zlink-systems/framework 0.25.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/Channels/IZLinkFanoutClient.d.ts +0 -6
- 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/RouteMesh/RuntimeTopology.d.ts +8 -0
- package/dist/contracts/Spots/Contracts.d.ts +1 -1
- package/dist/internal.d.ts +5 -0
- package/dist/internal.js +16 -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 +28 -0
- package/dist/runtime/activation-admission.js +57 -0
- 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 +19 -17
- package/dist/runtime/actors/actor-handoff.d.ts +13 -7
- package/dist/runtime/actors/actor-handoff.js +36 -25
- 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 +85 -123
- 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 +3 -3
- package/dist/runtime/actors/actor-remote-joiner.js +11 -17
- 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-contracts.d.ts +4 -2
- 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/actor-source-transfer.d.ts +5 -5
- package/dist/runtime/actors/bound-session-wire.js +2 -7
- package/dist/runtime/actors/deferred-join-completion.d.ts +19 -0
- package/dist/runtime/actors/deferred-join-completion.js +21 -0
- package/dist/runtime/actors/index.d.ts +10 -8
- package/dist/runtime/actors/index.js +101 -73
- 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 +7 -1
- package/dist/runtime/admission.js +11 -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 +8 -33
- package/dist/runtime/backend/mesh-actor-session-node-adapter.js +3 -26
- 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-factory.d.ts +1 -2
- package/dist/runtime/backend/node/node-backend-adapter-factory.js +4 -18
- package/dist/runtime/backend/node/node-backend-adapter-support.d.ts +7 -4
- package/dist/runtime/backend/node/node-backend-adapter-support.js +28 -34
- package/dist/runtime/backend/node/node-event-loop-poller.d.ts +2 -2
- package/dist/runtime/backend/node/node-event-loop-poller.js +11 -6
- package/dist/runtime/backend/node/node-monitor-backend-adapter.js +1 -0
- package/dist/runtime/backend/node/node-raw-binding-port.d.ts +1 -1
- package/dist/runtime/backend/node/node-raw-binding-port.js +51 -19
- package/dist/runtime/backend/node/node-raw-mesh-backend.d.ts +21 -19
- package/dist/runtime/backend/node/node-raw-mesh-backend.js +171 -111
- package/dist/runtime/backend/node/node-socket-backend-adapter.js +4 -3
- package/dist/runtime/backend/raw-binding-port.d.ts +13 -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 -9
- package/dist/runtime/channels/channel-clients.js +68 -60
- 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 -18
- 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.d.ts +2 -5
- package/dist/runtime/channels/channel-runtime-manager.js +4 -12
- package/dist/runtime/channels/channel-socket-options.js +3 -2
- package/dist/runtime/channels/channel-socket-registry.d.ts +30 -32
- package/dist/runtime/channels/channel-socket-registry.js +296 -235
- package/dist/runtime/channels/channel-transports.d.ts +11 -20
- 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 +133 -81
- 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 +22 -9
- package/dist/runtime/execution/index.js +107 -37
- package/dist/runtime/execution/serial-execution-queue.d.ts +12 -7
- package/dist/runtime/execution/serial-execution-queue.js +99 -26
- 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/listener-records.d.ts +11 -0
- package/dist/runtime/foundation/listener-records.js +20 -0
- 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 +18 -26
- package/dist/runtime/foundation/raw-service-mesh-runtime.js +122 -469
- 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.d.ts +1 -0
- package/dist/runtime/foundation/service-authority-payload-codec.js +30 -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 +23 -8
- 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-coordinator.d.ts +9 -0
- package/dist/runtime/foundation/service-relocation-coordinator.js +14 -1
- package/dist/runtime/foundation/service-relocation-object-owner.d.ts +8 -0
- package/dist/runtime/foundation/service-relocation-object-owner.js +19 -6
- 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 -19
- 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 +28 -24
- package/dist/runtime/foundation/service-stateful-runtime.js +297 -244
- package/dist/runtime/foundation/service-stateful-wire-codec.d.ts +12 -7
- package/dist/runtime/foundation/service-stateful-wire-codec.js +240 -143
- package/dist/runtime/foundation/service-topology-registry.d.ts +1 -3
- package/dist/runtime/foundation/service-topology-registry.js +22 -61
- 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 +28 -28
- package/dist/runtime/host/actor-transfer-runtime.js +210 -256
- 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 +19 -14
- package/dist/runtime/host/index.js +234 -175
- 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 +11 -23
- package/dist/runtime/host/route-mesh-runtime.d.ts +14 -10
- package/dist/runtime/host/route-mesh-runtime.js +178 -257
- 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 +71 -38
- package/dist/runtime/host/service-relocation-host-runtime.js +816 -651
- 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 -7
- package/dist/runtime/host/spot-runtime-options-factory.js +53 -21
- package/dist/runtime/host/stateful-authority-route-runtime.js +6 -2
- package/dist/runtime/host/user-spot-creation-coordinator.d.ts +14 -6
- package/dist/runtime/host/user-spot-creation-coordinator.js +96 -95
- 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 +79 -27
- 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 +5 -10
- package/dist/runtime/locations/lifecycle.js +4 -33
- 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 +44 -30
- 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 +8 -2
- package/dist/runtime/locations/spot-location-claims.js +40 -23
- 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 +2 -0
- package/dist/runtime/protocol/service_wire_codec.generated.js +17 -8
- package/dist/runtime/protocol/service_wire_pilot_codec.generated.d.ts +1 -0
- package/dist/runtime/protocol/service_wire_pilot_codec.generated.js +3 -2
- package/dist/runtime/spots/formal-remote-actor-admission-registry.d.ts +3 -3
- package/dist/runtime/spots/formal-remote-actor-admission-registry.js +4 -4
- package/dist/runtime/spots/formal-remote-actor-transfer-registry.d.ts +6 -3
- package/dist/runtime/spots/index.d.ts +29 -29
- package/dist/runtime/spots/index.js +441 -313
- package/dist/runtime/spots/spot-activation-registry.d.ts +4 -4
- package/dist/runtime/spots/spot-activation-registry.js +27 -60
- package/dist/runtime/spots/spot-activation-state.d.ts +2 -11
- package/dist/runtime/spots/spot-activation-state.js +4 -17
- package/dist/runtime/spots/spot-activation.d.ts +10 -9
- package/dist/runtime/spots/spot-activation.js +103 -81
- 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 +5 -55
- package/dist/runtime/spots/spot-actor-lifecycle-drain.js +2 -2
- package/dist/runtime/spots/spot-actor-membership.d.ts +7 -5
- package/dist/runtime/spots/spot-actor-membership.js +44 -53
- 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 +3 -4
- package/dist/runtime/spots/spot-entry-activation.js +9 -21
- 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 +6 -5
- package/dist/runtime/spots/spot-node-autoconnect.js +22 -31
- package/dist/runtime/spots/spot-node-runtime-manager.d.ts +22 -21
- package/dist/runtime/spots/spot-node-runtime-manager.js +73 -82
- package/dist/runtime/spots/spot-outbound.d.ts +4 -3
- package/dist/runtime/spots/spot-outbound.js +10 -37
- 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 -2
- package/dist/runtime/spots/spot-routed-actor-admission.js +3 -2
- package/dist/runtime/spots/spot-routed-frame-dispatch.d.ts +2 -7
- package/dist/runtime/spots/spot-routed-frame-dispatch.js +1 -70
- 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 +4 -20
- package/dist/runtime/spots/spot-serial-executor.d.ts +5 -0
- package/dist/runtime/spots/spot-serial-executor.js +9 -2
- package/dist/runtime/spots/spot-serial-turn-executor.d.ts +29 -6
- package/dist/runtime/spots/spot-serial-turn-executor.js +89 -13
- package/dist/runtime/spots/spot-timer.d.ts +3 -2
- package/dist/runtime/streams/actor-session-binding-registry.d.ts +17 -32
- package/dist/runtime/streams/actor-session-binding-registry.js +145 -367
- package/dist/runtime/streams/actor-session-binding-runtime-owner.d.ts +2 -6
- 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 +12 -19
- package/dist/runtime/streams/index.d.ts +15 -14
- package/dist/runtime/streams/index.js +38 -39
- 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/session-serial-executor.js +2 -2
- 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/Channels/IZLinkFanoutClient.ts +0 -7
- 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/RouteMesh/RuntimeTopology.ts +10 -0
- package/src/contracts/Spots/Contracts.ts +1 -1
- package/src/internal.ts +15 -0
- package/src/nest-integration.ts +28 -10
- package/src/runtime/abort.ts +6 -5
- package/src/runtime/activation-admission.ts +72 -0
- 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 +45 -39
- package/src/runtime/actors/actor-handoff.ts +55 -45
- package/src/runtime/actors/actor-lifecycle-snapshot.ts +2 -1
- package/src/runtime/actors/actor-local-native-join.ts +174 -215
- 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 +15 -36
- 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-contracts.ts +4 -10
- package/src/runtime/actors/actor-runtime-state.ts +85 -247
- package/src/runtime/actors/actor-source-transfer.ts +5 -18
- package/src/runtime/actors/bound-session-wire.ts +2 -8
- package/src/runtime/actors/deferred-join-completion.ts +44 -0
- package/src/runtime/actors/index.ts +122 -88
- 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 +13 -2
- package/src/runtime/application-jobs/application-job-queue-scope.ts +4 -4
- package/src/runtime/backend/contracts/index.ts +15 -42
- package/src/runtime/backend/mesh-actor-session-node-adapter.ts +4 -28
- package/src/runtime/backend/mesh-dispatch-pump.ts +111 -117
- package/src/runtime/backend/node/node-backend-adapter-factory.ts +5 -25
- package/src/runtime/backend/node/node-backend-adapter-support.ts +32 -35
- package/src/runtime/backend/node/node-event-loop-poller.ts +16 -8
- package/src/runtime/backend/node/node-monitor-backend-adapter.ts +1 -0
- package/src/runtime/backend/node/node-raw-binding-port.ts +58 -23
- package/src/runtime/backend/node/node-raw-mesh-backend.ts +252 -162
- package/src/runtime/backend/node/node-socket-backend-adapter.ts +5 -4
- package/src/runtime/backend/raw-binding-port.ts +14 -1
- package/src/runtime/backend/runtime-values.ts +4 -1
- package/src/runtime/channels/channel-clients.ts +132 -96
- 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 -31
- 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 +8 -15
- package/src/runtime/channels/channel-socket-options.ts +8 -2
- package/src/runtime/channels/channel-socket-registry.ts +369 -262
- package/src/runtime/channels/channel-transports.ts +161 -115
- 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 +175 -106
- 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 +116 -38
- package/src/runtime/execution/serial-execution-queue.ts +179 -34
- 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/listener-records.ts +21 -0
- 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 +170 -571
- package/src/runtime/foundation/runtime-state-projections.ts +9 -1
- package/src/runtime/foundation/service-authority-payload-codec.ts +41 -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 +30 -19
- 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-coordinator.ts +13 -0
- package/src/runtime/foundation/service-relocation-object-owner.ts +23 -7
- 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 -25
- package/src/runtime/foundation/service-stateful-registry.ts +14 -2
- package/src/runtime/foundation/service-stateful-runtime.ts +435 -327
- package/src/runtime/foundation/service-stateful-wire-codec.ts +329 -199
- package/src/runtime/foundation/service-topology-registry.ts +30 -79
- 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 +266 -418
- 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 +408 -312
- 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 +12 -44
- package/src/runtime/host/route-mesh-runtime.ts +236 -275
- 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 +1161 -904
- 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 +92 -30
- package/src/runtime/host/stateful-authority-route-runtime.ts +8 -4
- package/src/runtime/host/user-spot-creation-coordinator.ts +182 -163
- 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 +110 -31
- package/src/runtime/locations/key-codec.ts +3 -2
- package/src/runtime/locations/lease-tracker.ts +8 -14
- package/src/runtime/locations/lifecycle.ts +16 -45
- 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 +90 -58
- package/src/runtime/locations/runtime.ts +220 -110
- package/src/runtime/locations/spot-location-claims.ts +54 -26
- 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 +27 -10
- package/src/runtime/protocol/service_wire_pilot_codec.generated.ts +4 -4
- package/src/runtime/spots/formal-remote-actor-admission-registry.ts +6 -6
- package/src/runtime/spots/formal-remote-actor-transfer-registry.ts +6 -3
- package/src/runtime/spots/index.ts +687 -437
- package/src/runtime/spots/spot-activation-registry.ts +42 -71
- package/src/runtime/spots/spot-activation-state.ts +4 -16
- package/src/runtime/spots/spot-activation.ts +167 -115
- package/src/runtime/spots/spot-actor-admission-coordinator.ts +5 -57
- package/src/runtime/spots/spot-actor-join-dispatch.ts +25 -79
- package/src/runtime/spots/spot-actor-lifecycle-drain.ts +20 -18
- package/src/runtime/spots/spot-actor-membership.ts +107 -75
- 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 -33
- package/src/runtime/spots/spot-lifecycle-metrics.ts +3 -2
- package/src/runtime/spots/spot-manager-public.ts +29 -21
- package/src/runtime/spots/spot-node-autoconnect.ts +20 -26
- package/src/runtime/spots/spot-node-runtime-manager.ts +145 -140
- package/src/runtime/spots/spot-outbound.ts +47 -68
- 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 -6
- package/src/runtime/spots/spot-routed-frame-dispatch.ts +6 -77
- package/src/runtime/spots/spot-routed-spot-packet-dispatch.ts +95 -22
- package/src/runtime/spots/spot-runtime-ports.ts +10 -43
- package/src/runtime/spots/spot-serial-executor.ts +10 -2
- package/src/runtime/spots/spot-serial-turn-executor.ts +120 -13
- package/src/runtime/spots/spot-timer.ts +3 -2
- package/src/runtime/streams/actor-session-binding-registry.ts +182 -560
- package/src/runtime/streams/actor-session-binding-runtime-owner.ts +1 -19
- package/src/runtime/streams/bound-actor-relay-sender.ts +89 -43
- package/src/runtime/streams/bound-session-service.ts +23 -37
- package/src/runtime/streams/index.ts +102 -88
- 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/session-serial-executor.ts +2 -2
- 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/deferred-join-accepted-journal.d.ts +0 -47
- package/dist/runtime/actors/deferred-join-accepted-journal.js +0 -992
- 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/deferred-join-accepted-journal.ts +0 -1346
- package/src/runtime/actors/post-commit-actor-location.ts +0 -121
- package/src/runtime/spots/spot-native-actor-join-admission.ts +0 -155
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ZLinkActorSessionBindingRegistry = exports.ZLinkActorSessionBindingTermination = void 0;
|
|
4
|
-
const framework_errors_internal_1 = require("../framework-errors-internal");
|
|
5
|
-
const abort_1 = require("../abort");
|
|
3
|
+
exports.ZLinkActorSessionBindingRegistry = exports.ZLinkActorSessionBindingTermination = exports.DEFAULT_TERMINAL_RELOCATION_CAPACITY = void 0;
|
|
6
4
|
const node_async_hooks_1 = require("node:async_hooks");
|
|
5
|
+
const ZLinkFrameworkException_1 = require("../../contracts/Errors/ZLinkFrameworkException");
|
|
6
|
+
const Options_1 = require("../../contracts/Locations/Options");
|
|
7
|
+
const abort_1 = require("../abort");
|
|
7
8
|
const state_lane_1 = require("../execution/state-lane");
|
|
8
|
-
const
|
|
9
|
+
const framework_errors_internal_1 = require("../framework-errors-internal");
|
|
10
|
+
exports.DEFAULT_TERMINAL_RELOCATION_CAPACITY = 4096;
|
|
9
11
|
const detachedStateLaneResource = new node_async_hooks_1.AsyncResource('zlink:actor-session-binding-registry');
|
|
10
12
|
var ZLinkActorSessionBindingTermination;
|
|
11
13
|
(function (ZLinkActorSessionBindingTermination) {
|
|
@@ -14,7 +16,6 @@ var ZLinkActorSessionBindingTermination;
|
|
|
14
16
|
})(ZLinkActorSessionBindingTermination || (exports.ZLinkActorSessionBindingTermination = ZLinkActorSessionBindingTermination = {}));
|
|
15
17
|
class ZLinkActorSessionBindingRegistry {
|
|
16
18
|
terminalRelocationCapacity;
|
|
17
|
-
outboundCapacity;
|
|
18
19
|
sealWaitTimeoutMs;
|
|
19
20
|
errorSink;
|
|
20
21
|
lane = new state_lane_1.ZLinkStateLane();
|
|
@@ -24,24 +25,20 @@ class ZLinkActorSessionBindingRegistry {
|
|
|
24
25
|
activeFrameWaiters = new Map();
|
|
25
26
|
relocations = new Map();
|
|
26
27
|
terminalRelocations = new Map();
|
|
27
|
-
constructor(terminalRelocationCapacity =
|
|
28
|
+
constructor(terminalRelocationCapacity = exports.DEFAULT_TERMINAL_RELOCATION_CAPACITY,
|
|
28
29
|
// Spec 06 — SessionRelocationSealTimeout bounds how long a session
|
|
29
30
|
// relocation seal may hold ingress (default 3,000 ms, finite only).
|
|
30
31
|
// Every wait on the seal (accept paths) and on active-frame drain
|
|
31
32
|
// (the sealing side) must observe that bound; an unbounded wait here
|
|
32
33
|
// turns a lost control or a lifecycle interlock into a silent stall
|
|
33
34
|
// (spec 48:205 — transport/deadline limits apply during relocation).
|
|
34
|
-
sealWaitTimeoutMs =
|
|
35
|
+
sealWaitTimeoutMs = Options_1.zlinkDefaultLocationOptions.sessionRelocationSealTimeoutMs, errorSink) {
|
|
35
36
|
this.terminalRelocationCapacity = terminalRelocationCapacity;
|
|
36
|
-
this.outboundCapacity = outboundCapacity;
|
|
37
37
|
this.sealWaitTimeoutMs = sealWaitTimeoutMs;
|
|
38
38
|
this.errorSink = errorSink;
|
|
39
39
|
if (!Number.isSafeInteger(terminalRelocationCapacity) || terminalRelocationCapacity <= 0) {
|
|
40
40
|
throw new RangeError('Session relocation terminal capacity must be a positive safe integer.');
|
|
41
41
|
}
|
|
42
|
-
if (!Number.isSafeInteger(outboundCapacity) || outboundCapacity <= 0) {
|
|
43
|
-
throw new RangeError('Session relocation outbound capacity must be a positive safe integer.');
|
|
44
|
-
}
|
|
45
42
|
if (!Number.isSafeInteger(sealWaitTimeoutMs) || sealWaitTimeoutMs <= 0) {
|
|
46
43
|
throw new RangeError('Session relocation seal timeout must be a positive safe integer.');
|
|
47
44
|
}
|
|
@@ -49,7 +46,7 @@ class ZLinkActorSessionBindingRegistry {
|
|
|
49
46
|
async bind(context, actor, bindingToken, authorityFence, sessionIdentity, commitActor) {
|
|
50
47
|
await this.lane.run(() => this.commitCore(undefined, context, actor, bindingToken, authorityFence, sessionIdentity, commitActor));
|
|
51
48
|
}
|
|
52
|
-
|
|
49
|
+
commitCore(previous, context, actor, bindingToken, authorityFence, sessionIdentity, commitActor) {
|
|
53
50
|
const current = this.routes.get(actor.actorId);
|
|
54
51
|
if (current !== previous) {
|
|
55
52
|
throw (0, framework_errors_internal_1.createInternalFrameworkException)(framework_errors_internal_1.ZLinkFrameworkInternalErrorKind.ActorSessionNotBound, `Actor '${actor.actorId}' session binding changed before route commit.`, true);
|
|
@@ -76,7 +73,17 @@ class ZLinkActorSessionBindingRegistry {
|
|
|
76
73
|
}
|
|
77
74
|
}
|
|
78
75
|
if (!sameBinding && actorSlot !== undefined) {
|
|
79
|
-
|
|
76
|
+
// Session–Actor binding §5-2: `$zlink.actor.bound` enters the ordered
|
|
77
|
+
// STREAM queue before the slot is published; transport completion is
|
|
78
|
+
// not awaited inside the state lane (execution gate).
|
|
79
|
+
void context
|
|
80
|
+
.actorSlotControls.enqueueBound(actorSlot, actor.actorId)
|
|
81
|
+
.catch(async (error) => {
|
|
82
|
+
this.errorSink?.()?.reportRuntimeTaskException('session actor bound', error);
|
|
83
|
+
// The client never learned the slot, so the binding ends through
|
|
84
|
+
// the one unbind path; no `$zlink.actor.unbound` follows.
|
|
85
|
+
await this.unbind(actor.actorId, context, bindingToken, ZLinkActorSessionBindingTermination.PhysicalDisconnect).catch((unbindError) => this.errorSink?.()?.reportRuntimeTaskException('session actor bound', unbindError));
|
|
86
|
+
});
|
|
80
87
|
}
|
|
81
88
|
}
|
|
82
89
|
catch (error) {
|
|
@@ -110,14 +117,14 @@ class ZLinkActorSessionBindingRegistry {
|
|
|
110
117
|
async replaceAndReleaseSeal(previous, context, actor, bindingToken, sealId, authorityFence, sessionIdentity, commitActor) {
|
|
111
118
|
await this.lane.run(() => this.replaceAndReleaseSealCore(previous, context, actor, bindingToken, sealId, authorityFence, sessionIdentity, commitActor));
|
|
112
119
|
}
|
|
113
|
-
|
|
120
|
+
replaceAndReleaseSealCore(previous, context, actor, bindingToken, sealId, authorityFence, sessionIdentity, commitActor) {
|
|
114
121
|
if (previous.sealId !== sealId) {
|
|
115
122
|
throw (0, framework_errors_internal_1.createInternalFrameworkException)(framework_errors_internal_1.ZLinkFrameworkInternalErrorKind.ActorLocationStale, `Actor '${actor.actorId}' route switch did not match its relocation seal.`, true);
|
|
116
123
|
}
|
|
117
124
|
// JavaScript cannot interleave another ingress turn between these two
|
|
118
125
|
// synchronous mutations. The replacement preserves the seal, then the
|
|
119
126
|
// exact release publishes the route to held ingress as one owner turn.
|
|
120
|
-
|
|
127
|
+
this.commitCore(previous, context, actor, bindingToken, authorityFence, sessionIdentity, commitActor);
|
|
121
128
|
if (!this.abortSealCore(actor.actorId, sealId)) {
|
|
122
129
|
throw (0, framework_errors_internal_1.createInternalFrameworkException)(framework_errors_internal_1.ZLinkFrameworkInternalErrorKind.ActorLocationStale, `Actor '${actor.actorId}' route switch lost its relocation seal.`, true);
|
|
123
130
|
}
|
|
@@ -131,6 +138,17 @@ class ZLinkActorSessionBindingRegistry {
|
|
|
131
138
|
async route(actorId) {
|
|
132
139
|
return await this.lane.run(() => this.routeCore(actorId));
|
|
133
140
|
}
|
|
141
|
+
/** Selects the route only when it is the exact Session binding (§8.1 validation values). */
|
|
142
|
+
async routeForSessionBinding(actorId, sessionRid, bindingGeneration) {
|
|
143
|
+
return await this.lane.run(() => {
|
|
144
|
+
const route = this.routeCore(actorId);
|
|
145
|
+
const generation = route?.actor.ref.bindingGeneration;
|
|
146
|
+
return route?.sessionIdentity === sessionRid &&
|
|
147
|
+
(bindingGeneration === undefined || generation === bindingGeneration)
|
|
148
|
+
? route
|
|
149
|
+
: undefined;
|
|
150
|
+
});
|
|
151
|
+
}
|
|
134
152
|
routeCore(actorId) {
|
|
135
153
|
return this.routes.get(actorId);
|
|
136
154
|
}
|
|
@@ -145,9 +163,13 @@ class ZLinkActorSessionBindingRegistry {
|
|
|
145
163
|
return Object.freeze({ context: route.context });
|
|
146
164
|
}
|
|
147
165
|
async unbind(actorId, context, bindingToken, termination = ZLinkActorSessionBindingTermination.BindingEnd) {
|
|
148
|
-
await this.lane.run(() =>
|
|
166
|
+
const { submission } = await this.lane.run(() => ({
|
|
167
|
+
submission: this.unbindCore(actorId, context, bindingToken, termination)
|
|
168
|
+
}));
|
|
169
|
+
await submission;
|
|
149
170
|
}
|
|
150
|
-
|
|
171
|
+
/** Fixes the unbind order in the lane; the caller awaits transport completion outside it. */
|
|
172
|
+
unbindCore(actorId, context, bindingToken, termination) {
|
|
151
173
|
const route = this.routes.get(actorId);
|
|
152
174
|
if (route === undefined || route.context !== context || route.bindingToken !== bindingToken) {
|
|
153
175
|
return;
|
|
@@ -156,29 +178,33 @@ class ZLinkActorSessionBindingRegistry {
|
|
|
156
178
|
context.unbindLocal(actorId, bindingToken);
|
|
157
179
|
this.rejectSealWaiters(actorId, new Error(`Actor '${actorId}' session binding was removed while ingress was held.`));
|
|
158
180
|
this.rejectActiveFrameWaiters(actorId, new Error(`Actor '${actorId}' session binding was removed while accepted frames were active.`));
|
|
159
|
-
this.clearRouteRelocation(actorId, route
|
|
181
|
+
this.clearRouteRelocation(actorId, route);
|
|
160
182
|
if (termination === ZLinkActorSessionBindingTermination.BindingEnd &&
|
|
161
183
|
route.actorSlot !== undefined) {
|
|
162
|
-
|
|
184
|
+
return context.actorSlotControls?.enqueueUnbound(route.actorSlot);
|
|
163
185
|
}
|
|
186
|
+
return undefined;
|
|
164
187
|
}
|
|
165
188
|
async unbindActor(actorId) {
|
|
166
|
-
await this.lane.run(() =>
|
|
189
|
+
const { submission } = await this.lane.run(() => ({
|
|
190
|
+
submission: this.unbindActorCore(actorId)
|
|
191
|
+
}));
|
|
192
|
+
await submission;
|
|
167
193
|
}
|
|
168
|
-
|
|
194
|
+
unbindActorCore(actorId) {
|
|
169
195
|
const route = this.routes.get(actorId);
|
|
170
196
|
if (route === undefined) {
|
|
171
|
-
return;
|
|
197
|
+
return undefined;
|
|
172
198
|
}
|
|
173
|
-
|
|
199
|
+
return this.unbindCore(actorId, route.context, route.bindingToken, ZLinkActorSessionBindingTermination.BindingEnd);
|
|
174
200
|
}
|
|
175
201
|
async cleanup(context) {
|
|
176
202
|
await this.lane.run(() => this.cleanupCore(context));
|
|
177
203
|
}
|
|
178
|
-
|
|
204
|
+
cleanupCore(context) {
|
|
179
205
|
for (const route of [...this.routes.values()]) {
|
|
180
206
|
if (route.context === context) {
|
|
181
|
-
|
|
207
|
+
this.unbindCore(route.actor.actorId, context, route.bindingToken, ZLinkActorSessionBindingTermination.PhysicalDisconnect);
|
|
182
208
|
}
|
|
183
209
|
}
|
|
184
210
|
}
|
|
@@ -214,6 +240,25 @@ class ZLinkActorSessionBindingRegistry {
|
|
|
214
240
|
throw (0, framework_errors_internal_1.createInternalFrameworkException)(framework_errors_internal_1.ZLinkFrameworkInternalErrorKind.ActorLocationStale, `Actor '${actorId}' session ingress is sealed for relocation.`, true);
|
|
215
241
|
}
|
|
216
242
|
}
|
|
243
|
+
async acceptOneWay(actorId, bindingToken, prepare) {
|
|
244
|
+
return await this.lane.run(() => {
|
|
245
|
+
const route = this.requireRouteCore(actorId);
|
|
246
|
+
this.requireCurrentTokenCore(actorId, bindingToken);
|
|
247
|
+
const queue = this.relocations.get(actorId);
|
|
248
|
+
if (queue === undefined ||
|
|
249
|
+
(route.sealId === undefined &&
|
|
250
|
+
queue.ingress.length === 0 &&
|
|
251
|
+
queue.ingressDrain === undefined))
|
|
252
|
+
return false;
|
|
253
|
+
queue.ingress.push({
|
|
254
|
+
...prepare(),
|
|
255
|
+
sealId: route.sealId
|
|
256
|
+
});
|
|
257
|
+
if (route.sealId === undefined)
|
|
258
|
+
this.startHeldOneWayDrain(actorId, queue);
|
|
259
|
+
return true;
|
|
260
|
+
});
|
|
261
|
+
}
|
|
217
262
|
/**
|
|
218
263
|
* Holds Session ingress accepted after a relocation seal until the target
|
|
219
264
|
* route is published and the seal is released. The caller keeps the
|
|
@@ -350,6 +395,9 @@ class ZLinkActorSessionBindingRegistry {
|
|
|
350
395
|
throw (0, framework_errors_internal_1.createInternalFrameworkException)(framework_errors_internal_1.ZLinkFrameworkInternalErrorKind.ActorSessionNotBound, `Actor '${actorId}' session route seal was fenced by its binding identity.`, true);
|
|
351
396
|
}
|
|
352
397
|
route.sealId = sealId;
|
|
398
|
+
if (!this.relocations.has(actorId)) {
|
|
399
|
+
this.relocations.set(actorId, { actorId, seals: new Map(), ingress: [] });
|
|
400
|
+
}
|
|
353
401
|
// A pre-seal REQUEST is captured as part of installing command 42. Its
|
|
354
402
|
// Session frame no longer gates the seal; its single submission attempt
|
|
355
403
|
// and terminal continue under the request admission state above.
|
|
@@ -398,13 +446,7 @@ class ZLinkActorSessionBindingRegistry {
|
|
|
398
446
|
resolveTerminal = resolve;
|
|
399
447
|
});
|
|
400
448
|
const ready = this.waitForActiveFramesCore(claim.actorId, signal);
|
|
401
|
-
const actorQueue =
|
|
402
|
-
actorId: claim.actorId,
|
|
403
|
-
seals: new Map(),
|
|
404
|
-
outbound: [],
|
|
405
|
-
nextArrivalOrder: 1n,
|
|
406
|
-
outboundCount: 0
|
|
407
|
-
};
|
|
449
|
+
const actorQueue = this.relocations.get(claim.actorId);
|
|
408
450
|
const state = {
|
|
409
451
|
...claim,
|
|
410
452
|
phase: 'sealed',
|
|
@@ -423,108 +465,8 @@ class ZLinkActorSessionBindingRegistry {
|
|
|
423
465
|
relocationSnapshotCore(actorId, sealId) {
|
|
424
466
|
return this.relocations.get(actorId)?.seals.get(sealId);
|
|
425
467
|
}
|
|
426
|
-
async
|
|
427
|
-
|
|
428
|
-
}
|
|
429
|
-
retainRelocationOutboundCorePublic(actorId, operation, sealId) {
|
|
430
|
-
if (sealId !== undefined) {
|
|
431
|
-
const queue = this.relocations.get(actorId);
|
|
432
|
-
const state = queue?.seals.get(sealId);
|
|
433
|
-
if (queue === undefined ||
|
|
434
|
-
state === undefined ||
|
|
435
|
-
(queue.activeSealId !== sealId &&
|
|
436
|
-
!(queue.activeSealId === undefined && state.phase === 'terminal'))) {
|
|
437
|
-
failRetainedOutbound(operation, new Error(`Actor '${actorId}' Session outbound did not match its exact relocation seal.`));
|
|
438
|
-
return 'rejected';
|
|
439
|
-
}
|
|
440
|
-
}
|
|
441
|
-
return this.retainRelocationOutboundCore(actorId, operation, 'legacy');
|
|
442
|
-
}
|
|
443
|
-
async admitRelocationOutbound(claim, operation) {
|
|
444
|
-
return await this.lane.run(() => this.admitRelocationOutboundCore(claim, operation));
|
|
445
|
-
}
|
|
446
|
-
admitRelocationOutboundCore(claim, operation) {
|
|
447
|
-
const queue = this.relocations.get(claim.actorId);
|
|
448
|
-
const state = queue?.activeSealId === undefined ? undefined : queue.seals.get(queue.activeSealId);
|
|
449
|
-
const error = this.outboundAdmissionError(claim);
|
|
450
|
-
if (error !== undefined) {
|
|
451
|
-
failRetainedOutbound(operation, error);
|
|
452
|
-
return 'rejected';
|
|
453
|
-
}
|
|
454
|
-
if (queue === undefined || state === undefined) {
|
|
455
|
-
if (!this.matchesCurrentProducerNode(claim)) {
|
|
456
|
-
failRetainedOutbound(operation, new Error(`Actor '${claim.actorId}' Session outbound admission was fenced by its current binding.`));
|
|
457
|
-
return 'rejected';
|
|
458
|
-
}
|
|
459
|
-
if (queue === undefined)
|
|
460
|
-
return 'passThrough';
|
|
461
|
-
return this.retainRelocationOutboundCore(claim.actorId, operation, 'source', claim);
|
|
462
|
-
}
|
|
463
|
-
if (state.phase === 'sealed' || state.phase === 'applying') {
|
|
464
|
-
const matchesSource = matchesRelocationSourceProof(state, claim);
|
|
465
|
-
const matchesCurrent = this.matchesCurrentProducerNode(claim);
|
|
466
|
-
const authorization = matchesSource || matchesCurrent ? 'source' : 'pendingTarget';
|
|
467
|
-
return this.retainRelocationOutboundCore(claim.actorId, operation, authorization, claim);
|
|
468
|
-
}
|
|
469
|
-
const acceptedProof = state.acceptedProducerProof;
|
|
470
|
-
if (acceptedProof === undefined || !matchesAcceptedProducerProof(acceptedProof, claim)) {
|
|
471
|
-
failRetainedOutbound(operation, new Error(`Actor '${claim.actorId}' Session outbound admission did not match its accepted producer proof.`));
|
|
472
|
-
return 'rejected';
|
|
473
|
-
}
|
|
474
|
-
return this.retainRelocationOutboundCore(claim.actorId, operation, 'source', claim);
|
|
475
|
-
}
|
|
476
|
-
retainRelocationOutboundCore(actorId, operation, authorization, claim) {
|
|
477
|
-
const queue = this.relocations.get(actorId);
|
|
478
|
-
const state = queue?.activeSealId === undefined ? undefined : queue.seals.get(queue.activeSealId);
|
|
479
|
-
if (queue === undefined)
|
|
480
|
-
return 'passThrough';
|
|
481
|
-
if (state === undefined || state.phase === 'applied' || state.phase === 'terminal') {
|
|
482
|
-
if (queue.drainPromise === undefined && queue.outbound.length === 0)
|
|
483
|
-
return 'passThrough';
|
|
484
|
-
if (!this.reserveOutbound(queue, operation))
|
|
485
|
-
return 'rejected';
|
|
486
|
-
queue.outbound.push({
|
|
487
|
-
operation,
|
|
488
|
-
authorization,
|
|
489
|
-
arrivalOrder: queue.nextArrivalOrder++,
|
|
490
|
-
...(claim === undefined ? {} : { claim }),
|
|
491
|
-
released: true,
|
|
492
|
-
settled: false
|
|
493
|
-
});
|
|
494
|
-
this.startOutboundDrain(queue);
|
|
495
|
-
return 'retained';
|
|
496
|
-
}
|
|
497
|
-
if (!this.reserveOutbound(queue, operation))
|
|
498
|
-
return 'rejected';
|
|
499
|
-
queue.outbound.push({
|
|
500
|
-
sealId: state.sealId,
|
|
501
|
-
operation,
|
|
502
|
-
authorization,
|
|
503
|
-
arrivalOrder: queue.nextArrivalOrder++,
|
|
504
|
-
...(claim === undefined ? {} : { claim }),
|
|
505
|
-
released: false,
|
|
506
|
-
settled: false
|
|
507
|
-
});
|
|
508
|
-
return 'retained';
|
|
509
|
-
}
|
|
510
|
-
async discardRelocationOutbound(actorId, sealId, error) {
|
|
511
|
-
await this.lane.run(() => this.discardRelocationOutboundCore(actorId, sealId, error));
|
|
512
|
-
}
|
|
513
|
-
discardRelocationOutboundCore(actorId, sealId, error) {
|
|
514
|
-
const queue = this.relocations.get(actorId);
|
|
515
|
-
if (queue === undefined)
|
|
516
|
-
return;
|
|
517
|
-
for (let index = queue.outbound.length - 1; index >= 0; index--) {
|
|
518
|
-
const entry = queue.outbound[index];
|
|
519
|
-
if (entry.sealId !== sealId)
|
|
520
|
-
continue;
|
|
521
|
-
queue.outbound.splice(index, 1);
|
|
522
|
-
this.failOutbound(queue, entry, error);
|
|
523
|
-
}
|
|
524
|
-
this.deleteEmptyRelocationQueue(queue);
|
|
525
|
-
}
|
|
526
|
-
async applyRelocation(actorId, sealId, applyFingerprint, action, commitOwnerTransition, acceptedProducerProof) {
|
|
527
|
-
const prepared = await this.lane.run(() => this.prepareRelocationApply(actorId, sealId, applyFingerprint, action, acceptedProducerProof));
|
|
468
|
+
async applyRelocation(actorId, sealId, applyFingerprint, commitOwnerTransition) {
|
|
469
|
+
const prepared = await this.lane.run(() => this.prepareRelocationApply(actorId, sealId, applyFingerprint));
|
|
528
470
|
if (prepared.applyPromise !== undefined) {
|
|
529
471
|
await prepared.applyPromise;
|
|
530
472
|
return;
|
|
@@ -544,7 +486,7 @@ class ZLinkActorSessionBindingRegistry {
|
|
|
544
486
|
});
|
|
545
487
|
await prepared.promise;
|
|
546
488
|
}
|
|
547
|
-
prepareRelocationApply(actorId, sealId, applyFingerprint
|
|
489
|
+
prepareRelocationApply(actorId, sealId, applyFingerprint) {
|
|
548
490
|
const queue = this.relocations.get(actorId);
|
|
549
491
|
const state = queue?.seals.get(sealId);
|
|
550
492
|
if (queue === undefined || state === undefined) {
|
|
@@ -554,15 +496,7 @@ class ZLinkActorSessionBindingRegistry {
|
|
|
554
496
|
if (state.applyFingerprint !== applyFingerprint || state.applyPromise === undefined) {
|
|
555
497
|
throw (0, framework_errors_internal_1.createInternalFrameworkException)(framework_errors_internal_1.ZLinkFrameworkInternalErrorKind.ActorLocationStale, `Actor '${actorId}' Session seal received a conflicting route apply.`, true);
|
|
556
498
|
}
|
|
557
|
-
return {
|
|
558
|
-
}
|
|
559
|
-
if (action === 'commit' &&
|
|
560
|
-
acceptedProducerProof !== undefined &&
|
|
561
|
-
!validAcceptedTargetProof(state, acceptedProducerProof)) {
|
|
562
|
-
throw (0, framework_errors_internal_1.createInternalFrameworkException)(framework_errors_internal_1.ZLinkFrameworkInternalErrorKind.ActorLocationStale, `Actor '${actorId}' command 44 target producer proof did not match its Session seal.`, true);
|
|
563
|
-
}
|
|
564
|
-
if (action === 'abort' && acceptedProducerProof !== undefined) {
|
|
565
|
-
throw (0, framework_errors_internal_1.createInternalFrameworkException)(framework_errors_internal_1.ZLinkFrameworkInternalErrorKind.ActorLocationStale, `Actor '${actorId}' abort route supplied a target producer proof.`, true);
|
|
499
|
+
return { state, applyPromise: state.applyPromise };
|
|
566
500
|
}
|
|
567
501
|
state.phase = 'applying';
|
|
568
502
|
state.applyFingerprint = applyFingerprint;
|
|
@@ -574,69 +508,19 @@ class ZLinkActorSessionBindingRegistry {
|
|
|
574
508
|
});
|
|
575
509
|
state.applyPromise = promise;
|
|
576
510
|
return {
|
|
577
|
-
queue,
|
|
578
511
|
state,
|
|
579
|
-
action,
|
|
580
|
-
acceptedProducerProof,
|
|
581
512
|
promise,
|
|
582
513
|
resolve,
|
|
583
|
-
reject
|
|
584
|
-
actorId,
|
|
585
|
-
sealId
|
|
514
|
+
reject
|
|
586
515
|
};
|
|
587
516
|
}
|
|
588
517
|
completeRelocationApply(prepared) {
|
|
589
|
-
|
|
590
|
-
const proof = action === 'commit'
|
|
591
|
-
? (acceptedProducerProof ?? this.currentProducerProof(actorId))
|
|
592
|
-
: relocationSourceProof(state);
|
|
593
|
-
state.acceptedProducerProof = proof;
|
|
594
|
-
for (let index = queue.outbound.length - 1; index >= 0; index--) {
|
|
595
|
-
const entry = queue.outbound[index];
|
|
596
|
-
if (entry.sealId !== sealId)
|
|
597
|
-
continue;
|
|
598
|
-
if (entry.authorization !== 'pendingTarget') {
|
|
599
|
-
entry.released = true;
|
|
600
|
-
continue;
|
|
601
|
-
}
|
|
602
|
-
if (action === 'commit' &&
|
|
603
|
-
proof !== undefined &&
|
|
604
|
-
entry.claim !== undefined &&
|
|
605
|
-
matchesAcceptedProducerProof(proof, entry.claim)) {
|
|
606
|
-
entry.released = true;
|
|
607
|
-
continue;
|
|
608
|
-
}
|
|
609
|
-
queue.outbound.splice(index, 1);
|
|
610
|
-
this.failOutbound(queue, entry, new Error(`Actor '${actorId}' pending Session producer did not match command 44 proof.`));
|
|
611
|
-
}
|
|
612
|
-
this.startOutboundDrain(queue);
|
|
613
|
-
state.phase = 'applied';
|
|
518
|
+
prepared.state.phase = 'applied';
|
|
614
519
|
}
|
|
615
520
|
failRelocationApply(prepared) {
|
|
616
521
|
prepared.state.phase = 'sealed';
|
|
617
522
|
prepared.state.applyFingerprint = undefined;
|
|
618
523
|
prepared.state.applyPromise = undefined;
|
|
619
|
-
prepared.state.acceptedProducerProof = undefined;
|
|
620
|
-
}
|
|
621
|
-
currentProducerProof(actorId) {
|
|
622
|
-
const route = this.routes.get(actorId);
|
|
623
|
-
const actorRef = (route?.actor).ref;
|
|
624
|
-
const sessionIdentity = route?.sessionIdentity;
|
|
625
|
-
if (route === undefined ||
|
|
626
|
-
actorRef === undefined ||
|
|
627
|
-
sessionIdentity === undefined ||
|
|
628
|
-
actorRef.ownerNodeGeneration === undefined)
|
|
629
|
-
return undefined;
|
|
630
|
-
return {
|
|
631
|
-
actorId,
|
|
632
|
-
objectGeneration: BigInt(actorRef.objectGeneration ??
|
|
633
|
-
actorRef.generation ??
|
|
634
|
-
-1),
|
|
635
|
-
actorNodeRid: String(actorRef.nodeRid ?? ''),
|
|
636
|
-
actorNodeGeneration: BigInt(actorRef.ownerNodeGeneration),
|
|
637
|
-
sessionIdentity: String(sessionIdentity),
|
|
638
|
-
bindingGeneration: BigInt(actorRef.bindingGeneration ?? -1)
|
|
639
|
-
};
|
|
640
524
|
}
|
|
641
525
|
async observeRelocationTerminal(actorId, sealId, applyFingerprint) {
|
|
642
526
|
await this.lane.run(() => this.observeRelocationTerminalCore(actorId, sealId, applyFingerprint));
|
|
@@ -662,7 +546,7 @@ class ZLinkActorSessionBindingRegistry {
|
|
|
662
546
|
}
|
|
663
547
|
/**
|
|
664
548
|
* Actor-wide relocation teardown: every seal (active and terminal-retained)
|
|
665
|
-
*
|
|
549
|
+
* for `actorId` is discarded unconditionally.
|
|
666
550
|
* Reserved for paths where the Actor itself is gone or being torn down
|
|
667
551
|
* (destroy, ownership clear, relocation-seal expiry/failure) — never for a
|
|
668
552
|
* single physical route's disconnect, which must not disturb a relocation
|
|
@@ -675,9 +559,14 @@ class ZLinkActorSessionBindingRegistry {
|
|
|
675
559
|
const queue = this.relocations.get(actorId);
|
|
676
560
|
if (queue === undefined)
|
|
677
561
|
return;
|
|
562
|
+
this.rejectSealWaiters(actorId, error, error instanceof ZLinkFrameworkException_1.ZLinkFrameworkException &&
|
|
563
|
+
error.kind === ZLinkFrameworkException_1.ZLinkFrameworkErrorKind.DeadlineExceeded
|
|
564
|
+
? 'target_closed'
|
|
565
|
+
: error instanceof ZLinkFrameworkException_1.ZLinkFrameworkException &&
|
|
566
|
+
error.kind === ZLinkFrameworkException_1.ZLinkFrameworkErrorKind.ShuttingDown
|
|
567
|
+
? 'shutdown'
|
|
568
|
+
: 'stale_target');
|
|
678
569
|
this.relocations.delete(actorId);
|
|
679
|
-
for (const entry of queue.outbound.splice(0))
|
|
680
|
-
this.failOutbound(queue, entry, error);
|
|
681
570
|
for (const state of queue.seals.values()) {
|
|
682
571
|
this.terminalRelocations.delete(state);
|
|
683
572
|
if (state.phase !== 'terminal')
|
|
@@ -688,14 +577,14 @@ class ZLinkActorSessionBindingRegistry {
|
|
|
688
577
|
* Spec 48 §137: a relocation seal's lifecycle is independent of any single
|
|
689
578
|
* physical route's binding. Unbinding one physical route (a disconnect)
|
|
690
579
|
* must retire only the still-open (nonterminal) relocation seal that this
|
|
691
|
-
* exact route's Session owns
|
|
580
|
+
* exact route's Session owns — it
|
|
692
581
|
* must never reach into a seal that has already reached 'terminal' (its
|
|
693
582
|
* bounded retention exists precisely so a late same-seal relay can still
|
|
694
583
|
* pass on a successor route) nor into a different Session's active seal
|
|
695
584
|
* (a concurrent successor that already re-sealed before this stale route
|
|
696
585
|
* noticed the disconnect).
|
|
697
586
|
*/
|
|
698
|
-
clearRouteRelocation(actorId, route
|
|
587
|
+
clearRouteRelocation(actorId, route) {
|
|
699
588
|
const queue = this.relocations.get(actorId);
|
|
700
589
|
if (queue === undefined)
|
|
701
590
|
return;
|
|
@@ -710,13 +599,6 @@ class ZLinkActorSessionBindingRegistry {
|
|
|
710
599
|
this.deleteEmptyRelocationQueue(queue);
|
|
711
600
|
return;
|
|
712
601
|
}
|
|
713
|
-
for (let index = queue.outbound.length - 1; index >= 0; index--) {
|
|
714
|
-
const entry = queue.outbound[index];
|
|
715
|
-
if (entry.sealId !== activeSealId)
|
|
716
|
-
continue;
|
|
717
|
-
queue.outbound.splice(index, 1);
|
|
718
|
-
this.failOutbound(queue, entry, error);
|
|
719
|
-
}
|
|
720
602
|
queue.activeSealId = undefined;
|
|
721
603
|
queue.seals.delete(activeSealId);
|
|
722
604
|
this.terminalRelocations.delete(activeState);
|
|
@@ -900,113 +782,6 @@ class ZLinkActorSessionBindingRegistry {
|
|
|
900
782
|
for (const waiter of waiters)
|
|
901
783
|
waiter.reject(error);
|
|
902
784
|
}
|
|
903
|
-
startOutboundDrain(queue) {
|
|
904
|
-
if (queue.drainPromise !== undefined)
|
|
905
|
-
return;
|
|
906
|
-
const drain = startOutsideStateLane(async () => {
|
|
907
|
-
for (;;) {
|
|
908
|
-
const entry = await this.lane.run(() => {
|
|
909
|
-
const current = queue.outbound.at(0);
|
|
910
|
-
if (current === undefined || !current.released)
|
|
911
|
-
return undefined;
|
|
912
|
-
if (current.settled) {
|
|
913
|
-
queue.outbound.shift();
|
|
914
|
-
return null;
|
|
915
|
-
}
|
|
916
|
-
return current;
|
|
917
|
-
});
|
|
918
|
-
if (entry === undefined)
|
|
919
|
-
return;
|
|
920
|
-
if (entry === null)
|
|
921
|
-
continue;
|
|
922
|
-
try {
|
|
923
|
-
const delivered = await entry.operation.deliver();
|
|
924
|
-
await this.lane.run(() => {
|
|
925
|
-
if (delivered)
|
|
926
|
-
this.settleOutbound(queue, entry);
|
|
927
|
-
else
|
|
928
|
-
this.failOutbound(queue, entry, new Error(`Actor '${queue.actorId}' retained Session outbound delivery was rejected.`));
|
|
929
|
-
if (queue.outbound[0] === entry)
|
|
930
|
-
queue.outbound.shift();
|
|
931
|
-
});
|
|
932
|
-
}
|
|
933
|
-
catch (error) {
|
|
934
|
-
await this.lane.run(() => {
|
|
935
|
-
this.failOutbound(queue, entry, error);
|
|
936
|
-
if (queue.outbound[0] === entry)
|
|
937
|
-
queue.outbound.shift();
|
|
938
|
-
});
|
|
939
|
-
}
|
|
940
|
-
}
|
|
941
|
-
});
|
|
942
|
-
startOutsideStateLane(() => {
|
|
943
|
-
void drain.finally(async () => await this.lane.run(() => {
|
|
944
|
-
if (queue.drainPromise === drain)
|
|
945
|
-
queue.drainPromise = undefined;
|
|
946
|
-
if (queue.outbound[0]?.released === true)
|
|
947
|
-
this.startOutboundDrain(queue);
|
|
948
|
-
else
|
|
949
|
-
this.deleteEmptyRelocationQueue(queue);
|
|
950
|
-
}));
|
|
951
|
-
});
|
|
952
|
-
queue.drainPromise = drain;
|
|
953
|
-
}
|
|
954
|
-
reserveOutbound(queue, operation) {
|
|
955
|
-
if (queue.outboundCount < this.outboundCapacity) {
|
|
956
|
-
queue.outboundCount++;
|
|
957
|
-
return true;
|
|
958
|
-
}
|
|
959
|
-
failRetainedOutbound(operation, new Error(`Actor '${queue.actorId}' Session relocation outbound capacity was exhausted.`));
|
|
960
|
-
return false;
|
|
961
|
-
}
|
|
962
|
-
settleOutbound(queue, entry) {
|
|
963
|
-
if (entry.settled)
|
|
964
|
-
return;
|
|
965
|
-
entry.settled = true;
|
|
966
|
-
queue.outboundCount--;
|
|
967
|
-
}
|
|
968
|
-
failOutbound(queue, entry, error) {
|
|
969
|
-
if (entry.settled)
|
|
970
|
-
return;
|
|
971
|
-
this.settleOutbound(queue, entry);
|
|
972
|
-
failRetainedOutbound(entry.operation, error);
|
|
973
|
-
}
|
|
974
|
-
outboundAdmissionError(claim) {
|
|
975
|
-
if (claim.actorId.length === 0 ||
|
|
976
|
-
claim.objectGeneration <= 0n ||
|
|
977
|
-
claim.actorNodeRid.length === 0 ||
|
|
978
|
-
claim.actorNodeGeneration <= 0n ||
|
|
979
|
-
claim.producerNodeRid.length === 0 ||
|
|
980
|
-
claim.producerNodeGeneration <= 0n ||
|
|
981
|
-
claim.bindingGeneration <= 0n ||
|
|
982
|
-
claim.sessionIdentity.length === 0 ||
|
|
983
|
-
!(0, routing_id_1.routingIdsEqual)(claim.producerNodeRid, claim.actorNodeRid) ||
|
|
984
|
-
claim.producerNodeGeneration !== claim.actorNodeGeneration) {
|
|
985
|
-
return new Error(`Actor '${claim.actorId}' Session outbound admission claim is invalid.`);
|
|
986
|
-
}
|
|
987
|
-
const route = this.routes.get(claim.actorId);
|
|
988
|
-
const ref = route?.actor;
|
|
989
|
-
const actorRef = ref?.ref;
|
|
990
|
-
const routeSessionIdentity = route?.sessionIdentity;
|
|
991
|
-
if (route === undefined ||
|
|
992
|
-
actorRef === undefined ||
|
|
993
|
-
String(actorRef.actorId ?? claim.actorId) !== claim.actorId ||
|
|
994
|
-
BigInt(actorRef.objectGeneration ??
|
|
995
|
-
actorRef.generation ??
|
|
996
|
-
-1) !== claim.objectGeneration ||
|
|
997
|
-
BigInt(actorRef.bindingGeneration ?? -1) !== claim.bindingGeneration ||
|
|
998
|
-
String(routeSessionIdentity ?? '') !== claim.sessionIdentity) {
|
|
999
|
-
return new Error(`Actor '${claim.actorId}' Session outbound admission was fenced by its current binding.`);
|
|
1000
|
-
}
|
|
1001
|
-
return undefined;
|
|
1002
|
-
}
|
|
1003
|
-
matchesCurrentProducerNode(claim) {
|
|
1004
|
-
const route = this.routes.get(claim.actorId);
|
|
1005
|
-
const actorRef = (route?.actor).ref;
|
|
1006
|
-
return (route !== undefined &&
|
|
1007
|
-
actorRef !== undefined &&
|
|
1008
|
-
(0, routing_id_1.routingIdsEqual)(String(actorRef.nodeRid ?? ''), claim.actorNodeRid));
|
|
1009
|
-
}
|
|
1010
785
|
rememberTerminalRelocation(state) {
|
|
1011
786
|
this.terminalRelocations.delete(state);
|
|
1012
787
|
this.terminalRelocations.set(state, true);
|
|
@@ -1025,13 +800,21 @@ class ZLinkActorSessionBindingRegistry {
|
|
|
1025
800
|
deleteEmptyRelocationQueue(queue) {
|
|
1026
801
|
if (queue.activeSealId === undefined &&
|
|
1027
802
|
queue.seals.size === 0 &&
|
|
1028
|
-
queue.
|
|
1029
|
-
queue.
|
|
803
|
+
queue.ingress.length === 0 &&
|
|
804
|
+
queue.ingressDrain === undefined &&
|
|
1030
805
|
this.relocations.get(queue.actorId) === queue) {
|
|
1031
806
|
this.relocations.delete(queue.actorId);
|
|
1032
807
|
}
|
|
1033
808
|
}
|
|
1034
|
-
resolveSealWaiters(actorId,
|
|
809
|
+
resolveSealWaiters(actorId, sealId) {
|
|
810
|
+
const queue = this.relocations.get(actorId);
|
|
811
|
+
if (queue !== undefined) {
|
|
812
|
+
for (const entry of queue.ingress) {
|
|
813
|
+
if (entry.sealId === sealId)
|
|
814
|
+
entry.sealId = undefined;
|
|
815
|
+
}
|
|
816
|
+
this.startHeldOneWayDrain(actorId, queue);
|
|
817
|
+
}
|
|
1035
818
|
const waiters = this.sealWaiters.get(actorId);
|
|
1036
819
|
if (waiters === undefined)
|
|
1037
820
|
return;
|
|
@@ -1039,7 +822,12 @@ class ZLinkActorSessionBindingRegistry {
|
|
|
1039
822
|
for (const waiter of waiters)
|
|
1040
823
|
waiter.resolve();
|
|
1041
824
|
}
|
|
1042
|
-
rejectSealWaiters(actorId, error) {
|
|
825
|
+
rejectSealWaiters(actorId, error, reason = 'target_closed') {
|
|
826
|
+
const queue = this.relocations.get(actorId);
|
|
827
|
+
if (queue !== undefined) {
|
|
828
|
+
for (const delivery of queue.ingress.splice(0))
|
|
829
|
+
delivery.drop(reason, error);
|
|
830
|
+
}
|
|
1043
831
|
const waiters = this.sealWaiters.get(actorId);
|
|
1044
832
|
if (waiters === undefined)
|
|
1045
833
|
return;
|
|
@@ -1047,6 +835,44 @@ class ZLinkActorSessionBindingRegistry {
|
|
|
1047
835
|
for (const waiter of waiters)
|
|
1048
836
|
waiter.reject(error);
|
|
1049
837
|
}
|
|
838
|
+
startHeldOneWayDrain(actorId, queue) {
|
|
839
|
+
if (queue.ingressDrain !== undefined)
|
|
840
|
+
return;
|
|
841
|
+
const drain = startOutsideStateLane(async () => {
|
|
842
|
+
for (;;) {
|
|
843
|
+
const next = await this.lane.run(() => {
|
|
844
|
+
if (this.relocations.get(actorId) !== queue)
|
|
845
|
+
return undefined;
|
|
846
|
+
const first = queue.ingress.at(0);
|
|
847
|
+
if (first === undefined || first.sealId !== undefined)
|
|
848
|
+
return undefined;
|
|
849
|
+
return queue.ingress.shift();
|
|
850
|
+
});
|
|
851
|
+
if (next === undefined)
|
|
852
|
+
return;
|
|
853
|
+
try {
|
|
854
|
+
await next.deliver();
|
|
855
|
+
}
|
|
856
|
+
catch (error) {
|
|
857
|
+
next.drop('stale_target', error);
|
|
858
|
+
}
|
|
859
|
+
}
|
|
860
|
+
});
|
|
861
|
+
queue.ingressDrain = drain;
|
|
862
|
+
startOutsideStateLane(() => {
|
|
863
|
+
void drain.finally(async () => {
|
|
864
|
+
await this.lane.run(() => {
|
|
865
|
+
if (queue.ingressDrain !== drain)
|
|
866
|
+
return;
|
|
867
|
+
queue.ingressDrain = undefined;
|
|
868
|
+
if (queue.ingress.at(0)?.sealId === undefined && queue.ingress.length > 0)
|
|
869
|
+
this.startHeldOneWayDrain(actorId, queue);
|
|
870
|
+
else
|
|
871
|
+
this.deleteEmptyRelocationQueue(queue);
|
|
872
|
+
});
|
|
873
|
+
});
|
|
874
|
+
});
|
|
875
|
+
}
|
|
1050
876
|
}
|
|
1051
877
|
exports.ZLinkActorSessionBindingRegistry = ZLinkActorSessionBindingRegistry;
|
|
1052
878
|
function assertRelocationClaim(state, claim) {
|
|
@@ -1061,54 +887,6 @@ function assertRelocationClaim(state, claim) {
|
|
|
1061
887
|
function startOutsideStateLane(work) {
|
|
1062
888
|
return detachedStateLaneResource.runInAsyncScope(work);
|
|
1063
889
|
}
|
|
1064
|
-
function matchesRelocationSourceProof(state, claim) {
|
|
1065
|
-
return (state.actorId === claim.actorId &&
|
|
1066
|
-
state.actorGeneration === claim.objectGeneration &&
|
|
1067
|
-
state.bindingGeneration === claim.bindingGeneration &&
|
|
1068
|
-
state.sessionIdentity === claim.sessionIdentity &&
|
|
1069
|
-
state.actorNodeRid !== undefined &&
|
|
1070
|
-
(0, routing_id_1.routingIdsEqual)(state.actorNodeRid, claim.actorNodeRid) &&
|
|
1071
|
-
state.actorNodeGeneration === claim.actorNodeGeneration);
|
|
1072
|
-
}
|
|
1073
|
-
function matchesAcceptedProducerProof(proof, claim) {
|
|
1074
|
-
return (proof.actorId === claim.actorId &&
|
|
1075
|
-
proof.objectGeneration === claim.objectGeneration &&
|
|
1076
|
-
(0, routing_id_1.routingIdsEqual)(proof.actorNodeRid, claim.actorNodeRid) &&
|
|
1077
|
-
proof.actorNodeGeneration === claim.actorNodeGeneration &&
|
|
1078
|
-
proof.sessionIdentity === claim.sessionIdentity &&
|
|
1079
|
-
proof.bindingGeneration === claim.bindingGeneration);
|
|
1080
|
-
}
|
|
1081
|
-
function validAcceptedTargetProof(state, proof) {
|
|
1082
|
-
return (proof.actorId === state.actorId &&
|
|
1083
|
-
proof.objectGeneration === state.actorGeneration &&
|
|
1084
|
-
proof.actorNodeRid.length > 0 &&
|
|
1085
|
-
proof.actorNodeGeneration > 0n &&
|
|
1086
|
-
proof.sessionIdentity === state.sessionIdentity &&
|
|
1087
|
-
proof.bindingGeneration === state.bindingGeneration);
|
|
1088
|
-
}
|
|
1089
|
-
function relocationSourceProof(state) {
|
|
1090
|
-
if (state.sessionIdentity === undefined ||
|
|
1091
|
-
state.actorNodeRid === undefined ||
|
|
1092
|
-
state.actorNodeGeneration === undefined)
|
|
1093
|
-
return undefined;
|
|
1094
|
-
return {
|
|
1095
|
-
actorId: state.actorId,
|
|
1096
|
-
objectGeneration: state.actorGeneration,
|
|
1097
|
-
actorNodeRid: state.actorNodeRid,
|
|
1098
|
-
actorNodeGeneration: state.actorNodeGeneration,
|
|
1099
|
-
sessionIdentity: state.sessionIdentity,
|
|
1100
|
-
bindingGeneration: state.bindingGeneration
|
|
1101
|
-
};
|
|
1102
|
-
}
|
|
1103
|
-
function failRetainedOutbound(operation, error) {
|
|
1104
|
-
try {
|
|
1105
|
-
operation.fail(error);
|
|
1106
|
-
}
|
|
1107
|
-
catch {
|
|
1108
|
-
// The aggregate has already removed the entry. A failure observer cannot
|
|
1109
|
-
// retain or settle the same delivery a second time.
|
|
1110
|
-
}
|
|
1111
|
-
}
|
|
1112
890
|
function assertSuccessorSessionIdentity(predecessor, successor) {
|
|
1113
891
|
if (predecessor.actorGeneration !== successor.actorGeneration ||
|
|
1114
892
|
predecessor.bindingGeneration !== successor.bindingGeneration ||
|