@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
|
@@ -3,6 +3,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.ZLinkUserSpotCreationCoordinator = exports.ZLinkHostSpotAddressTransport = exports.ZLinkRelocationStateIncompatibleError = exports.ZLinkRouteMeshRuntimeCoordinator = exports.ZLinkRetiringRollbackError = exports.ZLinkDrainingStatePublishError = exports.transferIdString = exports.ZLinkActorTransferAuthorityRuntime = exports.ZLinkFrameworkRuntimeHost = void 0;
|
|
4
4
|
exports.hasUnsupportedManualTopology = hasUnsupportedManualTopology;
|
|
5
5
|
exports.hasExactPeerReadiness = hasExactPeerReadiness;
|
|
6
|
+
const contracts_1 = require("../../contracts");
|
|
7
|
+
const request_runtime_1 = require("../foundation/request-runtime");
|
|
8
|
+
const internal_observation_1 = require("../internal-observation");
|
|
6
9
|
const relocation_blob_1 = require("../locations/relocation-blob");
|
|
7
10
|
const application_job_queue_scope_1 = require("../application-jobs/application-job-queue-scope");
|
|
8
11
|
const location_store_pages_1 = require("../locations/location-store-pages");
|
|
@@ -10,7 +13,7 @@ const descriptor_publication_1 = require("../locations/descriptor-publication");
|
|
|
10
13
|
const stream_wire_1 = require("@zlink-systems/stream-wire");
|
|
11
14
|
const node_crypto_1 = require("node:crypto");
|
|
12
15
|
const node_util_1 = require("node:util");
|
|
13
|
-
const
|
|
16
|
+
const contracts_2 = require("../../contracts");
|
|
14
17
|
const ConfigurationException_1 = require("../../contracts/Configuration/ConfigurationException");
|
|
15
18
|
const DiagnosticsValidation_1 = require("../../contracts/Configuration/DiagnosticsValidation");
|
|
16
19
|
const InternalDefaults_1 = require("../../contracts/Configuration/InternalDefaults");
|
|
@@ -35,6 +38,7 @@ const channel_envelope_1 = require("../channels/channel-envelope");
|
|
|
35
38
|
const diagnostics_1 = require("../diagnostics");
|
|
36
39
|
const runtime_metrics_1 = require("../diagnostics/runtime-metrics");
|
|
37
40
|
const runtime_observation_queue_1 = require("../diagnostics/runtime-observation-queue");
|
|
41
|
+
const message_flow_delivery_1 = require("../diagnostics/message-flow-delivery");
|
|
38
42
|
const topology_runtime_projections_1 = require("../diagnostics/topology-runtime-projections");
|
|
39
43
|
const execution_1 = require("../execution");
|
|
40
44
|
const listener_records_1 = require("../foundation/listener-records");
|
|
@@ -79,10 +83,26 @@ const HANDOFF_ACCEPTANCE_POLL_INTERVAL_MS = 10;
|
|
|
79
83
|
const DEFAULT_HOST_CONTROL_TIMEOUT_MS = 30_000;
|
|
80
84
|
class ZLinkFrameworkRuntimeHost {
|
|
81
85
|
options;
|
|
86
|
+
[internal_observation_1.inspectRuntime]() {
|
|
87
|
+
return Object.freeze({
|
|
88
|
+
ownerLeaseUsable: this.locationOwner.currentRuntime?.ownerLeaseUsable,
|
|
89
|
+
ownerId: this.locationOwner.currentRuntime?.ownerId,
|
|
90
|
+
hasOwnerToken: this.locationOwner.currentRuntime?.currentOwnerToken !== undefined,
|
|
91
|
+
ownerAdmissionOpen: this.admission.ownerAdmissionOpen(),
|
|
92
|
+
channelRuntimeStarted: this.channelRuntime !== undefined,
|
|
93
|
+
fanoutStoreIsLocationStore: this.locationOwner.currentStores?.fanoutStore ===
|
|
94
|
+
this.locationOwner.currentStores?.locationStore,
|
|
95
|
+
fanoutStoreMethods: Object.freeze({
|
|
96
|
+
update: typeof this.locationOwner.currentStores?.fanoutStore?.updateFanoutPublisher,
|
|
97
|
+
remove: typeof this.locationOwner.currentStores?.fanoutStore?.removeFanoutPublisher,
|
|
98
|
+
list: typeof this.locationOwner.currentStores?.fanoutStore?.listFanoutPublishers
|
|
99
|
+
})
|
|
100
|
+
});
|
|
101
|
+
}
|
|
82
102
|
backendAdapterFactory;
|
|
83
103
|
lifecycleSink;
|
|
84
104
|
executionState;
|
|
85
|
-
runtimeState =
|
|
105
|
+
runtimeState = contracts_2.ZLinkFrameworkRuntimeState.Preparing;
|
|
86
106
|
runtimeStatus;
|
|
87
107
|
runtimeObservationSource = Symbol('zlink.framework-runtime');
|
|
88
108
|
runtimeDeadline;
|
|
@@ -123,7 +143,7 @@ class ZLinkFrameworkRuntimeHost {
|
|
|
123
143
|
applicationJobQueue;
|
|
124
144
|
capacityStatus;
|
|
125
145
|
metricRegistrations = [];
|
|
126
|
-
admission
|
|
146
|
+
admission;
|
|
127
147
|
activationAdmission = new activation_admission_1.ZLinkActivationAdmission((meshName) => this.options.registration.spotNodes.get(meshName)?.activationConcurrencyLimit ??
|
|
128
148
|
InternalDefaults_1.DEFAULT_ACTIVATION_CONCURRENCY_LIMIT);
|
|
129
149
|
cachedLocationSpotRouteResolver;
|
|
@@ -133,6 +153,7 @@ class ZLinkFrameworkRuntimeHost {
|
|
|
133
153
|
messageFlowModeCell = {
|
|
134
154
|
mode: 'errors'
|
|
135
155
|
};
|
|
156
|
+
telemetryLease = (0, message_flow_delivery_1.openTelemetryLease)();
|
|
136
157
|
dispatchErrorReporters = new WeakMap();
|
|
137
158
|
runtimeOrPreStartErrorSink = {
|
|
138
159
|
reportRuntimeTaskException: (taskName, error) => (this.errorSink ?? this.preStartErrorSink).reportRuntimeTaskException(taskName, error)
|
|
@@ -142,6 +163,7 @@ class ZLinkFrameworkRuntimeHost {
|
|
|
142
163
|
channelTransport = () => this.channelRuntime;
|
|
143
164
|
channelRuntimeOptions = new channels_1.DefaultZLinkChannelRuntimeOptions(() => this.channelRuntime);
|
|
144
165
|
routeMeshRuntimeOptions = new route_mesh_runtime_options_1.DefaultZLinkRouteMeshRuntimeOptions(() => this.spotNodeRuntime);
|
|
166
|
+
requests = new request_runtime_1.RequestRuntime();
|
|
145
167
|
routeTransport;
|
|
146
168
|
spotAddressTransport;
|
|
147
169
|
spotPublisherTransport = new spots_1.ZLinkRuntimeSpotPublisherTransport(() => this.spotNodeRuntime);
|
|
@@ -155,6 +177,9 @@ class ZLinkFrameworkRuntimeHost {
|
|
|
155
177
|
routeMeshCoordinator;
|
|
156
178
|
constructor(options, internalOptions) {
|
|
157
179
|
this.options = options;
|
|
180
|
+
const factories = internalOptions;
|
|
181
|
+
this.spotNodeRuntime = factories?.spotNodeRuntime;
|
|
182
|
+
this.admission = (factories?.createAdmissionGate ?? ((ownerOpen) => new admission_1.ZLinkRuntimeAdmissionGate(ownerOpen)))(() => this.ownerAdmissionOpen());
|
|
158
183
|
this.backendAdapterFactory = resolveBackendAdapterFactory(internalOptions);
|
|
159
184
|
this.lifecycleSink = options.lifecycleSink;
|
|
160
185
|
this.runtimeEventPublisher =
|
|
@@ -172,8 +197,15 @@ class ZLinkFrameworkRuntimeHost {
|
|
|
172
197
|
this.fanoutRuntime = new topology_runtime_projections_1.ZLinkFanoutRuntimeProjection(() => this.channelRuntime, () => this.runtimeState);
|
|
173
198
|
this.meshRouters = new mesh_router_resolver_1.MeshRouterResolver(options.registration);
|
|
174
199
|
this.spotRouterChannelIdForMesh = this.meshRouters.spotRouterChannelIdByMesh();
|
|
175
|
-
this.routeTransport = new channels_1.ZLinkRuntimeRouteTransport(() =>
|
|
200
|
+
this.routeTransport = new channels_1.ZLinkRuntimeRouteTransport(() => {
|
|
201
|
+
if (this.channelRuntime === undefined &&
|
|
202
|
+
this.runtimeState === contracts_2.ZLinkFrameworkRuntimeState.Stopped) {
|
|
203
|
+
throw (0, framework_errors_internal_1.createInternalFrameworkException)(framework_errors_internal_1.ZLinkFrameworkInternalErrorKind.RuntimeShutdown, 'Route channel runtime is stopped.');
|
|
204
|
+
}
|
|
205
|
+
return this.channelRuntime;
|
|
206
|
+
}, (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(), () => this.createDispatchErrorReporter(this.runtimeOrPreStartErrorSink).flow, this.requests);
|
|
176
207
|
this.spotAddressTransport = new spot_address_transport_1.ZLinkHostSpotAddressTransport({
|
|
208
|
+
requests: this.requests,
|
|
177
209
|
resolver: () => this.createLocationSpotRouteResolver(),
|
|
178
210
|
routed: this.routeTransport,
|
|
179
211
|
meshNames: () => [...this.options.registration.spotNodes]
|
|
@@ -225,9 +257,10 @@ class ZLinkFrameworkRuntimeHost {
|
|
|
225
257
|
: this.boundSessionRelay.actorPackets.confirmRemoteSessionBinding(actor, sessionNode.status().routingId, sessionRid, signal, options);
|
|
226
258
|
},
|
|
227
259
|
relay: (actor, header, payload) => this.boundSessionRelay.actorPackets.relayActorPacket(actor, header, payload),
|
|
228
|
-
notifyDisconnected: (actor, signal, binding) => this.boundSessionRelay.actorPackets.notifyBoundActorDisconnected(actor, signal, binding)
|
|
260
|
+
notifyDisconnected: (actor, signal, binding, authorityFence) => this.boundSessionRelay.actorPackets.notifyBoundActorDisconnected(actor, signal, binding, authorityFence)
|
|
229
261
|
});
|
|
230
262
|
this.actorHandoff = new actors_1.ZLinkActorHandoffCoordinator({
|
|
263
|
+
requests: this.requests,
|
|
231
264
|
routedTransport: this.routeTransport,
|
|
232
265
|
messageFollowDurationMs: options.registration.locations.options.messageFollowDurationMs,
|
|
233
266
|
requestTimeoutMs: options.registration.requestTimeoutMs,
|
|
@@ -385,7 +418,9 @@ class ZLinkFrameworkRuntimeHost {
|
|
|
385
418
|
});
|
|
386
419
|
this.actorTransferRegistry = new actors_1.ZLinkActorTransferRegistry(options.registration.spotNodes, options.providerResolver, options.registration.messageSerializers);
|
|
387
420
|
this.boundSessionFactory = new streams_1.DefaultZLinkBoundSessionFactory(this.streamBindingRuntime);
|
|
388
|
-
|
|
421
|
+
const createBoundSessionRelay = factories?.createBoundSessionRelay ??
|
|
422
|
+
((relayOptions) => new bound_session_relay_1.ZLinkBoundSessionRelay(relayOptions));
|
|
423
|
+
this.boundSessionRelay = createBoundSessionRelay({
|
|
389
424
|
requestTimeoutMs: options.registration.requestTimeoutMs,
|
|
390
425
|
sessionRelocationSealTimeoutMs: options.registration.locations.options.sessionRelocationSealTimeoutMs ??
|
|
391
426
|
Locations_1.zlinkDefaultLocationOptions.sessionRelocationSealTimeoutMs,
|
|
@@ -500,6 +535,7 @@ class ZLinkFrameworkRuntimeHost {
|
|
|
500
535
|
shutdownSignal: () => this.executionState?.abortController.signal
|
|
501
536
|
});
|
|
502
537
|
this.serviceRelocation = new service_relocation_host_runtime_1.ZLinkHostServiceRelocationRuntime({
|
|
538
|
+
requests: this.requests,
|
|
503
539
|
flowCreationEnabled: () => this.flowCreationEnabled(),
|
|
504
540
|
messageFlow: () => this.createDispatchErrorReporter(this.runtimeOrPreStartErrorSink).flow,
|
|
505
541
|
registration: options.registration,
|
|
@@ -523,7 +559,7 @@ class ZLinkFrameworkRuntimeHost {
|
|
|
523
559
|
clear: () => this.boundSessionRelay.boundSessions.clearServiceWireSessionRelocations()
|
|
524
560
|
},
|
|
525
561
|
trackInstanceSpot: (input) => this.locationOwner.currentLifecycle?.trackInstanceSpot(input),
|
|
526
|
-
|
|
562
|
+
observeActorAuthorityVersion: (actorId, storeVersion) => this.actorClientLocationResolver?.observeActorAuthorityVersion(actorId, storeVersion),
|
|
527
563
|
reconcileStatefulAuthorityRoutes: (signal) => this.statefulAuthorityRoutes?.reconcile(signal) ?? Promise.resolve(),
|
|
528
564
|
runtimeEventPublisher: this.runtimeEventPublisher,
|
|
529
565
|
metrics: this.metrics,
|
|
@@ -537,7 +573,8 @@ class ZLinkFrameworkRuntimeHost {
|
|
|
537
573
|
...options.registration.locations.options
|
|
538
574
|
}.ownerLeaseTtlMs
|
|
539
575
|
});
|
|
540
|
-
this.routeMeshCoordinator =
|
|
576
|
+
this.routeMeshCoordinator = (factories?.createRouteMeshCoordinator ??
|
|
577
|
+
((meshOptions) => new route_mesh_runtime_1.ZLinkRouteMeshRuntimeCoordinator(meshOptions)))({
|
|
541
578
|
meshNames: [...options.registration.spotNodes.keys()],
|
|
542
579
|
meshOptions: options.registration.spotNodes,
|
|
543
580
|
meshNode: (meshName) => this.spotNodeRuntime?.meshNode(meshName),
|
|
@@ -624,15 +661,15 @@ class ZLinkFrameworkRuntimeHost {
|
|
|
624
661
|
if (!Number.isFinite(deadlineMs) || deadlineMs <= 0) {
|
|
625
662
|
return Promise.reject(new RangeError('Relocation deadlineMs must be greater than zero.'));
|
|
626
663
|
}
|
|
627
|
-
if (this.runtimeRelocationResult?.outcome ===
|
|
664
|
+
if (this.runtimeRelocationResult?.outcome === contracts_2.ZLinkFrameworkRelocationOutcome.Relocated) {
|
|
628
665
|
return Promise.resolve(this.runtimeRelocationResult);
|
|
629
666
|
}
|
|
630
667
|
if (this.shutdownOperation !== undefined) {
|
|
631
668
|
return Promise.resolve({
|
|
632
669
|
mode: options.mode,
|
|
633
670
|
effectiveTargetApplicationVersion,
|
|
634
|
-
outcome:
|
|
635
|
-
reason:
|
|
671
|
+
outcome: contracts_2.ZLinkFrameworkRelocationOutcome.Blocked,
|
|
672
|
+
reason: contracts_2.ZLinkFrameworkRelocationReason.ShutdownRequested
|
|
636
673
|
});
|
|
637
674
|
}
|
|
638
675
|
const operationKey = `${options.mode}:${effectiveTargetApplicationVersion}`;
|
|
@@ -643,34 +680,34 @@ class ZLinkFrameworkRuntimeHost {
|
|
|
643
680
|
return Promise.resolve({
|
|
644
681
|
mode: options.mode,
|
|
645
682
|
effectiveTargetApplicationVersion,
|
|
646
|
-
outcome:
|
|
647
|
-
reason:
|
|
683
|
+
outcome: contracts_2.ZLinkFrameworkRelocationOutcome.Blocked,
|
|
684
|
+
reason: contracts_2.ZLinkFrameworkRelocationReason.OperationInProgress
|
|
648
685
|
});
|
|
649
686
|
}
|
|
650
|
-
if (this.runtimeState !==
|
|
687
|
+
if (this.runtimeState !== contracts_2.ZLinkFrameworkRuntimeState.Serving) {
|
|
651
688
|
return Promise.resolve({
|
|
652
689
|
mode: options.mode,
|
|
653
690
|
effectiveTargetApplicationVersion,
|
|
654
|
-
outcome:
|
|
655
|
-
reason: this.runtimeState ===
|
|
656
|
-
?
|
|
657
|
-
:
|
|
691
|
+
outcome: contracts_2.ZLinkFrameworkRelocationOutcome.Blocked,
|
|
692
|
+
reason: this.runtimeState === contracts_2.ZLinkFrameworkRuntimeState.Relocating
|
|
693
|
+
? contracts_2.ZLinkFrameworkRelocationReason.OperationInProgress
|
|
694
|
+
: contracts_2.ZLinkFrameworkRelocationReason.RuntimeNotReady
|
|
658
695
|
});
|
|
659
696
|
}
|
|
660
697
|
if (!this.admission.acceptsNewWork) {
|
|
661
698
|
return Promise.resolve({
|
|
662
699
|
mode: options.mode,
|
|
663
700
|
effectiveTargetApplicationVersion,
|
|
664
|
-
outcome:
|
|
665
|
-
reason:
|
|
701
|
+
outcome: contracts_2.ZLinkFrameworkRelocationOutcome.Blocked,
|
|
702
|
+
reason: contracts_2.ZLinkFrameworkRelocationReason.StoreUnavailable
|
|
666
703
|
});
|
|
667
704
|
}
|
|
668
705
|
if (hasUnsupportedManualTopology(this.options.registration)) {
|
|
669
706
|
return Promise.resolve({
|
|
670
707
|
mode: options.mode,
|
|
671
708
|
effectiveTargetApplicationVersion,
|
|
672
|
-
outcome:
|
|
673
|
-
reason:
|
|
709
|
+
outcome: contracts_2.ZLinkFrameworkRelocationOutcome.Blocked,
|
|
710
|
+
reason: contracts_2.ZLinkFrameworkRelocationReason.ManualTopologyUnsupported
|
|
674
711
|
});
|
|
675
712
|
}
|
|
676
713
|
this.runtimeDeadline = new Date(Date.now() + deadlineMs);
|
|
@@ -696,7 +733,7 @@ class ZLinkFrameworkRuntimeHost {
|
|
|
696
733
|
}
|
|
697
734
|
async runRelocation(mode, effectiveTargetApplicationVersion, deadlineMs, stopStartingSignal) {
|
|
698
735
|
if (!this.isStarted) {
|
|
699
|
-
return this.completeRelocation(blockedRelocation(mode, effectiveTargetApplicationVersion,
|
|
736
|
+
return this.completeRelocation(blockedRelocation(mode, effectiveTargetApplicationVersion, contracts_2.ZLinkFrameworkRelocationReason.RuntimeNotReady));
|
|
700
737
|
}
|
|
701
738
|
const deadlineAtMs = performance.now() + deadlineMs;
|
|
702
739
|
const remainingDeadlineMs = () => Math.max(1, deadlineAtMs - performance.now());
|
|
@@ -713,39 +750,39 @@ class ZLinkFrameworkRuntimeHost {
|
|
|
713
750
|
const descriptorPreparation = await this.routeMeshCoordinator.prepareHostRetire(remainingDeadlineMs());
|
|
714
751
|
if (descriptorPreparation !== 'prepared') {
|
|
715
752
|
return this.resetBlockedRelocation(blockedRelocation(mode, effectiveTargetApplicationVersion, descriptorPreparation === 'deadline_exceeded'
|
|
716
|
-
?
|
|
717
|
-
:
|
|
753
|
+
? contracts_2.ZLinkFrameworkRelocationReason.DeadlineExceeded
|
|
754
|
+
: contracts_2.ZLinkFrameworkRelocationReason.StoreUnavailable));
|
|
718
755
|
}
|
|
719
|
-
this.setRuntimeState(
|
|
756
|
+
this.setRuntimeState(contracts_2.ZLinkFrameworkRuntimeState.Relocating);
|
|
720
757
|
const drained = await this.routeMeshCoordinator.relocateHost(remainingDeadlineMs(), stopStartingSignal);
|
|
721
758
|
if (drained.kind === 'forceStopped') {
|
|
722
759
|
// Settled authority on both sides or an expired source owner lease
|
|
723
760
|
// ends the host in Error (spec 30 §13).
|
|
724
761
|
if (drained.error instanceof service_relocation_coordinator_1.ServiceRelocationAuthorityError) {
|
|
725
|
-
return this.completeRelocation(blockedRelocation(mode, effectiveTargetApplicationVersion,
|
|
762
|
+
return this.completeRelocation(blockedRelocation(mode, effectiveTargetApplicationVersion, contracts_2.ZLinkFrameworkRelocationReason.RelocationFailed));
|
|
726
763
|
}
|
|
727
764
|
return this.resetBlockedRelocation(blockedRelocation(mode, effectiveTargetApplicationVersion, stopStartingSignal.aborted
|
|
728
|
-
?
|
|
765
|
+
? contracts_2.ZLinkFrameworkRelocationReason.ShutdownRequested
|
|
729
766
|
: drained.error instanceof service_relocation_host_runtime_1.ZLinkRelocationStateIncompatibleError
|
|
730
|
-
?
|
|
767
|
+
? contracts_2.ZLinkFrameworkRelocationReason.StateIncompatible
|
|
731
768
|
: relocationReason(drained.reason)));
|
|
732
769
|
}
|
|
733
770
|
await this.publishHostRelocated();
|
|
734
771
|
return this.completeRelocation({
|
|
735
772
|
mode,
|
|
736
773
|
effectiveTargetApplicationVersion,
|
|
737
|
-
outcome:
|
|
738
|
-
reason:
|
|
774
|
+
outcome: contracts_2.ZLinkFrameworkRelocationOutcome.Relocated,
|
|
775
|
+
reason: contracts_2.ZLinkFrameworkRelocationReason.None
|
|
739
776
|
});
|
|
740
777
|
}
|
|
741
778
|
catch (error) {
|
|
742
779
|
const result = blockedRelocation(mode, effectiveTargetApplicationVersion, stopStartingSignal.aborted
|
|
743
|
-
?
|
|
780
|
+
? contracts_2.ZLinkFrameworkRelocationReason.ShutdownRequested
|
|
744
781
|
: (0, abort_1.isDeadlineExceededError)(error)
|
|
745
|
-
?
|
|
782
|
+
? contracts_2.ZLinkFrameworkRelocationReason.DeadlineExceeded
|
|
746
783
|
: error instanceof service_relocation_host_runtime_1.ZLinkRelocationStateIncompatibleError
|
|
747
|
-
?
|
|
748
|
-
:
|
|
784
|
+
? contracts_2.ZLinkFrameworkRelocationReason.StateIncompatible
|
|
785
|
+
: contracts_2.ZLinkFrameworkRelocationReason.RelocationFailed);
|
|
749
786
|
return error instanceof route_mesh_runtime_1.ZLinkRetiringRollbackError
|
|
750
787
|
? this.completeRelocation(result)
|
|
751
788
|
: this.resetBlockedRelocation(result);
|
|
@@ -756,10 +793,10 @@ class ZLinkFrameworkRuntimeHost {
|
|
|
756
793
|
const deadlineAtMs = performance.now() + deadlineMs;
|
|
757
794
|
try {
|
|
758
795
|
this.admission.close();
|
|
759
|
-
if (this.runtimeState ===
|
|
796
|
+
if (this.runtimeState === contracts_2.ZLinkFrameworkRuntimeState.Preparing) {
|
|
760
797
|
this.executionState?.abortController.abort();
|
|
761
798
|
}
|
|
762
|
-
this.setRuntimeState(
|
|
799
|
+
this.setRuntimeState(contracts_2.ZLinkFrameworkRuntimeState.Draining);
|
|
763
800
|
if (this.relocationOperation !== undefined &&
|
|
764
801
|
this.relocationStopStarting?.signal.aborted === true) {
|
|
765
802
|
await this.relocationOperation;
|
|
@@ -777,27 +814,27 @@ class ZLinkFrameworkRuntimeHost {
|
|
|
777
814
|
await this.stop();
|
|
778
815
|
if (drain.kind === 'forceStopped') {
|
|
779
816
|
return this.completeTermination({
|
|
780
|
-
outcome:
|
|
817
|
+
outcome: contracts_2.ZLinkFrameworkTerminationOutcome.ForceStopped,
|
|
781
818
|
reason: drain.reason === 'deadline_exceeded'
|
|
782
|
-
?
|
|
783
|
-
:
|
|
819
|
+
? contracts_2.ZLinkFrameworkTerminationReason.DeadlineExceeded
|
|
820
|
+
: contracts_2.ZLinkFrameworkTerminationReason.TeardownFailed
|
|
784
821
|
});
|
|
785
822
|
}
|
|
786
823
|
if (performance.now() >= deadlineAtMs) {
|
|
787
824
|
throw (0, abort_1.createDeadlineExceededError)('Shutdown resource cleanup exceeded its deadline.');
|
|
788
825
|
}
|
|
789
826
|
return this.completeTermination({
|
|
790
|
-
outcome:
|
|
791
|
-
reason:
|
|
827
|
+
outcome: contracts_2.ZLinkFrameworkTerminationOutcome.Stopped,
|
|
828
|
+
reason: contracts_2.ZLinkFrameworkTerminationReason.None
|
|
792
829
|
});
|
|
793
830
|
}
|
|
794
831
|
catch (error) {
|
|
795
832
|
await this.stop().catch(() => undefined);
|
|
796
833
|
return this.completeTermination({
|
|
797
|
-
outcome:
|
|
834
|
+
outcome: contracts_2.ZLinkFrameworkTerminationOutcome.ForceStopped,
|
|
798
835
|
reason: (0, abort_1.isDeadlineExceededError)(error)
|
|
799
|
-
?
|
|
800
|
-
:
|
|
836
|
+
? contracts_2.ZLinkFrameworkTerminationReason.DeadlineExceeded
|
|
837
|
+
: contracts_2.ZLinkFrameworkTerminationReason.TeardownFailed
|
|
801
838
|
});
|
|
802
839
|
}
|
|
803
840
|
});
|
|
@@ -822,8 +859,8 @@ class ZLinkFrameworkRuntimeHost {
|
|
|
822
859
|
}
|
|
823
860
|
resetBlockedRelocation(result) {
|
|
824
861
|
this.recordRelocationResult(result);
|
|
825
|
-
if (this.runtimeState ===
|
|
826
|
-
this.setRuntimeState(
|
|
862
|
+
if (this.runtimeState === contracts_2.ZLinkFrameworkRuntimeState.Relocating) {
|
|
863
|
+
this.setRuntimeState(contracts_2.ZLinkFrameworkRuntimeState.Serving);
|
|
827
864
|
}
|
|
828
865
|
this.runtimeDeadline = undefined;
|
|
829
866
|
this.relocationTargetApplicationVersion = undefined;
|
|
@@ -837,9 +874,9 @@ class ZLinkFrameworkRuntimeHost {
|
|
|
837
874
|
this.runtimeRelocationResult = result;
|
|
838
875
|
this.runtimeDeadline = undefined;
|
|
839
876
|
this.recordRelocationResult(result);
|
|
840
|
-
this.setRuntimeState(result.outcome ===
|
|
841
|
-
?
|
|
842
|
-
:
|
|
877
|
+
this.setRuntimeState(result.outcome === contracts_2.ZLinkFrameworkRelocationOutcome.Relocated
|
|
878
|
+
? contracts_2.ZLinkFrameworkRuntimeState.Relocated
|
|
879
|
+
: contracts_2.ZLinkFrameworkRuntimeState.Error);
|
|
843
880
|
return result;
|
|
844
881
|
}
|
|
845
882
|
recordRelocationResult(result) {
|
|
@@ -847,10 +884,10 @@ class ZLinkFrameworkRuntimeHost {
|
|
|
847
884
|
this.metrics.duration(runtime_metrics_1.METRIC_NAMES.HostRelocationDuration, Math.max(0, performance.now() - this.relocationOperationStartedAt) /
|
|
848
885
|
runtime_metrics_1.MILLISECONDS_PER_SECOND, {
|
|
849
886
|
mode: relocationModeMetricName(result.mode),
|
|
850
|
-
outcome: result.outcome ===
|
|
887
|
+
outcome: result.outcome === contracts_2.ZLinkFrameworkRelocationOutcome.Relocated ? 'relocated' : 'blocked'
|
|
851
888
|
});
|
|
852
889
|
}
|
|
853
|
-
if (result.outcome ===
|
|
890
|
+
if (result.outcome === contracts_2.ZLinkFrameworkRelocationOutcome.Blocked) {
|
|
854
891
|
this.metrics.count(runtime_metrics_1.METRIC_NAMES.HostRelocationBlocked, 1, {
|
|
855
892
|
mode: relocationModeMetricName(result.mode),
|
|
856
893
|
reason: relocationReasonMetricName(result.reason)
|
|
@@ -871,12 +908,12 @@ class ZLinkFrameworkRuntimeHost {
|
|
|
871
908
|
this.runtimeDeadline = undefined;
|
|
872
909
|
if (this.shutdownOperationStartedAt !== undefined) {
|
|
873
910
|
this.metrics.duration(runtime_metrics_1.METRIC_NAMES.HostShutdownDuration, Math.max(0, performance.now() - this.shutdownOperationStartedAt) / runtime_metrics_1.MILLISECONDS_PER_SECOND, {
|
|
874
|
-
outcome: result.outcome ===
|
|
911
|
+
outcome: result.outcome === contracts_2.ZLinkFrameworkTerminationOutcome.Stopped
|
|
875
912
|
? 'stopped'
|
|
876
913
|
: 'force_stopped'
|
|
877
914
|
});
|
|
878
915
|
}
|
|
879
|
-
if (result.outcome ===
|
|
916
|
+
if (result.outcome === contracts_2.ZLinkFrameworkTerminationOutcome.ForceStopped) {
|
|
880
917
|
this.metrics.count(runtime_metrics_1.METRIC_NAMES.HostShutdownForced, 1, {
|
|
881
918
|
reason: terminationReasonMetricName(result.reason)
|
|
882
919
|
});
|
|
@@ -888,7 +925,7 @@ class ZLinkFrameworkRuntimeHost {
|
|
|
888
925
|
outcome: result.outcome,
|
|
889
926
|
reason: result.reason
|
|
890
927
|
});
|
|
891
|
-
this.setRuntimeState(
|
|
928
|
+
this.setRuntimeState(contracts_2.ZLinkFrameworkRuntimeState.Stopped);
|
|
892
929
|
return result;
|
|
893
930
|
}
|
|
894
931
|
setRuntimeState(state) {
|
|
@@ -1004,7 +1041,13 @@ class ZLinkFrameworkRuntimeHost {
|
|
|
1004
1041
|
if (this.executionState !== undefined) {
|
|
1005
1042
|
return;
|
|
1006
1043
|
}
|
|
1007
|
-
this.
|
|
1044
|
+
const previousLease = this.telemetryLease;
|
|
1045
|
+
this.telemetryLease = (0, message_flow_delivery_1.renewTelemetryLease)(previousLease);
|
|
1046
|
+
if (this.telemetryLease !== previousLease) {
|
|
1047
|
+
this.dispatchErrorReporters = new WeakMap();
|
|
1048
|
+
this.cachedDiagnosticsContext = undefined;
|
|
1049
|
+
}
|
|
1050
|
+
this.setRuntimeState(contracts_2.ZLinkFrameworkRuntimeState.Preparing);
|
|
1008
1051
|
this.lifecycleSink?.push('framework:start');
|
|
1009
1052
|
const listenerRecords = new listener_records_1.ZLinkListenerRecords();
|
|
1010
1053
|
this.listenerRecords = listenerRecords;
|
|
@@ -1024,10 +1067,11 @@ class ZLinkFrameworkRuntimeHost {
|
|
|
1024
1067
|
this.messageFlowModeCell.mode =
|
|
1025
1068
|
this.options.registration.dispatch?.diagnostics.messageFlow ?? 'errors';
|
|
1026
1069
|
const dispatchErrors = this.createDispatchErrorReporter(this.executionState.errorSink);
|
|
1027
|
-
channelRuntime = new channels_1.ZLinkChannelRuntimeManager(this.options.registration, channelAdapter, context, this.options.providerResolver, { ...this.createChannelRuntimeOptions(), listenerRecords });
|
|
1070
|
+
channelRuntime = new channels_1.ZLinkChannelRuntimeManager(this.options.registration, channelAdapter, context, this.options.providerResolver, { ...this.createChannelRuntimeOptions(), listenerRecords, requests: this.requests });
|
|
1028
1071
|
this.channelRuntime = channelRuntime;
|
|
1029
1072
|
channelRuntime.prepareMeshDispatch(this.executionState.taskRunner);
|
|
1030
1073
|
spotNodeRuntime = new spots_1.ZLinkSpotNodeRuntimeManager({
|
|
1074
|
+
requests: this.requests,
|
|
1031
1075
|
...this.createSpotNodeRuntimeOptions(context, dispatchErrors),
|
|
1032
1076
|
listenerRecords
|
|
1033
1077
|
});
|
|
@@ -1045,7 +1089,7 @@ class ZLinkFrameworkRuntimeHost {
|
|
|
1045
1089
|
await this.publishOrStayPreparing(locationRuntime, async (publishSignal) => {
|
|
1046
1090
|
await spotNodeRuntime.startLocationAutoConnect(publishSignal);
|
|
1047
1091
|
await channelRuntime.startLocationAutoConnect(publishSignal);
|
|
1048
|
-
await spotNodeRuntime.publishMeshNodeState(
|
|
1092
|
+
await spotNodeRuntime.publishMeshNodeState(contracts_2.ZLinkFrameworkRuntimeState.Preparing, publishSignal);
|
|
1049
1093
|
});
|
|
1050
1094
|
}
|
|
1051
1095
|
streamRuntime = new streams_1.ZLinkStreamRuntimeManager({
|
|
@@ -1108,6 +1152,8 @@ class ZLinkFrameworkRuntimeHost {
|
|
|
1108
1152
|
}
|
|
1109
1153
|
}
|
|
1110
1154
|
async stop() {
|
|
1155
|
+
(0, message_flow_delivery_1.retireTelemetryLease)(this.telemetryLease);
|
|
1156
|
+
this.requests.close(new contracts_1.ZLinkFrameworkException(contracts_1.ZLinkFrameworkErrorKind.ShuttingDown, 'Host stopped.'));
|
|
1111
1157
|
await this.runWithShutdownDeadline(DEFAULT_HOST_CONTROL_TIMEOUT_MS, async () => this.runLifecycle(() => this.stopCore()));
|
|
1112
1158
|
}
|
|
1113
1159
|
runtimeMetricMeshSnapshots() {
|
|
@@ -1133,7 +1179,7 @@ class ZLinkFrameworkRuntimeHost {
|
|
|
1133
1179
|
meshName,
|
|
1134
1180
|
source,
|
|
1135
1181
|
configuredPeers: status.peers.length,
|
|
1136
|
-
connectedPeers: status.peers.filter((peer) => peer.state !==
|
|
1182
|
+
connectedPeers: status.peers.filter((peer) => peer.state !== contracts_2.ZLinkPeerState.NotConnected)
|
|
1137
1183
|
.length,
|
|
1138
1184
|
readyPeers: status.readyPeerCount,
|
|
1139
1185
|
channels: status.channels.map((channel) => ({
|
|
@@ -1190,7 +1236,7 @@ class ZLinkFrameworkRuntimeHost {
|
|
|
1190
1236
|
this.listenerRecords.clear();
|
|
1191
1237
|
this.lifecycleSink?.push('framework:stopped');
|
|
1192
1238
|
if (this.shutdownOperation === undefined) {
|
|
1193
|
-
this.setRuntimeState(
|
|
1239
|
+
this.setRuntimeState(contracts_2.ZLinkFrameworkRuntimeState.Stopped);
|
|
1194
1240
|
}
|
|
1195
1241
|
}
|
|
1196
1242
|
installOwnerLeaseRecoveryPublication(runtime, spotNodeRuntime, channelRuntime) {
|
|
@@ -1198,7 +1244,7 @@ class ZLinkFrameworkRuntimeHost {
|
|
|
1198
1244
|
const handler = (_renewal, wasOwnerLeaseUsable) => {
|
|
1199
1245
|
if (!this.ownerAdmissionOpen())
|
|
1200
1246
|
return;
|
|
1201
|
-
if (wasOwnerLeaseUsable && this.runtimeState !==
|
|
1247
|
+
if (wasOwnerLeaseUsable && this.runtimeState !== contracts_2.ZLinkFrameworkRuntimeState.Preparing)
|
|
1202
1248
|
return;
|
|
1203
1249
|
if (recoveryOperation !== undefined)
|
|
1204
1250
|
return;
|
|
@@ -1219,17 +1265,17 @@ class ZLinkFrameworkRuntimeHost {
|
|
|
1219
1265
|
if (!this.ownerAdmissionOpen())
|
|
1220
1266
|
return;
|
|
1221
1267
|
await this.publishOrStayPreparing(runtime, async (signal) => {
|
|
1222
|
-
await spotNodeRuntime.publishMeshNodeState(
|
|
1268
|
+
await spotNodeRuntime.publishMeshNodeState(contracts_2.ZLinkFrameworkRuntimeState.Preparing, signal);
|
|
1223
1269
|
if (runtime.ownerLeaseUsable === false)
|
|
1224
1270
|
return;
|
|
1225
|
-
if (this.runtimeState !==
|
|
1271
|
+
if (this.runtimeState !== contracts_2.ZLinkFrameworkRuntimeState.Preparing) {
|
|
1226
1272
|
await spotNodeRuntime.publishMeshNodeState(this.runtimeState, signal);
|
|
1227
1273
|
}
|
|
1228
1274
|
await spotNodeRuntime.startLocationAutoConnect(signal);
|
|
1229
1275
|
await channelRuntime.startLocationAutoConnect(signal);
|
|
1230
1276
|
await channelRuntime.reclaimLocationOwnerRows(signal);
|
|
1231
1277
|
await this.locationOwner.currentLifecycle?.reclaimOwnerRows();
|
|
1232
|
-
if (this.runtimeState ===
|
|
1278
|
+
if (this.runtimeState === contracts_2.ZLinkFrameworkRuntimeState.Preparing) {
|
|
1233
1279
|
await this.enterServing(spotNodeRuntime, signal);
|
|
1234
1280
|
}
|
|
1235
1281
|
});
|
|
@@ -1241,9 +1287,9 @@ class ZLinkFrameworkRuntimeHost {
|
|
|
1241
1287
|
if (store !== undefined) {
|
|
1242
1288
|
await this.startStatefulAuthority(store, spotNodeRuntime, signal);
|
|
1243
1289
|
}
|
|
1244
|
-
await spotNodeRuntime.publishMeshNodeState(
|
|
1290
|
+
await spotNodeRuntime.publishMeshNodeState(contracts_2.ZLinkFrameworkRuntimeState.Serving, signal);
|
|
1245
1291
|
this.routeMeshCoordinator.markServing();
|
|
1246
|
-
this.setRuntimeState(
|
|
1292
|
+
this.setRuntimeState(contracts_2.ZLinkFrameworkRuntimeState.Serving);
|
|
1247
1293
|
}
|
|
1248
1294
|
// Location runtime §5: a startup publication the Store does not confirm (a
|
|
1249
1295
|
// provider error, or no answer within the renew timeout) leaves the host in
|
|
@@ -1366,10 +1412,10 @@ class ZLinkFrameworkRuntimeHost {
|
|
|
1366
1412
|
await awaitWithDrainSignal(this.streamRuntime?.notifyServerDrain(meshName), signal);
|
|
1367
1413
|
}
|
|
1368
1414
|
async publishMeshRetiring(meshName, signal) {
|
|
1369
|
-
await this.spotNodeRuntime?.publishMeshNodeState(
|
|
1415
|
+
await this.spotNodeRuntime?.publishMeshNodeState(contracts_2.ZLinkFrameworkRuntimeState.Relocating, signal, meshName);
|
|
1370
1416
|
}
|
|
1371
1417
|
async publishMeshServing(meshName, signal) {
|
|
1372
|
-
await this.spotNodeRuntime?.reconcileAndPublishMeshNodeState(
|
|
1418
|
+
await this.spotNodeRuntime?.reconcileAndPublishMeshNodeState(contracts_2.ZLinkFrameworkRuntimeState.Serving, meshName, signal);
|
|
1373
1419
|
// A failed relocation rolls the local object barriers back before the
|
|
1374
1420
|
// descriptor is published as Serving. Reconcile the durable authority
|
|
1375
1421
|
// routes before returning so the next local request cannot observe the
|
|
@@ -1382,7 +1428,7 @@ class ZLinkFrameworkRuntimeHost {
|
|
|
1382
1428
|
if (node !== undefined) {
|
|
1383
1429
|
await node.publishDraining?.();
|
|
1384
1430
|
}
|
|
1385
|
-
await this.spotNodeRuntime?.publishMeshNodeState(
|
|
1431
|
+
await this.spotNodeRuntime?.publishMeshNodeState(contracts_2.ZLinkFrameworkRuntimeState.Draining, signal, meshName);
|
|
1386
1432
|
}
|
|
1387
1433
|
async preflightAutomaticPeerReadiness(deadlineAt, targetApplicationVersion) {
|
|
1388
1434
|
// A host with no local stateful workload has nothing to move. The public
|
|
@@ -1394,7 +1440,7 @@ class ZLinkFrameworkRuntimeHost {
|
|
|
1394
1440
|
return undefined;
|
|
1395
1441
|
const location = this.locationOwner.currentRuntime;
|
|
1396
1442
|
if (location === undefined)
|
|
1397
|
-
return
|
|
1443
|
+
return contracts_2.ZLinkFrameworkRelocationReason.StoreUnavailable;
|
|
1398
1444
|
let storeUnavailable = false;
|
|
1399
1445
|
while (performance.now() < deadlineAt) {
|
|
1400
1446
|
try {
|
|
@@ -1409,8 +1455,8 @@ class ZLinkFrameworkRuntimeHost {
|
|
|
1409
1455
|
Locations_1.zlinkDefaultLocationOptions.pollingIntervalMs, Math.max(1, deadlineAt - performance.now()))));
|
|
1410
1456
|
}
|
|
1411
1457
|
return storeUnavailable
|
|
1412
|
-
?
|
|
1413
|
-
:
|
|
1458
|
+
? contracts_2.ZLinkFrameworkRelocationReason.StoreUnavailable
|
|
1459
|
+
: contracts_2.ZLinkFrameworkRelocationReason.TargetUnavailable;
|
|
1414
1460
|
}
|
|
1415
1461
|
hasLocalStatefulRelocationWork() {
|
|
1416
1462
|
const spotManager = this.spotManager;
|
|
@@ -1447,7 +1493,7 @@ class ZLinkFrameworkRuntimeHost {
|
|
|
1447
1493
|
return true;
|
|
1448
1494
|
}
|
|
1449
1495
|
async publishHostRelocated() {
|
|
1450
|
-
await Promise.all([...this.options.registration.spotNodes.keys()].map((meshName) => this.spotNodeRuntime?.publishMeshNodeState(
|
|
1496
|
+
await Promise.all([...this.options.registration.spotNodes.keys()].map((meshName) => this.spotNodeRuntime?.publishMeshNodeState(contracts_2.ZLinkFrameworkRuntimeState.Relocated, undefined, meshName)));
|
|
1451
1497
|
}
|
|
1452
1498
|
async publishHostDraining(signal) {
|
|
1453
1499
|
try {
|
|
@@ -1613,7 +1659,7 @@ class ZLinkFrameworkRuntimeHost {
|
|
|
1613
1659
|
const descriptors = await (0, location_store_pages_1.listAllMeshNodeDescriptors)(locationStore, meshName, signal);
|
|
1614
1660
|
const selected = await selectReadyLocationPlacementDescriptor(descriptors, meshNode, signal, (descriptor) => {
|
|
1615
1661
|
const capability = descriptor.objectCapabilities.find((candidate) => candidate.objectKind === 'actor' && candidate.stableType === stableType);
|
|
1616
|
-
return (descriptor.state ===
|
|
1662
|
+
return (descriptor.state === contracts_2.ZLinkFrameworkRuntimeState.Serving &&
|
|
1617
1663
|
descriptor.objectRole === 'server' &&
|
|
1618
1664
|
descriptor.placementWeight > 0 &&
|
|
1619
1665
|
descriptor.entrySpotId !== undefined &&
|
|
@@ -1642,10 +1688,33 @@ class ZLinkFrameworkRuntimeHost {
|
|
|
1642
1688
|
};
|
|
1643
1689
|
}
|
|
1644
1690
|
});
|
|
1691
|
+
const selectUserSpotMesh = (requestedMeshName) => {
|
|
1692
|
+
const clientMeshes = [...this.options.registration.spotNodes]
|
|
1693
|
+
.filter(([, node]) => (0, spot_address_transport_1.hasObjectClientCapability)(node.objectRole))
|
|
1694
|
+
.map(([meshName]) => meshName);
|
|
1695
|
+
const meshes = requestedMeshName === undefined ? clientMeshes : [requestedMeshName];
|
|
1696
|
+
if (meshes.length === 0) {
|
|
1697
|
+
throw (0, framework_errors_internal_1.createInternalFrameworkException)(framework_errors_internal_1.ZLinkFrameworkInternalErrorKind.ObjectClientNotConfigured, 'No object-client RouteMesh is configured.');
|
|
1698
|
+
}
|
|
1699
|
+
if (requestedMeshName === undefined && meshes.length > 1) {
|
|
1700
|
+
throw (0, framework_errors_internal_1.createInternalFrameworkException)(framework_errors_internal_1.ZLinkFrameworkInternalErrorKind.MeshSelectionRequired, 'Multiple object-client RouteMeshes are configured; call inMesh(...).');
|
|
1701
|
+
}
|
|
1702
|
+
const meshName = meshes[0];
|
|
1703
|
+
if (!this.options.registration.spotNodes.has(meshName)) {
|
|
1704
|
+
throw (0, framework_errors_internal_1.createInternalFrameworkException)(framework_errors_internal_1.ZLinkFrameworkInternalErrorKind.MeshNotFound, `RouteMesh '${meshName}' is not configured.`);
|
|
1705
|
+
}
|
|
1706
|
+
if (!clientMeshes.includes(meshName)) {
|
|
1707
|
+
throw (0, framework_errors_internal_1.createInternalFrameworkException)(framework_errors_internal_1.ZLinkFrameworkInternalErrorKind.ObjectClientNotConfigured, `RouteMesh '${meshName}' has no object-client role.`);
|
|
1708
|
+
}
|
|
1709
|
+
return meshName;
|
|
1710
|
+
};
|
|
1645
1711
|
const coordinator = (this.userSpotCoordinator = new user_spot_creation_coordinator_1.ZLinkUserSpotCreationCoordinator({
|
|
1646
1712
|
store: locationStore,
|
|
1647
|
-
|
|
1648
|
-
|
|
1713
|
+
leaseTracker: this.locationOwner.currentLeaseTracker,
|
|
1714
|
+
relocationPolicy: (meshName, stableType) => {
|
|
1715
|
+
const node = this.options.registration.spotNodes.get(selectUserSpotMesh(meshName));
|
|
1716
|
+
return node?.spotFactoryRegistrations?.[stableType]?.relocation.kind;
|
|
1717
|
+
},
|
|
1649
1718
|
publishReadyRoute: (meshName, route) => {
|
|
1650
1719
|
this.cachedLocationSpotRouteResolver?.invalidate?.(route.spot.spotId);
|
|
1651
1720
|
this.spotNodeRuntime?.meshNode(meshName)?.rememberSpotRoute?.(route);
|
|
@@ -1673,23 +1742,7 @@ class ZLinkFrameworkRuntimeHost {
|
|
|
1673
1742
|
}
|
|
1674
1743
|
},
|
|
1675
1744
|
target: async (request, signal, excludedNodeRids) => {
|
|
1676
|
-
const
|
|
1677
|
-
.filter(([, node]) => (0, spot_address_transport_1.hasObjectClientCapability)(node.objectRole))
|
|
1678
|
-
.map(([meshName]) => meshName);
|
|
1679
|
-
const meshes = request.meshName === undefined ? clientMeshes : [request.meshName];
|
|
1680
|
-
if (meshes.length === 0) {
|
|
1681
|
-
throw (0, framework_errors_internal_1.createInternalFrameworkException)(framework_errors_internal_1.ZLinkFrameworkInternalErrorKind.ObjectClientNotConfigured, 'No object-client RouteMesh is configured.');
|
|
1682
|
-
}
|
|
1683
|
-
if (request.meshName === undefined && meshes.length > 1) {
|
|
1684
|
-
throw (0, framework_errors_internal_1.createInternalFrameworkException)(framework_errors_internal_1.ZLinkFrameworkInternalErrorKind.MeshSelectionRequired, 'Multiple object-client RouteMeshes are configured; call inMesh(...).');
|
|
1685
|
-
}
|
|
1686
|
-
const meshName = meshes[0];
|
|
1687
|
-
if (!this.options.registration.spotNodes.has(meshName)) {
|
|
1688
|
-
throw (0, framework_errors_internal_1.createInternalFrameworkException)(framework_errors_internal_1.ZLinkFrameworkInternalErrorKind.MeshNotFound, `RouteMesh '${meshName}' is not configured.`);
|
|
1689
|
-
}
|
|
1690
|
-
if (!clientMeshes.includes(meshName)) {
|
|
1691
|
-
throw (0, framework_errors_internal_1.createInternalFrameworkException)(framework_errors_internal_1.ZLinkFrameworkInternalErrorKind.ObjectClientNotConfigured, `RouteMesh '${meshName}' has no object-client role.`);
|
|
1692
|
-
}
|
|
1745
|
+
const meshName = selectUserSpotMesh(request.meshName);
|
|
1693
1746
|
const meshNode = this.spotNodeRuntime?.meshNode(meshName);
|
|
1694
1747
|
const descriptors = await (0, location_store_pages_1.listAllMeshNodeDescriptors)(locationStore, meshName, signal);
|
|
1695
1748
|
const selected = await selectReadyLocationPlacementDescriptor(descriptors, meshNode, signal, (descriptor) => {
|
|
@@ -1764,7 +1817,7 @@ class ZLinkFrameworkRuntimeHost {
|
|
|
1764
1817
|
}, signal);
|
|
1765
1818
|
const reply = coordinated.result.reply;
|
|
1766
1819
|
let payload;
|
|
1767
|
-
if (reply !== undefined && coordinated.result.state !==
|
|
1820
|
+
if (reply !== undefined && coordinated.result.state !== contracts_2.ZLinkSpotCreateState.Existing) {
|
|
1768
1821
|
const message = (0, payload_codec_1.encodeFrameworkPayloadMessage)(reply, this.options.registration.messageSerializers);
|
|
1769
1822
|
try {
|
|
1770
1823
|
payload = {
|
|
@@ -1782,9 +1835,9 @@ class ZLinkFrameworkRuntimeHost {
|
|
|
1782
1835
|
failureCode: 0,
|
|
1783
1836
|
tail: {
|
|
1784
1837
|
kind: 'userSpotCreate',
|
|
1785
|
-
createResult: coordinated.result.state ===
|
|
1838
|
+
createResult: coordinated.result.state === contracts_2.ZLinkSpotCreateState.Existing
|
|
1786
1839
|
? 'existing'
|
|
1787
|
-
: coordinated.result.state ===
|
|
1840
|
+
: coordinated.result.state === contracts_2.ZLinkSpotCreateState.Created
|
|
1788
1841
|
? 'created'
|
|
1789
1842
|
: 'rejected',
|
|
1790
1843
|
spotId: String(coordinated.spot.spotId),
|
|
@@ -1870,7 +1923,7 @@ class ZLinkFrameworkRuntimeHost {
|
|
|
1870
1923
|
failureCode: 0,
|
|
1871
1924
|
tail: {
|
|
1872
1925
|
kind: 'userSpotClose',
|
|
1873
|
-
closed: await coordinator.handleRemoteClose(record, (spot, beginAuthority, closeSignal) => local.closeUserWithAuthority(spot.meshName, spot.spotId, beginAuthority, closeSignal), signal, (spot) => local.isSpotClosing(spot.meshName, spot.spotId))
|
|
1926
|
+
closed: await coordinator.handleRemoteClose(record, (spot, beginAuthority, closeSignal) => local.closeUserWithAuthority(spot.meshName, spot.spotId, beginAuthority, closeSignal, new Date(Number(record.deadlineUnixMs))), signal, (spot) => local.isSpotClosing(spot.meshName, spot.spotId))
|
|
1874
1927
|
}
|
|
1875
1928
|
};
|
|
1876
1929
|
}
|
|
@@ -1906,6 +1959,7 @@ class ZLinkFrameworkRuntimeHost {
|
|
|
1906
1959
|
}
|
|
1907
1960
|
actorRuntimeOptionsFactory() {
|
|
1908
1961
|
return new actor_runtime_options_factory_1.ZLinkActorRuntimeOptionsFactory({
|
|
1962
|
+
requests: this.requests,
|
|
1909
1963
|
terminateActorActivation: (actor, terminal) => this.spotNodeRuntime?.terminateActorActivation(actor, terminal) ?? terminal(),
|
|
1910
1964
|
registration: this.options.registration,
|
|
1911
1965
|
messageFlow: () => this.createDispatchErrorReporter(this.runtimeOrPreStartErrorSink).flow,
|
|
@@ -1944,7 +1998,7 @@ class ZLinkFrameworkRuntimeHost {
|
|
|
1944
1998
|
if (entrySpotId === undefined) {
|
|
1945
1999
|
throw new ConfigurationException_1.ZLinkConfigurationException(`Actor '${actorRef.actorId}' authority requires its RouteMesh Entry Spot.`);
|
|
1946
2000
|
}
|
|
1947
|
-
await (0, actors_1.publishInitialActorAuthority)(store, {
|
|
2001
|
+
const authority = await (0, actors_1.publishInitialActorAuthority)(store, {
|
|
1948
2002
|
actorType,
|
|
1949
2003
|
actor: actorRef,
|
|
1950
2004
|
meshName,
|
|
@@ -1952,9 +2006,9 @@ class ZLinkFrameworkRuntimeHost {
|
|
|
1952
2006
|
owner,
|
|
1953
2007
|
spotId: entrySpotId,
|
|
1954
2008
|
spotGeneration: ownerNodeGeneration,
|
|
1955
|
-
spotKind:
|
|
2009
|
+
spotKind: contracts_2.ZLinkSpotKind.Entry
|
|
1956
2010
|
}, signal);
|
|
1957
|
-
this.actorClientLocationResolver?.
|
|
2011
|
+
this.actorClientLocationResolver?.observeActorAuthorityVersion(actorRef.actorId, authority.storeVersion.value);
|
|
1958
2012
|
},
|
|
1959
2013
|
reportPostCommitError: (error) => this.runtimeOrPreStartErrorSink.reportRuntimeTaskException('post-commit actor binding', error),
|
|
1960
2014
|
reportBoundSessionSendError: (error) => this.runtimeOrPreStartErrorSink.reportRuntimeTaskException('bound session one-way submit', error),
|
|
@@ -1983,6 +2037,7 @@ class ZLinkFrameworkRuntimeHost {
|
|
|
1983
2037
|
return new channel_runtime_options_factory_1.ZLinkChannelRuntimeOptionsFactory({
|
|
1984
2038
|
monitoringAdapter: this.backendAdapterFactory.createMonitoringAdapter(),
|
|
1985
2039
|
messageFlowModeCell: this.messageFlowModeCell,
|
|
2040
|
+
telemetryLease: this.telemetryLease,
|
|
1986
2041
|
boundSessionRelay: this.boundSessionRelay,
|
|
1987
2042
|
applicationJobQueue: this.applicationJobQueue,
|
|
1988
2043
|
spotManager: () => this.spotManager,
|
|
@@ -2012,6 +2067,7 @@ class ZLinkFrameworkRuntimeHost {
|
|
|
2012
2067
|
}).create();
|
|
2013
2068
|
return {
|
|
2014
2069
|
...options,
|
|
2070
|
+
admission: this.admission,
|
|
2015
2071
|
errorSink: this.runtimeOrPreStartErrorSink,
|
|
2016
2072
|
peerAdmissionSealed: (meshName) => !this.admission.accepts(meshName),
|
|
2017
2073
|
messageFollowReceiver: (record) => {
|
|
@@ -2090,21 +2146,21 @@ class ZLinkFrameworkRuntimeHost {
|
|
|
2090
2146
|
if (channelRuntime === undefined) {
|
|
2091
2147
|
throw new ConfigurationException_1.ZLinkConfigurationException('MeshNode channel dispatch requires the channel runtime.');
|
|
2092
2148
|
}
|
|
2093
|
-
return channelRuntime.dispatchMeshChannel(meshName, record, signal, (dispatch, onRejected) => this.admitMeshDispatch(meshName, record, 'RouteMesh channel dispatch', dispatch, onRejected));
|
|
2149
|
+
return channelRuntime.dispatchMeshChannel(meshName, record, signal, (dispatch, onRejected, receiver, context) => this.admitMeshDispatch(meshName, record, 'RouteMesh channel dispatch', dispatch, onRejected, receiver, context));
|
|
2094
2150
|
}
|
|
2095
2151
|
case service_runtime_contracts_1.ReceiveKind.NodeSend:
|
|
2096
2152
|
case service_runtime_contracts_1.ReceiveKind.NodeRequest: {
|
|
2097
|
-
return this.dispatchMeshNodeRecord(meshName, record, signal, (dispatch, onRejected) => this.admitMeshDispatch(meshName, record, 'RouteMesh node dispatch', dispatch, onRejected));
|
|
2153
|
+
return this.dispatchMeshNodeRecord(meshName, record, signal, (dispatch, onRejected, receiver, context) => this.admitMeshDispatch(meshName, record, 'RouteMesh node dispatch', dispatch, onRejected, receiver, context));
|
|
2098
2154
|
}
|
|
2099
2155
|
case service_runtime_contracts_1.ReceiveKind.SpotSend:
|
|
2100
2156
|
case service_runtime_contracts_1.ReceiveKind.SpotRequest:
|
|
2101
2157
|
case service_runtime_contracts_1.ReceiveKind.SpotMulticast:
|
|
2102
|
-
return this.dispatchMeshSpotRecord(meshName, owner, record, (dispatch, onRejected) => this.admitMeshDispatch(meshName, record, 'RouteMesh Spot dispatch', dispatch, onRejected));
|
|
2158
|
+
return this.dispatchMeshSpotRecord(meshName, owner, record, (dispatch, onRejected, receiver, context) => this.admitMeshDispatch(meshName, record, 'RouteMesh Spot dispatch', dispatch, onRejected, receiver, context));
|
|
2103
2159
|
case service_runtime_contracts_1.ReceiveKind.InstanceSpotActivation:
|
|
2104
2160
|
if (this.spotManager === undefined) {
|
|
2105
2161
|
throw new ConfigurationException_1.ZLinkConfigurationException('MeshNode Instance Spot dispatch requires the Spot manager.');
|
|
2106
2162
|
}
|
|
2107
|
-
return this.spotManager.dispatchMeshInstance(meshName, owner, record, (dispatch, onRejected) => this.admitMeshDispatch(meshName, record, 'RouteMesh Instance Spot dispatch', dispatch, onRejected));
|
|
2163
|
+
return this.spotManager.dispatchMeshInstance(meshName, owner, record, (dispatch, onRejected, receiver, context) => this.admitMeshDispatch(meshName, record, 'RouteMesh Instance Spot dispatch', dispatch, onRejected, receiver, context));
|
|
2108
2164
|
case service_runtime_contracts_1.ReceiveKind.SpotControl:
|
|
2109
2165
|
if (this.spotManager === undefined) {
|
|
2110
2166
|
throw new ConfigurationException_1.ZLinkConfigurationException('MeshNode Spot control dispatch requires the Spot manager.');
|
|
@@ -2115,19 +2171,19 @@ class ZLinkFrameworkRuntimeHost {
|
|
|
2115
2171
|
if (this.spotManager === undefined) {
|
|
2116
2172
|
throw new ConfigurationException_1.ZLinkConfigurationException('MeshNode Actor dispatch requires the Spot manager.');
|
|
2117
2173
|
}
|
|
2118
|
-
return this.spotManager.dispatchMeshActor(applicationJobOrigin(), meshName, owner, record, (dispatch, onRejected) => this.admitMeshDispatch(meshName, record, 'RouteMesh Actor dispatch', dispatch, onRejected));
|
|
2174
|
+
return this.spotManager.dispatchMeshActor(applicationJobOrigin(), meshName, owner, record, (dispatch, onRejected, receiver, context) => this.admitMeshDispatch(meshName, record, 'RouteMesh Actor dispatch', dispatch, onRejected, receiver, context));
|
|
2119
2175
|
case service_runtime_contracts_1.ReceiveKind.SendReady:
|
|
2120
2176
|
return Promise.resolve();
|
|
2121
2177
|
default:
|
|
2122
2178
|
throw new ConfigurationException_1.ZLinkConfigurationException(`MeshNode record kind '${record.kind}' does not yet have a registered framework consumer.`);
|
|
2123
2179
|
}
|
|
2124
2180
|
}
|
|
2125
|
-
admitMeshDispatch(meshName, record, operation, dispatch, onRejected) {
|
|
2181
|
+
admitMeshDispatch(meshName, record, operation, dispatch, onRejected, receiver, context) {
|
|
2126
2182
|
// Execution gate §13 and host relocation §14 keep control progress independent
|
|
2127
2183
|
// of new application admission. Disconnect callbacks still use their owner gate.
|
|
2128
2184
|
if (record.domain === service_runtime_contracts_1.ReadyDomain.Infrastructure)
|
|
2129
|
-
return dispatch();
|
|
2130
|
-
if (!this.admission.accepts(meshName) &&
|
|
2185
|
+
return dispatch.call(receiver, context);
|
|
2186
|
+
if (!this.admission.accepts(meshName, record.kind) &&
|
|
2131
2187
|
(record.kind === service_runtime_contracts_1.ReceiveKind.NodeSend ||
|
|
2132
2188
|
record.kind === service_runtime_contracts_1.ReceiveKind.NodeRequest ||
|
|
2133
2189
|
record.kind === service_runtime_contracts_1.ReceiveKind.SpotSend ||
|
|
@@ -2136,10 +2192,10 @@ class ZLinkFrameworkRuntimeHost {
|
|
|
2136
2192
|
if (relay !== undefined &&
|
|
2137
2193
|
(0, protocol_1.decodeStreamHeader)(Buffer.from(relay.header, 'base64'), this.flowCreationEnabled()).name ===
|
|
2138
2194
|
actor_packet_relay_wire_1.ZLINK_REMOTE_ACTOR_SESSION_DISCONNECTED_PACKET) {
|
|
2139
|
-
return dispatch();
|
|
2195
|
+
return dispatch.call(receiver, context);
|
|
2140
2196
|
}
|
|
2141
2197
|
}
|
|
2142
|
-
return this.admission.run(meshName, operation, dispatch, onRejected);
|
|
2198
|
+
return this.admission.run(meshName, operation, dispatch, record.kind, onRejected, receiver, context);
|
|
2143
2199
|
}
|
|
2144
2200
|
async dispatchMeshActorBinding(meshName, record, signal) {
|
|
2145
2201
|
if (record.kindData?.kind !== 'actorBinding') {
|
|
@@ -2204,8 +2260,7 @@ class ZLinkFrameworkRuntimeHost {
|
|
|
2204
2260
|
replyBindingFailure(framework_errors_internal_1.ZLinkFrameworkInternalErrorKind.ActorLocationStale);
|
|
2205
2261
|
return;
|
|
2206
2262
|
}
|
|
2207
|
-
|
|
2208
|
-
state.installBoundSessionBinding({
|
|
2263
|
+
const incomingTarget = {
|
|
2209
2264
|
...target,
|
|
2210
2265
|
sessionNodeRid: binding.sessionNodeRid,
|
|
2211
2266
|
sessionRid: binding.sessionRid,
|
|
@@ -2213,19 +2268,92 @@ class ZLinkFrameworkRuntimeHost {
|
|
|
2213
2268
|
sessionOwnerId: binding.sessionOwnerId,
|
|
2214
2269
|
sessionOwnerLeaseGeneration: binding.sessionOwnerLeaseGeneration,
|
|
2215
2270
|
bindingGeneration: binding.bindingGeneration
|
|
2271
|
+
};
|
|
2272
|
+
const currentBinding = state.boundSession;
|
|
2273
|
+
const currentActor = state.actor;
|
|
2274
|
+
if (currentBinding === undefined ||
|
|
2275
|
+
currentActor?.onDuplicateBind === undefined ||
|
|
2276
|
+
samePhysicalSession(currentBinding, incomingTarget)) {
|
|
2277
|
+
state.installBoundSessionBinding(incomingTarget);
|
|
2278
|
+
replyBindingSuccess();
|
|
2279
|
+
return;
|
|
2280
|
+
}
|
|
2281
|
+
const spotManager = this.spotManager;
|
|
2282
|
+
if (spotManager === undefined || state.meshName === undefined) {
|
|
2283
|
+
replyBindingFailure(framework_errors_internal_1.ZLinkFrameworkInternalErrorKind.ActorLocationStale);
|
|
2284
|
+
return;
|
|
2285
|
+
}
|
|
2286
|
+
let callbackStarted;
|
|
2287
|
+
const started = new Promise((resolve) => {
|
|
2288
|
+
callbackStarted = resolve;
|
|
2216
2289
|
});
|
|
2217
|
-
|
|
2290
|
+
let callbackTimedOut = false;
|
|
2291
|
+
let timeoutHandle;
|
|
2292
|
+
const cancellation = new AbortController();
|
|
2293
|
+
const callbackSignal = signal === undefined ? cancellation.signal : AbortSignal.any([signal, cancellation.signal]);
|
|
2294
|
+
const turn = spotManager.executeActorTurn(state.meshName, state.actor?.context.spotId, state.actorId, async () => {
|
|
2295
|
+
const current = state.boundSession;
|
|
2296
|
+
const actor = state.actor;
|
|
2297
|
+
const duplicateCallback = current !== undefined && !samePhysicalSession(current, incomingTarget)
|
|
2298
|
+
? actor?.onDuplicateBind
|
|
2299
|
+
: undefined;
|
|
2300
|
+
if (duplicateCallback === undefined || actor === undefined || current === undefined) {
|
|
2301
|
+
state.installBoundSessionBinding(incomingTarget);
|
|
2302
|
+
replyBindingSuccess();
|
|
2303
|
+
return;
|
|
2304
|
+
}
|
|
2305
|
+
callbackStarted();
|
|
2306
|
+
const decision = await duplicateCallback.call(actor, sessionBindingIdentity(current), sessionBindingIdentity(incomingTarget), callbackSignal);
|
|
2307
|
+
if (callbackTimedOut)
|
|
2308
|
+
return;
|
|
2309
|
+
if (decision !== undefined && decision.length > 0) {
|
|
2310
|
+
if (Buffer.byteLength(decision, 'utf8') > 0xffff) {
|
|
2311
|
+
throw new RangeError('Duplicate bind rejection message exceeds Text16 capacity.');
|
|
2312
|
+
}
|
|
2313
|
+
if (record.replyFailure?.(runtime_values_1.RequestResult.Rejected, 0, {
|
|
2314
|
+
kind: 'streamBindRejected',
|
|
2315
|
+
rejectionMessage: decision
|
|
2316
|
+
}) !== runtime_values_1.SubmitResult.Ok) {
|
|
2317
|
+
throw new ConfigurationException_1.ZLinkConfigurationException(`MeshNode Actor binding target '${binding.actor.actorId}' rejection acknowledgement failed.`);
|
|
2318
|
+
}
|
|
2319
|
+
return;
|
|
2320
|
+
}
|
|
2321
|
+
state.installBoundSessionBinding(incomingTarget);
|
|
2322
|
+
replyBindingSuccess();
|
|
2323
|
+
});
|
|
2324
|
+
const timeout = started.then(() => new Promise((resolve) => {
|
|
2325
|
+
timeoutHandle = setTimeout(() => {
|
|
2326
|
+
callbackTimedOut = true;
|
|
2327
|
+
resolve('timedOut');
|
|
2328
|
+
}, this.options.registration.sessionReplacementCallbackTimeoutMs);
|
|
2329
|
+
}));
|
|
2330
|
+
try {
|
|
2331
|
+
const outcome = await Promise.race([turn.then(() => 'completed'), timeout]);
|
|
2332
|
+
if (outcome === 'timedOut') {
|
|
2333
|
+
cancellation.abort((0, abort_1.createDeadlineExceededError)('Duplicate bind callback timed out.'));
|
|
2334
|
+
if (record.replyFailure?.(runtime_values_1.RequestResult.TimedOut, 0) !== runtime_values_1.SubmitResult.Ok) {
|
|
2335
|
+
throw new ConfigurationException_1.ZLinkConfigurationException(`MeshNode Actor binding target '${binding.actor.actorId}' timeout acknowledgement failed.`);
|
|
2336
|
+
}
|
|
2337
|
+
void turn.catch((error) => this.runtimeOrPreStartErrorSink.reportRuntimeTaskException(`duplicate bind callback '${binding.actor.actorId}'`, error));
|
|
2338
|
+
}
|
|
2339
|
+
}
|
|
2340
|
+
finally {
|
|
2341
|
+
if (timeoutHandle !== undefined)
|
|
2342
|
+
clearTimeout(timeoutHandle);
|
|
2343
|
+
}
|
|
2218
2344
|
}
|
|
2219
2345
|
submitLocalMeshRoute(meshName, sourceNodeRid, parts) {
|
|
2220
2346
|
const state = this.executionState;
|
|
2221
2347
|
const channelRuntime = this.channelRuntime;
|
|
2222
|
-
if (state === undefined ||
|
|
2348
|
+
if (state === undefined ||
|
|
2349
|
+
channelRuntime === undefined ||
|
|
2350
|
+
!this.admission.accepts(meshName, service_runtime_contracts_1.ReceiveKind.NodeSend)) {
|
|
2223
2351
|
return { status: submission_result_1.ZLinkSubmitStatus.Shutdown };
|
|
2224
2352
|
}
|
|
2225
2353
|
if (!channelRuntime.canDispatchLocalMeshRoute(meshName)) {
|
|
2226
2354
|
return { status: submission_result_1.ZLinkSubmitStatus.TargetNotFound };
|
|
2227
2355
|
}
|
|
2228
|
-
const claim = this.admission.claim(meshName, 'RouteMesh local node dispatch');
|
|
2356
|
+
const claim = this.admission.claim(meshName, 'RouteMesh local node dispatch', service_runtime_contracts_1.ReceiveKind.NodeSend);
|
|
2229
2357
|
const ownedParts = [];
|
|
2230
2358
|
try {
|
|
2231
2359
|
for (const part of parts) {
|
|
@@ -2273,8 +2401,9 @@ class ZLinkFrameworkRuntimeHost {
|
|
|
2273
2401
|
packetName: envelope.packetName,
|
|
2274
2402
|
contentType: envelope.header.contentType,
|
|
2275
2403
|
sourceNodeRid: String(record.sourceNodeRid ?? ''),
|
|
2276
|
-
metadata: (0,
|
|
2277
|
-
correlationId: envelope.header.correlationId ?? undefined
|
|
2404
|
+
metadata: (0, contracts_2.zlinkMessageMetadata)(envelope.header.metadata),
|
|
2405
|
+
correlationId: envelope.header.correlationId ?? undefined,
|
|
2406
|
+
receivedAt: record.receivedAt ?? new Date()
|
|
2278
2407
|
};
|
|
2279
2408
|
try {
|
|
2280
2409
|
const dispatch = async () => {
|
|
@@ -2305,7 +2434,7 @@ class ZLinkFrameworkRuntimeHost {
|
|
|
2305
2434
|
if (existing !== undefined) {
|
|
2306
2435
|
return existing;
|
|
2307
2436
|
}
|
|
2308
|
-
const reporter = new channels_1.ZLinkDispatchErrorReporter(
|
|
2437
|
+
const reporter = new channels_1.ZLinkDispatchErrorReporter(this.diagnosticsContext(), this.metrics);
|
|
2309
2438
|
this.dispatchErrorReporters.set(errorSink, reporter);
|
|
2310
2439
|
return reporter;
|
|
2311
2440
|
}
|
|
@@ -2322,7 +2451,7 @@ class ZLinkFrameworkRuntimeHost {
|
|
|
2322
2451
|
};
|
|
2323
2452
|
}
|
|
2324
2453
|
diagnosticsContext() {
|
|
2325
|
-
this.cachedDiagnosticsContext ??= (0, diagnostics_1.createDiagnosticsContext)(this.options.registration.dispatch, this.options.providerResolver, this.messageFlowModeCell);
|
|
2454
|
+
this.cachedDiagnosticsContext ??= (0, diagnostics_1.createDiagnosticsContext)(this.options.registration.dispatch, this.options.providerResolver, this.messageFlowModeCell, this.telemetryLease);
|
|
2326
2455
|
return this.cachedDiagnosticsContext;
|
|
2327
2456
|
}
|
|
2328
2457
|
flowCreationEnabled() {
|
|
@@ -2394,16 +2523,39 @@ function hasUnsupportedManualTopology(registration) {
|
|
|
2394
2523
|
}
|
|
2395
2524
|
return false;
|
|
2396
2525
|
}
|
|
2526
|
+
function samePhysicalSession(left, right) {
|
|
2527
|
+
return (left.sessionNodeRid !== undefined &&
|
|
2528
|
+
left.sessionRid !== undefined &&
|
|
2529
|
+
left.sessionOwnerNodeGeneration !== undefined &&
|
|
2530
|
+
right.sessionNodeRid !== undefined &&
|
|
2531
|
+
right.sessionRid !== undefined &&
|
|
2532
|
+
right.sessionOwnerNodeGeneration !== undefined &&
|
|
2533
|
+
(0, routing_id_1.routingIdsEqual)(left.sessionNodeRid, right.sessionNodeRid) &&
|
|
2534
|
+
left.sessionRid === right.sessionRid &&
|
|
2535
|
+
left.sessionOwnerNodeGeneration === right.sessionOwnerNodeGeneration);
|
|
2536
|
+
}
|
|
2537
|
+
function sessionBindingIdentity(value) {
|
|
2538
|
+
if (value.sessionNodeRid === undefined ||
|
|
2539
|
+
value.sessionOwnerNodeGeneration === undefined ||
|
|
2540
|
+
value.bindingGeneration === undefined) {
|
|
2541
|
+
throw new ConfigurationException_1.ZLinkConfigurationException('Duplicate bind callback requires a complete identity.');
|
|
2542
|
+
}
|
|
2543
|
+
return {
|
|
2544
|
+
sessionOwnerNodeRid: value.sessionNodeRid,
|
|
2545
|
+
sessionOwnerNodeGeneration: value.sessionOwnerNodeGeneration,
|
|
2546
|
+
bindingGeneration: value.bindingGeneration
|
|
2547
|
+
};
|
|
2548
|
+
}
|
|
2397
2549
|
function hasConfiguredLocationStore(registration) {
|
|
2398
2550
|
return (registration.locations.useInMemoryStores || registration.locations.storeInstance !== undefined);
|
|
2399
2551
|
}
|
|
2400
2552
|
function hasExactPeerReadiness(descriptors, local, peers) {
|
|
2401
2553
|
const replacementDescriptors = descriptors.filter((descriptor) => !((0, routing_id_1.routingIdsEqual)(descriptor.rid, (0, routing_id_1.toBackendRoutingId)(local.routingId)) &&
|
|
2402
2554
|
descriptor.lifecycleGeneration === local.lifecycleGeneration) &&
|
|
2403
|
-
descriptor.state ===
|
|
2555
|
+
descriptor.state === contracts_2.ZLinkFrameworkRuntimeState.Serving &&
|
|
2404
2556
|
local.applicationVersion !== undefined &&
|
|
2405
2557
|
descriptor.applicationVersion === local.applicationVersion &&
|
|
2406
|
-
descriptor.objectRole ===
|
|
2558
|
+
descriptor.objectRole === contracts_2.ZLinkObjectRole.Server &&
|
|
2407
2559
|
(local.maintenanceWave === undefined || descriptor.maintenanceWave !== local.maintenanceWave));
|
|
2408
2560
|
return (replacementDescriptors.length > 0 &&
|
|
2409
2561
|
replacementDescriptors.some((descriptor) => peers.some((peer) => peer.routingId !== null &&
|
|
@@ -2478,60 +2630,60 @@ function resolveStreamPayloadCodec(registration) {
|
|
|
2478
2630
|
}
|
|
2479
2631
|
function runtimeStateMetricName(state) {
|
|
2480
2632
|
switch (state) {
|
|
2481
|
-
case
|
|
2633
|
+
case contracts_2.ZLinkFrameworkRuntimeState.Preparing:
|
|
2482
2634
|
return 'preparing';
|
|
2483
|
-
case
|
|
2635
|
+
case contracts_2.ZLinkFrameworkRuntimeState.Serving:
|
|
2484
2636
|
return 'serving';
|
|
2485
|
-
case
|
|
2637
|
+
case contracts_2.ZLinkFrameworkRuntimeState.Relocating:
|
|
2486
2638
|
return 'relocating';
|
|
2487
|
-
case
|
|
2639
|
+
case contracts_2.ZLinkFrameworkRuntimeState.Relocated:
|
|
2488
2640
|
return 'relocated';
|
|
2489
|
-
case
|
|
2641
|
+
case contracts_2.ZLinkFrameworkRuntimeState.Draining:
|
|
2490
2642
|
return 'draining';
|
|
2491
|
-
case
|
|
2643
|
+
case contracts_2.ZLinkFrameworkRuntimeState.Stopped:
|
|
2492
2644
|
return 'stopped';
|
|
2493
|
-
case
|
|
2645
|
+
case contracts_2.ZLinkFrameworkRuntimeState.Error:
|
|
2494
2646
|
return 'error';
|
|
2495
2647
|
}
|
|
2496
2648
|
}
|
|
2497
2649
|
function relocationModeMetricName(mode) {
|
|
2498
|
-
return mode ===
|
|
2650
|
+
return mode === contracts_2.ZLinkFrameworkRelocationMode.RollingUpdate
|
|
2499
2651
|
? 'rolling_update'
|
|
2500
2652
|
: 'planned_maintenance';
|
|
2501
2653
|
}
|
|
2502
2654
|
function relocationReasonMetricName(reason) {
|
|
2503
2655
|
switch (reason) {
|
|
2504
|
-
case
|
|
2656
|
+
case contracts_2.ZLinkFrameworkRelocationReason.None:
|
|
2505
2657
|
return 'none';
|
|
2506
|
-
case
|
|
2658
|
+
case contracts_2.ZLinkFrameworkRelocationReason.TargetUnavailable:
|
|
2507
2659
|
return 'target_unavailable';
|
|
2508
|
-
case
|
|
2660
|
+
case contracts_2.ZLinkFrameworkRelocationReason.StoreUnavailable:
|
|
2509
2661
|
return 'store_unavailable';
|
|
2510
|
-
case
|
|
2662
|
+
case contracts_2.ZLinkFrameworkRelocationReason.RelocationDisabled:
|
|
2511
2663
|
return 'relocation_disabled';
|
|
2512
|
-
case
|
|
2664
|
+
case contracts_2.ZLinkFrameworkRelocationReason.StateIncompatible:
|
|
2513
2665
|
return 'state_incompatible';
|
|
2514
|
-
case
|
|
2666
|
+
case contracts_2.ZLinkFrameworkRelocationReason.DeadlineExceeded:
|
|
2515
2667
|
return 'deadline_exceeded';
|
|
2516
|
-
case
|
|
2668
|
+
case contracts_2.ZLinkFrameworkRelocationReason.RelocationFailed:
|
|
2517
2669
|
return 'relocation_failed';
|
|
2518
|
-
case
|
|
2670
|
+
case contracts_2.ZLinkFrameworkRelocationReason.RuntimeNotReady:
|
|
2519
2671
|
return 'runtime_not_ready';
|
|
2520
|
-
case
|
|
2672
|
+
case contracts_2.ZLinkFrameworkRelocationReason.ManualTopologyUnsupported:
|
|
2521
2673
|
return 'manual_topology_unsupported';
|
|
2522
|
-
case
|
|
2674
|
+
case contracts_2.ZLinkFrameworkRelocationReason.ShutdownRequested:
|
|
2523
2675
|
return 'shutdown_requested';
|
|
2524
|
-
case
|
|
2676
|
+
case contracts_2.ZLinkFrameworkRelocationReason.OperationInProgress:
|
|
2525
2677
|
return 'operation_in_progress';
|
|
2526
2678
|
}
|
|
2527
2679
|
}
|
|
2528
2680
|
function terminationReasonMetricName(reason) {
|
|
2529
2681
|
switch (reason) {
|
|
2530
|
-
case
|
|
2682
|
+
case contracts_2.ZLinkFrameworkTerminationReason.None:
|
|
2531
2683
|
return 'none';
|
|
2532
|
-
case
|
|
2684
|
+
case contracts_2.ZLinkFrameworkTerminationReason.DeadlineExceeded:
|
|
2533
2685
|
return 'deadline_exceeded';
|
|
2534
|
-
case
|
|
2686
|
+
case contracts_2.ZLinkFrameworkTerminationReason.TeardownFailed:
|
|
2535
2687
|
return 'teardown_failed';
|
|
2536
2688
|
}
|
|
2537
2689
|
}
|
|
@@ -2614,13 +2766,13 @@ function randomBigIntBelow(exclusiveUpperBound) {
|
|
|
2614
2766
|
function relocationReason(reason) {
|
|
2615
2767
|
switch (reason) {
|
|
2616
2768
|
case 'deadline_exceeded':
|
|
2617
|
-
return
|
|
2769
|
+
return contracts_2.ZLinkFrameworkRelocationReason.DeadlineExceeded;
|
|
2618
2770
|
case 'store_unavailable':
|
|
2619
|
-
return
|
|
2771
|
+
return contracts_2.ZLinkFrameworkRelocationReason.StoreUnavailable;
|
|
2620
2772
|
case 'target_unavailable':
|
|
2621
|
-
return
|
|
2773
|
+
return contracts_2.ZLinkFrameworkRelocationReason.TargetUnavailable;
|
|
2622
2774
|
default:
|
|
2623
|
-
return
|
|
2775
|
+
return contracts_2.ZLinkFrameworkRelocationReason.RelocationFailed;
|
|
2624
2776
|
}
|
|
2625
2777
|
}
|
|
2626
2778
|
function rewriteAuthorityPayloadForOwner(payload, owner) {
|
|
@@ -2635,11 +2787,11 @@ function validateRelocationOptions(options, sourceApplicationVersion) {
|
|
|
2635
2787
|
throw new TypeError('Relocation mode is required.');
|
|
2636
2788
|
}
|
|
2637
2789
|
const mode = options.mode;
|
|
2638
|
-
if (mode !==
|
|
2639
|
-
mode !==
|
|
2790
|
+
if (mode !== contracts_2.ZLinkFrameworkRelocationMode.PlannedMaintenance &&
|
|
2791
|
+
mode !== contracts_2.ZLinkFrameworkRelocationMode.RollingUpdate) {
|
|
2640
2792
|
throw new TypeError('Relocation mode is required.');
|
|
2641
2793
|
}
|
|
2642
|
-
if (options.mode ===
|
|
2794
|
+
if (options.mode === contracts_2.ZLinkFrameworkRelocationMode.PlannedMaintenance) {
|
|
2643
2795
|
if (options.targetApplicationVersion !== undefined) {
|
|
2644
2796
|
throw new TypeError('PlannedMaintenance relocation cannot define targetApplicationVersion.');
|
|
2645
2797
|
}
|
|
@@ -2655,7 +2807,7 @@ function blockedRelocation(mode, effectiveTargetApplicationVersion, reason) {
|
|
|
2655
2807
|
return {
|
|
2656
2808
|
mode,
|
|
2657
2809
|
effectiveTargetApplicationVersion,
|
|
2658
|
-
outcome:
|
|
2810
|
+
outcome: contracts_2.ZLinkFrameworkRelocationOutcome.Blocked,
|
|
2659
2811
|
reason
|
|
2660
2812
|
};
|
|
2661
2813
|
}
|