@zlink-systems/framework 0.20.0 → 0.22.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/.tsbuildinfo +1 -1
- package/dist/contracts/Common/ZLinkMessage.js +5 -5
- package/dist/contracts/Configuration/CodecContentType.js +5 -7
- package/dist/contracts/Configuration/DiagnosticsValidation.js +1 -6
- package/dist/contracts/Configuration/EndpointNotation.js +4 -8
- package/dist/contracts/Configuration/Registration.js +14 -11
- package/dist/contracts/Configuration/RegistrationBuilders.js +32 -25
- package/dist/contracts/Configuration/RegistrationNormalizers.js +25 -26
- package/dist/contracts/Configuration/RegistrationValidators.js +36 -38
- package/dist/contracts/Configuration/SendTimeoutValidation.js +4 -4
- package/dist/contracts/Configuration/TimerRegistrationValidator.js +7 -7
- package/dist/contracts/Handlers/JsonContract.js +23 -11
- package/dist/contracts/Spots/SpotKind.js +16 -8
- package/dist/location-store-integration.js +16 -16
- package/dist/nest-integration.js +17 -11
- package/dist/runtime/abort.js +9 -5
- package/dist/runtime/actors/actor-authority-payload-codec.js +12 -16
- package/dist/runtime/actors/actor-authority-publication.js +18 -17
- package/dist/runtime/actors/actor-client.js +83 -63
- package/dist/runtime/actors/actor-context.js +24 -18
- package/dist/runtime/actors/actor-creation.js +4 -3
- package/dist/runtime/actors/actor-handoff.js +89 -92
- package/dist/runtime/actors/actor-local-native-join.js +18 -19
- package/dist/runtime/actors/actor-mailbox.js +1 -1
- package/dist/runtime/actors/actor-message-follow-context.js +24 -21
- package/dist/runtime/actors/actor-packet-relay-wire.js +1 -3
- package/dist/runtime/actors/actor-remote-joiner.js +20 -17
- package/dist/runtime/actors/actor-remote-wire.js +6 -7
- package/dist/runtime/actors/actor-runtime-state.js +87 -81
- package/dist/runtime/actors/actor-transfer-registry.js +3 -5
- package/dist/runtime/actors/bound-session-wire.js +14 -9
- package/dist/runtime/actors/deferred-join-accepted-journal.js +158 -124
- package/dist/runtime/actors/index.js +2 -5
- package/dist/runtime/actors/post-commit-actor-binder.js +3 -6
- package/dist/runtime/actors/post-commit-actor-location.js +1 -1
- package/dist/runtime/actors/spot-actor-dispatch.js +5 -5
- package/dist/runtime/actors/transferred-actor-rollback.js +4 -4
- package/dist/runtime/admission.js +2 -6
- package/dist/runtime/application-jobs/application-ingress-record-owner.js +2 -6
- package/dist/runtime/application-jobs/receive-flow-controller.js +11 -12
- package/dist/runtime/backend/mesh-completion-table.js +1 -3
- package/dist/runtime/backend/mesh-dispatch-pump.js +12 -16
- package/dist/runtime/backend/node/node-backend-adapter-factory.js +1 -3
- package/dist/runtime/backend/node/node-backend-adapter-support.js +26 -17
- package/dist/runtime/backend/node/node-mesh-backend-adapter.js +4 -3
- package/dist/runtime/backend/node/node-raw-binding-port.js +7 -6
- package/dist/runtime/backend/node/node-raw-mesh-backend.js +116 -113
- package/dist/runtime/backend/node/node-socket-backend-adapter.js +12 -13
- package/dist/runtime/backend/runtime-message.js +3 -3
- package/dist/runtime/backend/runtime-values.d.ts +2 -2
- package/dist/runtime/backend/runtime-values.js +4 -5
- package/dist/runtime/channels/channel-clients.js +27 -24
- package/dist/runtime/channels/channel-dispatch-pipeline.js +10 -18
- package/dist/runtime/channels/channel-dispatch-services.js +7 -4
- package/dist/runtime/channels/channel-dispatchers.js +9 -9
- package/dist/runtime/channels/channel-envelope-inspection.js +16 -13
- package/dist/runtime/channels/channel-envelope.js +83 -47
- package/dist/runtime/channels/channel-outbound-operations.js +8 -8
- package/dist/runtime/channels/channel-receive-loops.js +20 -22
- package/dist/runtime/channels/channel-receive-task-tracker.js +1 -1
- package/dist/runtime/channels/channel-runtime-lifecycle.js +61 -56
- package/dist/runtime/channels/channel-runtime-manager.js +18 -9
- package/dist/runtime/channels/channel-socket-registry.js +126 -123
- package/dist/runtime/channels/channel-transports.js +43 -33
- package/dist/runtime/channels/client-server-location-runtime.js +32 -40
- package/dist/runtime/channels/client-server-service-wire.js +29 -22
- package/dist/runtime/channels/dispatch-error-reporter.js +9 -7
- package/dist/runtime/channels/fanout-location-runtime.js +34 -47
- package/dist/runtime/channels/fanout-service-wire.js +3 -5
- package/dist/runtime/channels/local-spot-route-transport.js +7 -1
- package/dist/runtime/channels/route-member-snapshot.js +3 -3
- package/dist/runtime/channels/source-spot-router.js +6 -2
- package/dist/runtime/channels/spot-route-bridge-transport.js +5 -2
- package/dist/runtime/channels/spot-route-dispatch-strategy.js +2 -2
- package/dist/runtime/channels/spot-route-target-resolver.js +6 -6
- package/dist/runtime/diagnostics/index.js +38 -10
- package/dist/runtime/diagnostics/message-flow.js +47 -39
- package/dist/runtime/diagnostics/runtime-metrics.js +18 -9
- package/dist/runtime/diagnostics/runtime-observation-queue.js +8 -10
- package/dist/runtime/diagnostics/topology-runtime-projections.js +17 -10
- package/dist/runtime/execution/index.js +7 -6
- package/dist/runtime/execution/serial-execution-queue.js +12 -18
- package/dist/runtime/execution/state-lane.js +2 -2
- package/dist/runtime/foundation/actor-join-recovery-codec.js +31 -23
- package/dist/runtime/foundation/event-loop-resources.js +4 -4
- package/dist/runtime/foundation/message-follow-suppression-registry.js +4 -4
- package/dist/runtime/foundation/raw-service-mesh-runtime.js +136 -136
- package/dist/runtime/foundation/route-mesh-connection-policy.js +4 -4
- package/dist/runtime/foundation/runtime-state-projections.js +22 -11
- package/dist/runtime/foundation/service-authority-payload-codec.js +13 -15
- package/dist/runtime/foundation/service-discovery-registry.js +35 -33
- package/dist/runtime/foundation/service-instance-activation-recovery-codec.js +20 -22
- package/dist/runtime/foundation/service-liveness-registry.js +16 -12
- package/dist/runtime/foundation/service-maintenance-runtime.js +2 -4
- package/dist/runtime/foundation/service-relocation-aggregate-committer.js +24 -24
- package/dist/runtime/foundation/service-relocation-object-owner.js +6 -6
- package/dist/runtime/foundation/service-relocation-runtime.js +137 -94
- package/dist/runtime/foundation/service-runtime-contracts.js +5 -5
- package/dist/runtime/foundation/service-stateful-registry.js +24 -23
- package/dist/runtime/foundation/service-stateful-runtime.js +416 -438
- package/dist/runtime/foundation/service-stateful-wire-codec.js +95 -98
- package/dist/runtime/foundation/service-topology-registry.js +96 -95
- package/dist/runtime/foundation/service-weighted-selection.js +6 -11
- package/dist/runtime/foundation/service-wire-binary-primitives.js +5 -6
- package/dist/runtime/foundation/service-wire-m6a-codec.js +46 -35
- package/dist/runtime/framework-errors-internal.js +7 -10
- package/dist/runtime/handlers/handler-instance-scope.js +4 -5
- package/dist/runtime/handlers/index.js +3 -1
- package/dist/runtime/host/actor-packet-relay.js +74 -70
- package/dist/runtime/host/actor-placement-coordinator.js +29 -31
- package/dist/runtime/host/actor-runtime-options-factory.js +12 -14
- package/dist/runtime/host/actor-transfer-authority-runtime.js +7 -9
- package/dist/runtime/host/actor-transfer-runtime.js +176 -153
- package/dist/runtime/host/application-job-queue.js +18 -22
- package/dist/runtime/host/bound-session-relay.js +3 -1
- package/dist/runtime/host/channel-runtime-options-factory.js +31 -14
- package/dist/runtime/host/host-capacity-status.js +8 -4
- package/dist/runtime/host/index.js +244 -227
- package/dist/runtime/host/instance-activation-authority.js +93 -96
- package/dist/runtime/host/location-runtime-owner.js +16 -14
- package/dist/runtime/host/mesh-router-resolver.js +11 -13
- package/dist/runtime/host/relocation-direct-transfer.js +10 -9
- package/dist/runtime/host/remote-actor-join-receiver.js +20 -15
- package/dist/runtime/host/remote-actor-packet-target-store.js +18 -22
- package/dist/runtime/host/remote-bound-session-relay.js +97 -73
- package/dist/runtime/host/route-mesh-runtime.js +64 -69
- package/dist/runtime/host/runtime-shutdown.js +1 -2
- package/dist/runtime/host/service-relocation-host-runtime.js +586 -511
- package/dist/runtime/host/spot-address-transport.js +69 -71
- package/dist/runtime/host/spot-runtime-options-factory.js +30 -29
- package/dist/runtime/host/stateful-authority-route-runtime.js +65 -68
- package/dist/runtime/host/user-spot-creation-coordinator.js +61 -67
- package/dist/runtime/locations/actor-location-claims.js +26 -20
- package/dist/runtime/locations/aggregate-inventory-store.js +72 -75
- package/dist/runtime/locations/authority-key-codec.js +7 -7
- package/dist/runtime/locations/auto-connect-loop.js +3 -3
- package/dist/runtime/locations/auto-connect-planner.js +25 -19
- package/dist/runtime/locations/auto-connect-reconciler.js +51 -31
- package/dist/runtime/locations/in-memory-authority-store.js +128 -118
- package/dist/runtime/locations/in-memory-location-store.js +195 -168
- package/dist/runtime/locations/in-memory-provider-location-store.js +8 -10
- package/dist/runtime/locations/key-codec.js +1 -1
- package/dist/runtime/locations/lease-tracker.js +23 -21
- package/dist/runtime/locations/lifecycle.js +4 -5
- package/dist/runtime/locations/location-store-repository.js +368 -324
- package/dist/runtime/locations/opaque-record-key.js +2 -2
- package/dist/runtime/locations/resolvers.js +73 -82
- package/dist/runtime/locations/runtime.js +68 -63
- package/dist/runtime/locations/spot-location-claims.js +39 -35
- package/dist/runtime/messaging/framework-json-v1.js +7 -7
- package/dist/runtime/messaging/packet-name.js +7 -6
- package/dist/runtime/messaging/payload-codec.js +21 -18
- package/dist/runtime/protocol/service_wire_codec.generated.d.ts +30 -2
- package/dist/runtime/protocol/service_wire_codec.generated.js +1671 -234
- package/dist/runtime/routing-id.js +3 -5
- package/dist/runtime/spots/formal-remote-actor-admission-registry.js +35 -31
- package/dist/runtime/spots/formal-remote-actor-transfer-registry.js +1 -2
- package/dist/runtime/spots/index.js +208 -219
- package/dist/runtime/spots/spot-activation-registry.js +15 -14
- package/dist/runtime/spots/spot-activation-state.js +17 -15
- package/dist/runtime/spots/spot-activation.js +33 -16
- package/dist/runtime/spots/spot-actor-admission-coordinator.js +18 -15
- package/dist/runtime/spots/spot-actor-membership.js +1 -3
- package/dist/runtime/spots/spot-actor-packet-dispatch.js +23 -20
- package/dist/runtime/spots/spot-actor-packet-drain.js +12 -10
- package/dist/runtime/spots/spot-actor-packet-relay-dispatch.js +10 -6
- package/dist/runtime/spots/spot-closing.js +3 -7
- package/dist/runtime/spots/spot-context.js +2 -2
- package/dist/runtime/spots/spot-entry-activation.js +13 -14
- package/dist/runtime/spots/spot-handle.js +6 -3
- package/dist/runtime/spots/spot-handler-registry.js +12 -12
- package/dist/runtime/spots/spot-manager-public.js +5 -6
- package/dist/runtime/spots/spot-native-actor-join-admission.js +4 -3
- package/dist/runtime/spots/spot-node-autoconnect.js +15 -18
- package/dist/runtime/spots/spot-node-runtime-manager.js +74 -85
- package/dist/runtime/spots/spot-outbound.js +10 -14
- package/dist/runtime/spots/spot-remote-codec.js +22 -26
- package/dist/runtime/spots/spot-remote-route-codec.js +5 -7
- package/dist/runtime/spots/spot-route-packet-dispatch.js +16 -14
- package/dist/runtime/spots/spot-route-replies.js +4 -6
- package/dist/runtime/spots/spot-routed-actor-admission.js +9 -7
- package/dist/runtime/spots/spot-routed-bound-session-dispatch.js +1 -2
- package/dist/runtime/spots/spot-routed-frame-dispatch.js +5 -5
- package/dist/runtime/spots/spot-routed-spot-packet-dispatch.js +14 -10
- package/dist/runtime/spots/spot-serial-executor.js +5 -8
- package/dist/runtime/spots/spot-serial-turn-executor.js +4 -6
- package/dist/runtime/spots/spot-subscription-dispatch.js +5 -5
- package/dist/runtime/spots/spot-timer.js +25 -29
- package/dist/runtime/streams/actor-session-binding-registry.js +98 -107
- package/dist/runtime/streams/actor-session-lifecycle-coordinator.js +3 -1
- package/dist/runtime/streams/bound-actor-relay-sender.js +18 -16
- package/dist/runtime/streams/bound-session-service.js +8 -9
- package/dist/runtime/streams/index.js +20 -19
- package/dist/runtime/streams/managed-stream.js +32 -30
- package/dist/runtime/streams/native-fallback-bound-session.js +21 -17
- package/dist/runtime/streams/protocol.js +29 -18
- package/dist/runtime/streams/session-actor-coordinator.js +34 -37
- package/dist/runtime/streams/session-context.js +30 -28
- package/dist/runtime/streams/session-provider.js +2 -2
- package/dist/runtime/streams/session-serial-executor.js +1 -2
- package/dist/runtime/streams/stream-frame-factory.js +11 -5
- package/dist/runtime/streams/stream-session-runtime.js +70 -66
- package/dist/runtime/workers/index.js +15 -4
- package/package.json +2 -2
- package/src/contracts/Channels/RouteCalls.ts +6 -1
- package/src/contracts/Common/ZLinkMessage.ts +5 -5
- package/src/contracts/Common/ZLinkMessageMetadata.ts +4 -3
- package/src/contracts/Configuration/Builders.ts +14 -14
- package/src/contracts/Configuration/CodecContentType.ts +8 -10
- package/src/contracts/Configuration/DiagnosticsValidation.ts +1 -6
- package/src/contracts/Configuration/EndpointNotation.ts +11 -11
- package/src/contracts/Configuration/ObjectRoles.ts +1 -3
- package/src/contracts/Configuration/Registration.ts +46 -17
- package/src/contracts/Configuration/RegistrationBuilderPolicy.ts +10 -8
- package/src/contracts/Configuration/RegistrationBuilders.ts +107 -96
- package/src/contracts/Configuration/RegistrationCodecRegistry.ts +9 -3
- package/src/contracts/Configuration/RegistrationNormalizers.ts +116 -84
- package/src/contracts/Configuration/RegistrationTypes.ts +21 -25
- package/src/contracts/Configuration/RegistrationValidators.ts +122 -73
- package/src/contracts/Configuration/RouteChannelInternalState.ts +1 -4
- package/src/contracts/Configuration/RuntimeEndpointConnections.ts +4 -1
- package/src/contracts/Configuration/SendTimeoutValidation.ts +6 -4
- package/src/contracts/Configuration/TimerRegistrationValidator.ts +8 -13
- package/src/contracts/Dispatch/ZLinkDispatchOptions.ts +1 -6
- package/src/contracts/Errors/index.ts +1 -4
- package/src/contracts/Handlers/Attributes.ts +15 -9
- package/src/contracts/Handlers/IZLinkChannelHandlers.ts +24 -4
- package/src/contracts/Handlers/JsonContract.ts +53 -19
- package/src/contracts/Locations/ActorTransfer.ts +1 -5
- package/src/contracts/Locations/Authority.ts +4 -11
- package/src/contracts/Locations/Keys.ts +6 -1
- package/src/contracts/Locations/Options.ts +3 -2
- package/src/contracts/Locations/RelocationStore.ts +1 -4
- package/src/contracts/Locations/Resolvers.ts +5 -5
- package/src/contracts/Locations/RuntimeQuery.ts +6 -2
- package/src/contracts/Locations/Stores.ts +1 -2
- package/src/contracts/Locations/index.ts +2 -8
- package/src/contracts/RouteMesh/Contracts.ts +1 -7
- package/src/contracts/RouteMesh/RuntimeTopology.ts +1 -4
- package/src/contracts/Spots/Contracts.ts +2 -8
- package/src/contracts/Spots/SpotKind.ts +16 -8
- package/src/contracts/Spots/ZLinkSpot.ts +8 -11
- package/src/contracts/Streams/IZLinkSession.ts +0 -1
- package/src/contracts/Streams/IZLinkSessionActor.ts +5 -1
- package/src/contracts/Streams/IZLinkSessionPacketHandler.ts +5 -1
- package/src/internal.ts +5 -4
- package/src/location-store-integration.ts +24 -16
- package/src/nest-integration.ts +40 -25
- package/src/runtime/abort.ts +10 -4
- package/src/runtime/actors/actor-authority-payload-codec.ts +20 -29
- package/src/runtime/actors/actor-authority-publication.ts +92 -77
- package/src/runtime/actors/actor-client.ts +162 -133
- package/src/runtime/actors/actor-context.ts +138 -130
- package/src/runtime/actors/actor-creation.ts +47 -44
- package/src/runtime/actors/actor-execution-context.ts +6 -4
- package/src/runtime/actors/actor-handoff.ts +269 -293
- package/src/runtime/actors/actor-join-deferred-scope.ts +5 -4
- package/src/runtime/actors/actor-lifecycle-snapshot.ts +5 -8
- package/src/runtime/actors/actor-local-native-join.ts +131 -159
- package/src/runtime/actors/actor-mailbox.ts +16 -19
- package/src/runtime/actors/actor-message-follow-context.ts +46 -36
- package/src/runtime/actors/actor-packet-relay-wire.ts +32 -21
- package/src/runtime/actors/actor-remote-joiner.ts +50 -54
- package/src/runtime/actors/actor-remote-wire.ts +9 -13
- package/src/runtime/actors/actor-routed-join-transport.ts +10 -2
- package/src/runtime/actors/actor-runtime-contracts.ts +2 -5
- package/src/runtime/actors/actor-runtime-state.ts +127 -124
- package/src/runtime/actors/actor-transfer-registry.ts +9 -14
- package/src/runtime/actors/actor-transport-delivery-gate.ts +4 -6
- package/src/runtime/actors/bound-session-wire.ts +37 -17
- package/src/runtime/actors/deferred-join-accepted-journal.ts +351 -320
- package/src/runtime/actors/index.ts +43 -86
- package/src/runtime/actors/post-commit-actor-binder.ts +10 -10
- package/src/runtime/actors/post-commit-actor-location.ts +30 -23
- package/src/runtime/actors/spot-actor-dispatch.ts +78 -53
- package/src/runtime/actors/transferred-actor-rollback.ts +18 -13
- package/src/runtime/admission.ts +9 -9
- package/src/runtime/application-jobs/application-ingress-record-owner.ts +5 -15
- package/src/runtime/application-jobs/application-job-queue-handler-start-gate.ts +3 -2
- package/src/runtime/application-jobs/receive-flow-controller.ts +17 -14
- package/src/runtime/backend/contracts/index.ts +73 -52
- package/src/runtime/backend/mesh-actor-session-node-adapter.ts +4 -14
- package/src/runtime/backend/mesh-completion-table.ts +6 -9
- package/src/runtime/backend/mesh-dispatch-pump.ts +38 -30
- package/src/runtime/backend/node/node-backend-adapter-factory.ts +23 -21
- package/src/runtime/backend/node/node-backend-adapter-support.ts +36 -22
- package/src/runtime/backend/node/node-dealer-channel-client-transport.ts +59 -58
- package/src/runtime/backend/node/node-event-loop-poller.ts +2 -10
- package/src/runtime/backend/node/node-mesh-backend-adapter.ts +12 -5
- package/src/runtime/backend/node/node-monitor-backend-adapter.ts +4 -3
- package/src/runtime/backend/node/node-raw-binding-port.ts +29 -29
- package/src/runtime/backend/node/node-raw-mesh-backend.ts +335 -383
- package/src/runtime/backend/node/node-socket-backend-adapter.ts +101 -54
- package/src/runtime/backend/runtime-message.ts +5 -3
- package/src/runtime/backend/runtime-values.ts +10 -7
- package/src/runtime/channels/channel-autoconnect.ts +1 -4
- package/src/runtime/channels/channel-clients.ts +93 -73
- package/src/runtime/channels/channel-dispatch-pipeline.ts +40 -42
- package/src/runtime/channels/channel-dispatch-services.ts +51 -49
- package/src/runtime/channels/channel-dispatchers.ts +152 -96
- package/src/runtime/channels/channel-envelope-inspection.ts +20 -16
- package/src/runtime/channels/channel-envelope.ts +256 -150
- package/src/runtime/channels/channel-multipart.ts +13 -5
- package/src/runtime/channels/channel-outbound-operations.ts +37 -41
- package/src/runtime/channels/channel-receive-loops.ts +102 -98
- package/src/runtime/channels/channel-receive-task-tracker.ts +1 -1
- package/src/runtime/channels/channel-runtime-lifecycle.ts +248 -190
- package/src/runtime/channels/channel-runtime-manager.ts +63 -37
- package/src/runtime/channels/channel-socket-options.ts +3 -10
- package/src/runtime/channels/channel-socket-registry.ts +331 -273
- package/src/runtime/channels/channel-transports.ts +215 -197
- package/src/runtime/channels/client-server-location-runtime.ts +116 -100
- package/src/runtime/channels/client-server-service-wire.ts +37 -36
- package/src/runtime/channels/dispatch-error-reporter.ts +11 -8
- package/src/runtime/channels/fanout-location-runtime.ts +91 -94
- package/src/runtime/channels/fanout-service-wire.ts +5 -12
- package/src/runtime/channels/handler-filter-scope.ts +1 -4
- package/src/runtime/channels/index.ts +1 -4
- package/src/runtime/channels/local-spot-route-transport.ts +20 -5
- package/src/runtime/channels/route-member-snapshot.ts +11 -5
- package/src/runtime/channels/router-socket-spot-route-transport.ts +1 -7
- package/src/runtime/channels/source-spot-router.ts +26 -22
- package/src/runtime/channels/spot-direct-envelope.ts +10 -8
- package/src/runtime/channels/spot-node-route-transport.ts +13 -16
- package/src/runtime/channels/spot-route-bridge-transport.ts +26 -9
- package/src/runtime/channels/spot-route-dispatch-strategy.ts +40 -13
- package/src/runtime/channels/spot-route-target-resolver.ts +18 -9
- package/src/runtime/codecs/index.ts +3 -2
- package/src/runtime/diagnostics/flow-context.ts +12 -3
- package/src/runtime/diagnostics/index.ts +96 -61
- package/src/runtime/diagnostics/internal-event-contracts.ts +87 -33
- package/src/runtime/diagnostics/message-flow.ts +95 -76
- package/src/runtime/diagnostics/runtime-metrics.ts +46 -24
- package/src/runtime/diagnostics/runtime-observation-queue.ts +17 -28
- package/src/runtime/diagnostics/topology-runtime-projections.ts +62 -43
- package/src/runtime/execution/index.ts +18 -26
- package/src/runtime/execution/serial-execution-queue.ts +31 -40
- package/src/runtime/execution/state-lane.ts +2 -2
- package/src/runtime/foundation/actor-join-recovery-codec.ts +69 -51
- package/src/runtime/foundation/event-loop-resources.ts +8 -4
- package/src/runtime/foundation/message-follow-suppression-registry.ts +7 -14
- package/src/runtime/foundation/operation-identity.ts +1 -2
- package/src/runtime/foundation/operation-registry.ts +8 -2
- package/src/runtime/foundation/raw-service-mesh-runtime.ts +312 -385
- package/src/runtime/foundation/route-mesh-connection-policy.ts +7 -8
- package/src/runtime/foundation/runtime-state-projections.ts +24 -23
- package/src/runtime/foundation/service-authority-payload-codec.ts +54 -57
- package/src/runtime/foundation/service-discovery-registry.ts +67 -59
- package/src/runtime/foundation/service-instance-activation-recovery-codec.ts +28 -29
- package/src/runtime/foundation/service-liveness-registry.ts +18 -13
- package/src/runtime/foundation/service-mailbox.ts +14 -14
- package/src/runtime/foundation/service-maintenance-runtime.ts +22 -21
- package/src/runtime/foundation/service-metadata-codec.ts +2 -9
- package/src/runtime/foundation/service-relocation-aggregate-committer.ts +39 -36
- package/src/runtime/foundation/service-relocation-coordinator.ts +1 -4
- package/src/runtime/foundation/service-relocation-object-owner.ts +40 -58
- package/src/runtime/foundation/service-relocation-runtime.ts +292 -216
- package/src/runtime/foundation/service-runtime-contracts.ts +8 -8
- package/src/runtime/foundation/service-session-binding-ingress-port.ts +1 -4
- package/src/runtime/foundation/service-stateful-registry.ts +69 -59
- package/src/runtime/foundation/service-stateful-runtime.ts +1174 -1112
- package/src/runtime/foundation/service-stateful-wire-codec.ts +318 -270
- package/src/runtime/foundation/service-topology-registry.ts +157 -159
- package/src/runtime/foundation/service-weighted-selection.ts +9 -15
- package/src/runtime/foundation/service-wire-binary-primitives.ts +6 -12
- package/src/runtime/foundation/service-wire-m6a-codec.ts +69 -47
- package/src/runtime/framework-errors-internal.ts +31 -30
- package/src/runtime/handlers/handler-instance-scope.ts +18 -29
- package/src/runtime/handlers/index.ts +18 -8
- package/src/runtime/host/actor-packet-relay.ts +290 -261
- package/src/runtime/host/actor-placement-coordinator.ts +165 -150
- package/src/runtime/host/actor-runtime-options-factory.ts +89 -87
- package/src/runtime/host/actor-transfer-authority-runtime.ts +46 -38
- package/src/runtime/host/actor-transfer-runtime.ts +391 -395
- package/src/runtime/host/application-job-queue.ts +32 -48
- package/src/runtime/host/bound-session-relay.ts +7 -9
- package/src/runtime/host/channel-runtime-options-factory.ts +75 -35
- package/src/runtime/host/host-capacity-status.ts +10 -9
- package/src/runtime/host/index.ts +861 -789
- package/src/runtime/host/instance-activation-authority.ts +125 -143
- package/src/runtime/host/location-runtime-owner.ts +38 -26
- package/src/runtime/host/mesh-router-resolver.ts +30 -23
- package/src/runtime/host/relocation-direct-transfer.ts +15 -15
- package/src/runtime/host/relocation-integrity-fault-gate.ts +3 -2
- package/src/runtime/host/remote-actor-join-receiver.ts +43 -34
- package/src/runtime/host/remote-actor-packet-target-store.ts +54 -52
- package/src/runtime/host/remote-bound-session-relay.ts +274 -247
- package/src/runtime/host/route-mesh-runtime-options.ts +1 -3
- package/src/runtime/host/route-mesh-runtime.ts +227 -181
- package/src/runtime/host/runtime-shutdown.ts +4 -3
- package/src/runtime/host/service-relocation-control.ts +14 -5
- package/src/runtime/host/service-relocation-host-runtime.ts +1388 -1165
- package/src/runtime/host/spot-address-transport.ts +284 -237
- package/src/runtime/host/spot-node-runtime-options-factory.ts +14 -8
- package/src/runtime/host/spot-runtime-options-factory.ts +71 -62
- package/src/runtime/host/stateful-authority-route-runtime.ts +117 -116
- package/src/runtime/host/user-spot-creation-coordinator.ts +225 -220
- package/src/runtime/locations/actor-location-claims.ts +61 -49
- package/src/runtime/locations/actor-session-route-claims.ts +1 -4
- package/src/runtime/locations/aggregate-inventory-store.ts +105 -134
- package/src/runtime/locations/authority-key-codec.ts +13 -10
- package/src/runtime/locations/auto-connect-loop.ts +14 -11
- package/src/runtime/locations/auto-connect-planner.ts +42 -31
- package/src/runtime/locations/auto-connect-reconciler.ts +106 -63
- package/src/runtime/locations/canonical-codec.ts +3 -1
- package/src/runtime/locations/creation-operation-id.ts +4 -3
- package/src/runtime/locations/domain-store-contract.ts +13 -7
- package/src/runtime/locations/in-memory-authority-store.ts +232 -199
- package/src/runtime/locations/in-memory-location-store.ts +432 -250
- package/src/runtime/locations/in-memory-provider-location-store.ts +16 -17
- package/src/runtime/locations/internal-store-contracts.ts +95 -38
- package/src/runtime/locations/key-codec.ts +3 -4
- package/src/runtime/locations/lease-tracker.ts +36 -27
- package/src/runtime/locations/lifecycle-runtime.ts +15 -3
- package/src/runtime/locations/lifecycle.ts +33 -28
- package/src/runtime/locations/location-store-repository.ts +1329 -1185
- package/src/runtime/locations/opaque-record-key.ts +4 -9
- package/src/runtime/locations/resolvers.ts +201 -178
- package/src/runtime/locations/runtime.ts +251 -159
- package/src/runtime/locations/spot-location-claims.ts +110 -112
- package/src/runtime/messaging/creation-payload-codec.ts +4 -1
- package/src/runtime/messaging/framework-json-v1.ts +34 -15
- package/src/runtime/messaging/packet-name.ts +8 -6
- package/src/runtime/messaging/payload-codec.ts +70 -50
- package/src/runtime/messaging/submission-result.ts +6 -9
- package/src/runtime/protocol/service_wire_codec.generated.ts +1376 -159
- package/src/runtime/protocol/service_wire_pilot_codec.generated.ts +1 -1
- package/src/runtime/routing-id.ts +10 -7
- package/src/runtime/spots/formal-remote-actor-admission-registry.ts +56 -62
- package/src/runtime/spots/formal-remote-actor-transfer-registry.ts +23 -20
- package/src/runtime/spots/index.ts +593 -563
- package/src/runtime/spots/spot-activation-registry.ts +38 -34
- package/src/runtime/spots/spot-activation-state.ts +43 -51
- package/src/runtime/spots/spot-activation.ts +179 -116
- package/src/runtime/spots/spot-actor-admission-coordinator.ts +110 -78
- package/src/runtime/spots/spot-actor-join-dispatch.ts +57 -41
- package/src/runtime/spots/spot-actor-lifecycle-drain.ts +5 -7
- package/src/runtime/spots/spot-actor-membership.ts +25 -27
- package/src/runtime/spots/spot-actor-packet-dispatch.ts +184 -153
- package/src/runtime/spots/spot-actor-packet-drain.ts +54 -42
- package/src/runtime/spots/spot-actor-packet-relay-dispatch.ts +37 -39
- package/src/runtime/spots/spot-closing.ts +11 -12
- package/src/runtime/spots/spot-context.ts +46 -26
- package/src/runtime/spots/spot-entry-activation.ts +84 -65
- package/src/runtime/spots/spot-handle.ts +17 -15
- package/src/runtime/spots/spot-handler-registry.ts +44 -31
- package/src/runtime/spots/spot-location-claim.ts +5 -4
- package/src/runtime/spots/spot-manager-public.ts +62 -82
- package/src/runtime/spots/spot-native-actor-join-admission.ts +20 -16
- package/src/runtime/spots/spot-node-autoconnect.ts +54 -61
- package/src/runtime/spots/spot-node-runtime-manager.ts +230 -221
- package/src/runtime/spots/spot-outbound.ts +47 -59
- package/src/runtime/spots/spot-publisher-transport.ts +5 -4
- package/src/runtime/spots/spot-remote-codec.ts +66 -65
- package/src/runtime/spots/spot-remote-route-codec.ts +61 -41
- package/src/runtime/spots/spot-route-packet-dispatch.ts +128 -95
- package/src/runtime/spots/spot-route-replies.ts +23 -24
- package/src/runtime/spots/spot-route-reply-wire.ts +3 -2
- package/src/runtime/spots/spot-routed-actor-admission.ts +37 -27
- package/src/runtime/spots/spot-routed-bound-session-dispatch.ts +11 -17
- package/src/runtime/spots/spot-routed-frame-dispatch.ts +18 -15
- package/src/runtime/spots/spot-routed-spot-packet-dispatch.ts +35 -26
- package/src/runtime/spots/spot-routing-internal.ts +1 -4
- package/src/runtime/spots/spot-runtime-ports.ts +5 -5
- package/src/runtime/spots/spot-serial-executor.ts +5 -9
- package/src/runtime/spots/spot-serial-turn-executor.ts +19 -26
- package/src/runtime/spots/spot-subscription-dispatch.ts +56 -46
- package/src/runtime/spots/spot-timer.ts +98 -91
- package/src/runtime/streams/actor-session-binding-registry.ts +277 -235
- package/src/runtime/streams/actor-session-binding-runtime-owner.ts +7 -4
- package/src/runtime/streams/actor-session-lifecycle-coordinator.ts +3 -1
- package/src/runtime/streams/bound-actor-relay-sender.ts +53 -51
- package/src/runtime/streams/bound-session-response-target.ts +29 -8
- package/src/runtime/streams/bound-session-service.ts +39 -39
- package/src/runtime/streams/index.ts +176 -100
- package/src/runtime/streams/managed-stream.ts +98 -87
- package/src/runtime/streams/native-fallback-bound-session.ts +57 -52
- package/src/runtime/streams/protocol.ts +73 -43
- package/src/runtime/streams/session-actor-coordinator.ts +97 -89
- package/src/runtime/streams/session-calls.ts +2 -8
- package/src/runtime/streams/session-context.ts +66 -48
- package/src/runtime/streams/session-provider.ts +5 -7
- package/src/runtime/streams/session-serial-executor.ts +7 -6
- package/src/runtime/streams/stream-binding-runtime-ports.ts +79 -29
- package/src/runtime/streams/stream-frame-factory.ts +55 -38
- package/src/runtime/streams/stream-session-runtime.ts +268 -210
- package/src/runtime/workers/index.ts +68 -29
|
@@ -135,11 +135,14 @@ class ZLinkFrameworkRuntimeHost {
|
|
|
135
135
|
this.options = options;
|
|
136
136
|
this.backendAdapterFactory = resolveBackendAdapterFactory(internalOptions);
|
|
137
137
|
this.lifecycleSink = options.lifecycleSink;
|
|
138
|
-
this.runtimeEventPublisher =
|
|
138
|
+
this.runtimeEventPublisher =
|
|
139
|
+
options.runtimeEventPublisher ?? new diagnostics_1.DefaultZLinkRuntimeEventPublisher();
|
|
139
140
|
this.metrics = new diagnostics_1.ZLinkRuntimeMetrics(options.registration.metrics?.meterProvider);
|
|
140
141
|
this.applicationJobQueue = new application_job_queue_1.ApplicationJobQueue((0, application_job_queue_1.resolveApplicationJobQueueConfiguration)(options.registration.applicationJobQueue, () => (0, application_job_queue_1.nodeEffectiveProcessorCount)(options.registration.worker?.maxThreads)), undefined, () => {
|
|
141
142
|
try {
|
|
142
|
-
return this.options.providerResolver
|
|
143
|
+
return (this.options.providerResolver
|
|
144
|
+
?.get?.(application_job_queue_handler_start_gate_1.ZLINK_INTERNAL_APPLICATION_JOB_QUEUE_HANDLER_START_GATE)
|
|
145
|
+
?.shouldHoldPermitBeforeHandler() === true);
|
|
143
146
|
}
|
|
144
147
|
catch {
|
|
145
148
|
return false;
|
|
@@ -150,8 +153,8 @@ class ZLinkFrameworkRuntimeHost {
|
|
|
150
153
|
this.fanoutRuntime = new topology_runtime_projections_1.ZLinkFanoutRuntimeProjection(() => this.channelRuntime, () => this.runtimeState);
|
|
151
154
|
this.meshRouters = new mesh_router_resolver_1.MeshRouterResolver(options.registration);
|
|
152
155
|
this.spotRouterChannelIdForMesh = this.meshRouters.spotRouterChannelIdByMesh();
|
|
153
|
-
const sendTimeoutMsForSpotMesh = (meshName) => options.registration.spotNodes.get(meshName)?.router?.sendTimeoutMs
|
|
154
|
-
|
|
156
|
+
const sendTimeoutMsForSpotMesh = (meshName) => options.registration.spotNodes.get(meshName)?.router?.sendTimeoutMs ??
|
|
157
|
+
LEGACY_MESH_SEND_TIMEOUT_MS;
|
|
155
158
|
const sendTimeoutMsForSpotRouteChannel = (routeChannelId) => {
|
|
156
159
|
const routeChannel = options.registration.routeChannelOptions.get(routeChannelId);
|
|
157
160
|
if (routeChannel !== undefined) {
|
|
@@ -159,7 +162,7 @@ class ZLinkFrameworkRuntimeHost {
|
|
|
159
162
|
}
|
|
160
163
|
return sendTimeoutMsForSpotMesh(routeChannelId);
|
|
161
164
|
};
|
|
162
|
-
const defaultSpotSendTimeoutMs = Math.max(LEGACY_MESH_SEND_TIMEOUT_MS, ...[...options.registration.spotNodes.values()].map(node => node.router?.sendTimeoutMs ?? LEGACY_MESH_SEND_TIMEOUT_MS), ...[...options.registration.routeChannelOptions.values()].map(route => route.sendTimeoutMs ?? LEGACY_MESH_SEND_TIMEOUT_MS));
|
|
165
|
+
const defaultSpotSendTimeoutMs = Math.max(LEGACY_MESH_SEND_TIMEOUT_MS, ...[...options.registration.spotNodes.values()].map((node) => node.router?.sendTimeoutMs ?? LEGACY_MESH_SEND_TIMEOUT_MS), ...[...options.registration.routeChannelOptions.values()].map((route) => route.sendTimeoutMs ?? LEGACY_MESH_SEND_TIMEOUT_MS));
|
|
163
166
|
this.routeTransport = new channels_1.ZLinkRuntimeRouteTransport(() => this.channelRuntime, (routerChannelId) => this.meshRouters.canUseRouterChannel(routerChannelId), () => this.spotNodeRuntime, { serializers: options.registration.messageSerializers }, (meshName, targetNodeRid) => this.meshRouters.classifyManualNodeTarget(meshName, targetNodeRid), (meshName, sourceNodeRid, parts) => this.submitLocalMeshRoute(meshName, sourceNodeRid, parts), this.metrics, () => this.flowCreationEnabled());
|
|
164
167
|
this.spotAddressTransport = new spot_address_transport_1.ZLinkHostSpotAddressTransport({
|
|
165
168
|
resolver: () => this.createLocationSpotRouteResolver(),
|
|
@@ -188,16 +191,15 @@ class ZLinkFrameworkRuntimeHost {
|
|
|
188
191
|
streamPayloadCodec: resolveStreamPayloadCodec(options.registration),
|
|
189
192
|
streamCompression: options.registration.streamCompression,
|
|
190
193
|
messageSerializers: options.registration.messageSerializers,
|
|
191
|
-
sessionRelocationSealTimeoutMs: options.registration.locations.options.sessionRelocationSealTimeoutMs
|
|
192
|
-
|
|
194
|
+
sessionRelocationSealTimeoutMs: options.registration.locations.options.sessionRelocationSealTimeoutMs ??
|
|
195
|
+
Locations_1.zlinkDefaultLocationOptions.sessionRelocationSealTimeoutMs,
|
|
193
196
|
metrics: this.metrics,
|
|
194
197
|
flowCreationEnabled: () => this.flowCreationEnabled(),
|
|
195
198
|
errorSink: () => this.errorSink ?? this.preStartErrorSink,
|
|
196
199
|
nativeActorNodeProvider: () => this.spotNodeRuntime?.primaryMeshNode,
|
|
197
200
|
nativeActorMeshNameProvider: () => this.meshRouters.primaryMeshName(),
|
|
198
201
|
actorAuthorityFenceResolver: async (actorId, signal) => {
|
|
199
|
-
const resolution = await this.createActorLocationResolver()
|
|
200
|
-
?.resolveDirectActorRoute(actorId, signal);
|
|
202
|
+
const resolution = await this.createActorLocationResolver()?.resolveDirectActorRoute(actorId, signal);
|
|
201
203
|
return resolution === undefined || resolution.kind !== 'ready'
|
|
202
204
|
? undefined
|
|
203
205
|
: {
|
|
@@ -227,18 +229,16 @@ class ZLinkFrameworkRuntimeHost {
|
|
|
227
229
|
const state = this.actorManager?.getState(actorId);
|
|
228
230
|
const current = state?.nativeActorRef;
|
|
229
231
|
const meshName = state?.meshName;
|
|
230
|
-
const node = meshName === undefined
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|| state.ownerLeaseGeneration !== owner.leaseGeneration
|
|
241
|
-
|| !(0, routing_id_1.routingIdsEqual)(node.routingId, current.nodeRid)) {
|
|
232
|
+
const node = meshName === undefined ? undefined : this.spotNodeRuntime?.meshNode(meshName)?.status();
|
|
233
|
+
if (owner === undefined ||
|
|
234
|
+
state === undefined ||
|
|
235
|
+
current === undefined ||
|
|
236
|
+
meshName === undefined ||
|
|
237
|
+
node === undefined ||
|
|
238
|
+
state.locationGeneration === undefined ||
|
|
239
|
+
state.ownerLeaseGeneration === undefined ||
|
|
240
|
+
state.ownerLeaseGeneration !== owner.leaseGeneration ||
|
|
241
|
+
!(0, routing_id_1.routingIdsEqual)(node.routingId, current.nodeRid)) {
|
|
242
242
|
throw new ConfigurationException_1.ZLinkConfigurationException(`Actor '${actorId}' handoff requires a committed source owner fence.`);
|
|
243
243
|
}
|
|
244
244
|
return {
|
|
@@ -255,17 +255,20 @@ class ZLinkFrameworkRuntimeHost {
|
|
|
255
255
|
validateReplySource: (source) => {
|
|
256
256
|
const owner = this.locationOwner.currentRuntime?.currentOwnerToken;
|
|
257
257
|
const node = this.spotNodeRuntime?.meshNode(source.meshName)?.status();
|
|
258
|
-
if (owner === undefined ||
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
258
|
+
if (owner === undefined ||
|
|
259
|
+
node === undefined ||
|
|
260
|
+
owner.ownerId !== source.ownerId ||
|
|
261
|
+
owner.leaseGeneration !== source.ownerLeaseGeneration ||
|
|
262
|
+
node.lifecycleGeneration !== source.nodeGeneration) {
|
|
262
263
|
return false;
|
|
263
264
|
}
|
|
264
265
|
return (0, routing_id_1.routingIdsEqual)(node.routingId, (0, routing_id_1.decodeRoutingId)(source.nodeRid, source.nodeRidHex));
|
|
265
266
|
},
|
|
266
267
|
onMarker: (marker, actorId, index, context) => {
|
|
267
268
|
if (marker === 'message_follow_relay' && context !== undefined) {
|
|
268
|
-
this.options.providerResolver
|
|
269
|
+
this.options.providerResolver
|
|
270
|
+
?.get?.(actor_transport_delivery_gate_1.ZLINK_INTERNAL_ACTOR_TRANSPORT_DELIVERY_GATE)
|
|
271
|
+
?.recordMessageFollowRelay?.(actorId, context);
|
|
269
272
|
}
|
|
270
273
|
if (marker === 'message_follow_route_removed') {
|
|
271
274
|
this.serviceRelocation.completeActorJoinSourceCleanup(actorId);
|
|
@@ -333,8 +336,9 @@ class ZLinkFrameworkRuntimeHost {
|
|
|
333
336
|
const current = state?.nativeActorRef;
|
|
334
337
|
if (actorRef === undefined)
|
|
335
338
|
return state?.remoteActorPacketTarget !== undefined;
|
|
336
|
-
return current !== undefined &&
|
|
337
|
-
|
|
339
|
+
return (current !== undefined &&
|
|
340
|
+
(current.generation !== actorRef.objectGeneration ||
|
|
341
|
+
!(0, routing_id_1.routingIdsEqual)(current.nodeRid, actorRef.nodeRid)));
|
|
338
342
|
},
|
|
339
343
|
isCurrentHandoffTarget: (actorId, spotId) => {
|
|
340
344
|
const currentSpotId = this.actorManager?.getState(actorId)?.spotId;
|
|
@@ -342,9 +346,9 @@ class ZLinkFrameworkRuntimeHost {
|
|
|
342
346
|
},
|
|
343
347
|
isCurrentActorRef: (actorId, actorRef) => {
|
|
344
348
|
const current = this.actorManager?.getState(actorId)?.nativeActorRef;
|
|
345
|
-
return current !== undefined
|
|
346
|
-
|
|
347
|
-
|
|
349
|
+
return (current !== undefined &&
|
|
350
|
+
current.generation === actorRef.objectGeneration &&
|
|
351
|
+
(0, routing_id_1.routingIdsEqual)(current.nodeRid, actorRef.nodeRid));
|
|
348
352
|
},
|
|
349
353
|
currentOwnerFence: (actorId) => {
|
|
350
354
|
const state = this.actorManager?.getState(actorId);
|
|
@@ -353,10 +357,13 @@ class ZLinkFrameworkRuntimeHost {
|
|
|
353
357
|
const node = state?.meshName === undefined
|
|
354
358
|
? undefined
|
|
355
359
|
: this.spotNodeRuntime?.meshNode(state.meshName)?.status();
|
|
356
|
-
if (state === undefined ||
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
+
if (state === undefined ||
|
|
361
|
+
current === undefined ||
|
|
362
|
+
owner === undefined ||
|
|
363
|
+
node === undefined ||
|
|
364
|
+
state.locationGeneration === undefined ||
|
|
365
|
+
state.ownerLeaseGeneration === undefined ||
|
|
366
|
+
!(0, routing_id_1.routingIdsEqual)(node.routingId, current.nodeRid)) {
|
|
360
367
|
return undefined;
|
|
361
368
|
}
|
|
362
369
|
return (0, actor_message_follow_context_1.ownerFence)({
|
|
@@ -373,8 +380,8 @@ class ZLinkFrameworkRuntimeHost {
|
|
|
373
380
|
this.boundSessionFactory = new streams_1.DefaultZLinkBoundSessionFactory(this.streamBindingRuntime);
|
|
374
381
|
this.boundSessionRelay = new bound_session_relay_1.ZLinkBoundSessionRelay({
|
|
375
382
|
requestTimeoutMs: options.registration.requestTimeoutMs,
|
|
376
|
-
sessionRelocationSealTimeoutMs: options.registration.locations.options.sessionRelocationSealTimeoutMs
|
|
377
|
-
|
|
383
|
+
sessionRelocationSealTimeoutMs: options.registration.locations.options.sessionRelocationSealTimeoutMs ??
|
|
384
|
+
Locations_1.zlinkDefaultLocationOptions.sessionRelocationSealTimeoutMs,
|
|
378
385
|
routeTransport: this.routeTransport,
|
|
379
386
|
streamBindingRuntime: () => this.streamBindingRuntime,
|
|
380
387
|
meshRouters: this.meshRouters,
|
|
@@ -384,8 +391,8 @@ class ZLinkFrameworkRuntimeHost {
|
|
|
384
391
|
detachedTaskRunner: this.detachedTaskRunner(),
|
|
385
392
|
actorSessionNode: (actorId) => {
|
|
386
393
|
const state = this.actorManager?.getState(actorId);
|
|
387
|
-
const meshName = state?.meshName
|
|
388
|
-
|
|
394
|
+
const meshName = state?.meshName ??
|
|
395
|
+
(state?.actorType === undefined
|
|
389
396
|
? undefined
|
|
390
397
|
: this.meshRouters.actorMeshName(state.actorType));
|
|
391
398
|
const runtime = this.spotNodeRuntime;
|
|
@@ -502,8 +509,8 @@ class ZLinkFrameworkRuntimeHost {
|
|
|
502
509
|
providerResolver: options.providerResolver,
|
|
503
510
|
locationStore: () => this.locationOwner.currentStores?.locationStore,
|
|
504
511
|
currentOwner: () => this.locationOwner.currentRuntime?.currentOwnerToken,
|
|
505
|
-
liveDescriptors: (meshName, signal) => this.locationOwner.currentRuntime?.listLiveMeshNodes(meshName, signal)
|
|
506
|
-
|
|
512
|
+
liveDescriptors: (meshName, signal) => this.locationOwner.currentRuntime?.listLiveMeshNodes(meshName, signal) ??
|
|
513
|
+
Promise.resolve([]),
|
|
507
514
|
localDescriptor: (meshName) => this.spotNodeRuntime?.meshNodeDescriptor(meshName),
|
|
508
515
|
meshNode: (meshName) => this.spotNodeRuntime?.meshNode(meshName),
|
|
509
516
|
completions: (meshName) => this.spotNodeRuntime?.meshCompletionTable(meshName),
|
|
@@ -513,7 +520,7 @@ class ZLinkFrameworkRuntimeHost {
|
|
|
513
520
|
actorTransfer: this.actorTransferRuntime,
|
|
514
521
|
boundSessionRelocation: {
|
|
515
522
|
receiveSeal: (value, signal) => this.boundSessionRelay.boundSessions.receiveServiceWireSessionRelocationSeal(value, signal),
|
|
516
|
-
receiveRoute: value => this.boundSessionRelay.boundSessions.receiveServiceWireSessionRelocationRoute(value),
|
|
523
|
+
receiveRoute: (value) => this.boundSessionRelay.boundSessions.receiveServiceWireSessionRelocationRoute(value),
|
|
517
524
|
clear: () => this.boundSessionRelay.boundSessions.clearServiceWireSessionRelocations()
|
|
518
525
|
},
|
|
519
526
|
trackInstanceSpot: (input) => this.locationOwner.currentLifecycle?.trackInstanceSpot(input),
|
|
@@ -550,9 +557,7 @@ class ZLinkFrameworkRuntimeHost {
|
|
|
550
557
|
return true;
|
|
551
558
|
}
|
|
552
559
|
const runtime = this.locationOwner.currentRuntime;
|
|
553
|
-
return runtime !== undefined
|
|
554
|
-
&& runtime.ownerLeaseUsable
|
|
555
|
-
&& runtime.lastError === undefined;
|
|
560
|
+
return runtime !== undefined && runtime.ownerLeaseUsable && runtime.lastError === undefined;
|
|
556
561
|
},
|
|
557
562
|
hostState: () => this.runtimeState,
|
|
558
563
|
admission: this.admission,
|
|
@@ -731,8 +736,8 @@ class ZLinkFrameworkRuntimeHost {
|
|
|
731
736
|
try {
|
|
732
737
|
this.admission.close();
|
|
733
738
|
this.setRuntimeState(contracts_1.ZLinkFrameworkRuntimeState.Draining);
|
|
734
|
-
if (this.relocationOperation !== undefined
|
|
735
|
-
|
|
739
|
+
if (this.relocationOperation !== undefined &&
|
|
740
|
+
this.relocationStopStarting?.signal.aborted === true) {
|
|
736
741
|
await this.relocationOperation;
|
|
737
742
|
}
|
|
738
743
|
// Seal application admission before the public status reports that the
|
|
@@ -795,9 +800,7 @@ class ZLinkFrameworkRuntimeHost {
|
|
|
795
800
|
if (this.relocationOperationStartedAt !== undefined) {
|
|
796
801
|
this.metrics.duration('zlink.host.relocation.duration', Math.max(0, performance.now() - this.relocationOperationStartedAt) / 1000, {
|
|
797
802
|
mode: relocationModeMetricName(result.mode),
|
|
798
|
-
outcome: result.outcome === contracts_1.ZLinkFrameworkRelocationOutcome.Relocated
|
|
799
|
-
? 'relocated'
|
|
800
|
-
: 'blocked'
|
|
803
|
+
outcome: result.outcome === contracts_1.ZLinkFrameworkRelocationOutcome.Relocated ? 'relocated' : 'blocked'
|
|
801
804
|
});
|
|
802
805
|
}
|
|
803
806
|
if (result.outcome === contracts_1.ZLinkFrameworkRelocationOutcome.Blocked) {
|
|
@@ -863,10 +866,8 @@ class ZLinkFrameworkRuntimeHost {
|
|
|
863
866
|
notifyTopologyHostStateChanged() {
|
|
864
867
|
const callbacks = [
|
|
865
868
|
() => this.routeMeshCoordinator.hostStateChanged(),
|
|
866
|
-
() => this.clientServerRuntime
|
|
867
|
-
|
|
868
|
-
() => this.fanoutRuntime
|
|
869
|
-
.hostStateChanged()
|
|
869
|
+
() => this.clientServerRuntime.hostStateChanged(),
|
|
870
|
+
() => this.fanoutRuntime.hostStateChanged()
|
|
870
871
|
];
|
|
871
872
|
for (const callback of callbacks) {
|
|
872
873
|
try {
|
|
@@ -885,10 +886,8 @@ class ZLinkFrameworkRuntimeHost {
|
|
|
885
886
|
stopTopologyObservers() {
|
|
886
887
|
const callbacks = [
|
|
887
888
|
() => this.routeMeshCoordinator.stopObservers(),
|
|
888
|
-
() => this.clientServerRuntime
|
|
889
|
-
|
|
890
|
-
() => this.fanoutRuntime
|
|
891
|
-
.stopObservers()
|
|
889
|
+
() => this.clientServerRuntime.stopObservers(),
|
|
890
|
+
() => this.fanoutRuntime.stopObservers()
|
|
892
891
|
];
|
|
893
892
|
for (const callback of callbacks) {
|
|
894
893
|
try {
|
|
@@ -963,8 +962,7 @@ class ZLinkFrameworkRuntimeHost {
|
|
|
963
962
|
this.executionState = new execution_1.ZLinkFrameworkExecutionState(context);
|
|
964
963
|
// Seed the shared live-mode cell from the configured mode (default errorsOnly).
|
|
965
964
|
this.messageFlowModeCell.mode =
|
|
966
|
-
this.options.registration.dispatch?.diagnostics.messageFlow ??
|
|
967
|
-
'errors';
|
|
965
|
+
this.options.registration.dispatch?.diagnostics.messageFlow ?? 'errors';
|
|
968
966
|
const dispatchErrors = this.createDispatchErrorReporter(this.executionState.errorSink);
|
|
969
967
|
channelRuntime = new channels_1.ZLinkChannelRuntimeManager(this.options.registration, channelAdapter, context, this.options.providerResolver, this.createChannelRuntimeOptions());
|
|
970
968
|
this.channelRuntime = channelRuntime;
|
|
@@ -1001,9 +999,7 @@ class ZLinkFrameworkRuntimeHost {
|
|
|
1001
999
|
dispatchErrors,
|
|
1002
1000
|
metrics: this.metrics,
|
|
1003
1001
|
applicationJobQueue: this.applicationJobQueue,
|
|
1004
|
-
acceptNewSession: (meshName) => meshName === undefined
|
|
1005
|
-
? this.admission.acceptsNewWork
|
|
1006
|
-
: this.admission.accepts(meshName),
|
|
1002
|
+
acceptNewSession: (meshName) => meshName === undefined ? this.admission.acceptsNewWork : this.admission.accepts(meshName),
|
|
1007
1003
|
primaryMeshName: this.meshRouters.primaryMeshName(),
|
|
1008
1004
|
nativeMeshNode: spotNodeRuntime.primaryMeshNode,
|
|
1009
1005
|
meshCompletions: spotNodeRuntime.primaryMeshCompletions,
|
|
@@ -1054,27 +1050,26 @@ class ZLinkFrameworkRuntimeHost {
|
|
|
1054
1050
|
continue;
|
|
1055
1051
|
}
|
|
1056
1052
|
const descriptor = this.spotNodeRuntime?.meshNodeDescriptor(meshName);
|
|
1057
|
-
const hasManual = (options.router?.manualConnections?.length ?? 0) > 0
|
|
1058
|
-
|
|
1059
|
-
|
|
1053
|
+
const hasManual = (options.router?.manualConnections?.length ?? 0) > 0 ||
|
|
1054
|
+
(options.router?.manualPeerConnections?.length ?? 0) > 0 ||
|
|
1055
|
+
(options.pubSub?.manualConnections?.length ?? 0) > 0;
|
|
1060
1056
|
const hasDiscovery = hasConfiguredLocationStore(this.options.registration);
|
|
1061
|
-
const source = hasManual && hasDiscovery
|
|
1062
|
-
? 'manual_and_redis'
|
|
1063
|
-
: hasManual ? 'manual' : 'redis';
|
|
1057
|
+
const source = hasManual && hasDiscovery ? 'manual_and_redis' : hasManual ? 'manual' : 'redis';
|
|
1064
1058
|
const emptyCapacity = { active: 0, reserved: 0, limit: 0 };
|
|
1065
1059
|
snapshots.push({
|
|
1066
1060
|
meshName,
|
|
1067
1061
|
source,
|
|
1068
1062
|
configuredPeers: status.peers.length,
|
|
1069
|
-
connectedPeers: status.peers.filter(peer => peer.state !== contracts_1.ZLinkPeerState.NotConnected)
|
|
1063
|
+
connectedPeers: status.peers.filter((peer) => peer.state !== contracts_1.ZLinkPeerState.NotConnected)
|
|
1064
|
+
.length,
|
|
1070
1065
|
readyPeers: status.readyPeerCount,
|
|
1071
|
-
channels: status.channels.map(channel => ({
|
|
1066
|
+
channels: status.channels.map((channel) => ({
|
|
1072
1067
|
channelName: channel.channelName,
|
|
1073
1068
|
readyMembers: channel.readyTargetCount
|
|
1074
1069
|
})),
|
|
1075
1070
|
actorCapacity: descriptor?.populationCapacity.actors ?? emptyCapacity,
|
|
1076
1071
|
spotCapacity: descriptor?.populationCapacity.spots ?? emptyCapacity,
|
|
1077
|
-
spotTypeCapacities: (descriptor?.populationCapacity.spotTypes ?? []).map(capacity => ({
|
|
1072
|
+
spotTypeCapacities: (descriptor?.populationCapacity.spotTypes ?? []).map((capacity) => ({
|
|
1078
1073
|
spotKind: capacity.objectKind === 'instance_spot' ? 'instance' : 'user',
|
|
1079
1074
|
stableType: capacity.stableType,
|
|
1080
1075
|
active: capacity.active,
|
|
@@ -1126,8 +1121,7 @@ class ZLinkFrameworkRuntimeHost {
|
|
|
1126
1121
|
const handler = () => {
|
|
1127
1122
|
if (!this.ownerAdmissionOpen())
|
|
1128
1123
|
return;
|
|
1129
|
-
void this.resumeOwnerLeaseOwnedWork(runtime, spotNodeRuntime, channelRuntime)
|
|
1130
|
-
.catch(error => {
|
|
1124
|
+
void this.resumeOwnerLeaseOwnedWork(runtime, spotNodeRuntime, channelRuntime).catch((error) => {
|
|
1131
1125
|
runtime.closeOwnerLeaseAdmission(error);
|
|
1132
1126
|
this.runtimeOrPreStartErrorSink.reportRuntimeTaskException('owner lease recovery', error);
|
|
1133
1127
|
});
|
|
@@ -1142,10 +1136,10 @@ class ZLinkFrameworkRuntimeHost {
|
|
|
1142
1136
|
const signal = this.executionState?.abortController.signal;
|
|
1143
1137
|
await spotNodeRuntime.publishMeshNodeState(contracts_1.ZLinkFrameworkRuntimeState.Preparing, signal);
|
|
1144
1138
|
const store = this.locationOwner.currentStores?.locationStore;
|
|
1145
|
-
if (this.statefulAuthorityRoutes === undefined
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1139
|
+
if (this.statefulAuthorityRoutes === undefined &&
|
|
1140
|
+
store !== undefined &&
|
|
1141
|
+
this.executionState !== undefined &&
|
|
1142
|
+
this.requiresStatefulAuthorityRuntime()) {
|
|
1149
1143
|
const routes = this.createStatefulAuthorityRoutes(store, spotNodeRuntime);
|
|
1150
1144
|
await routes.start(signal);
|
|
1151
1145
|
this.statefulAuthorityRoutes = routes;
|
|
@@ -1164,8 +1158,8 @@ class ZLinkFrameworkRuntimeHost {
|
|
|
1164
1158
|
creationStore: locationStore,
|
|
1165
1159
|
relocationStore: this.options.registration.locations.relocationStoreInstance,
|
|
1166
1160
|
meshNodes: spotNodeRuntime.meshNodesByName,
|
|
1167
|
-
pollingIntervalMs: this.options.registration.locations.options.pollingIntervalMs
|
|
1168
|
-
|
|
1161
|
+
pollingIntervalMs: this.options.registration.locations.options.pollingIntervalMs ??
|
|
1162
|
+
Locations_1.zlinkDefaultLocationOptions.pollingIntervalMs,
|
|
1169
1163
|
pageSize: 1000,
|
|
1170
1164
|
reportError: (error) => this.runtimeOrPreStartErrorSink.reportRuntimeTaskException('stateful authority route reconciliation', error),
|
|
1171
1165
|
onSpotRouteChanged: (spotId) => this.cachedLocationSpotRouteResolver?.invalidate?.(spotId)
|
|
@@ -1173,9 +1167,9 @@ class ZLinkFrameworkRuntimeHost {
|
|
|
1173
1167
|
}
|
|
1174
1168
|
requiresStatefulAuthorityRuntime() {
|
|
1175
1169
|
for (const options of this.options.registration.spotNodes.values()) {
|
|
1176
|
-
if (Object.keys(options.spotFactoryRegistrations ?? {}).length > 0
|
|
1177
|
-
|
|
1178
|
-
|
|
1170
|
+
if (Object.keys(options.spotFactoryRegistrations ?? {}).length > 0 ||
|
|
1171
|
+
Object.keys(options.instanceSpotFactoryRegistrations ?? {}).length > 0 ||
|
|
1172
|
+
Object.keys(options.actorFactoryRegistrations ?? {}).length > 0) {
|
|
1179
1173
|
return true;
|
|
1180
1174
|
}
|
|
1181
1175
|
}
|
|
@@ -1216,7 +1210,8 @@ class ZLinkFrameworkRuntimeHost {
|
|
|
1216
1210
|
}
|
|
1217
1211
|
}
|
|
1218
1212
|
removeOwnerLeaseRecoveryPublication() {
|
|
1219
|
-
if (this.ownerLeaseRecoveryRuntime !== undefined &&
|
|
1213
|
+
if (this.ownerLeaseRecoveryRuntime !== undefined &&
|
|
1214
|
+
this.ownerLeaseRecoveryHandler !== undefined) {
|
|
1220
1215
|
this.ownerLeaseRecoveryRuntime.removeOwnerLeaseRenewedHandler(this.ownerLeaseRecoveryHandler);
|
|
1221
1216
|
}
|
|
1222
1217
|
this.ownerLeaseRecoveryRuntime = undefined;
|
|
@@ -1281,8 +1276,8 @@ class ZLinkFrameworkRuntimeHost {
|
|
|
1281
1276
|
catch {
|
|
1282
1277
|
storeUnavailable = true;
|
|
1283
1278
|
}
|
|
1284
|
-
await new Promise((resolve) => setTimeout(resolve, Math.min(this.options.registration.locations.options.pollingIntervalMs
|
|
1285
|
-
|
|
1279
|
+
await new Promise((resolve) => setTimeout(resolve, Math.min(this.options.registration.locations.options.pollingIntervalMs ??
|
|
1280
|
+
Locations_1.zlinkDefaultLocationOptions.pollingIntervalMs, Math.max(1, deadlineAt - performance.now()))));
|
|
1286
1281
|
}
|
|
1287
1282
|
return storeUnavailable
|
|
1288
1283
|
? contracts_1.ZLinkFrameworkRelocationReason.StoreUnavailable
|
|
@@ -1300,8 +1295,8 @@ class ZLinkFrameworkRuntimeHost {
|
|
|
1300
1295
|
}
|
|
1301
1296
|
async hasExactAutomaticPeerReadiness(location, targetApplicationVersion) {
|
|
1302
1297
|
for (const [meshName, registration] of this.options.registration.spotNodes) {
|
|
1303
|
-
if ((registration.router?.manualConnections?.length ?? 0) > 0
|
|
1304
|
-
|
|
1298
|
+
if ((registration.router?.manualConnections?.length ?? 0) > 0 ||
|
|
1299
|
+
(registration.router?.manualPeerConnections?.length ?? 0) > 0) {
|
|
1305
1300
|
continue;
|
|
1306
1301
|
}
|
|
1307
1302
|
const node = this.spotNodeRuntime?.meshNode(meshName);
|
|
@@ -1323,12 +1318,12 @@ class ZLinkFrameworkRuntimeHost {
|
|
|
1323
1318
|
return true;
|
|
1324
1319
|
}
|
|
1325
1320
|
async publishHostRelocated() {
|
|
1326
|
-
await Promise.all([...this.options.registration.spotNodes.keys()].map(meshName => this.spotNodeRuntime?.publishMeshNodeState(contracts_1.ZLinkFrameworkRuntimeState.Relocated, undefined, meshName)));
|
|
1321
|
+
await Promise.all([...this.options.registration.spotNodes.keys()].map((meshName) => this.spotNodeRuntime?.publishMeshNodeState(contracts_1.ZLinkFrameworkRuntimeState.Relocated, undefined, meshName)));
|
|
1327
1322
|
}
|
|
1328
1323
|
async publishHostDraining(signal) {
|
|
1329
1324
|
try {
|
|
1330
1325
|
const runtime = this.locationOwner.currentRuntime;
|
|
1331
|
-
if (runtime !== undefined && !await runtime.publishDraining(signal)) {
|
|
1326
|
+
if (runtime !== undefined && !(await runtime.publishDraining(signal))) {
|
|
1332
1327
|
throw new Error('Draining descriptor publication returned false.');
|
|
1333
1328
|
}
|
|
1334
1329
|
}
|
|
@@ -1415,12 +1410,12 @@ class ZLinkFrameworkRuntimeHost {
|
|
|
1415
1410
|
// coordinator after application initialization. The legacy location
|
|
1416
1411
|
// claim would expose a Creating object before that Ready barrier.
|
|
1417
1412
|
locationLifecycle: () => undefined,
|
|
1418
|
-
releaseInstanceAuthority: (meshName, spotId, objectGeneration) => this.locationOwner.currentLifecycle?.releaseSpot(meshName, spotId, objectGeneration)
|
|
1419
|
-
|
|
1420
|
-
beginInstanceIdleClosingAuthority: (meshName, spotId) => this.locationOwner.currentLifecycle?.beginInstanceSpotClosing(meshName, spotId)
|
|
1421
|
-
|
|
1422
|
-
beginInstanceClosingAuthority: (meshName, spotId) => this.locationOwner.currentLifecycle?.beginInstanceSpotClosing(meshName, spotId)
|
|
1423
|
-
|
|
1413
|
+
releaseInstanceAuthority: (meshName, spotId, objectGeneration) => this.locationOwner.currentLifecycle?.releaseSpot(meshName, spotId, objectGeneration) ??
|
|
1414
|
+
Promise.resolve(),
|
|
1415
|
+
beginInstanceIdleClosingAuthority: (meshName, spotId) => this.locationOwner.currentLifecycle?.beginInstanceSpotClosing(meshName, spotId) ??
|
|
1416
|
+
Promise.resolve(undefined),
|
|
1417
|
+
beginInstanceClosingAuthority: (meshName, spotId) => this.locationOwner.currentLifecycle?.beginInstanceSpotClosing(meshName, spotId) ??
|
|
1418
|
+
Promise.resolve(undefined),
|
|
1424
1419
|
createLocationSpotRouteResolver: () => this.createLocationSpotRouteResolver(),
|
|
1425
1420
|
boundSessionRelay: this.boundSessionRelay,
|
|
1426
1421
|
actorHandoff: this.actorHandoff,
|
|
@@ -1433,7 +1428,9 @@ class ZLinkFrameworkRuntimeHost {
|
|
|
1433
1428
|
}).create(this.actorTransferRuntime),
|
|
1434
1429
|
activationConcurrencyLimitProvider: (meshName) => this.options.registration.spotNodes.get(meshName)?.activationConcurrencyLimit ?? 128,
|
|
1435
1430
|
onInstanceActivationConcurrencyChanged: (meshName) => {
|
|
1436
|
-
void this.spotNodeRuntime
|
|
1431
|
+
void this.spotNodeRuntime
|
|
1432
|
+
?.publishMeshNodeState(this.runtimeState, this.executionState?.abortController.signal, meshName)
|
|
1433
|
+
.catch(() => undefined);
|
|
1437
1434
|
}
|
|
1438
1435
|
};
|
|
1439
1436
|
}
|
|
@@ -1451,7 +1448,7 @@ class ZLinkFrameworkRuntimeHost {
|
|
|
1451
1448
|
}
|
|
1452
1449
|
return node.requestActorCreate(targetNodeRid, request, timeoutMs);
|
|
1453
1450
|
},
|
|
1454
|
-
decodeRemoteReply: payload => {
|
|
1451
|
+
decodeRemoteReply: (payload) => {
|
|
1455
1452
|
const message = runtime_message_1.ZLinkBufferMessage.from(payload);
|
|
1456
1453
|
try {
|
|
1457
1454
|
return (0, payload_codec_1.decodeFrameworkPayloadMessage)(message, this.options.registration.messageSerializers);
|
|
@@ -1477,17 +1474,16 @@ class ZLinkFrameworkRuntimeHost {
|
|
|
1477
1474
|
}
|
|
1478
1475
|
const meshNode = this.spotNodeRuntime?.meshNode(meshName);
|
|
1479
1476
|
const descriptors = (await locationStore.listMeshNodes(meshName, undefined, signal)).items;
|
|
1480
|
-
const selected = await selectReadyLocationPlacementDescriptor(descriptors, meshNode, signal, descriptor => {
|
|
1481
|
-
const capability = descriptor.objectCapabilities.find(candidate => candidate.objectKind === 'actor'
|
|
1482
|
-
&& candidate.stableType === stableType);
|
|
1477
|
+
const selected = await selectReadyLocationPlacementDescriptor(descriptors, meshNode, signal, (descriptor) => {
|
|
1478
|
+
const capability = descriptor.objectCapabilities.find((candidate) => candidate.objectKind === 'actor' && candidate.stableType === stableType);
|
|
1483
1479
|
const actors = descriptor.populationCapacity.actors;
|
|
1484
|
-
return descriptor.state === contracts_1.ZLinkFrameworkRuntimeState.Serving
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1480
|
+
return (descriptor.state === contracts_1.ZLinkFrameworkRuntimeState.Serving &&
|
|
1481
|
+
descriptor.objectRole === 'server' &&
|
|
1482
|
+
descriptor.placementWeight > 0 &&
|
|
1483
|
+
descriptor.entrySpotId !== undefined &&
|
|
1484
|
+
excludedNodeRids?.has(String(descriptor.rid)) !== true &&
|
|
1485
|
+
(actors.limit === 0 || actors.active + actors.reserved < actors.limit) &&
|
|
1486
|
+
capability !== undefined);
|
|
1491
1487
|
});
|
|
1492
1488
|
if (selected === undefined)
|
|
1493
1489
|
return undefined;
|
|
@@ -1506,8 +1502,8 @@ class ZLinkFrameworkRuntimeHost {
|
|
|
1506
1502
|
ownerId: selected.ownerId,
|
|
1507
1503
|
leaseGeneration: selected.leaseGeneration
|
|
1508
1504
|
},
|
|
1509
|
-
isLocal: String(localStatus.routingId) === String(selected.rid)
|
|
1510
|
-
|
|
1505
|
+
isLocal: String(localStatus.routingId) === String(selected.rid) &&
|
|
1506
|
+
localStatus.lifecycleGeneration === selected.lifecycleGeneration
|
|
1511
1507
|
};
|
|
1512
1508
|
}
|
|
1513
1509
|
});
|
|
@@ -1519,7 +1515,9 @@ class ZLinkFrameworkRuntimeHost {
|
|
|
1519
1515
|
},
|
|
1520
1516
|
forgetReadyRoute: (meshName, route) => {
|
|
1521
1517
|
this.cachedLocationSpotRouteResolver?.invalidate?.(route.spot.spotId);
|
|
1522
|
-
this.spotNodeRuntime
|
|
1518
|
+
this.spotNodeRuntime
|
|
1519
|
+
?.meshNode(meshName)
|
|
1520
|
+
?.forgetSpotRoute?.(route.spot, route.authorityOwnerGeneration, route.storeVersion);
|
|
1523
1521
|
},
|
|
1524
1522
|
remoteCreate: (meshName, targetNodeRid, request, timeoutMs) => {
|
|
1525
1523
|
const node = this.spotNodeRuntime?.meshNode(meshName);
|
|
@@ -1528,7 +1526,7 @@ class ZLinkFrameworkRuntimeHost {
|
|
|
1528
1526
|
}
|
|
1529
1527
|
return node.requestUserSpotCreate(targetNodeRid, request, timeoutMs);
|
|
1530
1528
|
},
|
|
1531
|
-
decodeRemoteReply: payload => {
|
|
1529
|
+
decodeRemoteReply: (payload) => {
|
|
1532
1530
|
const message = runtime_message_1.ZLinkBufferMessage.from(payload);
|
|
1533
1531
|
try {
|
|
1534
1532
|
return (0, payload_codec_1.decodeFrameworkPayloadMessage)(message, this.options.registration.messageSerializers);
|
|
@@ -1557,22 +1555,19 @@ class ZLinkFrameworkRuntimeHost {
|
|
|
1557
1555
|
}
|
|
1558
1556
|
const meshNode = this.spotNodeRuntime?.meshNode(meshName);
|
|
1559
1557
|
const descriptors = (await locationStore.listMeshNodes(meshName, undefined, signal)).items;
|
|
1560
|
-
const selected = await selectReadyLocationPlacementDescriptor(descriptors, meshNode, signal, descriptor => {
|
|
1561
|
-
const capability = descriptor.objectCapabilities.find(candidate => candidate.objectKind === 'user_spot'
|
|
1562
|
-
|
|
1563
|
-
const spotTypeCapacity = descriptor.populationCapacity.spotTypes.find(candidate => candidate.objectKind === 'user_spot'
|
|
1564
|
-
&& candidate.stableType === request.stableType);
|
|
1558
|
+
const selected = await selectReadyLocationPlacementDescriptor(descriptors, meshNode, signal, (descriptor) => {
|
|
1559
|
+
const capability = descriptor.objectCapabilities.find((candidate) => candidate.objectKind === 'user_spot' && candidate.stableType === request.stableType);
|
|
1560
|
+
const spotTypeCapacity = descriptor.populationCapacity.spotTypes.find((candidate) => candidate.objectKind === 'user_spot' && candidate.stableType === request.stableType);
|
|
1565
1561
|
const spots = descriptor.populationCapacity.spots;
|
|
1566
|
-
return descriptor.state === 1
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
< spotTypeCapacity.limit);
|
|
1562
|
+
return (descriptor.state === 1 &&
|
|
1563
|
+
descriptor.objectRole === 'server' &&
|
|
1564
|
+
descriptor.placementWeight > 0 &&
|
|
1565
|
+
excludedNodeRids?.has(String(descriptor.rid)) !== true &&
|
|
1566
|
+
(spots.limit === 0 || spots.active + spots.reserved < spots.limit) &&
|
|
1567
|
+
capability !== undefined &&
|
|
1568
|
+
(spotTypeCapacity === undefined ||
|
|
1569
|
+
spotTypeCapacity.limit === 0 ||
|
|
1570
|
+
spotTypeCapacity.active + spotTypeCapacity.reserved < spotTypeCapacity.limit));
|
|
1576
1571
|
});
|
|
1577
1572
|
if (selected === undefined)
|
|
1578
1573
|
return undefined;
|
|
@@ -1585,9 +1580,9 @@ class ZLinkFrameworkRuntimeHost {
|
|
|
1585
1580
|
ownerId: selected.ownerId,
|
|
1586
1581
|
leaseGeneration: selected.leaseGeneration
|
|
1587
1582
|
},
|
|
1588
|
-
isLocal: localStatus !== undefined
|
|
1589
|
-
|
|
1590
|
-
|
|
1583
|
+
isLocal: localStatus !== undefined &&
|
|
1584
|
+
String(localStatus.routingId) === String(selected.rid) &&
|
|
1585
|
+
localStatus.lifecycleGeneration === selected.lifecycleGeneration
|
|
1591
1586
|
};
|
|
1592
1587
|
}
|
|
1593
1588
|
});
|
|
@@ -1632,8 +1627,7 @@ class ZLinkFrameworkRuntimeHost {
|
|
|
1632
1627
|
}, signal);
|
|
1633
1628
|
const reply = coordinated.result.reply;
|
|
1634
1629
|
let payload;
|
|
1635
|
-
if (reply !== undefined
|
|
1636
|
-
&& coordinated.result.state !== contracts_1.ZLinkSpotCreateState.Existing) {
|
|
1630
|
+
if (reply !== undefined && coordinated.result.state !== contracts_1.ZLinkSpotCreateState.Existing) {
|
|
1637
1631
|
const message = (0, payload_codec_1.encodeFrameworkPayloadMessage)(reply, this.options.registration.messageSerializers);
|
|
1638
1632
|
try {
|
|
1639
1633
|
payload = {
|
|
@@ -1670,8 +1664,7 @@ class ZLinkFrameworkRuntimeHost {
|
|
|
1670
1664
|
}
|
|
1671
1665
|
return await actorPlacement.handleRemoteCreate(record, async (requestPayload, authority, createSignal) => {
|
|
1672
1666
|
const request = (0, creation_payload_codec_1.decodeFrameworkCreationPayload)(requestPayload, this.options.registration.messageSerializers);
|
|
1673
|
-
const entrySpotId = this.spotNodeRuntime
|
|
1674
|
-
?.meshNodeDescriptor(meshName)?.entrySpotId;
|
|
1667
|
+
const entrySpotId = this.spotNodeRuntime?.meshNodeDescriptor(meshName)?.entrySpotId;
|
|
1675
1668
|
if (entrySpotId === undefined) {
|
|
1676
1669
|
throw new ConfigurationException_1.ZLinkConfigurationException(`Remote Actor creation requires the '${meshName}' MeshNode Entry Spot descriptor.`);
|
|
1677
1670
|
}
|
|
@@ -1700,8 +1693,8 @@ class ZLinkFrameworkRuntimeHost {
|
|
|
1700
1693
|
...(reply === undefined ? {} : { reply })
|
|
1701
1694
|
};
|
|
1702
1695
|
}
|
|
1703
|
-
if (local.actorRef.objectGeneration !== authority.objectGeneration
|
|
1704
|
-
|
|
1696
|
+
if (local.actorRef.objectGeneration !== authority.objectGeneration ||
|
|
1697
|
+
String(local.actorRef.nodeRid) !== record.reservation.targetNodeRid) {
|
|
1705
1698
|
throw (0, framework_errors_internal_1.createInternalFrameworkException)(framework_errors_internal_1.ZLinkFrameworkInternalErrorKind.ActorCreateFailed, `Actor '${record.actorId}' native authority does not match its placement reservation.`);
|
|
1706
1699
|
}
|
|
1707
1700
|
let reply;
|
|
@@ -1794,8 +1787,8 @@ class ZLinkFrameworkRuntimeHost {
|
|
|
1794
1787
|
primaryMeshCompletions: () => this.spotNodeRuntime?.primaryMeshCompletions,
|
|
1795
1788
|
meshNode: (meshName) => this.spotNodeRuntime?.meshNode(meshName),
|
|
1796
1789
|
meshCompletions: (meshName) => this.spotNodeRuntime?.meshCompletionTable(meshName),
|
|
1797
|
-
notifyEntrySpotActorCreated: (nodeRid, actor, createRequest, signal) => this.spotNodeRuntime?.notifyEntrySpotActorCreated(nodeRid, actor, createRequest, signal)
|
|
1798
|
-
|
|
1790
|
+
notifyEntrySpotActorCreated: (nodeRid, actor, createRequest, signal) => this.spotNodeRuntime?.notifyEntrySpotActorCreated(nodeRid, actor, createRequest, signal) ??
|
|
1791
|
+
Promise.resolve(undefined),
|
|
1799
1792
|
locationLifecycle: () => this.locationOwner.currentLifecycle,
|
|
1800
1793
|
primaryMeshName: () => this.meshRouters.primaryMeshName(),
|
|
1801
1794
|
actorMeshName: (actorType) => this.meshRouters.actorMeshName(actorType),
|
|
@@ -1909,8 +1902,10 @@ class ZLinkFrameworkRuntimeHost {
|
|
|
1909
1902
|
},
|
|
1910
1903
|
meshRecordDispatcher: (meshName, owner, record) => this.dispatchMeshRecord(meshName, owner, record, this.executionState?.abortController.signal),
|
|
1911
1904
|
instanceActivationConcurrencyProvider: (meshName) => {
|
|
1912
|
-
return this.spotManager?.instanceActivationConcurrency(meshName)
|
|
1913
|
-
|
|
1905
|
+
return (this.spotManager?.instanceActivationConcurrency(meshName) ?? {
|
|
1906
|
+
active: 0,
|
|
1907
|
+
limit: this.options.registration.spotNodes.get(meshName)?.activationConcurrencyLimit ?? 128
|
|
1908
|
+
});
|
|
1914
1909
|
}
|
|
1915
1910
|
};
|
|
1916
1911
|
}
|
|
@@ -1930,8 +1925,7 @@ class ZLinkFrameworkRuntimeHost {
|
|
|
1930
1925
|
const terminal = kind === framework_errors_internal_1.ZLinkFrameworkInternalErrorKind.ActorGenerationStale
|
|
1931
1926
|
? { terminalResult: runtime_values_1.RequestResult.InvalidState, failureCode: 0 }
|
|
1932
1927
|
: (0, framework_errors_internal_1.internalFrameworkWireReply)((0, framework_errors_internal_1.createInternalFrameworkException)(kind, message));
|
|
1933
|
-
if (record.replyFailure?.(terminal.terminalResult, terminal.failureCode)
|
|
1934
|
-
!== runtime_values_1.SubmitResult.Ok) {
|
|
1928
|
+
if (record.replyFailure?.(terminal.terminalResult, terminal.failureCode) !== runtime_values_1.SubmitResult.Ok) {
|
|
1935
1929
|
throw new ConfigurationException_1.ZLinkConfigurationException(`MeshNode Actor binding target '${binding.actor.actorId}' failure acknowledgement failed.`);
|
|
1936
1930
|
}
|
|
1937
1931
|
};
|
|
@@ -1942,10 +1936,10 @@ class ZLinkFrameworkRuntimeHost {
|
|
|
1942
1936
|
};
|
|
1943
1937
|
const state = this.actorManager?.getState(binding.actor.actorId);
|
|
1944
1938
|
const nativeActorRef = state?.nativeActorRef;
|
|
1945
|
-
if (state === undefined
|
|
1946
|
-
|
|
1947
|
-
|
|
1948
|
-
|
|
1939
|
+
if (state === undefined ||
|
|
1940
|
+
nativeActorRef === undefined ||
|
|
1941
|
+
nativeActorRef.actorId !== binding.actor.actorId ||
|
|
1942
|
+
!(0, routing_id_1.routingIdsEqual)(nativeActorRef.nodeRid, binding.actor.nodeRid)) {
|
|
1949
1943
|
replyBindingFailure(framework_errors_internal_1.ZLinkFrameworkInternalErrorKind.ActorLocationStale, `Actor '${binding.actor.actorId}' binding target is no longer current.`);
|
|
1950
1944
|
return;
|
|
1951
1945
|
}
|
|
@@ -1953,21 +1947,20 @@ class ZLinkFrameworkRuntimeHost {
|
|
|
1953
1947
|
replyBindingFailure(framework_errors_internal_1.ZLinkFrameworkInternalErrorKind.ActorGenerationStale, `Actor '${binding.actor.actorId}' binding object generation is stale.`);
|
|
1954
1948
|
return;
|
|
1955
1949
|
}
|
|
1956
|
-
const node = state.meshName === meshName
|
|
1957
|
-
? this.spotNodeRuntime?.meshNode(meshName)
|
|
1958
|
-
: undefined;
|
|
1950
|
+
const node = state.meshName === meshName ? this.spotNodeRuntime?.meshNode(meshName) : undefined;
|
|
1959
1951
|
const localStatus = node?.status();
|
|
1960
1952
|
// ownsLocation tracks local cleanup responsibility, not Actor authority.
|
|
1961
1953
|
// A relocation target can exact-read committed authority without owning that cleanup.
|
|
1962
|
-
if (localStatus === undefined
|
|
1963
|
-
|
|
1964
|
-
|
|
1965
|
-
|
|
1966
|
-
|
|
1954
|
+
if (localStatus === undefined ||
|
|
1955
|
+
!(0, routing_id_1.routingIdsEqual)(localStatus.routingId, binding.actor.nodeRid) ||
|
|
1956
|
+
localStatus.lifecycleGeneration !== binding.actorNodeGeneration ||
|
|
1957
|
+
state.locationGeneration !== binding.authorityOwnerGeneration ||
|
|
1958
|
+
state.isMoving) {
|
|
1967
1959
|
replyBindingFailure(framework_errors_internal_1.ZLinkFrameworkInternalErrorKind.ActorLocationStale, `Actor '${binding.actor.actorId}' binding authority fence is stale.`);
|
|
1968
1960
|
return;
|
|
1969
1961
|
}
|
|
1970
|
-
const sessionOwnerIsLocal = (0, routing_id_1.routingIdsEqual)(localStatus.routingId, binding.sessionNodeRid) &&
|
|
1962
|
+
const sessionOwnerIsLocal = (0, routing_id_1.routingIdsEqual)(localStatus.routingId, binding.sessionNodeRid) &&
|
|
1963
|
+
localStatus.lifecycleGeneration === binding.sessionOwnerNodeGeneration;
|
|
1971
1964
|
if (binding.transition === 'tombstone') {
|
|
1972
1965
|
const actorRef = {
|
|
1973
1966
|
actorId: binding.actor.actorId,
|
|
@@ -2026,7 +2019,7 @@ class ZLinkFrameworkRuntimeHost {
|
|
|
2026
2019
|
if (record.kind === service_runtime_contracts_1.ReceiveKind.NodeRequest && record.parts.length === 1) {
|
|
2027
2020
|
const terminal = (0, actors_2.decodeRemoteActorSourceLeaveTerminal)(record.parts[0].data());
|
|
2028
2021
|
if (terminal !== undefined) {
|
|
2029
|
-
if (await this.spotManager?.completeFormalSourceLeaveTerminal(terminal.actorId, terminal.transferId, terminal.succeeded) !== true) {
|
|
2022
|
+
if ((await this.spotManager?.completeFormalSourceLeaveTerminal(terminal.actorId, terminal.transferId, terminal.succeeded)) !== true) {
|
|
2030
2023
|
throw new ConfigurationException_1.ZLinkConfigurationException(`Actor '${terminal.actorId}' has no matching formal transfer terminal gate.`);
|
|
2031
2024
|
}
|
|
2032
2025
|
if (record.reply(Buffer.alloc(0)) !== runtime_values_1.SubmitResult.Ok) {
|
|
@@ -2117,7 +2110,9 @@ class ZLinkFrameworkRuntimeHost {
|
|
|
2117
2110
|
async dispatchMeshSpotRecord(meshName, owner, record) {
|
|
2118
2111
|
const envelope = (0, channel_envelope_1.decodeChannelEnvelope)(record.parts, undefined, this.flowCreationEnabled());
|
|
2119
2112
|
if (envelope.packetName === actors_1.ZLINK_REMOTE_ACTOR_PACKET_RELAY_PACKET) {
|
|
2120
|
-
const payload = (0, channel_envelope_1.decodeChannelPayload)(envelope, {
|
|
2113
|
+
const payload = (0, channel_envelope_1.decodeChannelPayload)(envelope, {
|
|
2114
|
+
serializers: this.options.registration.messageSerializers
|
|
2115
|
+
});
|
|
2121
2116
|
const context = {
|
|
2122
2117
|
meshName,
|
|
2123
2118
|
packetName: envelope.packetName,
|
|
@@ -2127,8 +2122,7 @@ class ZLinkFrameworkRuntimeHost {
|
|
|
2127
2122
|
correlationId: envelope.header.correlationId ?? undefined
|
|
2128
2123
|
};
|
|
2129
2124
|
try {
|
|
2130
|
-
const response = await this.boundSessionRelay.actorPackets
|
|
2131
|
-
.receiveRemoteActorPacketRelay(payload, context);
|
|
2125
|
+
const response = await this.boundSessionRelay.actorPackets.receiveRemoteActorPacketRelay(payload, context);
|
|
2132
2126
|
if (record.kind === service_runtime_contracts_1.ReceiveKind.SpotRequest) {
|
|
2133
2127
|
record.reply((0, channel_envelope_1.encodeChannelReplyParts)(envelope.header, response));
|
|
2134
2128
|
}
|
|
@@ -2141,7 +2135,7 @@ class ZLinkFrameworkRuntimeHost {
|
|
|
2141
2135
|
}
|
|
2142
2136
|
return;
|
|
2143
2137
|
}
|
|
2144
|
-
if (await this.spotNodeRuntime?.dispatchEntrySpotRecord(meshName, owner, record) === true) {
|
|
2138
|
+
if ((await this.spotNodeRuntime?.dispatchEntrySpotRecord(meshName, owner, record)) === true) {
|
|
2145
2139
|
return;
|
|
2146
2140
|
}
|
|
2147
2141
|
if (this.spotManager === undefined) {
|
|
@@ -2176,7 +2170,7 @@ class ZLinkFrameworkRuntimeHost {
|
|
|
2176
2170
|
}
|
|
2177
2171
|
flowCreationEnabled() {
|
|
2178
2172
|
const mode = this.executionState === undefined
|
|
2179
|
-
? this.options.registration.dispatch?.diagnostics.messageFlow ?? 'errors'
|
|
2173
|
+
? (this.options.registration.dispatch?.diagnostics.messageFlow ?? 'errors')
|
|
2180
2174
|
: this.messageFlowModeCell.mode;
|
|
2181
2175
|
return mode !== 'off';
|
|
2182
2176
|
}
|
|
@@ -2207,12 +2201,12 @@ class ZLinkFrameworkRuntimeHost {
|
|
|
2207
2201
|
const resolver = authority === undefined
|
|
2208
2202
|
? legacy
|
|
2209
2203
|
: new locations_1.ZLinkAuthoritySpotRouteResolver(authority, this.meshRouters.spotRouterChannelIdByMesh(), legacy, this.locationOwner.currentLeaseTracker, this.options.registration.locations.options.routeCacheMaxAgeMs, undefined, async (meshName, nodeRid, expectedLifecycleGeneration, signal) => {
|
|
2210
|
-
const descriptor = (await authority.listMeshNodes(meshName, undefined, signal)).items.find((candidate) => (0, routing_id_1.routingIdsEqual)(candidate.rid, nodeRid)
|
|
2211
|
-
|
|
2204
|
+
const descriptor = (await authority.listMeshNodes(meshName, undefined, signal)).items.find((candidate) => (0, routing_id_1.routingIdsEqual)(candidate.rid, nodeRid) &&
|
|
2205
|
+
candidate.lifecycleGeneration === expectedLifecycleGeneration);
|
|
2212
2206
|
return descriptor?.state;
|
|
2213
2207
|
});
|
|
2214
2208
|
this.cachedLocationSpotRouteResolver = resolver;
|
|
2215
|
-
this.locationOwner.setSpotRouteInvalidator(resolver === undefined ? undefined : spotId => resolver.invalidate?.(spotId));
|
|
2209
|
+
this.locationOwner.setSpotRouteInvalidator(resolver === undefined ? undefined : (spotId) => resolver.invalidate?.(spotId));
|
|
2216
2210
|
return resolver;
|
|
2217
2211
|
}
|
|
2218
2212
|
createActorLocationResolver() {
|
|
@@ -2225,42 +2219,40 @@ function hasUnsupportedManualTopology(registration) {
|
|
|
2225
2219
|
return true;
|
|
2226
2220
|
}
|
|
2227
2221
|
for (const node of registration.spotNodes.values()) {
|
|
2228
|
-
if ((node.router?.manualConnections?.length ?? 0) > 0
|
|
2229
|
-
|
|
2222
|
+
if ((node.router?.manualConnections?.length ?? 0) > 0 ||
|
|
2223
|
+
(node.router?.manualPeerConnections?.length ?? 0) > 0) {
|
|
2230
2224
|
return true;
|
|
2231
2225
|
}
|
|
2232
2226
|
}
|
|
2233
2227
|
for (const channel of registration.channels.values()) {
|
|
2234
|
-
if ((channel.client?.manualConnections?.length ?? 0) > 0
|
|
2235
|
-
|
|
2228
|
+
if ((channel.client?.manualConnections?.length ?? 0) > 0 ||
|
|
2229
|
+
(channel.subscriber?.manualConnections?.length ?? 0) > 0) {
|
|
2236
2230
|
return true;
|
|
2237
2231
|
}
|
|
2238
|
-
if (channel.publisher !== undefined
|
|
2239
|
-
|
|
2240
|
-
|
|
2232
|
+
if (channel.publisher !== undefined &&
|
|
2233
|
+
!registration.locations.useInMemoryStores &&
|
|
2234
|
+
registration.locations.storeInstance === undefined) {
|
|
2241
2235
|
return true;
|
|
2242
2236
|
}
|
|
2243
2237
|
}
|
|
2244
2238
|
return false;
|
|
2245
2239
|
}
|
|
2246
2240
|
function hasConfiguredLocationStore(registration) {
|
|
2247
|
-
return registration.locations.useInMemoryStores
|
|
2248
|
-
|| registration.locations.storeInstance !== undefined;
|
|
2241
|
+
return (registration.locations.useInMemoryStores || registration.locations.storeInstance !== undefined);
|
|
2249
2242
|
}
|
|
2250
2243
|
function hasExactPeerReadiness(descriptors, local, peers) {
|
|
2251
|
-
const replacementDescriptors = descriptors.filter((descriptor) => !(String(descriptor.rid) === String(local.routingId)
|
|
2252
|
-
|
|
2253
|
-
|
|
2254
|
-
|
|
2255
|
-
|
|
2256
|
-
|
|
2257
|
-
|
|
2258
|
-
|
|
2259
|
-
|
|
2260
|
-
|
|
2261
|
-
|
|
2262
|
-
|
|
2263
|
-
&& peer.state === 3));
|
|
2244
|
+
const replacementDescriptors = descriptors.filter((descriptor) => !(String(descriptor.rid) === String(local.routingId) &&
|
|
2245
|
+
descriptor.lifecycleGeneration === local.lifecycleGeneration) &&
|
|
2246
|
+
descriptor.state === contracts_1.ZLinkFrameworkRuntimeState.Serving &&
|
|
2247
|
+
local.applicationVersion !== undefined &&
|
|
2248
|
+
descriptor.applicationVersion === local.applicationVersion &&
|
|
2249
|
+
descriptor.objectRole === contracts_1.ZLinkObjectRole.Server &&
|
|
2250
|
+
(local.maintenanceWave === undefined || descriptor.maintenanceWave !== local.maintenanceWave));
|
|
2251
|
+
return (replacementDescriptors.length > 0 &&
|
|
2252
|
+
replacementDescriptors.some((descriptor) => peers.some((peer) => peer.routingId !== null &&
|
|
2253
|
+
String(peer.routingId) === String(descriptor.rid) &&
|
|
2254
|
+
peer.lifecycleGeneration === descriptor.lifecycleGeneration &&
|
|
2255
|
+
peer.state === 3)));
|
|
2264
2256
|
}
|
|
2265
2257
|
var actor_transfer_authority_runtime_2 = require("./actor-transfer-authority-runtime");
|
|
2266
2258
|
Object.defineProperty(exports, "ZLinkActorTransferAuthorityRuntime", { enumerable: true, get: function () { return actor_transfer_authority_runtime_2.ZLinkActorTransferAuthorityRuntime; } });
|
|
@@ -2302,7 +2294,7 @@ async function awaitWithDrainSignal(operation, signal) {
|
|
|
2302
2294
|
void operation.then(() => {
|
|
2303
2295
|
signal.removeEventListener('abort', onAbort);
|
|
2304
2296
|
resolve();
|
|
2305
|
-
}, error => {
|
|
2297
|
+
}, (error) => {
|
|
2306
2298
|
signal.removeEventListener('abort', onAbort);
|
|
2307
2299
|
reject(error);
|
|
2308
2300
|
});
|
|
@@ -2315,9 +2307,9 @@ class ZLinkDrainingStatePublishError extends Error {
|
|
|
2315
2307
|
}
|
|
2316
2308
|
}
|
|
2317
2309
|
function resolveBackendAdapterFactory(internalOptions) {
|
|
2318
|
-
if (typeof internalOptions === 'object'
|
|
2319
|
-
|
|
2320
|
-
|
|
2310
|
+
if (typeof internalOptions === 'object' &&
|
|
2311
|
+
internalOptions !== null &&
|
|
2312
|
+
'backendAdapterFactory' in internalOptions) {
|
|
2321
2313
|
const factory = internalOptions.backendAdapterFactory;
|
|
2322
2314
|
if (factory !== undefined) {
|
|
2323
2315
|
return factory;
|
|
@@ -2334,13 +2326,20 @@ function resolveStreamPayloadCodec(registration) {
|
|
|
2334
2326
|
}
|
|
2335
2327
|
function runtimeStateMetricName(state) {
|
|
2336
2328
|
switch (state) {
|
|
2337
|
-
case contracts_1.ZLinkFrameworkRuntimeState.Preparing:
|
|
2338
|
-
|
|
2339
|
-
case contracts_1.ZLinkFrameworkRuntimeState.
|
|
2340
|
-
|
|
2341
|
-
case contracts_1.ZLinkFrameworkRuntimeState.
|
|
2342
|
-
|
|
2343
|
-
case contracts_1.ZLinkFrameworkRuntimeState.
|
|
2329
|
+
case contracts_1.ZLinkFrameworkRuntimeState.Preparing:
|
|
2330
|
+
return 'preparing';
|
|
2331
|
+
case contracts_1.ZLinkFrameworkRuntimeState.Serving:
|
|
2332
|
+
return 'serving';
|
|
2333
|
+
case contracts_1.ZLinkFrameworkRuntimeState.Relocating:
|
|
2334
|
+
return 'relocating';
|
|
2335
|
+
case contracts_1.ZLinkFrameworkRuntimeState.Relocated:
|
|
2336
|
+
return 'relocated';
|
|
2337
|
+
case contracts_1.ZLinkFrameworkRuntimeState.Draining:
|
|
2338
|
+
return 'draining';
|
|
2339
|
+
case contracts_1.ZLinkFrameworkRuntimeState.Stopped:
|
|
2340
|
+
return 'stopped';
|
|
2341
|
+
case contracts_1.ZLinkFrameworkRuntimeState.Error:
|
|
2342
|
+
return 'error';
|
|
2344
2343
|
}
|
|
2345
2344
|
}
|
|
2346
2345
|
function relocationModeMetricName(mode) {
|
|
@@ -2350,30 +2349,44 @@ function relocationModeMetricName(mode) {
|
|
|
2350
2349
|
}
|
|
2351
2350
|
function relocationReasonMetricName(reason) {
|
|
2352
2351
|
switch (reason) {
|
|
2353
|
-
case contracts_1.ZLinkFrameworkRelocationReason.None:
|
|
2354
|
-
|
|
2355
|
-
case contracts_1.ZLinkFrameworkRelocationReason.
|
|
2356
|
-
|
|
2357
|
-
case contracts_1.ZLinkFrameworkRelocationReason.
|
|
2358
|
-
|
|
2359
|
-
case contracts_1.ZLinkFrameworkRelocationReason.
|
|
2360
|
-
|
|
2361
|
-
case contracts_1.ZLinkFrameworkRelocationReason.
|
|
2362
|
-
|
|
2363
|
-
case contracts_1.ZLinkFrameworkRelocationReason.
|
|
2352
|
+
case contracts_1.ZLinkFrameworkRelocationReason.None:
|
|
2353
|
+
return 'none';
|
|
2354
|
+
case contracts_1.ZLinkFrameworkRelocationReason.TargetUnavailable:
|
|
2355
|
+
return 'target_unavailable';
|
|
2356
|
+
case contracts_1.ZLinkFrameworkRelocationReason.StoreUnavailable:
|
|
2357
|
+
return 'store_unavailable';
|
|
2358
|
+
case contracts_1.ZLinkFrameworkRelocationReason.RelocationDisabled:
|
|
2359
|
+
return 'relocation_disabled';
|
|
2360
|
+
case contracts_1.ZLinkFrameworkRelocationReason.StateIncompatible:
|
|
2361
|
+
return 'state_incompatible';
|
|
2362
|
+
case contracts_1.ZLinkFrameworkRelocationReason.DeadlineExceeded:
|
|
2363
|
+
return 'deadline_exceeded';
|
|
2364
|
+
case contracts_1.ZLinkFrameworkRelocationReason.RelocationFailed:
|
|
2365
|
+
return 'relocation_failed';
|
|
2366
|
+
case contracts_1.ZLinkFrameworkRelocationReason.RuntimeNotReady:
|
|
2367
|
+
return 'runtime_not_ready';
|
|
2368
|
+
case contracts_1.ZLinkFrameworkRelocationReason.ManualTopologyUnsupported:
|
|
2369
|
+
return 'manual_topology_unsupported';
|
|
2370
|
+
case contracts_1.ZLinkFrameworkRelocationReason.ShutdownRequested:
|
|
2371
|
+
return 'shutdown_requested';
|
|
2372
|
+
case contracts_1.ZLinkFrameworkRelocationReason.OperationInProgress:
|
|
2373
|
+
return 'operation_in_progress';
|
|
2364
2374
|
}
|
|
2365
2375
|
}
|
|
2366
2376
|
function terminationReasonMetricName(reason) {
|
|
2367
2377
|
switch (reason) {
|
|
2368
|
-
case contracts_1.ZLinkFrameworkTerminationReason.None:
|
|
2369
|
-
|
|
2370
|
-
case contracts_1.ZLinkFrameworkTerminationReason.
|
|
2378
|
+
case contracts_1.ZLinkFrameworkTerminationReason.None:
|
|
2379
|
+
return 'none';
|
|
2380
|
+
case contracts_1.ZLinkFrameworkTerminationReason.DeadlineExceeded:
|
|
2381
|
+
return 'deadline_exceeded';
|
|
2382
|
+
case contracts_1.ZLinkFrameworkTerminationReason.TeardownFailed:
|
|
2383
|
+
return 'teardown_failed';
|
|
2371
2384
|
}
|
|
2372
2385
|
}
|
|
2373
2386
|
function isStreamPayloadCodec(codec) {
|
|
2374
|
-
return typeof codec === 'object'
|
|
2375
|
-
|
|
2376
|
-
|
|
2387
|
+
return (typeof codec === 'object' &&
|
|
2388
|
+
codec !== null &&
|
|
2389
|
+
typeof codec.encode === 'function');
|
|
2377
2390
|
}
|
|
2378
2391
|
function selectLocationPlacementDescriptor(descriptors) {
|
|
2379
2392
|
const total = descriptors.reduce((sum, descriptor) => sum + BigInt(descriptor.placementWeight), 0n);
|
|
@@ -2394,7 +2407,7 @@ async function selectReadyLocationPlacementDescriptor(descriptors, node, signal,
|
|
|
2394
2407
|
return undefined;
|
|
2395
2408
|
for (;;) {
|
|
2396
2409
|
const localStatus = node?.status();
|
|
2397
|
-
const selected = selectLocationPlacementDescriptor(eligible.filter(descriptor => isPlacementTargetReady(node, localStatus, descriptor)));
|
|
2410
|
+
const selected = selectLocationPlacementDescriptor(eligible.filter((descriptor) => isPlacementTargetReady(node, localStatus, descriptor)));
|
|
2398
2411
|
if (selected !== undefined)
|
|
2399
2412
|
return selected;
|
|
2400
2413
|
try {
|
|
@@ -2408,9 +2421,9 @@ async function selectReadyLocationPlacementDescriptor(descriptors, node, signal,
|
|
|
2408
2421
|
function isPlacementTargetReady(node, localStatus, descriptor) {
|
|
2409
2422
|
if (node === undefined)
|
|
2410
2423
|
return true;
|
|
2411
|
-
if (localStatus !== undefined
|
|
2412
|
-
|
|
2413
|
-
|
|
2424
|
+
if (localStatus !== undefined &&
|
|
2425
|
+
String(localStatus.routingId) === String(descriptor.rid) &&
|
|
2426
|
+
localStatus.lifecycleGeneration === descriptor.lifecycleGeneration) {
|
|
2414
2427
|
return true;
|
|
2415
2428
|
}
|
|
2416
2429
|
return node.isPeerRouteReady?.(descriptor.rid, descriptor.lifecycleGeneration) ?? true;
|
|
@@ -2448,17 +2461,21 @@ function randomBigIntBelow(exclusiveUpperBound) {
|
|
|
2448
2461
|
}
|
|
2449
2462
|
function relocationReason(reason) {
|
|
2450
2463
|
switch (reason) {
|
|
2451
|
-
case 'deadline_exceeded':
|
|
2452
|
-
|
|
2453
|
-
case '
|
|
2454
|
-
|
|
2464
|
+
case 'deadline_exceeded':
|
|
2465
|
+
return contracts_1.ZLinkFrameworkRelocationReason.DeadlineExceeded;
|
|
2466
|
+
case 'store_unavailable':
|
|
2467
|
+
return contracts_1.ZLinkFrameworkRelocationReason.StoreUnavailable;
|
|
2468
|
+
case 'target_unavailable':
|
|
2469
|
+
return contracts_1.ZLinkFrameworkRelocationReason.TargetUnavailable;
|
|
2470
|
+
default:
|
|
2471
|
+
return contracts_1.ZLinkFrameworkRelocationReason.RelocationFailed;
|
|
2455
2472
|
}
|
|
2456
2473
|
}
|
|
2457
2474
|
function rewriteAuthorityPayloadForOwner(payload, owner) {
|
|
2458
2475
|
const applicationPayload = (0, service_relocation_runtime_1.serviceRelocationAuthorityApplicationPayload)(payload);
|
|
2459
2476
|
const rewritten = (0, actors_2.isActorAuthorityPayload)(applicationPayload)
|
|
2460
2477
|
? (0, actors_2.rewriteActorAuthorityOwner)(applicationPayload, owner)
|
|
2461
|
-
: (0, service_authority_payload_codec_1.rewriteServiceAuthorityOwner)(applicationPayload, owner) ?? applicationPayload;
|
|
2478
|
+
: ((0, service_authority_payload_codec_1.rewriteServiceAuthorityOwner)(applicationPayload, owner) ?? applicationPayload);
|
|
2462
2479
|
return (0, service_relocation_runtime_1.replaceServiceRelocationAuthorityApplicationPayload)(payload, rewritten);
|
|
2463
2480
|
}
|
|
2464
2481
|
function validateRelocationOptions(options, sourceApplicationVersion) {
|
|
@@ -2466,8 +2483,8 @@ function validateRelocationOptions(options, sourceApplicationVersion) {
|
|
|
2466
2483
|
throw new TypeError('Relocation mode is required.');
|
|
2467
2484
|
}
|
|
2468
2485
|
const mode = options.mode;
|
|
2469
|
-
if (mode !== contracts_1.ZLinkFrameworkRelocationMode.PlannedMaintenance
|
|
2470
|
-
|
|
2486
|
+
if (mode !== contracts_1.ZLinkFrameworkRelocationMode.PlannedMaintenance &&
|
|
2487
|
+
mode !== contracts_1.ZLinkFrameworkRelocationMode.RollingUpdate) {
|
|
2471
2488
|
throw new TypeError('Relocation mode is required.');
|
|
2472
2489
|
}
|
|
2473
2490
|
if (options.mode === contracts_1.ZLinkFrameworkRelocationMode.PlannedMaintenance) {
|
|
@@ -2476,8 +2493,8 @@ function validateRelocationOptions(options, sourceApplicationVersion) {
|
|
|
2476
2493
|
}
|
|
2477
2494
|
return sourceApplicationVersion;
|
|
2478
2495
|
}
|
|
2479
|
-
if (typeof options.targetApplicationVersion !== 'bigint'
|
|
2480
|
-
|
|
2496
|
+
if (typeof options.targetApplicationVersion !== 'bigint' ||
|
|
2497
|
+
options.targetApplicationVersion <= sourceApplicationVersion) {
|
|
2481
2498
|
throw new TypeError('RollingUpdate relocation requires a targetApplicationVersion greater than the source version.');
|
|
2482
2499
|
}
|
|
2483
2500
|
return options.targetApplicationVersion;
|