@zlink-systems/framework 0.30.3 → 0.32.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/Actors/ZLinkActor.d.ts +2 -0
- package/dist/contracts/Actors/ZLinkSessionBindingIdentity.d.ts +6 -0
- package/dist/contracts/Actors/ZLinkSessionBindingIdentity.js +2 -0
- package/dist/contracts/Actors/index.d.ts +1 -0
- package/dist/contracts/Actors/index.js +1 -0
- package/dist/contracts/Common/CoreTypes.d.ts +1 -0
- package/dist/contracts/Common/HandlerMessageType.d.ts +8 -0
- package/dist/contracts/Common/HandlerMessageType.js +41 -0
- package/dist/contracts/Common/ZLinkEncodedPayload.d.ts +1 -1
- package/dist/contracts/Common/ZLinkEncodedPayload.js +12 -20
- package/dist/contracts/Common/ZLinkMessage.js +11 -7
- package/dist/contracts/Common/encoded-payload-storage.d.ts +0 -2
- package/dist/contracts/Common/encoded-payload-storage.js +4 -16
- package/dist/contracts/Common/index.d.ts +1 -1
- package/dist/contracts/Common/payload-slab.d.ts +4 -0
- package/dist/contracts/Common/payload-slab.js +30 -0
- package/dist/contracts/Configuration/RegistrationBuilders.js +15 -9
- package/dist/contracts/Configuration/RegistrationTypes.d.ts +19 -0
- package/dist/contracts/Handlers/Contexts.d.ts +1 -0
- package/dist/contracts/Locations/Authority.d.ts +2 -0
- package/dist/internal.d.ts +9 -0
- package/dist/internal.js +23 -1
- package/dist/nest-integration.d.ts +1 -0
- package/dist/nest-integration.js +3 -1
- package/dist/runtime/actors/actor-client.d.ts +6 -2
- package/dist/runtime/actors/actor-client.js +120 -82
- package/dist/runtime/actors/actor-context.js +16 -5
- package/dist/runtime/actors/actor-execution-context.js +2 -2
- package/dist/runtime/actors/actor-handoff.d.ts +12 -1
- package/dist/runtime/actors/actor-handoff.js +79 -34
- package/dist/runtime/actors/actor-join-deferred-scope.js +6 -6
- package/dist/runtime/actors/actor-local-native-join.d.ts +2 -2
- package/dist/runtime/actors/actor-local-native-join.js +19 -17
- package/dist/runtime/actors/actor-mailbox.d.ts +1 -1
- package/dist/runtime/actors/actor-remote-joiner.d.ts +2 -2
- package/dist/runtime/actors/actor-remote-joiner.js +4 -4
- package/dist/runtime/actors/actor-routed-join-transport.d.ts +9 -3
- package/dist/runtime/actors/actor-routed-json-request.d.ts +3 -0
- package/dist/runtime/actors/actor-runtime-contracts.d.ts +2 -2
- package/dist/runtime/actors/actor-runtime-state.d.ts +1 -1
- package/dist/runtime/actors/spot-actor-dispatch.d.ts +9 -5
- package/dist/runtime/actors/spot-actor-dispatch.js +60 -38
- package/dist/runtime/admission.d.ts +6 -4
- package/dist/runtime/admission.js +21 -10
- package/dist/runtime/application-jobs/application-ingress-record-owner.d.ts +1 -0
- package/dist/runtime/application-jobs/application-ingress-record-owner.js +3 -0
- package/dist/runtime/backend/contracts/index.d.ts +26 -10
- package/dist/runtime/backend/mesh-completion-table.d.ts +7 -1
- package/dist/runtime/backend/mesh-completion-table.js +84 -20
- package/dist/runtime/backend/mesh-dispatch-pump.d.ts +19 -6
- package/dist/runtime/backend/mesh-dispatch-pump.js +246 -147
- package/dist/runtime/backend/node/node-backend-adapter-support.d.ts +3 -2
- package/dist/runtime/backend/node/node-backend-adapter-support.js +27 -19
- package/dist/runtime/backend/node/node-dealer-channel-client-transport.d.ts +5 -2
- package/dist/runtime/backend/node/node-dealer-channel-client-transport.js +70 -13
- package/dist/runtime/backend/node/node-event-loop-poller.d.ts +2 -2
- package/dist/runtime/backend/node/node-event-loop-poller.js +4 -3
- package/dist/runtime/backend/node/node-mesh-backend-adapter.js +5 -1
- package/dist/runtime/backend/node/node-raw-binding-port.d.ts +7 -2
- package/dist/runtime/backend/node/node-raw-binding-port.js +99 -63
- package/dist/runtime/backend/node/node-raw-mesh-backend.d.ts +34 -16
- package/dist/runtime/backend/node/node-raw-mesh-backend.js +210 -106
- package/dist/runtime/backend/node/node-socket-backend-adapter.js +20 -6
- package/dist/runtime/backend/raw-binding-port.d.ts +6 -3
- package/dist/runtime/channels/channel-clients.js +3 -3
- package/dist/runtime/channels/channel-dispatch-pipeline.d.ts +11 -7
- package/dist/runtime/channels/channel-dispatch-pipeline.js +40 -22
- package/dist/runtime/channels/channel-dispatch-services.d.ts +3 -1
- package/dist/runtime/channels/channel-dispatch-services.js +7 -6
- package/dist/runtime/channels/channel-dispatchers.d.ts +13 -6
- package/dist/runtime/channels/channel-dispatchers.js +57 -36
- package/dist/runtime/channels/channel-envelope.d.ts +2 -2
- package/dist/runtime/channels/channel-envelope.js +609 -83
- package/dist/runtime/channels/channel-multipart.d.ts +1 -0
- package/dist/runtime/channels/channel-multipart.js +10 -6
- package/dist/runtime/channels/channel-outbound-operations.d.ts +6 -9
- package/dist/runtime/channels/channel-outbound-operations.js +107 -105
- package/dist/runtime/channels/channel-receive-loops.d.ts +9 -7
- package/dist/runtime/channels/channel-receive-loops.js +126 -90
- package/dist/runtime/channels/channel-runtime-lifecycle.d.ts +23 -6
- package/dist/runtime/channels/channel-runtime-lifecycle.js +47 -38
- package/dist/runtime/channels/channel-runtime-manager.d.ts +13 -6
- package/dist/runtime/channels/channel-runtime-manager.js +32 -14
- package/dist/runtime/channels/channel-socket-registry.d.ts +28 -4
- package/dist/runtime/channels/channel-socket-registry.js +9 -1
- package/dist/runtime/channels/channel-transports.d.ts +23 -16
- package/dist/runtime/channels/channel-transports.js +139 -119
- package/dist/runtime/channels/dispatch-error-reporter.d.ts +4 -4
- package/dist/runtime/channels/dispatch-error-reporter.js +5 -5
- package/dist/runtime/channels/fanout-location-runtime.d.ts +1 -1
- package/dist/runtime/channels/local-spot-route-transport.d.ts +5 -2
- package/dist/runtime/channels/local-spot-route-transport.js +15 -18
- package/dist/runtime/channels/router-socket-spot-route-transport.d.ts +6 -3
- package/dist/runtime/channels/router-socket-spot-route-transport.js +33 -19
- package/dist/runtime/channels/source-spot-router.d.ts +6 -3
- package/dist/runtime/channels/source-spot-router.js +34 -23
- package/dist/runtime/channels/spot-node-route-transport.d.ts +6 -3
- package/dist/runtime/channels/spot-node-route-transport.js +23 -17
- package/dist/runtime/channels/spot-route-bridge-transport.d.ts +6 -3
- package/dist/runtime/channels/spot-route-bridge-transport.js +38 -24
- package/dist/runtime/channels/spot-route-dispatch-strategy.d.ts +8 -4
- package/dist/runtime/channels/spot-route-dispatch-strategy.js +36 -23
- package/dist/runtime/diagnostics/dispatch-error-details.js +9 -3
- package/dist/runtime/diagnostics/message-flow-bootstrap.d.ts +1 -0
- package/dist/runtime/diagnostics/message-flow-bootstrap.js +8 -0
- package/dist/runtime/diagnostics/message-flow-delivery.d.ts +47 -0
- package/dist/runtime/diagnostics/message-flow-delivery.js +149 -0
- package/dist/runtime/diagnostics/message-flow-record.d.ts +50 -0
- package/dist/runtime/diagnostics/message-flow-record.js +228 -0
- package/dist/runtime/diagnostics/message-flow-worker.d.ts +1 -0
- package/dist/runtime/diagnostics/message-flow-worker.js +118 -0
- package/dist/runtime/diagnostics/message-flow.d.ts +7 -19
- package/dist/runtime/diagnostics/message-flow.js +42 -290
- package/dist/runtime/diagnostics/runtime-metrics.d.ts +4 -3
- package/dist/runtime/diagnostics/runtime-metrics.js +8 -4
- package/dist/runtime/execution/index.d.ts +1 -0
- package/dist/runtime/execution/index.js +6 -3
- package/dist/runtime/execution/serial-execution-queue.d.ts +26 -13
- package/dist/runtime/execution/serial-execution-queue.js +75 -71
- package/dist/runtime/foundation/durable-service-request.d.ts +12 -3
- package/dist/runtime/foundation/durable-service-request.js +158 -73
- package/dist/runtime/foundation/operation-registry.d.ts +33 -3
- package/dist/runtime/foundation/operation-registry.js +272 -33
- package/dist/runtime/foundation/raw-service-mesh-runtime.d.ts +62 -23
- package/dist/runtime/foundation/raw-service-mesh-runtime.js +373 -194
- package/dist/runtime/foundation/request-runtime.d.ts +17 -0
- package/dist/runtime/foundation/request-runtime.js +163 -0
- package/dist/runtime/foundation/service-discovery-registry.d.ts +4 -0
- package/dist/runtime/foundation/service-discovery-registry.js +6 -0
- package/dist/runtime/foundation/service-liveness-registry.d.ts +1 -1
- package/dist/runtime/foundation/service-mailbox.d.ts +4 -2
- package/dist/runtime/foundation/service-mailbox.js +4 -1
- package/dist/runtime/foundation/service-relocation-object-owner.d.ts +2 -2
- package/dist/runtime/foundation/service-relocation-object-owner.js +12 -5
- package/dist/runtime/foundation/service-runtime-contracts.d.ts +7 -2
- package/dist/runtime/foundation/service-stateful-registry.d.ts +6 -2
- package/dist/runtime/foundation/service-stateful-registry.js +38 -17
- package/dist/runtime/foundation/service-stateful-runtime.d.ts +91 -26
- package/dist/runtime/foundation/service-stateful-runtime.js +245 -120
- package/dist/runtime/foundation/service-stateful-wire-codec.d.ts +3 -0
- package/dist/runtime/foundation/service-stateful-wire-codec.js +15 -0
- package/dist/runtime/foundation/service-topology-registry.d.ts +2 -0
- package/dist/runtime/foundation/service-topology-registry.js +13 -3
- package/dist/runtime/foundation/service-wire-constants.generated.d.ts +1 -0
- package/dist/runtime/foundation/service-wire-constants.generated.js +12 -0
- package/dist/runtime/foundation/service-wire-m6a-codec.d.ts +5 -1
- package/dist/runtime/foundation/service-wire-m6a-codec.js +50 -15
- package/dist/runtime/host/actor-packet-relay.d.ts +5 -6
- package/dist/runtime/host/actor-packet-relay.js +58 -57
- package/dist/runtime/host/actor-placement-coordinator.d.ts +1 -1
- package/dist/runtime/host/actor-runtime-options-factory.d.ts +2 -0
- package/dist/runtime/host/actor-runtime-options-factory.js +3 -2
- package/dist/runtime/host/actor-transfer-runtime.d.ts +3 -3
- package/dist/runtime/host/application-job-queue.d.ts +7 -5
- package/dist/runtime/host/application-job-queue.js +33 -21
- package/dist/runtime/host/bound-session-relay.js +0 -1
- package/dist/runtime/host/channel-runtime-options-factory.d.ts +2 -0
- package/dist/runtime/host/channel-runtime-options-factory.js +1 -0
- package/dist/runtime/host/entry-actor-runtime.d.ts +5 -2
- package/dist/runtime/host/entry-actor-runtime.js +2 -2
- package/dist/runtime/host/index.d.ts +106 -37
- package/dist/runtime/host/index.js +303 -151
- package/dist/runtime/host/location-runtime-owner.d.ts +2 -2
- package/dist/runtime/host/location-runtime-owner.js +1 -1
- package/dist/runtime/host/service-relocation-host-runtime.d.ts +195 -45
- package/dist/runtime/host/service-relocation-host-runtime.js +257 -144
- package/dist/runtime/host/spot-address-transport.d.ts +3 -0
- package/dist/runtime/host/spot-address-transport.js +73 -76
- package/dist/runtime/host/spot-runtime-options-factory.js +2 -0
- package/dist/runtime/host/user-spot-creation-coordinator.d.ts +3 -1
- package/dist/runtime/host/user-spot-creation-coordinator.js +49 -21
- package/dist/runtime/internal-observation.d.ts +1 -0
- package/dist/runtime/internal-observation.js +5 -0
- package/dist/runtime/locations/actor-location-claims.d.ts +1 -1
- package/dist/runtime/locations/actor-location-claims.js +15 -6
- package/dist/runtime/locations/auto-connect-loop.d.ts +0 -1
- package/dist/runtime/locations/auto-connect-loop.js +25 -19
- package/dist/runtime/locations/auto-connect-planner.js +2 -5
- package/dist/runtime/locations/auto-connect-reconciler.d.ts +1 -0
- package/dist/runtime/locations/auto-connect-reconciler.js +35 -23
- package/dist/runtime/locations/in-memory-authority-store.d.ts +1 -0
- package/dist/runtime/locations/in-memory-authority-store.js +15 -5
- package/dist/runtime/locations/in-memory-location-store.d.ts +0 -2
- package/dist/runtime/locations/in-memory-location-store.js +1 -38
- package/dist/runtime/locations/lifecycle.d.ts +1 -1
- package/dist/runtime/locations/lifecycle.js +2 -2
- package/dist/runtime/locations/location-store-repository.d.ts +0 -1
- package/dist/runtime/locations/location-store-repository.js +163 -246
- package/dist/runtime/locations/resolvers.d.ts +8 -1
- package/dist/runtime/locations/resolvers.js +16 -2
- package/dist/runtime/locations/runtime.d.ts +3 -3
- package/dist/runtime/locations/runtime.js +12 -16
- package/dist/runtime/messaging/creation-payload-codec.js +8 -7
- package/dist/runtime/messaging/framework-json-v1.d.ts +1 -1
- package/dist/runtime/messaging/framework-json-v1.js +6 -2
- package/dist/runtime/messaging/payload-codec.js +21 -35
- package/dist/runtime/messaging/request-deadline.d.ts +4 -2
- package/dist/runtime/messaging/request-deadline.js +40 -25
- package/dist/runtime/messaging/request-result.d.ts +14 -1
- package/dist/runtime/messaging/request-result.js +74 -13
- package/dist/runtime/protocol/service_wire_codec.generated.d.ts +4 -0
- package/dist/runtime/protocol/service_wire_codec.generated.js +17 -7
- package/dist/runtime/spots/index.d.ts +28 -7
- package/dist/runtime/spots/index.js +31 -6
- package/dist/runtime/spots/spot-activation-registry.d.ts +3 -2
- package/dist/runtime/spots/spot-activation-registry.js +13 -8
- package/dist/runtime/spots/spot-activation-state.d.ts +2 -0
- package/dist/runtime/spots/spot-activation-state.js +1 -0
- package/dist/runtime/spots/spot-actor-admission-coordinator.d.ts +9 -4
- package/dist/runtime/spots/spot-actor-admission-coordinator.js +33 -12
- package/dist/runtime/spots/spot-actor-ingress-admission.d.ts +40 -0
- package/dist/runtime/spots/spot-actor-ingress-admission.js +78 -0
- package/dist/runtime/spots/spot-actor-membership.js +3 -3
- package/dist/runtime/spots/spot-actor-packet-dispatch.d.ts +16 -43
- package/dist/runtime/spots/spot-actor-packet-dispatch.js +56 -113
- package/dist/runtime/spots/spot-actor-packet-drain.d.ts +1 -0
- package/dist/runtime/spots/spot-actor-packet-drain.js +12 -5
- package/dist/runtime/spots/spot-entry-activation.d.ts +4 -3
- package/dist/runtime/spots/spot-entry-activation.js +7 -12
- package/dist/runtime/spots/spot-handler-registry.d.ts +5 -1
- package/dist/runtime/spots/spot-handler-registry.js +31 -15
- package/dist/runtime/spots/spot-manager-public.js +3 -2
- package/dist/runtime/spots/spot-node-runtime-manager.d.ts +11 -6
- package/dist/runtime/spots/spot-node-runtime-manager.js +6 -1
- package/dist/runtime/spots/spot-outbound.d.ts +8 -2
- package/dist/runtime/spots/spot-outbound.js +5 -5
- package/dist/runtime/spots/spot-route-packet-dispatch.js +13 -8
- package/dist/runtime/spots/spot-routed-spot-packet-dispatch.d.ts +3 -3
- package/dist/runtime/spots/spot-routed-spot-packet-dispatch.js +9 -5
- package/dist/runtime/spots/spot-runtime-ports.d.ts +2 -2
- package/dist/runtime/spots/spot-serial-executor.d.ts +2 -1
- package/dist/runtime/spots/spot-serial-turn-executor.js +20 -26
- package/dist/runtime/spots/spot-subscription-dispatch.js +5 -2
- package/dist/runtime/spots/spot-timer.d.ts +1 -1
- package/dist/runtime/streams/actor-session-binding-registry.d.ts +11 -3
- package/dist/runtime/streams/actor-session-binding-registry.js +28 -0
- package/dist/runtime/streams/bound-actor-relay-sender.d.ts +2 -2
- package/dist/runtime/streams/bound-actor-relay-sender.js +3 -4
- package/dist/runtime/streams/bound-session-service.js +6 -7
- package/dist/runtime/streams/index.d.ts +3 -3
- package/dist/runtime/streams/index.js +22 -2
- package/dist/runtime/streams/managed-stream.js +2 -1
- package/dist/runtime/streams/session-calls.d.ts +1 -1
- package/dist/runtime/streams/session-calls.js +3 -9
- package/dist/runtime/streams/session-context.d.ts +2 -2
- package/dist/runtime/streams/session-context.js +2 -2
- package/dist/runtime/streams/stream-session-runtime.d.ts +1 -0
- package/dist/runtime/streams/stream-session-runtime.js +64 -33
- package/package.json +3 -3
- package/src/contracts/Actors/ZLinkActor.ts +6 -0
- package/src/contracts/Actors/ZLinkSessionBindingIdentity.ts +7 -0
- package/src/contracts/Actors/index.ts +1 -0
- package/src/contracts/Common/CoreTypes.ts +1 -0
- package/src/contracts/Common/HandlerMessageType.ts +50 -0
- package/src/contracts/Common/ZLinkEncodedPayload.ts +13 -25
- package/src/contracts/Common/ZLinkMessage.ts +11 -7
- package/src/contracts/Common/encoded-payload-storage.ts +4 -16
- package/src/contracts/Common/index.ts +1 -1
- package/src/contracts/Common/payload-slab.ts +29 -0
- package/src/contracts/Configuration/RegistrationBuilders.ts +29 -15
- package/src/contracts/Configuration/RegistrationTypes.ts +19 -0
- package/src/contracts/Handlers/Contexts.ts +1 -0
- package/src/contracts/Locations/Authority.ts +7 -1
- package/src/internal.ts +17 -0
- package/src/nest-integration.ts +1 -0
- package/src/runtime/actors/actor-client.ts +257 -163
- package/src/runtime/actors/actor-context.ts +26 -14
- package/src/runtime/actors/actor-execution-context.ts +2 -2
- package/src/runtime/actors/actor-handoff.ts +86 -51
- package/src/runtime/actors/actor-join-deferred-scope.ts +6 -6
- package/src/runtime/actors/actor-local-native-join.ts +38 -17
- package/src/runtime/actors/actor-mailbox.ts +1 -1
- package/src/runtime/actors/actor-remote-joiner.ts +8 -4
- package/src/runtime/actors/actor-routed-join-transport.ts +13 -5
- package/src/runtime/actors/actor-routed-json-request.ts +3 -0
- package/src/runtime/actors/actor-runtime-contracts.ts +4 -2
- package/src/runtime/actors/actor-runtime-state.ts +1 -1
- package/src/runtime/actors/spot-actor-dispatch.ts +70 -68
- package/src/runtime/admission.ts +42 -15
- package/src/runtime/application-jobs/application-ingress-record-owner.ts +4 -0
- package/src/runtime/backend/contracts/index.ts +77 -10
- package/src/runtime/backend/mesh-completion-table.ts +106 -15
- package/src/runtime/backend/mesh-dispatch-pump.ts +294 -146
- package/src/runtime/backend/node/node-backend-adapter-support.ts +42 -32
- package/src/runtime/backend/node/node-dealer-channel-client-transport.ts +91 -34
- package/src/runtime/backend/node/node-event-loop-poller.ts +14 -5
- package/src/runtime/backend/node/node-mesh-backend-adapter.ts +5 -1
- package/src/runtime/backend/node/node-raw-binding-port.ts +180 -69
- package/src/runtime/backend/node/node-raw-mesh-backend.ts +386 -157
- package/src/runtime/backend/node/node-socket-backend-adapter.ts +56 -11
- package/src/runtime/backend/raw-binding-port.ts +13 -5
- package/src/runtime/channels/channel-clients.ts +26 -11
- package/src/runtime/channels/channel-dispatch-pipeline.ts +77 -65
- package/src/runtime/channels/channel-dispatch-services.ts +7 -12
- package/src/runtime/channels/channel-dispatchers.ts +93 -39
- package/src/runtime/channels/channel-envelope.ts +680 -144
- package/src/runtime/channels/channel-multipart.ts +17 -13
- package/src/runtime/channels/channel-outbound-operations.ts +204 -178
- package/src/runtime/channels/channel-receive-loops.ts +160 -107
- package/src/runtime/channels/channel-runtime-lifecycle.ts +64 -59
- package/src/runtime/channels/channel-runtime-manager.ts +74 -27
- package/src/runtime/channels/channel-socket-registry.ts +20 -5
- package/src/runtime/channels/channel-transports.ts +414 -287
- package/src/runtime/channels/dispatch-error-reporter.ts +4 -9
- package/src/runtime/channels/local-spot-route-transport.ts +27 -29
- package/src/runtime/channels/router-socket-spot-route-transport.ts +63 -32
- package/src/runtime/channels/source-spot-router.ts +75 -38
- package/src/runtime/channels/spot-node-route-transport.ts +67 -37
- package/src/runtime/channels/spot-route-bridge-transport.ts +62 -30
- package/src/runtime/channels/spot-route-dispatch-strategy.ts +105 -34
- package/src/runtime/diagnostics/dispatch-error-details.ts +10 -2
- package/src/runtime/diagnostics/message-flow-bootstrap.ts +6 -0
- package/src/runtime/diagnostics/message-flow-delivery.ts +171 -0
- package/src/runtime/diagnostics/message-flow-record.ts +295 -0
- package/src/runtime/diagnostics/message-flow-worker.ts +146 -0
- package/src/runtime/diagnostics/message-flow.ts +49 -362
- package/src/runtime/diagnostics/runtime-metrics.ts +10 -4
- package/src/runtime/execution/index.ts +6 -0
- package/src/runtime/execution/serial-execution-queue.ts +94 -96
- package/src/runtime/foundation/durable-service-request.ts +212 -89
- package/src/runtime/foundation/operation-registry.ts +287 -38
- package/src/runtime/foundation/raw-service-mesh-runtime.ts +617 -292
- package/src/runtime/foundation/request-runtime.ts +227 -0
- package/src/runtime/foundation/service-discovery-registry.ts +7 -0
- package/src/runtime/foundation/service-liveness-registry.ts +1 -1
- package/src/runtime/foundation/service-mailbox.ts +7 -2
- package/src/runtime/foundation/service-relocation-object-owner.ts +21 -6
- package/src/runtime/foundation/service-runtime-contracts.ts +12 -2
- package/src/runtime/foundation/service-stateful-registry.ts +52 -19
- package/src/runtime/foundation/service-stateful-runtime.ts +365 -198
- package/src/runtime/foundation/service-stateful-wire-codec.ts +18 -0
- package/src/runtime/foundation/service-topology-registry.ts +21 -3
- package/src/runtime/foundation/service-wire-constants.generated.ts +10 -0
- package/src/runtime/foundation/service-wire-m6a-codec.ts +69 -17
- package/src/runtime/host/actor-packet-relay.ts +160 -156
- package/src/runtime/host/actor-placement-coordinator.ts +1 -1
- package/src/runtime/host/actor-runtime-options-factory.ts +7 -2
- package/src/runtime/host/actor-transfer-runtime.ts +3 -3
- package/src/runtime/host/application-job-queue.ts +56 -27
- package/src/runtime/host/bound-session-relay.ts +0 -1
- package/src/runtime/host/channel-runtime-options-factory.ts +3 -0
- package/src/runtime/host/entry-actor-runtime.ts +14 -6
- package/src/runtime/host/index.ts +388 -113
- package/src/runtime/host/location-runtime-owner.ts +3 -3
- package/src/runtime/host/service-relocation-host-runtime.ts +380 -252
- package/src/runtime/host/spot-address-transport.ts +110 -95
- package/src/runtime/host/spot-runtime-options-factory.ts +3 -0
- package/src/runtime/host/user-spot-creation-coordinator.ts +69 -22
- package/src/runtime/internal-observation.ts +2 -0
- package/src/runtime/locations/actor-location-claims.ts +42 -16
- package/src/runtime/locations/auto-connect-loop.ts +24 -16
- package/src/runtime/locations/auto-connect-planner.ts +2 -5
- package/src/runtime/locations/auto-connect-reconciler.ts +37 -24
- package/src/runtime/locations/in-memory-authority-store.ts +27 -7
- package/src/runtime/locations/in-memory-location-store.ts +1 -74
- package/src/runtime/locations/lifecycle.ts +4 -2
- package/src/runtime/locations/location-store-repository.ts +228 -308
- package/src/runtime/locations/resolvers.ts +20 -8
- package/src/runtime/locations/runtime.ts +16 -28
- package/src/runtime/messaging/creation-payload-codec.ts +12 -10
- package/src/runtime/messaging/framework-json-v1.ts +10 -1
- package/src/runtime/messaging/payload-codec.ts +50 -75
- package/src/runtime/messaging/request-deadline.ts +47 -39
- package/src/runtime/messaging/request-result.ts +88 -17
- package/src/runtime/protocol/service_wire_codec.generated.ts +18 -8
- package/src/runtime/protocol/service_wire_pilot_codec.generated.ts +1 -1
- package/src/runtime/spots/index.ts +57 -10
- package/src/runtime/spots/spot-activation-registry.ts +12 -8
- package/src/runtime/spots/spot-activation-state.ts +2 -0
- package/src/runtime/spots/spot-actor-admission-coordinator.ts +62 -37
- package/src/runtime/spots/spot-actor-ingress-admission.ts +157 -0
- package/src/runtime/spots/spot-actor-membership.ts +8 -5
- package/src/runtime/spots/spot-actor-packet-dispatch.ts +122 -206
- package/src/runtime/spots/spot-actor-packet-drain.ts +21 -6
- package/src/runtime/spots/spot-entry-activation.ts +25 -35
- package/src/runtime/spots/spot-handler-registry.ts +72 -15
- package/src/runtime/spots/spot-manager-public.ts +4 -2
- package/src/runtime/spots/spot-node-runtime-manager.ts +16 -7
- package/src/runtime/spots/spot-outbound.ts +26 -10
- package/src/runtime/spots/spot-route-packet-dispatch.ts +18 -8
- package/src/runtime/spots/spot-routed-spot-packet-dispatch.ts +14 -8
- package/src/runtime/spots/spot-runtime-ports.ts +5 -2
- package/src/runtime/spots/spot-serial-executor.ts +1 -1
- package/src/runtime/spots/spot-serial-turn-executor.ts +25 -40
- package/src/runtime/spots/spot-subscription-dispatch.ts +9 -2
- package/src/runtime/spots/spot-timer.ts +1 -1
- package/src/runtime/streams/actor-session-binding-registry.ts +46 -3
- package/src/runtime/streams/bound-actor-relay-sender.ts +16 -5
- package/src/runtime/streams/bound-session-service.ts +10 -7
- package/src/runtime/streams/index.ts +30 -4
- package/src/runtime/streams/managed-stream.ts +2 -1
- package/src/runtime/streams/session-calls.ts +9 -14
- package/src/runtime/streams/session-context.ts +6 -11
- package/src/runtime/streams/stream-session-runtime.ts +79 -40
- package/dist/runtime/spots/spot-lifecycle-metrics.d.ts +0 -8
- package/dist/runtime/spots/spot-lifecycle-metrics.js +0 -17
- package/src/runtime/spots/spot-lifecycle-metrics.ts +0 -16
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import { ZLinkFrameworkException, ZLinkFrameworkErrorKind } from '../../contracts';
|
|
2
|
+
import { RequestRuntime } from '../foundation/request-runtime';
|
|
3
|
+
import { inspectRuntime } from '../internal-observation';
|
|
1
4
|
import { ZLinkProviderRelocationRepository } from '../locations/relocation-blob';
|
|
2
5
|
import type { ApplicationJobOrigin } from '../application-jobs/contracts';
|
|
3
6
|
import { currentApplicationJobOrigin } from '../application-jobs/application-job-queue-scope';
|
|
@@ -9,6 +12,7 @@ import { isDeepStrictEqual } from 'node:util';
|
|
|
9
12
|
import {
|
|
10
13
|
type ActorRef,
|
|
11
14
|
type RoutingId,
|
|
15
|
+
type ZLinkSessionBindingIdentity,
|
|
12
16
|
type ZLinkClientServerRuntime,
|
|
13
17
|
type ZLinkFanoutRuntime,
|
|
14
18
|
type ZLinkFrameworkLifecycleOptions,
|
|
@@ -125,6 +129,11 @@ import {
|
|
|
125
129
|
} from '../diagnostics';
|
|
126
130
|
import { METRIC_NAMES, MILLISECONDS_PER_SECOND } from '../diagnostics/runtime-metrics';
|
|
127
131
|
import { RuntimeEventQueue } from '../diagnostics/runtime-observation-queue';
|
|
132
|
+
import {
|
|
133
|
+
openTelemetryLease,
|
|
134
|
+
renewTelemetryLease,
|
|
135
|
+
retireTelemetryLease
|
|
136
|
+
} from '../diagnostics/message-flow-delivery';
|
|
128
137
|
import {
|
|
129
138
|
ZLinkClientServerRuntimeProjection,
|
|
130
139
|
ZLinkFanoutRuntimeProjection
|
|
@@ -207,7 +216,7 @@ import {
|
|
|
207
216
|
nodeEffectiveProcessorCount,
|
|
208
217
|
resolveApplicationJobQueueConfiguration
|
|
209
218
|
} from './application-job-queue';
|
|
210
|
-
import { ZLinkBoundSessionRelay } from './bound-session-relay';
|
|
219
|
+
import { ZLinkBoundSessionRelay, type ZLinkBoundSessionRelayOptions } from './bound-session-relay';
|
|
211
220
|
import { ZLinkChannelRuntimeOptionsFactory } from './channel-runtime-options-factory';
|
|
212
221
|
import { ZLinkEntryActorRuntimeService } from './entry-actor-runtime';
|
|
213
222
|
import { HostCapacityStatusProjection } from './host-capacity-status';
|
|
@@ -255,10 +264,28 @@ export interface ZLinkFrameworkRuntimeHostOptions {
|
|
|
255
264
|
export class ZLinkFrameworkRuntimeHost
|
|
256
265
|
implements ZLinkFrameworkRuntimeLifecycle, ZLinkFrameworkRuntime, ZLinkMessageFlowControl
|
|
257
266
|
{
|
|
267
|
+
[inspectRuntime]() {
|
|
268
|
+
return Object.freeze({
|
|
269
|
+
ownerLeaseUsable: this.locationOwner.currentRuntime?.ownerLeaseUsable,
|
|
270
|
+
ownerId: this.locationOwner.currentRuntime?.ownerId,
|
|
271
|
+
hasOwnerToken: this.locationOwner.currentRuntime?.currentOwnerToken !== undefined,
|
|
272
|
+
ownerAdmissionOpen: this.admission.ownerAdmissionOpen(),
|
|
273
|
+
channelRuntimeStarted: this.channelRuntime !== undefined,
|
|
274
|
+
fanoutStoreIsLocationStore:
|
|
275
|
+
this.locationOwner.currentStores?.fanoutStore ===
|
|
276
|
+
this.locationOwner.currentStores?.locationStore,
|
|
277
|
+
fanoutStoreMethods: Object.freeze({
|
|
278
|
+
update: typeof this.locationOwner.currentStores?.fanoutStore?.updateFanoutPublisher,
|
|
279
|
+
remove: typeof this.locationOwner.currentStores?.fanoutStore?.removeFanoutPublisher,
|
|
280
|
+
list: typeof this.locationOwner.currentStores?.fanoutStore?.listFanoutPublishers
|
|
281
|
+
})
|
|
282
|
+
});
|
|
283
|
+
}
|
|
284
|
+
|
|
258
285
|
private readonly backendAdapterFactory: ZLinkBackendAdapterFactory;
|
|
259
286
|
private readonly lifecycleSink?: string[];
|
|
260
|
-
|
|
261
|
-
|
|
287
|
+
executionState?: ZLinkFrameworkExecutionState;
|
|
288
|
+
runtimeState = ZLinkFrameworkRuntimeState.Preparing;
|
|
262
289
|
private runtimeStatus?: ZLinkFrameworkRuntimeStatus;
|
|
263
290
|
private readonly runtimeObservationSource = Symbol('zlink.framework-runtime');
|
|
264
291
|
private runtimeDeadline?: Date;
|
|
@@ -273,21 +300,21 @@ export class ZLinkFrameworkRuntimeHost
|
|
|
273
300
|
private shutdownOperationStartedAt?: number;
|
|
274
301
|
private relocationTargetApplicationVersion?: bigint;
|
|
275
302
|
private readonly runtimeObservers = new Set<RuntimeEventQueue<ZLinkFrameworkRuntimeStatus>>();
|
|
276
|
-
|
|
277
|
-
|
|
303
|
+
channelRuntime?: ZLinkChannelRuntimeManager;
|
|
304
|
+
spotNodeRuntime?: ZLinkSpotNodeRuntimeManager;
|
|
278
305
|
private streamRuntime?: ZLinkStreamRuntimeManager;
|
|
279
306
|
private statefulAuthorityRoutes?: ZLinkStatefulAuthorityRouteRuntime;
|
|
280
|
-
|
|
307
|
+
readonly locationOwner: ZLinkLocationRuntimeOwner;
|
|
281
308
|
private readonly meshRouters: MeshRouterResolver;
|
|
282
|
-
|
|
309
|
+
readonly boundSessionRelay: ZLinkBoundSessionRelay;
|
|
283
310
|
private readonly actorHandoff: ZLinkActorHandoffCoordinator;
|
|
284
311
|
private readonly actorTransferRegistry: ZLinkActorTransferRegistry;
|
|
285
312
|
private readonly actorTransferRuntime: ZLinkActorTransferRuntime;
|
|
286
313
|
private readonly actorTransferAuthorityRuntime: ZLinkActorTransferAuthorityRuntime;
|
|
287
|
-
|
|
288
|
-
|
|
314
|
+
readonly serviceRelocation: ZLinkHostServiceRelocationRuntime;
|
|
315
|
+
readonly entryActorRuntime: ZLinkEntryActorRuntimeService;
|
|
289
316
|
private actorManager?: DefaultZLinkActorManager;
|
|
290
|
-
|
|
317
|
+
actorPlacement?: ZLinkActorPlacementCoordinator;
|
|
291
318
|
private spotManager?: DefaultZLinkSpotManager;
|
|
292
319
|
private userSpotCoordinator?: ZLinkUserSpotCreationCoordinator;
|
|
293
320
|
private ownerLeaseRecoveryRuntime?: ZLinkLocationRuntime;
|
|
@@ -298,11 +325,11 @@ export class ZLinkFrameworkRuntimeHost
|
|
|
298
325
|
private readonly destroyedActorRefs = new Map<string, ActorRef>();
|
|
299
326
|
private readonly runtimeEventPublisher: ZLinkRuntimeEventPublisher;
|
|
300
327
|
private readonly metrics: ZLinkRuntimeMetrics;
|
|
301
|
-
|
|
328
|
+
readonly applicationJobQueue: ApplicationJobQueue;
|
|
302
329
|
private readonly capacityStatus: HostCapacityStatusProjection;
|
|
303
330
|
private readonly metricRegistrations: import('../diagnostics').ZLinkRuntimeMetricRegistration[] =
|
|
304
331
|
[];
|
|
305
|
-
|
|
332
|
+
readonly admission: ZLinkRuntimeAdmissionGate;
|
|
306
333
|
private readonly activationAdmission = new ZLinkActivationAdmission(
|
|
307
334
|
(meshName) =>
|
|
308
335
|
this.options.registration.spotNodes.get(meshName)?.activationConcurrencyLimit ??
|
|
@@ -315,11 +342,12 @@ export class ZLinkFrameworkRuntimeHost
|
|
|
315
342
|
private readonly messageFlowModeCell: ZLinkMessageFlowModeCell = {
|
|
316
343
|
mode: 'errors'
|
|
317
344
|
};
|
|
318
|
-
private
|
|
345
|
+
private telemetryLease = openTelemetryLease();
|
|
346
|
+
private dispatchErrorReporters = new WeakMap<
|
|
319
347
|
ZLinkDispatchErrorSink,
|
|
320
348
|
ZLinkDispatchErrorReporter
|
|
321
349
|
>();
|
|
322
|
-
|
|
350
|
+
readonly runtimeOrPreStartErrorSink: ZLinkDispatchErrorSink = {
|
|
323
351
|
reportRuntimeTaskException: (taskName: string, error: unknown) =>
|
|
324
352
|
(this.errorSink ?? this.preStartErrorSink).reportRuntimeTaskException(taskName, error)
|
|
325
353
|
};
|
|
@@ -330,6 +358,7 @@ export class ZLinkFrameworkRuntimeHost
|
|
|
330
358
|
readonly routeMeshRuntimeOptions = new DefaultZLinkRouteMeshRuntimeOptions(
|
|
331
359
|
() => this.spotNodeRuntime
|
|
332
360
|
);
|
|
361
|
+
private readonly requests = new RequestRuntime();
|
|
333
362
|
readonly routeTransport: ZLinkRuntimeRouteTransport;
|
|
334
363
|
readonly spotAddressTransport: ZLinkHostSpotAddressTransport;
|
|
335
364
|
readonly spotPublisherTransport = new ZLinkRuntimeSpotPublisherTransport(
|
|
@@ -342,11 +371,27 @@ export class ZLinkFrameworkRuntimeHost
|
|
|
342
371
|
readonly clientServerRuntime: ZLinkClientServerRuntime;
|
|
343
372
|
readonly fanoutRuntime: ZLinkFanoutRuntime;
|
|
344
373
|
private readonly relocationStore?: import('../../contracts/Locations/RelocationStore').ZLinkRelocationStore;
|
|
345
|
-
|
|
374
|
+
readonly routeMeshCoordinator: ZLinkRouteMeshRuntimeCoordinator;
|
|
346
375
|
constructor(
|
|
347
376
|
readonly options: ZLinkFrameworkRuntimeHostOptions,
|
|
348
377
|
internalOptions?: unknown
|
|
349
378
|
) {
|
|
379
|
+
const factories = internalOptions as
|
|
380
|
+
| {
|
|
381
|
+
readonly spotNodeRuntime?: ZLinkSpotNodeRuntimeManager;
|
|
382
|
+
readonly createBoundSessionRelay?: (
|
|
383
|
+
options: ZLinkBoundSessionRelayOptions
|
|
384
|
+
) => ZLinkBoundSessionRelay;
|
|
385
|
+
readonly createRouteMeshCoordinator?: (
|
|
386
|
+
options: ConstructorParameters<typeof ZLinkRouteMeshRuntimeCoordinator>[0]
|
|
387
|
+
) => ZLinkRouteMeshRuntimeCoordinator;
|
|
388
|
+
readonly createAdmissionGate?: (ownerOpen: () => boolean) => ZLinkRuntimeAdmissionGate;
|
|
389
|
+
}
|
|
390
|
+
| undefined;
|
|
391
|
+
this.spotNodeRuntime = factories?.spotNodeRuntime;
|
|
392
|
+
this.admission = (
|
|
393
|
+
factories?.createAdmissionGate ?? ((ownerOpen) => new ZLinkRuntimeAdmissionGate(ownerOpen))
|
|
394
|
+
)(() => this.ownerAdmissionOpen());
|
|
350
395
|
this.backendAdapterFactory = resolveBackendAdapterFactory(internalOptions);
|
|
351
396
|
this.lifecycleSink = options.lifecycleSink;
|
|
352
397
|
this.runtimeEventPublisher =
|
|
@@ -387,7 +432,18 @@ export class ZLinkFrameworkRuntimeHost
|
|
|
387
432
|
this.meshRouters = new MeshRouterResolver(options.registration);
|
|
388
433
|
this.spotRouterChannelIdForMesh = this.meshRouters.spotRouterChannelIdByMesh();
|
|
389
434
|
this.routeTransport = new ZLinkRuntimeRouteTransport(
|
|
390
|
-
() =>
|
|
435
|
+
() => {
|
|
436
|
+
if (
|
|
437
|
+
this.channelRuntime === undefined &&
|
|
438
|
+
this.runtimeState === ZLinkFrameworkRuntimeState.Stopped
|
|
439
|
+
) {
|
|
440
|
+
throw createInternalFrameworkException(
|
|
441
|
+
ZLinkFrameworkInternalErrorKind.RuntimeShutdown,
|
|
442
|
+
'Route channel runtime is stopped.'
|
|
443
|
+
);
|
|
444
|
+
}
|
|
445
|
+
return this.channelRuntime;
|
|
446
|
+
},
|
|
391
447
|
(routerChannelId) => this.meshRouters.canUseRouterChannel(routerChannelId),
|
|
392
448
|
() => this.spotNodeRuntime,
|
|
393
449
|
{ serializers: options.registration.messageSerializers },
|
|
@@ -396,9 +452,11 @@ export class ZLinkFrameworkRuntimeHost
|
|
|
396
452
|
(meshName, sourceNodeRid, parts) => this.submitLocalMeshRoute(meshName, sourceNodeRid, parts),
|
|
397
453
|
this.metrics,
|
|
398
454
|
() => this.flowCreationEnabled(),
|
|
399
|
-
() => this.createDispatchErrorReporter(this.runtimeOrPreStartErrorSink).flow
|
|
455
|
+
() => this.createDispatchErrorReporter(this.runtimeOrPreStartErrorSink).flow,
|
|
456
|
+
this.requests
|
|
400
457
|
);
|
|
401
458
|
this.spotAddressTransport = new ZLinkHostSpotAddressTransport({
|
|
459
|
+
requests: this.requests,
|
|
402
460
|
resolver: () => this.createLocationSpotRouteResolver(),
|
|
403
461
|
routed: this.routeTransport,
|
|
404
462
|
meshNames: () =>
|
|
@@ -462,10 +520,16 @@ export class ZLinkFrameworkRuntimeHost
|
|
|
462
520
|
},
|
|
463
521
|
relay: (actor, header, payload) =>
|
|
464
522
|
this.boundSessionRelay.actorPackets.relayActorPacket(actor, header, payload),
|
|
465
|
-
notifyDisconnected: (actor, signal, binding) =>
|
|
466
|
-
this.boundSessionRelay.actorPackets.notifyBoundActorDisconnected(
|
|
523
|
+
notifyDisconnected: (actor, signal, binding, authorityFence) =>
|
|
524
|
+
this.boundSessionRelay.actorPackets.notifyBoundActorDisconnected(
|
|
525
|
+
actor,
|
|
526
|
+
signal,
|
|
527
|
+
binding,
|
|
528
|
+
authorityFence
|
|
529
|
+
)
|
|
467
530
|
});
|
|
468
531
|
this.actorHandoff = new ZLinkActorHandoffCoordinator({
|
|
532
|
+
requests: this.requests,
|
|
469
533
|
routedTransport: this.routeTransport,
|
|
470
534
|
messageFollowDurationMs: options.registration.locations.options.messageFollowDurationMs,
|
|
471
535
|
requestTimeoutMs: options.registration.requestTimeoutMs,
|
|
@@ -657,7 +721,10 @@ export class ZLinkFrameworkRuntimeHost
|
|
|
657
721
|
options.registration.messageSerializers
|
|
658
722
|
);
|
|
659
723
|
this.boundSessionFactory = new DefaultZLinkBoundSessionFactory(this.streamBindingRuntime);
|
|
660
|
-
|
|
724
|
+
const createBoundSessionRelay =
|
|
725
|
+
factories?.createBoundSessionRelay ??
|
|
726
|
+
((relayOptions: ZLinkBoundSessionRelayOptions) => new ZLinkBoundSessionRelay(relayOptions));
|
|
727
|
+
this.boundSessionRelay = createBoundSessionRelay({
|
|
661
728
|
requestTimeoutMs: options.registration.requestTimeoutMs,
|
|
662
729
|
sessionRelocationSealTimeoutMs:
|
|
663
730
|
options.registration.locations.options.sessionRelocationSealTimeoutMs ??
|
|
@@ -785,6 +852,7 @@ export class ZLinkFrameworkRuntimeHost
|
|
|
785
852
|
shutdownSignal: () => this.executionState?.abortController.signal
|
|
786
853
|
});
|
|
787
854
|
this.serviceRelocation = new ZLinkHostServiceRelocationRuntime({
|
|
855
|
+
requests: this.requests,
|
|
788
856
|
flowCreationEnabled: () => this.flowCreationEnabled(),
|
|
789
857
|
messageFlow: () => this.createDispatchErrorReporter(this.runtimeOrPreStartErrorSink).flow,
|
|
790
858
|
registration: options.registration,
|
|
@@ -816,8 +884,8 @@ export class ZLinkFrameworkRuntimeHost
|
|
|
816
884
|
clear: () => this.boundSessionRelay.boundSessions.clearServiceWireSessionRelocations()
|
|
817
885
|
},
|
|
818
886
|
trackInstanceSpot: (input) => this.locationOwner.currentLifecycle?.trackInstanceSpot(input),
|
|
819
|
-
|
|
820
|
-
this.actorClientLocationResolver?.
|
|
887
|
+
observeActorAuthorityVersion: (actorId, storeVersion) =>
|
|
888
|
+
this.actorClientLocationResolver?.observeActorAuthorityVersion(actorId, storeVersion),
|
|
821
889
|
reconcileStatefulAuthorityRoutes: (signal) =>
|
|
822
890
|
this.statefulAuthorityRoutes?.reconcile(signal) ?? Promise.resolve(),
|
|
823
891
|
runtimeEventPublisher: this.runtimeEventPublisher,
|
|
@@ -832,7 +900,10 @@ export class ZLinkFrameworkRuntimeHost
|
|
|
832
900
|
...options.registration.locations.options
|
|
833
901
|
}.ownerLeaseTtlMs
|
|
834
902
|
});
|
|
835
|
-
this.routeMeshCoordinator =
|
|
903
|
+
this.routeMeshCoordinator = (
|
|
904
|
+
factories?.createRouteMeshCoordinator ??
|
|
905
|
+
((meshOptions) => new ZLinkRouteMeshRuntimeCoordinator(meshOptions))
|
|
906
|
+
)({
|
|
836
907
|
meshNames: [...options.registration.spotNodes.keys()],
|
|
837
908
|
meshOptions: options.registration.spotNodes,
|
|
838
909
|
meshNode: (meshName) => this.spotNodeRuntime?.meshNode(meshName),
|
|
@@ -1426,6 +1497,13 @@ export class ZLinkFrameworkRuntimeHost
|
|
|
1426
1497
|
return;
|
|
1427
1498
|
}
|
|
1428
1499
|
|
|
1500
|
+
const previousLease = this.telemetryLease;
|
|
1501
|
+
this.telemetryLease = renewTelemetryLease(previousLease);
|
|
1502
|
+
if (this.telemetryLease !== previousLease) {
|
|
1503
|
+
this.dispatchErrorReporters = new WeakMap();
|
|
1504
|
+
this.cachedDiagnosticsContext = undefined;
|
|
1505
|
+
}
|
|
1506
|
+
|
|
1429
1507
|
this.setRuntimeState(ZLinkFrameworkRuntimeState.Preparing);
|
|
1430
1508
|
this.lifecycleSink?.push('framework:start');
|
|
1431
1509
|
const listenerRecords = new ZLinkListenerRecords();
|
|
@@ -1451,11 +1529,12 @@ export class ZLinkFrameworkRuntimeHost
|
|
|
1451
1529
|
channelAdapter,
|
|
1452
1530
|
context,
|
|
1453
1531
|
this.options.providerResolver,
|
|
1454
|
-
{ ...this.createChannelRuntimeOptions(), listenerRecords }
|
|
1532
|
+
{ ...this.createChannelRuntimeOptions(), listenerRecords, requests: this.requests }
|
|
1455
1533
|
);
|
|
1456
1534
|
this.channelRuntime = channelRuntime;
|
|
1457
1535
|
channelRuntime.prepareMeshDispatch(this.executionState.taskRunner);
|
|
1458
1536
|
spotNodeRuntime = new ZLinkSpotNodeRuntimeManager({
|
|
1537
|
+
requests: this.requests,
|
|
1459
1538
|
...this.createSpotNodeRuntimeOptions(context, dispatchErrors),
|
|
1460
1539
|
listenerRecords
|
|
1461
1540
|
});
|
|
@@ -1553,12 +1632,16 @@ export class ZLinkFrameworkRuntimeHost
|
|
|
1553
1632
|
}
|
|
1554
1633
|
|
|
1555
1634
|
async stop(): Promise<void> {
|
|
1635
|
+
retireTelemetryLease(this.telemetryLease);
|
|
1636
|
+
this.requests.close(
|
|
1637
|
+
new ZLinkFrameworkException(ZLinkFrameworkErrorKind.ShuttingDown, 'Host stopped.')
|
|
1638
|
+
);
|
|
1556
1639
|
await this.runWithShutdownDeadline(DEFAULT_HOST_CONTROL_TIMEOUT_MS, async () =>
|
|
1557
1640
|
this.runLifecycle(() => this.stopCore())
|
|
1558
1641
|
);
|
|
1559
1642
|
}
|
|
1560
1643
|
|
|
1561
|
-
|
|
1644
|
+
runtimeMetricMeshSnapshots(): readonly ZLinkRuntimeMetricMeshSnapshot[] {
|
|
1562
1645
|
const snapshots: ZLinkRuntimeMetricMeshSnapshot[] = [];
|
|
1563
1646
|
for (const [meshName, options] of this.options.registration.spotNodes) {
|
|
1564
1647
|
let status;
|
|
@@ -1649,7 +1732,7 @@ export class ZLinkFrameworkRuntimeHost
|
|
|
1649
1732
|
}
|
|
1650
1733
|
}
|
|
1651
1734
|
|
|
1652
|
-
|
|
1735
|
+
installOwnerLeaseRecoveryPublication(
|
|
1653
1736
|
runtime: ZLinkLocationRuntime,
|
|
1654
1737
|
spotNodeRuntime: ZLinkSpotNodeRuntimeManager,
|
|
1655
1738
|
channelRuntime: ZLinkChannelRuntimeManager
|
|
@@ -1676,7 +1759,7 @@ export class ZLinkFrameworkRuntimeHost
|
|
|
1676
1759
|
runtime.addOwnerLeaseRenewedHandler(handler);
|
|
1677
1760
|
}
|
|
1678
1761
|
|
|
1679
|
-
|
|
1762
|
+
async resumeOwnerLeaseOwnedWork(
|
|
1680
1763
|
runtime: ZLinkLocationRuntime,
|
|
1681
1764
|
spotNodeRuntime: ZLinkSpotNodeRuntimeManager,
|
|
1682
1765
|
channelRuntime: ZLinkChannelRuntimeManager
|
|
@@ -1700,7 +1783,7 @@ export class ZLinkFrameworkRuntimeHost
|
|
|
1700
1783
|
|
|
1701
1784
|
// The one transition from Preparing to Serving: the host publishes its
|
|
1702
1785
|
// Serving descriptors first, then takes new application work.
|
|
1703
|
-
|
|
1786
|
+
async enterServing(
|
|
1704
1787
|
spotNodeRuntime: ZLinkSpotNodeRuntimeManager,
|
|
1705
1788
|
signal: AbortSignal | undefined
|
|
1706
1789
|
): Promise<void> {
|
|
@@ -1736,7 +1819,7 @@ export class ZLinkFrameworkRuntimeHost
|
|
|
1736
1819
|
}
|
|
1737
1820
|
}
|
|
1738
1821
|
|
|
1739
|
-
|
|
1822
|
+
async startStatefulAuthority(
|
|
1740
1823
|
locationStore: import('../locations/domain-store-contract').ZLinkDomainLocationStore,
|
|
1741
1824
|
spotNodeRuntime: ZLinkSpotNodeRuntimeManager,
|
|
1742
1825
|
signal: AbortSignal | undefined
|
|
@@ -1842,7 +1925,7 @@ export class ZLinkFrameworkRuntimeHost
|
|
|
1842
1925
|
}
|
|
1843
1926
|
}
|
|
1844
1927
|
|
|
1845
|
-
|
|
1928
|
+
removeOwnerLeaseRecoveryPublication(): void {
|
|
1846
1929
|
if (
|
|
1847
1930
|
this.ownerLeaseRecoveryRuntime !== undefined &&
|
|
1848
1931
|
this.ownerLeaseRecoveryHandler !== undefined
|
|
@@ -1936,7 +2019,7 @@ export class ZLinkFrameworkRuntimeHost
|
|
|
1936
2019
|
);
|
|
1937
2020
|
}
|
|
1938
2021
|
|
|
1939
|
-
|
|
2022
|
+
async preflightAutomaticPeerReadiness(
|
|
1940
2023
|
deadlineAt: number,
|
|
1941
2024
|
targetApplicationVersion: bigint
|
|
1942
2025
|
): Promise<ZLinkFrameworkRelocationReason | undefined> {
|
|
@@ -2017,7 +2100,7 @@ export class ZLinkFrameworkRuntimeHost
|
|
|
2017
2100
|
return true;
|
|
2018
2101
|
}
|
|
2019
2102
|
|
|
2020
|
-
|
|
2103
|
+
async publishHostRelocated(): Promise<void> {
|
|
2021
2104
|
await Promise.all(
|
|
2022
2105
|
[...this.options.registration.spotNodes.keys()].map((meshName) =>
|
|
2023
2106
|
this.spotNodeRuntime?.publishMeshNodeState(
|
|
@@ -2340,11 +2423,45 @@ export class ZLinkFrameworkRuntimeHost
|
|
|
2340
2423
|
};
|
|
2341
2424
|
}
|
|
2342
2425
|
});
|
|
2426
|
+
const selectUserSpotMesh = (requestedMeshName: string | undefined): string => {
|
|
2427
|
+
const clientMeshes = [...this.options.registration.spotNodes]
|
|
2428
|
+
.filter(([, node]) => hasObjectClientCapability(node.objectRole))
|
|
2429
|
+
.map(([meshName]) => meshName);
|
|
2430
|
+
const meshes = requestedMeshName === undefined ? clientMeshes : [requestedMeshName];
|
|
2431
|
+
if (meshes.length === 0) {
|
|
2432
|
+
throw createInternalFrameworkException(
|
|
2433
|
+
ZLinkFrameworkInternalErrorKind.ObjectClientNotConfigured,
|
|
2434
|
+
'No object-client RouteMesh is configured.'
|
|
2435
|
+
);
|
|
2436
|
+
}
|
|
2437
|
+
if (requestedMeshName === undefined && meshes.length > 1) {
|
|
2438
|
+
throw createInternalFrameworkException(
|
|
2439
|
+
ZLinkFrameworkInternalErrorKind.MeshSelectionRequired,
|
|
2440
|
+
'Multiple object-client RouteMeshes are configured; call inMesh(...).'
|
|
2441
|
+
);
|
|
2442
|
+
}
|
|
2443
|
+
const meshName = meshes[0]!;
|
|
2444
|
+
if (!this.options.registration.spotNodes.has(meshName)) {
|
|
2445
|
+
throw createInternalFrameworkException(
|
|
2446
|
+
ZLinkFrameworkInternalErrorKind.MeshNotFound,
|
|
2447
|
+
`RouteMesh '${meshName}' is not configured.`
|
|
2448
|
+
);
|
|
2449
|
+
}
|
|
2450
|
+
if (!clientMeshes.includes(meshName)) {
|
|
2451
|
+
throw createInternalFrameworkException(
|
|
2452
|
+
ZLinkFrameworkInternalErrorKind.ObjectClientNotConfigured,
|
|
2453
|
+
`RouteMesh '${meshName}' has no object-client role.`
|
|
2454
|
+
);
|
|
2455
|
+
}
|
|
2456
|
+
return meshName;
|
|
2457
|
+
};
|
|
2343
2458
|
const coordinator = (this.userSpotCoordinator = new ZLinkUserSpotCreationCoordinator({
|
|
2344
2459
|
store: locationStore,
|
|
2345
|
-
|
|
2346
|
-
|
|
2347
|
-
|
|
2460
|
+
leaseTracker: this.locationOwner.currentLeaseTracker!,
|
|
2461
|
+
relocationPolicy: (meshName, stableType) => {
|
|
2462
|
+
const node = this.options.registration.spotNodes.get(selectUserSpotMesh(meshName));
|
|
2463
|
+
return node?.spotFactoryRegistrations?.[stableType]?.relocation.kind;
|
|
2464
|
+
},
|
|
2348
2465
|
publishReadyRoute: (meshName, route) => {
|
|
2349
2466
|
this.cachedLocationSpotRouteResolver?.invalidate?.(route.spot.spotId);
|
|
2350
2467
|
this.spotNodeRuntime?.meshNode(meshName)?.rememberSpotRoute?.(route);
|
|
@@ -2377,35 +2494,7 @@ export class ZLinkFrameworkRuntimeHost
|
|
|
2377
2494
|
}
|
|
2378
2495
|
},
|
|
2379
2496
|
target: async (request, signal, excludedNodeRids) => {
|
|
2380
|
-
const
|
|
2381
|
-
.filter(([, node]) => hasObjectClientCapability(node.objectRole))
|
|
2382
|
-
.map(([meshName]) => meshName);
|
|
2383
|
-
const meshes = request.meshName === undefined ? clientMeshes : [request.meshName];
|
|
2384
|
-
if (meshes.length === 0) {
|
|
2385
|
-
throw createInternalFrameworkException(
|
|
2386
|
-
ZLinkFrameworkInternalErrorKind.ObjectClientNotConfigured,
|
|
2387
|
-
'No object-client RouteMesh is configured.'
|
|
2388
|
-
);
|
|
2389
|
-
}
|
|
2390
|
-
if (request.meshName === undefined && meshes.length > 1) {
|
|
2391
|
-
throw createInternalFrameworkException(
|
|
2392
|
-
ZLinkFrameworkInternalErrorKind.MeshSelectionRequired,
|
|
2393
|
-
'Multiple object-client RouteMeshes are configured; call inMesh(...).'
|
|
2394
|
-
);
|
|
2395
|
-
}
|
|
2396
|
-
const meshName = meshes[0]!;
|
|
2397
|
-
if (!this.options.registration.spotNodes.has(meshName)) {
|
|
2398
|
-
throw createInternalFrameworkException(
|
|
2399
|
-
ZLinkFrameworkInternalErrorKind.MeshNotFound,
|
|
2400
|
-
`RouteMesh '${meshName}' is not configured.`
|
|
2401
|
-
);
|
|
2402
|
-
}
|
|
2403
|
-
if (!clientMeshes.includes(meshName)) {
|
|
2404
|
-
throw createInternalFrameworkException(
|
|
2405
|
-
ZLinkFrameworkInternalErrorKind.ObjectClientNotConfigured,
|
|
2406
|
-
`RouteMesh '${meshName}' has no object-client role.`
|
|
2407
|
-
);
|
|
2408
|
-
}
|
|
2497
|
+
const meshName = selectUserSpotMesh(request.meshName);
|
|
2409
2498
|
const meshNode = this.spotNodeRuntime?.meshNode(meshName);
|
|
2410
2499
|
const descriptors = await listAllMeshNodeDescriptors(locationStore, meshName, signal);
|
|
2411
2500
|
const selected = await selectReadyLocationPlacementDescriptor(
|
|
@@ -2672,7 +2761,8 @@ export class ZLinkFrameworkRuntimeHost
|
|
|
2672
2761
|
spot.meshName,
|
|
2673
2762
|
spot.spotId,
|
|
2674
2763
|
beginAuthority,
|
|
2675
|
-
closeSignal
|
|
2764
|
+
closeSignal,
|
|
2765
|
+
new Date(Number(record.deadlineUnixMs))
|
|
2676
2766
|
),
|
|
2677
2767
|
signal,
|
|
2678
2768
|
(spot) => local.isSpotClosing(spot.meshName, spot.spotId)
|
|
@@ -2716,6 +2806,7 @@ export class ZLinkFrameworkRuntimeHost
|
|
|
2716
2806
|
|
|
2717
2807
|
private actorRuntimeOptionsFactory(): ZLinkActorRuntimeOptionsFactory {
|
|
2718
2808
|
return new ZLinkActorRuntimeOptionsFactory({
|
|
2809
|
+
requests: this.requests,
|
|
2719
2810
|
terminateActorActivation: (actor, terminal) =>
|
|
2720
2811
|
this.spotNodeRuntime?.terminateActorActivation(actor, terminal) ?? terminal(),
|
|
2721
2812
|
registration: this.options.registration,
|
|
@@ -2763,7 +2854,7 @@ export class ZLinkFrameworkRuntimeHost
|
|
|
2763
2854
|
`Actor '${actorRef.actorId}' authority requires its RouteMesh Entry Spot.`
|
|
2764
2855
|
);
|
|
2765
2856
|
}
|
|
2766
|
-
await publishInitialActorAuthority(
|
|
2857
|
+
const authority = await publishInitialActorAuthority(
|
|
2767
2858
|
store,
|
|
2768
2859
|
{
|
|
2769
2860
|
actorType,
|
|
@@ -2777,7 +2868,10 @@ export class ZLinkFrameworkRuntimeHost
|
|
|
2777
2868
|
},
|
|
2778
2869
|
signal
|
|
2779
2870
|
);
|
|
2780
|
-
this.actorClientLocationResolver?.
|
|
2871
|
+
this.actorClientLocationResolver?.observeActorAuthorityVersion(
|
|
2872
|
+
actorRef.actorId,
|
|
2873
|
+
authority.storeVersion.value
|
|
2874
|
+
);
|
|
2781
2875
|
},
|
|
2782
2876
|
reportPostCommitError: (error) =>
|
|
2783
2877
|
this.runtimeOrPreStartErrorSink.reportRuntimeTaskException(
|
|
@@ -2816,6 +2910,7 @@ export class ZLinkFrameworkRuntimeHost
|
|
|
2816
2910
|
return new ZLinkChannelRuntimeOptionsFactory({
|
|
2817
2911
|
monitoringAdapter: this.backendAdapterFactory.createMonitoringAdapter(),
|
|
2818
2912
|
messageFlowModeCell: this.messageFlowModeCell,
|
|
2913
|
+
telemetryLease: this.telemetryLease,
|
|
2819
2914
|
boundSessionRelay: this.boundSessionRelay,
|
|
2820
2915
|
applicationJobQueue: this.applicationJobQueue,
|
|
2821
2916
|
spotManager: () => this.spotManager,
|
|
@@ -2824,7 +2919,7 @@ export class ZLinkFrameworkRuntimeHost
|
|
|
2824
2919
|
}).create();
|
|
2825
2920
|
}
|
|
2826
2921
|
|
|
2827
|
-
|
|
2922
|
+
createSpotNodeRuntimeOptions(
|
|
2828
2923
|
context: ZLinkBackendContext,
|
|
2829
2924
|
dispatchErrors: ZLinkDispatchErrorReporter
|
|
2830
2925
|
) {
|
|
@@ -2854,6 +2949,7 @@ export class ZLinkFrameworkRuntimeHost
|
|
|
2854
2949
|
}).create();
|
|
2855
2950
|
return {
|
|
2856
2951
|
...options,
|
|
2952
|
+
admission: this.admission,
|
|
2857
2953
|
errorSink: this.runtimeOrPreStartErrorSink,
|
|
2858
2954
|
peerAdmissionSealed: (meshName: string) => !this.admission.accepts(meshName),
|
|
2859
2955
|
messageFollowReceiver: (record: ServiceMessageFollowRecord) => {
|
|
@@ -2946,7 +3042,7 @@ export class ZLinkFrameworkRuntimeHost
|
|
|
2946
3042
|
return;
|
|
2947
3043
|
}
|
|
2948
3044
|
|
|
2949
|
-
|
|
3045
|
+
dispatchMeshRecord(
|
|
2950
3046
|
applicationJobOrigin: () => ApplicationJobOrigin,
|
|
2951
3047
|
meshName: string,
|
|
2952
3048
|
owner: ReadyRecord,
|
|
@@ -2983,28 +3079,54 @@ export class ZLinkFrameworkRuntimeHost
|
|
|
2983
3079
|
meshName,
|
|
2984
3080
|
record,
|
|
2985
3081
|
signal,
|
|
2986
|
-
(dispatch, onRejected) =>
|
|
3082
|
+
(dispatch, onRejected, receiver, context) =>
|
|
2987
3083
|
this.admitMeshDispatch(
|
|
2988
3084
|
meshName,
|
|
2989
3085
|
record,
|
|
2990
3086
|
'RouteMesh channel dispatch',
|
|
2991
3087
|
dispatch,
|
|
2992
|
-
onRejected
|
|
3088
|
+
onRejected,
|
|
3089
|
+
receiver,
|
|
3090
|
+
context
|
|
2993
3091
|
)
|
|
2994
3092
|
);
|
|
2995
3093
|
}
|
|
2996
3094
|
case ReceiveKind.NodeSend:
|
|
2997
3095
|
case ReceiveKind.NodeRequest: {
|
|
2998
|
-
return this.dispatchMeshNodeRecord(
|
|
2999
|
-
|
|
3096
|
+
return this.dispatchMeshNodeRecord(
|
|
3097
|
+
meshName,
|
|
3098
|
+
record,
|
|
3099
|
+
signal,
|
|
3100
|
+
(dispatch, onRejected, receiver, context) =>
|
|
3101
|
+
this.admitMeshDispatch(
|
|
3102
|
+
meshName,
|
|
3103
|
+
record,
|
|
3104
|
+
'RouteMesh node dispatch',
|
|
3105
|
+
dispatch,
|
|
3106
|
+
onRejected,
|
|
3107
|
+
receiver,
|
|
3108
|
+
context
|
|
3109
|
+
)
|
|
3000
3110
|
);
|
|
3001
3111
|
}
|
|
3002
3112
|
|
|
3003
3113
|
case ReceiveKind.SpotSend:
|
|
3004
3114
|
case ReceiveKind.SpotRequest:
|
|
3005
3115
|
case ReceiveKind.SpotMulticast:
|
|
3006
|
-
return this.dispatchMeshSpotRecord(
|
|
3007
|
-
|
|
3116
|
+
return this.dispatchMeshSpotRecord(
|
|
3117
|
+
meshName,
|
|
3118
|
+
owner,
|
|
3119
|
+
record,
|
|
3120
|
+
(dispatch, onRejected, receiver, context) =>
|
|
3121
|
+
this.admitMeshDispatch(
|
|
3122
|
+
meshName,
|
|
3123
|
+
record,
|
|
3124
|
+
'RouteMesh Spot dispatch',
|
|
3125
|
+
dispatch,
|
|
3126
|
+
onRejected,
|
|
3127
|
+
receiver,
|
|
3128
|
+
context
|
|
3129
|
+
)
|
|
3008
3130
|
);
|
|
3009
3131
|
case ReceiveKind.InstanceSpotActivation:
|
|
3010
3132
|
if (this.spotManager === undefined) {
|
|
@@ -3016,13 +3138,15 @@ export class ZLinkFrameworkRuntimeHost
|
|
|
3016
3138
|
meshName,
|
|
3017
3139
|
owner,
|
|
3018
3140
|
record,
|
|
3019
|
-
(dispatch, onRejected) =>
|
|
3141
|
+
(dispatch, onRejected, receiver, context) =>
|
|
3020
3142
|
this.admitMeshDispatch(
|
|
3021
3143
|
meshName,
|
|
3022
3144
|
record,
|
|
3023
3145
|
'RouteMesh Instance Spot dispatch',
|
|
3024
3146
|
dispatch,
|
|
3025
|
-
onRejected
|
|
3147
|
+
onRejected,
|
|
3148
|
+
receiver,
|
|
3149
|
+
context
|
|
3026
3150
|
)
|
|
3027
3151
|
);
|
|
3028
3152
|
case ReceiveKind.SpotControl:
|
|
@@ -3044,13 +3168,15 @@ export class ZLinkFrameworkRuntimeHost
|
|
|
3044
3168
|
meshName,
|
|
3045
3169
|
owner,
|
|
3046
3170
|
record,
|
|
3047
|
-
(dispatch, onRejected) =>
|
|
3171
|
+
(dispatch, onRejected, receiver, context) =>
|
|
3048
3172
|
this.admitMeshDispatch(
|
|
3049
3173
|
meshName,
|
|
3050
3174
|
record,
|
|
3051
3175
|
'RouteMesh Actor dispatch',
|
|
3052
3176
|
dispatch,
|
|
3053
|
-
onRejected
|
|
3177
|
+
onRejected,
|
|
3178
|
+
receiver,
|
|
3179
|
+
context
|
|
3054
3180
|
)
|
|
3055
3181
|
);
|
|
3056
3182
|
case ReceiveKind.SendReady:
|
|
@@ -3062,18 +3188,21 @@ export class ZLinkFrameworkRuntimeHost
|
|
|
3062
3188
|
}
|
|
3063
3189
|
}
|
|
3064
3190
|
|
|
3065
|
-
private admitMeshDispatch(
|
|
3191
|
+
private admitMeshDispatch<TReceiver = void, TContext = void>(
|
|
3066
3192
|
meshName: string,
|
|
3067
3193
|
record: ReceiveRecord,
|
|
3068
3194
|
operation: string,
|
|
3069
|
-
dispatch: () => void | Promise<void>,
|
|
3070
|
-
onRejected?: (error: unknown) => void | Promise<void
|
|
3195
|
+
dispatch: (this: TReceiver, context: TContext) => void | Promise<void>,
|
|
3196
|
+
onRejected?: (this: TReceiver, error: unknown, context: TContext) => void | Promise<void>,
|
|
3197
|
+
receiver?: TReceiver,
|
|
3198
|
+
context?: TContext
|
|
3071
3199
|
): void | Promise<void> {
|
|
3072
3200
|
// Execution gate §13 and host relocation §14 keep control progress independent
|
|
3073
3201
|
// of new application admission. Disconnect callbacks still use their owner gate.
|
|
3074
|
-
if (record.domain === ReadyDomain.Infrastructure)
|
|
3202
|
+
if (record.domain === ReadyDomain.Infrastructure)
|
|
3203
|
+
return dispatch.call(receiver as TReceiver, context as TContext);
|
|
3075
3204
|
if (
|
|
3076
|
-
!this.admission.accepts(meshName) &&
|
|
3205
|
+
!this.admission.accepts(meshName, record.kind) &&
|
|
3077
3206
|
(record.kind === ReceiveKind.NodeSend ||
|
|
3078
3207
|
record.kind === ReceiveKind.NodeRequest ||
|
|
3079
3208
|
record.kind === ReceiveKind.SpotSend ||
|
|
@@ -3089,13 +3218,21 @@ export class ZLinkFrameworkRuntimeHost
|
|
|
3089
3218
|
decodeStreamHeader(Buffer.from(relay.header, 'base64'), this.flowCreationEnabled()).name ===
|
|
3090
3219
|
ZLINK_REMOTE_ACTOR_SESSION_DISCONNECTED_PACKET
|
|
3091
3220
|
) {
|
|
3092
|
-
return dispatch();
|
|
3221
|
+
return dispatch.call(receiver as TReceiver, context as TContext);
|
|
3093
3222
|
}
|
|
3094
3223
|
}
|
|
3095
|
-
return this.admission.run(
|
|
3224
|
+
return this.admission.run(
|
|
3225
|
+
meshName,
|
|
3226
|
+
operation,
|
|
3227
|
+
dispatch,
|
|
3228
|
+
record.kind,
|
|
3229
|
+
onRejected,
|
|
3230
|
+
receiver,
|
|
3231
|
+
context
|
|
3232
|
+
);
|
|
3096
3233
|
}
|
|
3097
3234
|
|
|
3098
|
-
|
|
3235
|
+
async dispatchMeshActorBinding(
|
|
3099
3236
|
meshName: string,
|
|
3100
3237
|
record: ReceiveRecord,
|
|
3101
3238
|
signal?: AbortSignal
|
|
@@ -3184,8 +3321,7 @@ export class ZLinkFrameworkRuntimeHost
|
|
|
3184
3321
|
replyBindingFailure(ZLinkFrameworkInternalErrorKind.ActorLocationStale);
|
|
3185
3322
|
return;
|
|
3186
3323
|
}
|
|
3187
|
-
|
|
3188
|
-
state.installBoundSessionBinding({
|
|
3324
|
+
const incomingTarget = {
|
|
3189
3325
|
...target,
|
|
3190
3326
|
sessionNodeRid: binding.sessionNodeRid,
|
|
3191
3327
|
sessionRid: binding.sessionRid,
|
|
@@ -3193,24 +3329,125 @@ export class ZLinkFrameworkRuntimeHost
|
|
|
3193
3329
|
sessionOwnerId: binding.sessionOwnerId,
|
|
3194
3330
|
sessionOwnerLeaseGeneration: binding.sessionOwnerLeaseGeneration,
|
|
3195
3331
|
bindingGeneration: binding.bindingGeneration
|
|
3332
|
+
};
|
|
3333
|
+
const currentBinding = state.boundSession;
|
|
3334
|
+
const currentActor = state.actor;
|
|
3335
|
+
if (
|
|
3336
|
+
currentBinding === undefined ||
|
|
3337
|
+
currentActor?.onDuplicateBind === undefined ||
|
|
3338
|
+
samePhysicalSession(currentBinding, incomingTarget)
|
|
3339
|
+
) {
|
|
3340
|
+
state.installBoundSessionBinding(incomingTarget);
|
|
3341
|
+
replyBindingSuccess();
|
|
3342
|
+
return;
|
|
3343
|
+
}
|
|
3344
|
+
const spotManager = this.spotManager;
|
|
3345
|
+
if (spotManager === undefined || state.meshName === undefined) {
|
|
3346
|
+
replyBindingFailure(ZLinkFrameworkInternalErrorKind.ActorLocationStale);
|
|
3347
|
+
return;
|
|
3348
|
+
}
|
|
3349
|
+
|
|
3350
|
+
let callbackStarted!: () => void;
|
|
3351
|
+
const started = new Promise<void>((resolve) => {
|
|
3352
|
+
callbackStarted = resolve;
|
|
3196
3353
|
});
|
|
3197
|
-
|
|
3354
|
+
let callbackTimedOut = false;
|
|
3355
|
+
let timeoutHandle: ReturnType<typeof setTimeout> | undefined;
|
|
3356
|
+
const cancellation = new AbortController();
|
|
3357
|
+
const callbackSignal =
|
|
3358
|
+
signal === undefined ? cancellation.signal : AbortSignal.any([signal, cancellation.signal]);
|
|
3359
|
+
const turn = spotManager.executeActorTurn(
|
|
3360
|
+
state.meshName,
|
|
3361
|
+
state.actor?.context.spotId,
|
|
3362
|
+
state.actorId,
|
|
3363
|
+
async () => {
|
|
3364
|
+
const current = state.boundSession;
|
|
3365
|
+
const actor = state.actor;
|
|
3366
|
+
const duplicateCallback =
|
|
3367
|
+
current !== undefined && !samePhysicalSession(current, incomingTarget)
|
|
3368
|
+
? actor?.onDuplicateBind
|
|
3369
|
+
: undefined;
|
|
3370
|
+
if (duplicateCallback === undefined || actor === undefined || current === undefined) {
|
|
3371
|
+
state.installBoundSessionBinding(incomingTarget);
|
|
3372
|
+
replyBindingSuccess();
|
|
3373
|
+
return;
|
|
3374
|
+
}
|
|
3375
|
+
callbackStarted();
|
|
3376
|
+
const decision = await duplicateCallback.call(
|
|
3377
|
+
actor,
|
|
3378
|
+
sessionBindingIdentity(current),
|
|
3379
|
+
sessionBindingIdentity(incomingTarget),
|
|
3380
|
+
callbackSignal
|
|
3381
|
+
);
|
|
3382
|
+
if (callbackTimedOut) return;
|
|
3383
|
+
if (decision !== undefined && decision.length > 0) {
|
|
3384
|
+
if (Buffer.byteLength(decision, 'utf8') > 0xffff) {
|
|
3385
|
+
throw new RangeError('Duplicate bind rejection message exceeds Text16 capacity.');
|
|
3386
|
+
}
|
|
3387
|
+
if (
|
|
3388
|
+
record.replyFailure?.(RequestResult.Rejected, 0, {
|
|
3389
|
+
kind: 'streamBindRejected',
|
|
3390
|
+
rejectionMessage: decision
|
|
3391
|
+
}) !== SubmitResult.Ok
|
|
3392
|
+
) {
|
|
3393
|
+
throw new ZLinkConfigurationException(
|
|
3394
|
+
`MeshNode Actor binding target '${binding.actor.actorId}' rejection acknowledgement failed.`
|
|
3395
|
+
);
|
|
3396
|
+
}
|
|
3397
|
+
return;
|
|
3398
|
+
}
|
|
3399
|
+
state.installBoundSessionBinding(incomingTarget);
|
|
3400
|
+
replyBindingSuccess();
|
|
3401
|
+
}
|
|
3402
|
+
);
|
|
3403
|
+
const timeout = started.then(
|
|
3404
|
+
() =>
|
|
3405
|
+
new Promise<'timedOut'>((resolve) => {
|
|
3406
|
+
timeoutHandle = setTimeout(() => {
|
|
3407
|
+
callbackTimedOut = true;
|
|
3408
|
+
resolve('timedOut');
|
|
3409
|
+
}, this.options.registration.sessionReplacementCallbackTimeoutMs);
|
|
3410
|
+
})
|
|
3411
|
+
);
|
|
3412
|
+
try {
|
|
3413
|
+
const outcome = await Promise.race([turn.then(() => 'completed' as const), timeout]);
|
|
3414
|
+
if (outcome === 'timedOut') {
|
|
3415
|
+
cancellation.abort(createDeadlineExceededError('Duplicate bind callback timed out.'));
|
|
3416
|
+
if (record.replyFailure?.(RequestResult.TimedOut, 0) !== SubmitResult.Ok) {
|
|
3417
|
+
throw new ZLinkConfigurationException(
|
|
3418
|
+
`MeshNode Actor binding target '${binding.actor.actorId}' timeout acknowledgement failed.`
|
|
3419
|
+
);
|
|
3420
|
+
}
|
|
3421
|
+
void turn.catch((error: unknown) =>
|
|
3422
|
+
this.runtimeOrPreStartErrorSink.reportRuntimeTaskException(
|
|
3423
|
+
`duplicate bind callback '${binding.actor.actorId}'`,
|
|
3424
|
+
error
|
|
3425
|
+
)
|
|
3426
|
+
);
|
|
3427
|
+
}
|
|
3428
|
+
} finally {
|
|
3429
|
+
if (timeoutHandle !== undefined) clearTimeout(timeoutHandle);
|
|
3430
|
+
}
|
|
3198
3431
|
}
|
|
3199
3432
|
|
|
3200
|
-
|
|
3201
|
-
meshName: string,
|
|
3202
|
-
sourceNodeRid: string,
|
|
3203
|
-
parts: readonly MessageLike[]
|
|
3204
|
-
) {
|
|
3433
|
+
submitLocalMeshRoute(meshName: string, sourceNodeRid: string, parts: readonly MessageLike[]) {
|
|
3205
3434
|
const state = this.executionState;
|
|
3206
3435
|
const channelRuntime = this.channelRuntime;
|
|
3207
|
-
if (
|
|
3436
|
+
if (
|
|
3437
|
+
state === undefined ||
|
|
3438
|
+
channelRuntime === undefined ||
|
|
3439
|
+
!this.admission.accepts(meshName, ReceiveKind.NodeSend)
|
|
3440
|
+
) {
|
|
3208
3441
|
return { status: ZLinkSubmitStatus.Shutdown } as const;
|
|
3209
3442
|
}
|
|
3210
3443
|
if (!channelRuntime.canDispatchLocalMeshRoute(meshName)) {
|
|
3211
3444
|
return { status: ZLinkSubmitStatus.TargetNotFound } as const;
|
|
3212
3445
|
}
|
|
3213
|
-
const claim = this.admission.claim(
|
|
3446
|
+
const claim = this.admission.claim(
|
|
3447
|
+
meshName,
|
|
3448
|
+
'RouteMesh local node dispatch',
|
|
3449
|
+
ReceiveKind.NodeSend
|
|
3450
|
+
);
|
|
3214
3451
|
const ownedParts: RuntimeMessage[] = [];
|
|
3215
3452
|
try {
|
|
3216
3453
|
for (const part of parts) {
|
|
@@ -3251,7 +3488,7 @@ export class ZLinkFrameworkRuntimeHost
|
|
|
3251
3488
|
return { status: ZLinkSubmitStatus.Submitted } as const;
|
|
3252
3489
|
}
|
|
3253
3490
|
|
|
3254
|
-
|
|
3491
|
+
async dispatchMeshSpotRecord(
|
|
3255
3492
|
meshName: string,
|
|
3256
3493
|
owner: ReadyRecord,
|
|
3257
3494
|
record: ReceiveRecord,
|
|
@@ -3268,7 +3505,8 @@ export class ZLinkFrameworkRuntimeHost
|
|
|
3268
3505
|
contentType: envelope.header.contentType,
|
|
3269
3506
|
sourceNodeRid: String(record.sourceNodeRid ?? '') as RoutingId,
|
|
3270
3507
|
metadata: zlinkMessageMetadata(envelope.header.metadata),
|
|
3271
|
-
correlationId: envelope.header.correlationId ?? undefined
|
|
3508
|
+
correlationId: envelope.header.correlationId ?? undefined,
|
|
3509
|
+
receivedAt: record.receivedAt ?? new Date()
|
|
3272
3510
|
};
|
|
3273
3511
|
try {
|
|
3274
3512
|
const dispatch = async () => {
|
|
@@ -3299,20 +3537,12 @@ export class ZLinkFrameworkRuntimeHost
|
|
|
3299
3537
|
await this.spotManager.dispatchMeshSpot(meshName, owner, record, admit);
|
|
3300
3538
|
}
|
|
3301
3539
|
|
|
3302
|
-
|
|
3303
|
-
errorSink: ZLinkDispatchErrorSink
|
|
3304
|
-
): ZLinkDispatchErrorReporter {
|
|
3540
|
+
createDispatchErrorReporter(errorSink: ZLinkDispatchErrorSink): ZLinkDispatchErrorReporter {
|
|
3305
3541
|
const existing = this.dispatchErrorReporters.get(errorSink);
|
|
3306
3542
|
if (existing !== undefined) {
|
|
3307
3543
|
return existing;
|
|
3308
3544
|
}
|
|
3309
|
-
const reporter = new ZLinkDispatchErrorReporter(
|
|
3310
|
-
undefined,
|
|
3311
|
-
undefined,
|
|
3312
|
-
errorSink,
|
|
3313
|
-
this.diagnosticsContext(),
|
|
3314
|
-
this.metrics
|
|
3315
|
-
);
|
|
3545
|
+
const reporter = new ZLinkDispatchErrorReporter(this.diagnosticsContext(), this.metrics);
|
|
3316
3546
|
this.dispatchErrorReporters.set(errorSink, reporter);
|
|
3317
3547
|
return reporter;
|
|
3318
3548
|
}
|
|
@@ -3336,12 +3566,13 @@ export class ZLinkFrameworkRuntimeHost
|
|
|
3336
3566
|
this.cachedDiagnosticsContext ??= createDiagnosticsContext(
|
|
3337
3567
|
this.options.registration.dispatch,
|
|
3338
3568
|
this.options.providerResolver,
|
|
3339
|
-
this.messageFlowModeCell
|
|
3569
|
+
this.messageFlowModeCell,
|
|
3570
|
+
this.telemetryLease
|
|
3340
3571
|
);
|
|
3341
3572
|
return this.cachedDiagnosticsContext;
|
|
3342
3573
|
}
|
|
3343
3574
|
|
|
3344
|
-
|
|
3575
|
+
flowCreationEnabled(): boolean {
|
|
3345
3576
|
const mode =
|
|
3346
3577
|
this.executionState === undefined
|
|
3347
3578
|
? (this.options.registration.dispatch?.diagnostics.messageFlow ?? 'errors')
|
|
@@ -3370,7 +3601,7 @@ export class ZLinkFrameworkRuntimeHost
|
|
|
3370
3601
|
return this.locationOwner.ensureRuntime(this.meshRouters.primaryMeshName());
|
|
3371
3602
|
}
|
|
3372
3603
|
|
|
3373
|
-
|
|
3604
|
+
createLocationSpotRouteResolver(): ZLinkSpotRouteResolver | undefined {
|
|
3374
3605
|
if (this.cachedLocationSpotRouteResolver !== undefined) {
|
|
3375
3606
|
return this.cachedLocationSpotRouteResolver;
|
|
3376
3607
|
}
|
|
@@ -3409,7 +3640,7 @@ export class ZLinkFrameworkRuntimeHost
|
|
|
3409
3640
|
return resolver;
|
|
3410
3641
|
}
|
|
3411
3642
|
|
|
3412
|
-
|
|
3643
|
+
createActorLocationResolver(): ZLinkStoreLocationResolvers | undefined {
|
|
3413
3644
|
return this.locationOwner.createActorLocationResolver(this.meshRouters.spotLocationMeshNames());
|
|
3414
3645
|
}
|
|
3415
3646
|
}
|
|
@@ -3451,6 +3682,50 @@ export function hasUnsupportedManualTopology(registration: ZLinkFrameworkRegistr
|
|
|
3451
3682
|
return false;
|
|
3452
3683
|
}
|
|
3453
3684
|
|
|
3685
|
+
function samePhysicalSession(
|
|
3686
|
+
left: {
|
|
3687
|
+
readonly sessionNodeRid?: RoutingId;
|
|
3688
|
+
readonly sessionRid?: RoutingId;
|
|
3689
|
+
readonly sessionOwnerNodeGeneration?: bigint;
|
|
3690
|
+
},
|
|
3691
|
+
right: {
|
|
3692
|
+
readonly sessionNodeRid?: RoutingId;
|
|
3693
|
+
readonly sessionRid?: RoutingId;
|
|
3694
|
+
readonly sessionOwnerNodeGeneration?: bigint;
|
|
3695
|
+
}
|
|
3696
|
+
): boolean {
|
|
3697
|
+
return (
|
|
3698
|
+
left.sessionNodeRid !== undefined &&
|
|
3699
|
+
left.sessionRid !== undefined &&
|
|
3700
|
+
left.sessionOwnerNodeGeneration !== undefined &&
|
|
3701
|
+
right.sessionNodeRid !== undefined &&
|
|
3702
|
+
right.sessionRid !== undefined &&
|
|
3703
|
+
right.sessionOwnerNodeGeneration !== undefined &&
|
|
3704
|
+
routingIdsEqual(left.sessionNodeRid, right.sessionNodeRid) &&
|
|
3705
|
+
left.sessionRid === right.sessionRid &&
|
|
3706
|
+
left.sessionOwnerNodeGeneration === right.sessionOwnerNodeGeneration
|
|
3707
|
+
);
|
|
3708
|
+
}
|
|
3709
|
+
|
|
3710
|
+
function sessionBindingIdentity(value: {
|
|
3711
|
+
readonly sessionNodeRid?: RoutingId;
|
|
3712
|
+
readonly sessionOwnerNodeGeneration?: bigint;
|
|
3713
|
+
readonly bindingGeneration?: bigint;
|
|
3714
|
+
}): ZLinkSessionBindingIdentity {
|
|
3715
|
+
if (
|
|
3716
|
+
value.sessionNodeRid === undefined ||
|
|
3717
|
+
value.sessionOwnerNodeGeneration === undefined ||
|
|
3718
|
+
value.bindingGeneration === undefined
|
|
3719
|
+
) {
|
|
3720
|
+
throw new ZLinkConfigurationException('Duplicate bind callback requires a complete identity.');
|
|
3721
|
+
}
|
|
3722
|
+
return {
|
|
3723
|
+
sessionOwnerNodeRid: value.sessionNodeRid,
|
|
3724
|
+
sessionOwnerNodeGeneration: value.sessionOwnerNodeGeneration,
|
|
3725
|
+
bindingGeneration: value.bindingGeneration
|
|
3726
|
+
};
|
|
3727
|
+
}
|
|
3728
|
+
|
|
3454
3729
|
function hasConfiguredLocationStore(registration: ZLinkFrameworkRegistration): boolean {
|
|
3455
3730
|
return (
|
|
3456
3731
|
registration.locations.useInMemoryStores || registration.locations.storeInstance !== undefined
|