@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,4 @@
|
|
|
1
|
+
import { dispatchActorPacketInMailbox } from './spot-actor-admission-coordinator';
|
|
1
2
|
import { currentApplicationJobOrigin } from '../application-jobs/application-job-queue-scope';
|
|
2
3
|
import type {
|
|
3
4
|
ActorRef,
|
|
@@ -70,9 +71,9 @@ import type {
|
|
|
70
71
|
ZLinkSpotActorHandoffRuntime,
|
|
71
72
|
ZLinkSpotBoundSessionRuntime
|
|
72
73
|
} from './spot-runtime-ports';
|
|
73
|
-
import { ZLinkSpotLifecycleMetrics } from './spot-lifecycle-metrics';
|
|
74
74
|
|
|
75
75
|
interface ZLinkEntrySpotActivationOptions {
|
|
76
|
+
readonly admission?: import('../admission').ZLinkRuntimeAdmissionGate;
|
|
76
77
|
readonly entrySpotType: Type<ZLinkEntrySpot>;
|
|
77
78
|
readonly timerHandlers?: readonly ZLinkEntrySpotTimerHandlerRegistration[];
|
|
78
79
|
readonly packetHandlers?: readonly ZLinkEntrySpotPacketHandlerRegistration[];
|
|
@@ -104,13 +105,12 @@ interface ZLinkEntrySpotActivationOptions {
|
|
|
104
105
|
|
|
105
106
|
export class ZLinkEntrySpotActivation {
|
|
106
107
|
private readonly serial: ZLinkSpotSerialTurnExecutor;
|
|
107
|
-
|
|
108
|
+
readonly spotSerialExecutor: ZLinkSpotSerialExecutor;
|
|
108
109
|
private readonly timers: ZLinkSpotTimerRegistry;
|
|
109
110
|
private readonly actorHandlers = new ZLinkSpotActorHandlerRegistryRuntime();
|
|
110
111
|
private readonly handlers: DefaultZLinkSpotHandlerRegistry;
|
|
111
112
|
private readonly outbound: DefaultZLinkSpotOutbound;
|
|
112
113
|
private readonly workerRuntime: ZLinkWorkerRuntime;
|
|
113
|
-
private readonly lifecycleMetrics: ZLinkSpotLifecycleMetrics;
|
|
114
114
|
private readonly packetDispatch: ZLinkRoutedSpotPacketDispatch;
|
|
115
115
|
private readonly actorPacketDispatch: ZLinkSpotActorPacketDispatch;
|
|
116
116
|
private initialized = false;
|
|
@@ -150,7 +150,6 @@ export class ZLinkEntrySpotActivation {
|
|
|
150
150
|
options.metrics,
|
|
151
151
|
() => options.dispatchErrors?.flow.flowCreationEnabled() ?? true
|
|
152
152
|
);
|
|
153
|
-
this.lifecycleMetrics = new ZLinkSpotLifecycleMetrics(options.metrics);
|
|
154
153
|
this.workerRuntime = options.workerRuntime ?? new ZLinkWorkerRuntime();
|
|
155
154
|
this.context = createEntrySpotContext({
|
|
156
155
|
spotId: String(options.nativeSpot.routingId),
|
|
@@ -192,17 +191,21 @@ export class ZLinkEntrySpotActivation {
|
|
|
192
191
|
dispatchErrors: options.dispatchErrors
|
|
193
192
|
});
|
|
194
193
|
this.actorPacketDispatch = new ZLinkSpotActorPacketDispatch({
|
|
194
|
+
admission: this.options.admission,
|
|
195
195
|
spot: () => this.entrySpot as unknown as ZLinkSpot,
|
|
196
196
|
spotId: () => String(this.options.nativeSpot.routingId),
|
|
197
197
|
registry: this.actorHandlers,
|
|
198
198
|
resolveActor: (targetActorId) => this.options.entryActorRuntime?.resolveActor(targetActorId),
|
|
199
|
-
routeBeforeLocal: (
|
|
199
|
+
routeBeforeLocal: (delivery) =>
|
|
200
200
|
this.options.entryActorRuntime?.routePacket(
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
201
|
+
delivery.actorId,
|
|
202
|
+
delivery.parts,
|
|
203
|
+
delivery.returnResponse,
|
|
204
|
+
delivery.remoteBoundSessionTarget,
|
|
205
|
+
delivery.fallbackActorRef,
|
|
206
|
+
delivery.origin,
|
|
207
|
+
delivery.requestTerminal,
|
|
208
|
+
delivery.messageFollowOrigin
|
|
206
209
|
),
|
|
207
210
|
onDisconnectActor: (actor) => this.notifyDisconnectActor(actor),
|
|
208
211
|
actorResponseSender: this.options.boundSessionRuntime?.sendActorResponse.bind(
|
|
@@ -260,7 +263,7 @@ export class ZLinkEntrySpotActivation {
|
|
|
260
263
|
|
|
261
264
|
dispatchPacketEncoded(
|
|
262
265
|
packetName: string | undefined,
|
|
263
|
-
decodePayload: () => unknown,
|
|
266
|
+
decodePayload: (messageType?: Type) => unknown,
|
|
264
267
|
context: { readonly channelName: string; readonly contentType?: string },
|
|
265
268
|
returnResponse: boolean
|
|
266
269
|
): Promise<unknown> {
|
|
@@ -304,7 +307,7 @@ export class ZLinkEntrySpotActivation {
|
|
|
304
307
|
await this.serial.execute(() => this.entrySpot.onInitialize?.());
|
|
305
308
|
this.attachActorJoinDispatch();
|
|
306
309
|
this.initialized = true;
|
|
307
|
-
this.
|
|
310
|
+
this.options.metrics?.recordSpotCount(this.options.spotNodeName, 'entry', 1);
|
|
308
311
|
}
|
|
309
312
|
|
|
310
313
|
async dispose(deadline?: Date): Promise<void> {
|
|
@@ -338,7 +341,7 @@ export class ZLinkEntrySpotActivation {
|
|
|
338
341
|
await this.options.nativeSpot.dispose();
|
|
339
342
|
});
|
|
340
343
|
if (this.initialized) {
|
|
341
|
-
this.
|
|
344
|
+
this.options.metrics?.recordSpotCount(this.options.spotNodeName, 'entry', -1);
|
|
342
345
|
}
|
|
343
346
|
if (errors.length === 1) throw errors[0];
|
|
344
347
|
if (errors.length > 1) throw new AggregateError(errors, 'Entry Spot cleanup failed.');
|
|
@@ -464,27 +467,14 @@ export class ZLinkEntrySpotActivation {
|
|
|
464
467
|
}
|
|
465
468
|
|
|
466
469
|
async dispatchActorPacket(delivery: ZLinkActorPacketDelivery): Promise<unknown> {
|
|
467
|
-
|
|
468
|
-
actorId,
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
const handoff = this.options.actorHandoffRuntime?.capture(
|
|
476
|
-
delivery.origin,
|
|
477
|
-
actorId,
|
|
478
|
-
parts,
|
|
479
|
-
returnResponse,
|
|
480
|
-
remoteBoundSessionTarget,
|
|
481
|
-
fallbackActorRef,
|
|
482
|
-
undefined,
|
|
483
|
-
messageFollowOrigin
|
|
484
|
-
);
|
|
485
|
-
if (handoff !== undefined) return await handoff;
|
|
486
|
-
return this.spotSerialExecutor.executeActor(actorId, () =>
|
|
487
|
-
this.dispatchActorPacketInsideMailbox(delivery)
|
|
470
|
+
return dispatchActorPacketInMailbox(
|
|
471
|
+
(operation) => this.spotSerialExecutor.executeActor(delivery.actorId, operation),
|
|
472
|
+
() =>
|
|
473
|
+
this.actorPacketDispatch.admitDelivery(
|
|
474
|
+
undefined,
|
|
475
|
+
delivery,
|
|
476
|
+
this.options.actorHandoffRuntime
|
|
477
|
+
)
|
|
488
478
|
);
|
|
489
479
|
}
|
|
490
480
|
|
|
@@ -539,7 +529,7 @@ export class ZLinkEntrySpotActivation {
|
|
|
539
529
|
private async dispatchActorPacketInsideMailbox(
|
|
540
530
|
delivery: ZLinkActorPacketDelivery
|
|
541
531
|
): Promise<unknown> {
|
|
542
|
-
return this.actorPacketDispatch.dispatchDelivery(delivery);
|
|
532
|
+
return this.actorPacketDispatch.dispatchDelivery(undefined, delivery);
|
|
543
533
|
}
|
|
544
534
|
|
|
545
535
|
private replyActorNoBind(
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { ZLinkHandlerMessageType } from '../../contracts/Common/HandlerMessageType';
|
|
1
2
|
import type {
|
|
2
3
|
Type,
|
|
3
4
|
ZLinkActor,
|
|
@@ -19,6 +20,7 @@ import type {
|
|
|
19
20
|
ZLinkSpotSubscriptionHandlerRegistration
|
|
20
21
|
} from '../../contracts/Configuration/RegistrationTypes';
|
|
21
22
|
import type { ZLinkProviderResolver } from '../../contracts/Common/ZLinkProviderResolver';
|
|
23
|
+
import { resolveHandlerMessageType } from '../../contracts/Common/HandlerMessageType';
|
|
22
24
|
import { prepareHandlerInstance } from '../handlers/handler-instance-scope';
|
|
23
25
|
import {
|
|
24
26
|
ZLinkFrameworkInternalErrorKind,
|
|
@@ -30,6 +32,7 @@ import { readZLinkDecoratorMetadata } from '../../contracts/Handlers/Attributes'
|
|
|
30
32
|
export interface ZLinkSpotHandlerRegistration {
|
|
31
33
|
readonly kind: 'packet' | 'subscribe' | 'actorSend' | 'actorRequest' | 'timer';
|
|
32
34
|
readonly handlerType: Type;
|
|
35
|
+
readonly messageType?: ZLinkHandlerMessageType;
|
|
33
36
|
readonly packetName?: string;
|
|
34
37
|
readonly channelName?: string;
|
|
35
38
|
readonly topic?: string;
|
|
@@ -61,7 +64,8 @@ export class DefaultZLinkSpotHandlerRegistry<
|
|
|
61
64
|
metadata.kind === 'spotActorSend' ? ZLinkActorPacketKind.Send : ZLinkActorPacketKind.Request,
|
|
62
65
|
handlerType,
|
|
63
66
|
Object as unknown as Type<TActor>,
|
|
64
|
-
resolvedPacketName
|
|
67
|
+
resolvedPacketName,
|
|
68
|
+
resolveHandlerMessageType(handlerType)
|
|
65
69
|
);
|
|
66
70
|
}
|
|
67
71
|
|
|
@@ -82,11 +86,24 @@ export class DefaultZLinkSpotHandlerRegistry<
|
|
|
82
86
|
metadata.kind === 'spotActorSend' ? ZLinkActorPacketKind.Send : ZLinkActorPacketKind.Request,
|
|
83
87
|
handlerType,
|
|
84
88
|
actorType as unknown as Type<TActor>,
|
|
85
|
-
metadata.packetName
|
|
89
|
+
metadata.packetName,
|
|
90
|
+
resolveHandlerMessageType(handlerType)
|
|
86
91
|
);
|
|
87
92
|
}
|
|
88
93
|
|
|
89
94
|
addPacket(handlerType: Type, packetName?: string): this {
|
|
95
|
+
return this.addPacketRegistration(
|
|
96
|
+
handlerType,
|
|
97
|
+
packetName,
|
|
98
|
+
resolveHandlerMessageType(handlerType)
|
|
99
|
+
);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
addPacketRegistration(
|
|
103
|
+
handlerType: Type,
|
|
104
|
+
packetName: string | undefined,
|
|
105
|
+
messageType: ZLinkHandlerMessageType | undefined
|
|
106
|
+
): this {
|
|
90
107
|
const declared = readZLinkDecoratorMetadata(handlerType).find(
|
|
91
108
|
(entry) => entry.kind === 'packet'
|
|
92
109
|
)?.packetName;
|
|
@@ -104,6 +121,7 @@ export class DefaultZLinkSpotHandlerRegistry<
|
|
|
104
121
|
this.entries.push({
|
|
105
122
|
kind: 'packet',
|
|
106
123
|
handlerType,
|
|
124
|
+
...(messageType === undefined ? {} : { messageType: messageType }),
|
|
107
125
|
packetName: resolvedPacketName
|
|
108
126
|
});
|
|
109
127
|
return this;
|
|
@@ -117,12 +135,14 @@ export class DefaultZLinkSpotHandlerRegistry<
|
|
|
117
135
|
kind: ZLinkActorPacketKind,
|
|
118
136
|
handlerType: Type,
|
|
119
137
|
actorType: Type<TActor>,
|
|
120
|
-
packetName: string
|
|
138
|
+
packetName: string,
|
|
139
|
+
messageType: ZLinkHandlerMessageType | undefined
|
|
121
140
|
): this {
|
|
122
141
|
prepareHandlerInstance(this.providerResolver, handlerType);
|
|
123
142
|
this.entries.push({
|
|
124
143
|
kind: kind === ZLinkActorPacketKind.Send ? 'actorSend' : 'actorRequest',
|
|
125
144
|
handlerType,
|
|
145
|
+
...(messageType === undefined ? {} : { messageType: messageType }),
|
|
126
146
|
actorType,
|
|
127
147
|
packetName
|
|
128
148
|
});
|
|
@@ -130,7 +150,8 @@ export class DefaultZLinkSpotHandlerRegistry<
|
|
|
130
150
|
kind,
|
|
131
151
|
packetName,
|
|
132
152
|
actorType,
|
|
133
|
-
handlerType
|
|
153
|
+
handlerType,
|
|
154
|
+
messageType: messageType
|
|
134
155
|
});
|
|
135
156
|
return this;
|
|
136
157
|
}
|
|
@@ -144,7 +165,8 @@ export class DefaultZLinkSpotHandlerRegistry<
|
|
|
144
165
|
ZLinkActorPacketKind.Send,
|
|
145
166
|
handlerType,
|
|
146
167
|
actorType,
|
|
147
|
-
packetName
|
|
168
|
+
packetName,
|
|
169
|
+
resolveHandlerMessageType(handlerType)
|
|
148
170
|
);
|
|
149
171
|
}
|
|
150
172
|
|
|
@@ -157,11 +179,26 @@ export class DefaultZLinkSpotHandlerRegistry<
|
|
|
157
179
|
ZLinkActorPacketKind.Request,
|
|
158
180
|
handlerType,
|
|
159
181
|
actorType,
|
|
160
|
-
packetName
|
|
182
|
+
packetName,
|
|
183
|
+
resolveHandlerMessageType(handlerType)
|
|
161
184
|
);
|
|
162
185
|
}
|
|
163
186
|
|
|
164
187
|
addSubscribe(handlerType: Type, channelName: string, topic: string): this {
|
|
188
|
+
return this.addSubscriptionRegistration(
|
|
189
|
+
handlerType,
|
|
190
|
+
channelName,
|
|
191
|
+
topic,
|
|
192
|
+
resolveHandlerMessageType(handlerType)
|
|
193
|
+
);
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
addSubscriptionRegistration(
|
|
197
|
+
handlerType: Type,
|
|
198
|
+
channelName: string,
|
|
199
|
+
topic: string,
|
|
200
|
+
messageType: ZLinkHandlerMessageType | undefined
|
|
201
|
+
): this {
|
|
165
202
|
if (channelName.trim().length === 0) {
|
|
166
203
|
throw createInternalFrameworkException(
|
|
167
204
|
ZLinkFrameworkInternalErrorKind.InvalidOperation,
|
|
@@ -189,7 +226,13 @@ export class DefaultZLinkSpotHandlerRegistry<
|
|
|
189
226
|
);
|
|
190
227
|
}
|
|
191
228
|
prepareHandlerInstance(this.providerResolver, handlerType);
|
|
192
|
-
this.entries.push({
|
|
229
|
+
this.entries.push({
|
|
230
|
+
kind: 'subscribe',
|
|
231
|
+
handlerType,
|
|
232
|
+
...(messageType === undefined ? {} : { messageType: messageType }),
|
|
233
|
+
channelName,
|
|
234
|
+
topic
|
|
235
|
+
});
|
|
193
236
|
return this;
|
|
194
237
|
}
|
|
195
238
|
|
|
@@ -259,7 +302,8 @@ export function applyEntrySpotHandlerRegistrations(
|
|
|
259
302
|
ZLinkActorPacketKind.Send,
|
|
260
303
|
handler.handlerType,
|
|
261
304
|
handler.actorType,
|
|
262
|
-
handler.packetName
|
|
305
|
+
handler.packetName,
|
|
306
|
+
handler.messageType
|
|
263
307
|
);
|
|
264
308
|
}
|
|
265
309
|
}
|
|
@@ -269,18 +313,24 @@ export function applyEntrySpotHandlerRegistrations(
|
|
|
269
313
|
ZLinkActorPacketKind.Request,
|
|
270
314
|
handler.handlerType,
|
|
271
315
|
handler.actorType,
|
|
272
|
-
handler.packetName
|
|
316
|
+
handler.packetName,
|
|
317
|
+
handler.messageType
|
|
273
318
|
);
|
|
274
319
|
}
|
|
275
320
|
}
|
|
276
321
|
for (const handler of registrations.packetHandlers ?? []) {
|
|
277
322
|
if (handler.entrySpotType === entrySpotType) {
|
|
278
|
-
registry.
|
|
323
|
+
registry.addPacketRegistration(handler.handlerType, handler.packetName, handler.messageType);
|
|
279
324
|
}
|
|
280
325
|
}
|
|
281
326
|
for (const handler of registrations.subscriptionHandlers ?? []) {
|
|
282
327
|
if (handler.entrySpotType === entrySpotType) {
|
|
283
|
-
registry.
|
|
328
|
+
registry.addSubscriptionRegistration(
|
|
329
|
+
handler.handlerType,
|
|
330
|
+
handler.channelName,
|
|
331
|
+
handler.topic,
|
|
332
|
+
handler.messageType
|
|
333
|
+
);
|
|
284
334
|
}
|
|
285
335
|
}
|
|
286
336
|
}
|
|
@@ -296,7 +346,8 @@ export function applySpotHandlerRegistrations(
|
|
|
296
346
|
ZLinkActorPacketKind.Send,
|
|
297
347
|
handler.handlerType,
|
|
298
348
|
handler.actorType,
|
|
299
|
-
handler.packetName
|
|
349
|
+
handler.packetName,
|
|
350
|
+
handler.messageType
|
|
300
351
|
);
|
|
301
352
|
}
|
|
302
353
|
}
|
|
@@ -306,18 +357,24 @@ export function applySpotHandlerRegistrations(
|
|
|
306
357
|
ZLinkActorPacketKind.Request,
|
|
307
358
|
handler.handlerType,
|
|
308
359
|
handler.actorType,
|
|
309
|
-
handler.packetName
|
|
360
|
+
handler.packetName,
|
|
361
|
+
handler.messageType
|
|
310
362
|
);
|
|
311
363
|
}
|
|
312
364
|
}
|
|
313
365
|
for (const handler of registrations.packetHandlers ?? []) {
|
|
314
366
|
if (isSpotImplementation(handler.spotType, spotType)) {
|
|
315
|
-
registry.
|
|
367
|
+
registry.addPacketRegistration(handler.handlerType, handler.packetName, handler.messageType);
|
|
316
368
|
}
|
|
317
369
|
}
|
|
318
370
|
for (const handler of registrations.subscriptionHandlers ?? []) {
|
|
319
371
|
if (isSpotImplementation(handler.spotType, spotType)) {
|
|
320
|
-
registry.
|
|
372
|
+
registry.addSubscriptionRegistration(
|
|
373
|
+
handler.handlerType,
|
|
374
|
+
handler.channelName,
|
|
375
|
+
handler.topic,
|
|
376
|
+
handler.messageType
|
|
377
|
+
);
|
|
321
378
|
}
|
|
322
379
|
}
|
|
323
380
|
}
|
|
@@ -96,6 +96,7 @@ export class ZLinkPublicSpotManager implements ZLinkSpotManager {
|
|
|
96
96
|
}
|
|
97
97
|
|
|
98
98
|
async close(spot: SpotRef, signal?: AbortSignal): Promise<boolean> {
|
|
99
|
+
const deadline = new Date(Date.now() + this.options.defaultTimeoutMs);
|
|
99
100
|
const resolved = await this.options.coordinator.resolveCloseTarget(spot, signal);
|
|
100
101
|
if (resolved === undefined) return false;
|
|
101
102
|
const current = resolved.spot;
|
|
@@ -107,7 +108,8 @@ export class ZLinkPublicSpotManager implements ZLinkSpotManager {
|
|
|
107
108
|
local.meshName,
|
|
108
109
|
local.spotId,
|
|
109
110
|
beginAuthority,
|
|
110
|
-
signal
|
|
111
|
+
signal,
|
|
112
|
+
deadline
|
|
111
113
|
),
|
|
112
114
|
signal
|
|
113
115
|
);
|
|
@@ -136,7 +138,7 @@ export class ZLinkPublicSpotManager implements ZLinkSpotManager {
|
|
|
136
138
|
authorityOwnerGeneration: snapshot.authorityOwnerGeneration,
|
|
137
139
|
expectedStoreVersion: snapshot.storeVersion.value
|
|
138
140
|
},
|
|
139
|
-
deadlineUnixMs: BigInt(
|
|
141
|
+
deadlineUnixMs: BigInt(deadline.getTime())
|
|
140
142
|
},
|
|
141
143
|
timeoutMs
|
|
142
144
|
);
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { RequestRuntime } from '../foundation/request-runtime';
|
|
1
2
|
import type { ZLinkMeshDispatchAdmission } from '../admission';
|
|
2
3
|
import type { ApplicationJobOrigin } from '../application-jobs/contracts';
|
|
3
4
|
import { RuntimeDisposal } from '../disposal';
|
|
@@ -5,6 +6,7 @@ import { randomUUID } from 'node:crypto';
|
|
|
5
6
|
import {
|
|
6
7
|
type ActorRef,
|
|
7
8
|
type RoutingId,
|
|
9
|
+
type Type,
|
|
8
10
|
type ZLinkActor,
|
|
9
11
|
type ZLinkChannelClient,
|
|
10
12
|
type ZLinkFanoutClient,
|
|
@@ -118,6 +120,8 @@ const ZLINK_SEND_DONT_WAIT = 1;
|
|
|
118
120
|
const EMPTY_SPOT_METADATA: ReadonlyMap<string, string> = new Map();
|
|
119
121
|
|
|
120
122
|
export interface ZLinkSpotNodeRuntimeManagerOptions {
|
|
123
|
+
readonly requests?: RequestRuntime;
|
|
124
|
+
readonly admission?: import('../admission').ZLinkRuntimeAdmissionGate;
|
|
121
125
|
readonly errorSink: import('../diagnostics/dispatch-error-port').ZLinkDispatchErrorSink;
|
|
122
126
|
readonly listenerRecords?: ZLinkListenerRecords;
|
|
123
127
|
readonly registration: ZLinkFrameworkRegistration;
|
|
@@ -154,10 +158,10 @@ export interface ZLinkSpotNodeRuntimeManagerOptions {
|
|
|
154
158
|
}
|
|
155
159
|
|
|
156
160
|
export class ZLinkSpotNodeRuntimeManager {
|
|
157
|
-
|
|
161
|
+
readonly meshNodes = new Map<string, ZLinkBackendMeshNode>();
|
|
158
162
|
private readonly meshPumps = new Map<string, ZLinkMeshDispatchPump>();
|
|
159
163
|
private readonly meshCompletions = new Map<string, ZLinkMeshCompletionTable>();
|
|
160
|
-
|
|
164
|
+
readonly entryActivations = new Map<string, ZLinkEntrySpotActivation>();
|
|
161
165
|
private readonly entryActivationStarts = new Map<string, Promise<void>>();
|
|
162
166
|
private readonly publishers = new Map<
|
|
163
167
|
string,
|
|
@@ -175,11 +179,11 @@ export class ZLinkSpotNodeRuntimeManager {
|
|
|
175
179
|
private readonly runtimeChannelWeights = new Map<string, Map<string, number>>();
|
|
176
180
|
private readonly entrySpotIds = new Map<string, string>();
|
|
177
181
|
private runtimeWeightPublication = Promise.resolve();
|
|
178
|
-
|
|
179
|
-
|
|
182
|
+
statePublication = Promise.resolve();
|
|
183
|
+
locationAutoConnect?: ZLinkSpotNodeLocationAutoConnectContext;
|
|
180
184
|
private readonly applicationJobQueue: ApplicationJobQueue;
|
|
181
185
|
|
|
182
|
-
constructor(
|
|
186
|
+
constructor(readonly options: ZLinkSpotNodeRuntimeManagerOptions) {
|
|
183
187
|
if ((options.detachedTaskRunner as unknown) === undefined) {
|
|
184
188
|
throw new ZLinkConfigurationException('Spot node runtime requires a detached task runner.');
|
|
185
189
|
}
|
|
@@ -300,12 +304,15 @@ export class ZLinkSpotNodeRuntimeManager {
|
|
|
300
304
|
const node = meshAdapter.createMeshNode(this.options.context, {
|
|
301
305
|
meshName: spotNodeName,
|
|
302
306
|
routingId,
|
|
307
|
+
sendHighWaterMark: spotNode.router?.sendHighWaterMark,
|
|
308
|
+
receiveHighWaterMark: spotNode.router?.receiveHighWaterMark,
|
|
303
309
|
receiveTimeoutMs: spotNode.router?.receiveTimeoutMs,
|
|
304
310
|
applicationJobQueue: this.applicationJobQueue,
|
|
305
311
|
infrastructureTaskRunner: this.options.detachedTaskRunner,
|
|
306
312
|
applicationJobReceiveFlowFailureSink: this.options.applicationJobReceiveFlowFailureSink,
|
|
307
313
|
peerAdmissionSealed: () => this.options.peerAdmissionSealed?.(spotNodeName) ?? false
|
|
308
314
|
});
|
|
315
|
+
if (this.options.requests !== undefined) node.setRequestRuntime?.(this.options.requests);
|
|
309
316
|
if (this.options.dispatchErrors !== undefined) {
|
|
310
317
|
node.setDispatchErrorReporter?.(this.options.dispatchErrors, spotNodeName);
|
|
311
318
|
}
|
|
@@ -1024,7 +1031,8 @@ export class ZLinkSpotNodeRuntimeManager {
|
|
|
1024
1031
|
this.options.dispatchErrors?.flow.flowCreationEnabled() ?? true
|
|
1025
1032
|
);
|
|
1026
1033
|
const codecs = { serializers: this.options.registration.messageSerializers };
|
|
1027
|
-
const decodePayload = () =>
|
|
1034
|
+
const decodePayload = (messageType?: Type) =>
|
|
1035
|
+
decodeChannelPayload(envelope, codecs, messageType);
|
|
1028
1036
|
const context = {
|
|
1029
1037
|
channelName: envelope.header.channelName,
|
|
1030
1038
|
contentType: envelope.header.contentType
|
|
@@ -1083,7 +1091,7 @@ export class ZLinkSpotNodeRuntimeManager {
|
|
|
1083
1091
|
}
|
|
1084
1092
|
}
|
|
1085
1093
|
|
|
1086
|
-
|
|
1094
|
+
async initializeEntrySpot(
|
|
1087
1095
|
spotNodeName: string,
|
|
1088
1096
|
node: ZLinkBackendMeshNode,
|
|
1089
1097
|
spotNode: ZLinkSpotNodeOptions
|
|
@@ -1092,6 +1100,7 @@ export class ZLinkSpotNodeRuntimeManager {
|
|
|
1092
1100
|
return;
|
|
1093
1101
|
}
|
|
1094
1102
|
const activation = new ZLinkEntrySpotActivation({
|
|
1103
|
+
admission: this.options.admission,
|
|
1095
1104
|
entrySpotType: spotNode.entrySpotType,
|
|
1096
1105
|
nativeSpot: node.entrySpot() as never,
|
|
1097
1106
|
nativeNode: node as unknown as ZLinkBackendSpotNode,
|
|
@@ -1,4 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { PendingOperation, OperationObserver } from '../foundation/operation-registry';
|
|
2
|
+
import {
|
|
3
|
+
createZLinkRequest,
|
|
4
|
+
mapZLinkRequestReply,
|
|
5
|
+
prepareZLinkRequestReply,
|
|
6
|
+
identityRequestReply,
|
|
7
|
+
type ZLinkRequestResult
|
|
8
|
+
} from '../messaging/request-result';
|
|
2
9
|
import {
|
|
3
10
|
type RoutingId,
|
|
4
11
|
type ZLinkChannelClient,
|
|
@@ -181,6 +188,7 @@ export interface ZLinkSpotAddressCallOptions {
|
|
|
181
188
|
readonly instanceSpotType?: string;
|
|
182
189
|
readonly initialMeshName?: string;
|
|
183
190
|
readonly timeoutMs?: number;
|
|
191
|
+
readonly requestOperation?: PendingOperation<unknown>;
|
|
184
192
|
readonly signal?: AbortSignal;
|
|
185
193
|
readonly sourceSpot?: ZLinkBackendSpot;
|
|
186
194
|
}
|
|
@@ -217,14 +225,16 @@ export interface ZLinkSpotRoutedTransport {
|
|
|
217
225
|
requestToSpot<TReply = unknown>(
|
|
218
226
|
spotRouteTarget: ZLinkSpotRouteTarget,
|
|
219
227
|
request: unknown,
|
|
220
|
-
options: ZLinkSpotRoutedRequestOptions
|
|
221
|
-
|
|
228
|
+
options: ZLinkSpotRoutedRequestOptions,
|
|
229
|
+
destination?: OperationObserver<unknown, unknown>
|
|
230
|
+
): ZLinkRequestResult<TReply>;
|
|
222
231
|
requestFromSpotToSpot?<TReply = unknown>(
|
|
223
232
|
sourceSpot: ZLinkBackendSpot,
|
|
224
233
|
spotRouteTarget: ZLinkSpotRouteTarget,
|
|
225
234
|
request: unknown,
|
|
226
|
-
options: ZLinkSpotRoutedRequestOptions
|
|
227
|
-
|
|
235
|
+
options: ZLinkSpotRoutedRequestOptions,
|
|
236
|
+
destination?: OperationObserver<unknown, unknown>
|
|
237
|
+
): ZLinkRequestResult<TReply>;
|
|
228
238
|
}
|
|
229
239
|
|
|
230
240
|
export interface ZLinkSpotRoutedSendOptions {
|
|
@@ -234,8 +244,10 @@ export interface ZLinkSpotRoutedSendOptions {
|
|
|
234
244
|
}
|
|
235
245
|
|
|
236
246
|
export interface ZLinkSpotRoutedRequestOptions extends ZLinkSpotRoutedSendOptions {
|
|
247
|
+
readonly deadlineMs?: number;
|
|
237
248
|
readonly onAdmitted?: () => void;
|
|
238
249
|
readonly timeoutMs?: number;
|
|
250
|
+
readonly requestOperation?: PendingOperation<unknown>;
|
|
239
251
|
readonly signal?: AbortSignal;
|
|
240
252
|
}
|
|
241
253
|
|
|
@@ -361,7 +373,8 @@ function createAddressedSpotRequestCall(
|
|
|
361
373
|
markSubmitted(options);
|
|
362
374
|
rejectSameSpotAsyncRequest(serial, spotId, 'async');
|
|
363
375
|
return createZLinkRequest(
|
|
364
|
-
(onAdmitted) =>
|
|
376
|
+
(onAdmitted) =>
|
|
377
|
+
prepareZLinkRequestReply(begin<TReply>(signal, onAdmitted), identityRequestReply),
|
|
365
378
|
(pending) => (serial.isCurrentTurn ? pending : deliverOnSerial(serial, pending))
|
|
366
379
|
);
|
|
367
380
|
},
|
|
@@ -501,7 +514,8 @@ function wrapRequestCall(
|
|
|
501
514
|
},
|
|
502
515
|
submit<TReply>(signal?: AbortSignal) {
|
|
503
516
|
return createZLinkRequest(
|
|
504
|
-
(onAdmitted) =>
|
|
517
|
+
(onAdmitted) =>
|
|
518
|
+
prepareZLinkRequestReply(begin<TReply>(signal, onAdmitted), identityRequestReply),
|
|
505
519
|
(pending) => (serial.isCurrentTurn ? pending : deliverOnSerial(serial, pending))
|
|
506
520
|
);
|
|
507
521
|
},
|
|
@@ -618,7 +632,8 @@ function wrapRoutedSpotRequestCall(
|
|
|
618
632
|
submit<TReply>(signal?: AbortSignal) {
|
|
619
633
|
rejectSameSpotAsyncRequest(serial, spot.spotId, 'async');
|
|
620
634
|
return createZLinkRequest(
|
|
621
|
-
(onAdmitted) =>
|
|
635
|
+
(onAdmitted) =>
|
|
636
|
+
prepareZLinkRequestReply(begin<TReply>(signal, onAdmitted), identityRequestReply),
|
|
622
637
|
(pending) => (serial.isCurrentTurn ? pending : deliverOnSerial(serial, pending))
|
|
623
638
|
);
|
|
624
639
|
},
|
|
@@ -649,6 +664,7 @@ export interface ZLinkSpotHandleCallOptions {
|
|
|
649
664
|
readonly onAdmitted?: () => void;
|
|
650
665
|
readonly metadata?: ReadonlyMap<string, string>;
|
|
651
666
|
readonly timeoutMs?: number;
|
|
667
|
+
readonly requestOperation?: PendingOperation<unknown>;
|
|
652
668
|
readonly signal?: AbortSignal;
|
|
653
669
|
readonly spotRouterChannelIdForMesh?: (meshName: string) => string;
|
|
654
670
|
readonly sourceSpot?: ZLinkBackendSpot;
|
|
@@ -685,7 +701,7 @@ export async function requestToSpotHandle<TReply = unknown>(
|
|
|
685
701
|
options: ZLinkSpotHandleCallOptions = {}
|
|
686
702
|
): Promise<TReply> {
|
|
687
703
|
const packetName = resolveFrameworkPacketName(request, undefined, 'SPOT');
|
|
688
|
-
const requestResolved =
|
|
704
|
+
const requestResolved = (resolved: ResolvedSpotHandle): ZLinkRequestResult<TReply> => {
|
|
689
705
|
const target = spotRefToSpotRouteTarget(resolved, options.spotRouterChannelIdForMesh);
|
|
690
706
|
const transportOptions = {
|
|
691
707
|
packetName,
|
|
@@ -705,7 +721,7 @@ export async function requestToSpotHandle<TReply = unknown>(
|
|
|
705
721
|
return transport.requestToSpot<TReply>(target, request, transportOptions);
|
|
706
722
|
};
|
|
707
723
|
|
|
708
|
-
return requestResolved(await requireSpotRef(spot, options.signal));
|
|
724
|
+
return mapZLinkRequestReply(requestResolved(await requireSpotRef(spot, options.signal)));
|
|
709
725
|
}
|
|
710
726
|
|
|
711
727
|
async function requireSpotRef(
|
|
@@ -46,6 +46,7 @@ import {
|
|
|
46
46
|
} from '../framework-errors-internal';
|
|
47
47
|
import { resolveLifecycleHandler } from '../handlers/handler-instance-scope';
|
|
48
48
|
import type { ZLinkSpotHandlerRegistration } from './spot-handler-registry';
|
|
49
|
+
import { resolveMessageTypeForDecode } from '../../contracts/Common/HandlerMessageType';
|
|
49
50
|
import { REMOTE_ACTOR_JOIN_PACKET } from './spot-remote-codec';
|
|
50
51
|
import { appendRouteReplyParts, hasReplyToken, submitRouteReply } from './spot-route-replies';
|
|
51
52
|
import type { ZLinkSpotSerialTurnExecutor } from './spot-serial-turn-executor';
|
|
@@ -78,9 +79,10 @@ export class ZLinkSpotRoutePacketDispatch {
|
|
|
78
79
|
constructor(private readonly options: ZLinkSpotRoutePacketDispatchOptions) {}
|
|
79
80
|
|
|
80
81
|
async dispatch(received: BackendReceived): Promise<boolean> {
|
|
82
|
+
const receivedAt = new Date();
|
|
81
83
|
const directEnvelope = decodeSpotDirectEnvelope(received.parts);
|
|
82
84
|
if (directEnvelope !== undefined) {
|
|
83
|
-
await this.dispatchSpotDirectEnvelope(received, directEnvelope);
|
|
85
|
+
await this.dispatchSpotDirectEnvelope(received, directEnvelope, receivedAt);
|
|
84
86
|
return true;
|
|
85
87
|
}
|
|
86
88
|
let envelope: ReturnType<typeof decodeChannelEnvelope>;
|
|
@@ -147,7 +149,8 @@ export class ZLinkSpotRoutePacketDispatch {
|
|
|
147
149
|
contentType: envelope.header.contentType,
|
|
148
150
|
packetName: envelope.packetName!,
|
|
149
151
|
metadata: zlinkMessageMetadata(envelope.header.metadata),
|
|
150
|
-
correlationId: envelope.header.correlationId ?? undefined
|
|
152
|
+
correlationId: envelope.header.correlationId ?? undefined,
|
|
153
|
+
receivedAt
|
|
151
154
|
};
|
|
152
155
|
try {
|
|
153
156
|
let response: unknown;
|
|
@@ -167,7 +170,11 @@ export class ZLinkSpotRoutePacketDispatch {
|
|
|
167
170
|
// Keep the wire payload raw until this Spot has acquired its
|
|
168
171
|
// execution authority. A rejected or superseded work item must not
|
|
169
172
|
// pay the deserialization cost.
|
|
170
|
-
const payload = decodeChannelPayload(
|
|
173
|
+
const payload = decodeChannelPayload(
|
|
174
|
+
envelope,
|
|
175
|
+
this.channelCodecs(),
|
|
176
|
+
resolveMessageTypeForDecode(registrations[0]?.messageType)
|
|
177
|
+
);
|
|
171
178
|
for (const registration of registrations) {
|
|
172
179
|
const handler = await resolveLifecycleHandler(
|
|
173
180
|
spot,
|
|
@@ -240,7 +247,8 @@ export class ZLinkSpotRoutePacketDispatch {
|
|
|
240
247
|
|
|
241
248
|
private async dispatchSpotDirectEnvelope(
|
|
242
249
|
received: BackendReceived,
|
|
243
|
-
envelope: ZLinkSpotDirectEnvelope
|
|
250
|
+
envelope: ZLinkSpotDirectEnvelope,
|
|
251
|
+
receivedAt: Date
|
|
244
252
|
): Promise<void> {
|
|
245
253
|
const replyable =
|
|
246
254
|
envelope.kind === ZLinkChannelMessageKind.Request && hasReplyToken(received.replyToken);
|
|
@@ -287,13 +295,15 @@ export class ZLinkSpotRoutePacketDispatch {
|
|
|
287
295
|
>,
|
|
288
296
|
this.options.providerResolver
|
|
289
297
|
);
|
|
290
|
-
|
|
291
|
-
response = await handler.handle(spot, envelope.payload, {
|
|
298
|
+
const handlerContext = {
|
|
292
299
|
channelName: envelope.channelName,
|
|
293
300
|
packetName: envelope.packetName!,
|
|
294
301
|
metadata: zlinkMessageMetadata(envelope.metadata),
|
|
295
|
-
correlationId: undefined
|
|
296
|
-
|
|
302
|
+
correlationId: undefined,
|
|
303
|
+
receivedAt
|
|
304
|
+
};
|
|
305
|
+
releaseApplicationJobPermitBeforeHandler();
|
|
306
|
+
response = await handler.handle(spot, envelope.payload, handlerContext);
|
|
297
307
|
}
|
|
298
308
|
},
|
|
299
309
|
zlinkSerialWorkOptions(
|