@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,5 @@
|
|
|
1
|
+
import type { ConnectionAttempt } from '@zlink-systems/zlink';
|
|
2
|
+
import type { OperationHandle } from '../foundation/operation-registry';
|
|
1
3
|
import type { SubmitResult } from './runtime-values';
|
|
2
4
|
export interface ZLinkRawSendSubmission {
|
|
3
5
|
readonly result: typeof SubmitResult.Ok | typeof SubmitResult.Backpressured;
|
|
@@ -12,7 +14,7 @@ export interface ZLinkRawReceivedRecord {
|
|
|
12
14
|
* record (Core ROUTER §10.1); 0n for a non-ROUTER receive. Equality only.
|
|
13
15
|
*/
|
|
14
16
|
readonly routeGeneration: bigint;
|
|
15
|
-
readonly reply?: (parts: readonly Uint8Array[]) => void;
|
|
17
|
+
readonly reply?: (parts: readonly (Uint8Array | string)[]) => void;
|
|
16
18
|
readonly parts: readonly Buffer[];
|
|
17
19
|
/** Releases the ordinary Framework-owned receive record exactly once. */
|
|
18
20
|
close(): void;
|
|
@@ -29,7 +31,7 @@ export interface ZLinkRawMonitorRecord {
|
|
|
29
31
|
readonly flags?: number;
|
|
30
32
|
}
|
|
31
33
|
export interface ZLinkRawSocketPort {
|
|
32
|
-
setReadableHandler(handler: (receiveReady: boolean, routeReady: boolean) => void): void;
|
|
34
|
+
setReadableHandler(handler: (receiveReady: boolean, routeReady: boolean, connectReady: boolean) => void): void;
|
|
33
35
|
bind(endpoint: string): void;
|
|
34
36
|
unbind(endpoint: string): void;
|
|
35
37
|
connect(endpoint: string): void;
|
|
@@ -56,10 +58,11 @@ export interface ZLinkRawRouterPort extends ZLinkRawSocketPort {
|
|
|
56
58
|
setRoutingId(routingId: string): void;
|
|
57
59
|
connectToRoutingId(routingId: string, endpoint: string): void;
|
|
58
60
|
send(targetRid: string, parts: readonly Uint8Array[]): Promise<void>;
|
|
59
|
-
request(targetRid: string, parts: readonly Uint8Array[], timeoutMs: number, recordReceived?: () => void, onAdmitted?: () => void): Promise<
|
|
61
|
+
request<T>(targetRid: string, parts: readonly Uint8Array[], timeoutMs: number, onReply: (parts: readonly Buffer[]) => T, onFailed: (error: unknown) => T, recordReceived?: () => void, onAdmitted?: () => void, existing?: Pick<OperationHandle<unknown>, 'id' | 'deadlineMs'>): Promise<T>;
|
|
60
62
|
receive(dontWait?: boolean): ZLinkRawReceivedRecord | undefined;
|
|
61
63
|
/** The selected route of every RID. The socket's one route observer calls it. */
|
|
62
64
|
routesSnapshot(): readonly ZLinkRawRouterRoute[];
|
|
65
|
+
connectionAttemptsSnapshot(): readonly ConnectionAttempt[];
|
|
63
66
|
}
|
|
64
67
|
export interface ZLinkRawDealerPort extends ZLinkRawSocketPort {
|
|
65
68
|
setRoutingId(routingId: string): void;
|
|
@@ -150,13 +150,13 @@ class DefaultZLinkRouteClient {
|
|
|
150
150
|
requestToSpot(spot, request) {
|
|
151
151
|
return new DefaultZLinkRequestCall(() => {
|
|
152
152
|
this.requireSpotTransport();
|
|
153
|
-
}, (_packetName, timeoutMs, metadata, signal, onAdmitted) => (0, spot_outbound_1.requestToSpotHandle)(this.requireSpotTransport(), spot, request, {
|
|
153
|
+
}, (_packetName, timeoutMs, metadata, signal, onAdmitted) => (0, request_result_1.prepareZLinkRequestReply)((0, spot_outbound_1.requestToSpotHandle)(this.requireSpotTransport(), spot, request, {
|
|
154
154
|
timeoutMs,
|
|
155
155
|
signal,
|
|
156
156
|
metadata,
|
|
157
157
|
onAdmitted,
|
|
158
158
|
spotRouterChannelIdForMesh: this.spotRouterChannelIdForMesh
|
|
159
|
-
}), this.registration.requestTimeoutMs ?? Registration_1.DEFAULT_REQUEST_TIMEOUT_MS);
|
|
159
|
+
}), request_result_1.identityRequestReply), this.registration.requestTimeoutMs ?? Registration_1.DEFAULT_REQUEST_TIMEOUT_MS);
|
|
160
160
|
}
|
|
161
161
|
defaultRequestTimeout(meshName) {
|
|
162
162
|
return (this.registration.spotNodes.get(meshName)?.requestTimeoutMs ??
|
|
@@ -340,7 +340,7 @@ class DefaultZLinkRequestCall {
|
|
|
340
340
|
(0, abort_1.throwIfAborted)(signal);
|
|
341
341
|
this.validate();
|
|
342
342
|
const pending = this.submitter(undefined, this.timeoutMs ?? this.defaultRequestTimeoutMs, this.selectedMetadata === undefined ? EMPTY_CALL_METADATA : new Map(this.selectedMetadata), signal, undefined, this.message);
|
|
343
|
-
return turn.yieldFrameworkPromise(pending);
|
|
343
|
+
return turn.yieldFrameworkPromise((0, request_result_1.mapZLinkRequestReply)(pending));
|
|
344
344
|
}
|
|
345
345
|
}
|
|
346
346
|
class DefaultZLinkPublishCall {
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
import type { ZLinkHandlerMessageType } from '../../contracts/Common/HandlerMessageType';
|
|
1
2
|
import type { ZLinkMeshDispatchAdmission } from '../admission';
|
|
2
3
|
import type { ZLinkMessageContext, ZLinkHandlerFilter, ZLinkUnhandledDispatchOptions, ZLinkFlowOrigin } from '../../contracts';
|
|
3
4
|
import { ZLinkFrameworkException } from '../../contracts';
|
|
4
|
-
import { ZLinkDispatchMessageKind, ZLinkDispatchErrorSurface } from '../../contracts/Dispatch/ZLinkDispatchOptions';
|
|
5
|
+
import { ZLinkRuntimeMessageFlowOutcome as ZLinkMessageFlowOutcome, ZLinkDispatchMessageKind, ZLinkDispatchErrorSurface } from '../../contracts/Dispatch/ZLinkDispatchOptions';
|
|
5
6
|
import { type ZLinkChannelEnvelope, type ZLinkChannelEnvelopeCodecRegistry } from './channel-envelope';
|
|
6
7
|
import type { ZLinkMalformedChannelHeaderInfo } from './channel-envelope-inspection';
|
|
7
8
|
import type { ZLinkDispatchErrorReporter } from './dispatch-error-reporter';
|
|
@@ -24,11 +25,12 @@ export interface ZLinkChannelDispatchFields {
|
|
|
24
25
|
interface ZLinkChannelDispatchHandler<TContext extends ZLinkMessageContext, TResult> {
|
|
25
26
|
handle(payload: unknown, context: TContext): Promise<TResult> | TResult;
|
|
26
27
|
}
|
|
27
|
-
interface ZLinkOneWayDispatch<TContext extends ZLinkMessageContext> {
|
|
28
|
+
export interface ZLinkOneWayDispatch<TContext extends ZLinkMessageContext> {
|
|
28
29
|
readonly fields: ZLinkChannelDispatchFields;
|
|
29
30
|
readonly envelope: ZLinkChannelEnvelope;
|
|
30
31
|
readonly codecs?: ZLinkChannelEnvelopeCodecRegistry;
|
|
31
32
|
readonly handler?: ZLinkChannelDispatchHandler<TContext, void>;
|
|
33
|
+
readonly messageType?: ZLinkHandlerMessageType;
|
|
32
34
|
readonly context: TContext;
|
|
33
35
|
readonly signal?: AbortSignal;
|
|
34
36
|
}
|
|
@@ -37,6 +39,7 @@ export interface ZLinkRequestDispatch<TContext extends ZLinkMessageContext> {
|
|
|
37
39
|
readonly envelope: ZLinkChannelEnvelope;
|
|
38
40
|
readonly codecs?: ZLinkChannelEnvelopeCodecRegistry;
|
|
39
41
|
readonly handler?: ZLinkChannelDispatchHandler<TContext, unknown>;
|
|
42
|
+
readonly messageType?: ZLinkHandlerMessageType;
|
|
40
43
|
readonly context: TContext;
|
|
41
44
|
readonly signal?: AbortSignal;
|
|
42
45
|
readonly missingHandlerMessage: string;
|
|
@@ -44,8 +47,8 @@ export interface ZLinkRequestDispatch<TContext extends ZLinkMessageContext> {
|
|
|
44
47
|
readonly writeError: (error: unknown) => void | Promise<void>;
|
|
45
48
|
}
|
|
46
49
|
export declare class ZLinkChannelDispatchPipeline {
|
|
47
|
-
|
|
48
|
-
|
|
50
|
+
readonly options: ZLinkChannelDispatchPipelineOptions;
|
|
51
|
+
readonly filters: readonly ZLinkHandlerFilter[];
|
|
49
52
|
private readonly unhandled;
|
|
50
53
|
constructor(options: ZLinkChannelDispatchPipelineOptions);
|
|
51
54
|
/**
|
|
@@ -64,7 +67,7 @@ export declare class ZLinkChannelDispatchPipeline {
|
|
|
64
67
|
*/
|
|
65
68
|
dispatchRequest<TContext extends ZLinkMessageContext>(dispatch: ZLinkRequestDispatch<TContext>, admit?: ZLinkMeshDispatchAdmission): void | Promise<void>;
|
|
66
69
|
private dispatchMissingRequest;
|
|
67
|
-
|
|
70
|
+
invokeInFlow<TContext extends ZLinkMessageContext, TResult>(dispatch: ZLinkOneWayDispatch<TContext> | ZLinkRequestDispatch<TContext>, handler: ZLinkChannelDispatchHandler<TContext, TResult>): unknown;
|
|
68
71
|
private completeRequest;
|
|
69
72
|
private replyPathMissing;
|
|
70
73
|
private failRequest;
|
|
@@ -84,13 +87,14 @@ export declare class ZLinkChannelDispatchPipeline {
|
|
|
84
87
|
readonly sourceRid?: string;
|
|
85
88
|
readonly writeProtocolError?: (error: ZLinkFrameworkException) => Promise<void>;
|
|
86
89
|
}): Promise<void>;
|
|
87
|
-
|
|
90
|
+
invoke<TContext extends ZLinkMessageContext, TResult>(dispatch: ZLinkOneWayDispatch<TContext> | ZLinkRequestDispatch<TContext>, handler: ZLinkChannelDispatchHandler<TContext, TResult>): TResult | undefined | typeof HANDLER_FILTER_REJECTED | Promise<TResult | undefined | typeof HANDLER_FILTER_REJECTED>;
|
|
88
91
|
private invokeFiltered;
|
|
89
92
|
private createFilterContext;
|
|
90
93
|
private dispatchKind;
|
|
91
94
|
private report;
|
|
92
|
-
|
|
95
|
+
trace(outcome: ZLinkMessageFlowOutcome, fields: ZLinkChannelDispatchFields): void;
|
|
93
96
|
private failureReason;
|
|
94
97
|
private applyOneWayUnhandled;
|
|
95
98
|
}
|
|
99
|
+
declare const HANDLER_FILTER_REJECTED: unique symbol;
|
|
96
100
|
export {};
|
|
@@ -9,6 +9,7 @@ const handlers_1 = require("../handlers");
|
|
|
9
9
|
const channel_envelope_1 = require("./channel-envelope");
|
|
10
10
|
const flow_context_1 = require("../diagnostics/flow-context");
|
|
11
11
|
const application_job_queue_scope_1 = require("../application-jobs/application-job-queue-scope");
|
|
12
|
+
const HandlerMessageType_1 = require("../../contracts/Common/HandlerMessageType");
|
|
12
13
|
class ZLinkChannelDispatchPipeline {
|
|
13
14
|
options;
|
|
14
15
|
filters;
|
|
@@ -25,9 +26,7 @@ class ZLinkChannelDispatchPipeline {
|
|
|
25
26
|
*/
|
|
26
27
|
dispatchOneWay(dispatch, admit) {
|
|
27
28
|
if (admit !== undefined) {
|
|
28
|
-
|
|
29
|
-
const record = dispatch;
|
|
30
|
-
return admit(() => pipeline.dispatchOneWay(record), (error) => pipeline.failOneWay(record.fields, error));
|
|
29
|
+
return admit(this.dispatchOneWay, this.failOneWay, this, dispatch);
|
|
31
30
|
}
|
|
32
31
|
this.trace(ZLinkDispatchOptions_1.ZLinkRuntimeMessageFlowOutcome.Received, dispatch.fields);
|
|
33
32
|
this.trace(ZLinkDispatchOptions_1.ZLinkRuntimeMessageFlowOutcome.Admitted, dispatch.fields);
|
|
@@ -38,14 +37,19 @@ class ZLinkChannelDispatchPipeline {
|
|
|
38
37
|
invocation = this.invokeInFlow(dispatch, dispatch.handler);
|
|
39
38
|
}
|
|
40
39
|
catch (error) {
|
|
41
|
-
this.failOneWay(
|
|
40
|
+
this.failOneWay(error, dispatch);
|
|
42
41
|
return;
|
|
43
42
|
}
|
|
44
43
|
if (!(0, abort_1.isPromiseLike)(invocation)) {
|
|
45
44
|
this.completeOneWay(dispatch.fields, invocation);
|
|
46
45
|
return;
|
|
47
46
|
}
|
|
48
|
-
|
|
47
|
+
{
|
|
48
|
+
// Keep captures block-scoped so synchronous dispatch allocates no V8 context.
|
|
49
|
+
const pipeline = this;
|
|
50
|
+
const record = dispatch;
|
|
51
|
+
return Promise.resolve(invocation).then((value) => pipeline.completeOneWay(record.fields, value), (error) => pipeline.failOneWay(error, record));
|
|
52
|
+
}
|
|
49
53
|
}
|
|
50
54
|
async dispatchMissingOneWay(fields) {
|
|
51
55
|
const action = fields.messageKind === ZLinkDispatchOptions_1.ZLinkDispatchMessageKind.Publish
|
|
@@ -59,7 +63,8 @@ class ZLinkChannelDispatchPipeline {
|
|
|
59
63
|
this.trace(ZLinkDispatchOptions_1.ZLinkRuntimeMessageFlowOutcome.Completed, fields);
|
|
60
64
|
}
|
|
61
65
|
}
|
|
62
|
-
failOneWay(
|
|
66
|
+
failOneWay(error, dispatch) {
|
|
67
|
+
const fields = dispatch.fields;
|
|
63
68
|
this.report(fields, this.failureReason(error), ZLinkDispatchOptions_1.ZLinkRuntimeDispatchErrorAction.Drop, error);
|
|
64
69
|
}
|
|
65
70
|
/**
|
|
@@ -69,9 +74,7 @@ class ZLinkChannelDispatchPipeline {
|
|
|
69
74
|
*/
|
|
70
75
|
dispatchRequest(dispatch, admit) {
|
|
71
76
|
if (admit !== undefined) {
|
|
72
|
-
|
|
73
|
-
const record = dispatch;
|
|
74
|
-
return admit(() => pipeline.dispatchRequest(record), (error) => pipeline.failRequest(record, error));
|
|
77
|
+
return admit(this.dispatchRequest, this.failRequest, this, dispatch);
|
|
75
78
|
}
|
|
76
79
|
this.trace(ZLinkDispatchOptions_1.ZLinkRuntimeMessageFlowOutcome.Received, dispatch.fields);
|
|
77
80
|
this.trace(ZLinkDispatchOptions_1.ZLinkRuntimeMessageFlowOutcome.Admitted, dispatch.fields);
|
|
@@ -82,11 +85,15 @@ class ZLinkChannelDispatchPipeline {
|
|
|
82
85
|
invocation = this.invokeInFlow(dispatch, dispatch.handler);
|
|
83
86
|
}
|
|
84
87
|
catch (error) {
|
|
85
|
-
return this.failRequest(
|
|
88
|
+
return this.failRequest(error, dispatch);
|
|
86
89
|
}
|
|
87
90
|
if (!(0, abort_1.isPromiseLike)(invocation))
|
|
88
91
|
return this.completeRequest(dispatch, invocation);
|
|
89
|
-
|
|
92
|
+
{
|
|
93
|
+
const pipeline = this;
|
|
94
|
+
const record = dispatch;
|
|
95
|
+
return Promise.resolve(invocation).then((value) => pipeline.completeRequest(record, value), (error) => pipeline.failRequest(error, record));
|
|
96
|
+
}
|
|
90
97
|
}
|
|
91
98
|
async dispatchMissingRequest(dispatch) {
|
|
92
99
|
const missing = (0, framework_errors_internal_1.createInternalFrameworkException)(framework_errors_internal_1.ZLinkFrameworkInternalErrorKind.HandlerNotFound, dispatch.missingHandlerMessage);
|
|
@@ -103,12 +110,12 @@ class ZLinkChannelDispatchPipeline {
|
|
|
103
110
|
invokeInFlow(dispatch, handler) {
|
|
104
111
|
const flow = (0, flow_context_1.createInboundFlow)(dispatch.fields.flowId, dispatch.fields.flowOrigin, this.options.dispatchErrors.flow.flowCreationEnabled(), undefined);
|
|
105
112
|
return flow === undefined
|
|
106
|
-
? this.invoke(dispatch
|
|
107
|
-
: (0, flow_context_1.runWithFlow)(flow,
|
|
113
|
+
? this.invoke(dispatch, handler)
|
|
114
|
+
: (0, flow_context_1.runWithFlow)(flow, this.invoke.bind(this, dispatch, handler));
|
|
108
115
|
}
|
|
109
116
|
completeRequest(dispatch, invocation) {
|
|
110
117
|
if (invocation === HANDLER_FILTER_REJECTED) {
|
|
111
|
-
return this.failRequest(
|
|
118
|
+
return this.failRequest((0, framework_errors_internal_1.createInternalFrameworkException)(framework_errors_internal_1.ZLinkFrameworkInternalErrorKind.RequestRejected, `A handler filter rejected '${this.options.channelName}:${dispatch.fields.packetName}'.`), dispatch);
|
|
112
119
|
}
|
|
113
120
|
let written;
|
|
114
121
|
try {
|
|
@@ -122,14 +129,18 @@ class ZLinkChannelDispatchPipeline {
|
|
|
122
129
|
this.trace(ZLinkDispatchOptions_1.ZLinkRuntimeMessageFlowOutcome.Replied, dispatch.fields);
|
|
123
130
|
return;
|
|
124
131
|
}
|
|
125
|
-
|
|
132
|
+
{
|
|
133
|
+
const pipeline = this;
|
|
134
|
+
const record = dispatch;
|
|
135
|
+
return written.then(() => pipeline.trace(ZLinkDispatchOptions_1.ZLinkRuntimeMessageFlowOutcome.Replied, record.fields), (error) => pipeline.replyPathMissing(record.fields, error));
|
|
136
|
+
}
|
|
126
137
|
}
|
|
127
138
|
replyPathMissing(fields, error) {
|
|
128
139
|
// Spec 26 §3.1: a failed reply write means the reply delivery path is
|
|
129
140
|
// gone; `unexpected_reply` names a surplus/late reply instead.
|
|
130
141
|
this.report(fields, ZLinkDispatchOptions_1.ZLinkRuntimeDispatchErrorReason.ReplyPathMissing, ZLinkDispatchOptions_1.ZLinkRuntimeDispatchErrorAction.Drop, error);
|
|
131
142
|
}
|
|
132
|
-
async failRequest(
|
|
143
|
+
async failRequest(error, dispatch) {
|
|
133
144
|
try {
|
|
134
145
|
await dispatch.writeError(error);
|
|
135
146
|
}
|
|
@@ -177,24 +188,30 @@ class ZLinkChannelDispatchPipeline {
|
|
|
177
188
|
error: input.error
|
|
178
189
|
});
|
|
179
190
|
}
|
|
180
|
-
invoke(
|
|
181
|
-
|
|
191
|
+
invoke(dispatch, handler) {
|
|
192
|
+
const envelope = dispatch.envelope;
|
|
193
|
+
const codecs = dispatch.codecs;
|
|
194
|
+
const context = dispatch.context;
|
|
195
|
+
const fields = dispatch.fields;
|
|
196
|
+
const signal = dispatch.signal;
|
|
182
197
|
if (this.filters.length === 0) {
|
|
183
198
|
// Fast path for the dominant unfiltered dispatch: skip the filter
|
|
184
199
|
// context object and chain machinery entirely.
|
|
185
|
-
const payload = (0, channel_envelope_1.decodeChannelPayload)(envelope, codecs);
|
|
200
|
+
const payload = (0, channel_envelope_1.decodeChannelPayload)(envelope, codecs, (0, HandlerMessageType_1.resolveMessageTypeForDecode)(dispatch.messageType));
|
|
186
201
|
this.trace(ZLinkDispatchOptions_1.ZLinkRuntimeMessageFlowOutcome.Dispatched, fields);
|
|
202
|
+
(0, application_job_queue_scope_1.releaseApplicationJobPermitBeforeHandler)();
|
|
187
203
|
return handler.handle(payload, context);
|
|
188
204
|
}
|
|
189
|
-
return this.invokeFiltered(envelope, codecs, handler, context, fields, signal);
|
|
205
|
+
return this.invokeFiltered(envelope, codecs, handler, context, fields, dispatch.messageType, signal);
|
|
190
206
|
}
|
|
191
|
-
async invokeFiltered(envelope, codecs, handler, context, fields, signal) {
|
|
207
|
+
async invokeFiltered(envelope, codecs, handler, context, fields, messageType, signal) {
|
|
192
208
|
let value;
|
|
193
209
|
const handlerInvoked = await (0, handlers_1.invokeZLinkHandlerFilters)(this.filters, this.createFilterContext(context, fields), async () => {
|
|
194
210
|
// Filters are the channel admission gate. Decode only after they have
|
|
195
211
|
// allowed the handler turn to proceed.
|
|
196
|
-
const payload = (0, channel_envelope_1.decodeChannelPayload)(envelope, codecs);
|
|
212
|
+
const payload = (0, channel_envelope_1.decodeChannelPayload)(envelope, codecs, (0, HandlerMessageType_1.resolveMessageTypeForDecode)(messageType));
|
|
197
213
|
this.trace(ZLinkDispatchOptions_1.ZLinkRuntimeMessageFlowOutcome.Dispatched, fields);
|
|
214
|
+
(0, application_job_queue_scope_1.releaseApplicationJobPermitBeforeHandler)();
|
|
198
215
|
value = await handler.handle(payload, context);
|
|
199
216
|
}, signal);
|
|
200
217
|
return handlerInvoked ? value : HANDLER_FILTER_REJECTED;
|
|
@@ -208,6 +225,7 @@ class ZLinkChannelDispatchPipeline {
|
|
|
208
225
|
contentType: context.contentType,
|
|
209
226
|
metadata: context.metadata,
|
|
210
227
|
correlationId: context.correlationId,
|
|
228
|
+
receivedAt: context.receivedAt,
|
|
211
229
|
dispatchKind
|
|
212
230
|
};
|
|
213
231
|
}
|
|
@@ -5,6 +5,7 @@ import type { ZLinkDispatchErrorSurface, ZLinkDispatchMessageKind } from '../../
|
|
|
5
5
|
import type { ZLinkFrameworkRegistration } from '../configuration';
|
|
6
6
|
import { ZLinkRuntimeMetrics, type ZLinkMessageFlowModeCell } from '../diagnostics';
|
|
7
7
|
import type { ZLinkRuntimeTaskErrorSink } from '../execution';
|
|
8
|
+
import { type ZLinkTelemetryLease } from '../diagnostics/message-flow-delivery';
|
|
8
9
|
import { ZLinkDispatchErrorReporter } from './dispatch-error-reporter';
|
|
9
10
|
import type { ZLinkChannelRequestHandler, ZLinkChannelSendHandler, ZLinkRouteRuntimeRequestHandler, ZLinkRouteRuntimeSendHandler } from './channel-dispatchers';
|
|
10
11
|
export interface ZLinkChannelOutboundTrace {
|
|
@@ -28,13 +29,14 @@ export declare class ZLinkChannelDispatchServices {
|
|
|
28
29
|
private readonly registration;
|
|
29
30
|
private readonly providerResolver?;
|
|
30
31
|
private readonly configuredMessageFlowModeCell?;
|
|
32
|
+
private readonly telemetryLease;
|
|
31
33
|
private readonly dispatchErrorReporters;
|
|
32
34
|
private messageFlowModeCellValue?;
|
|
33
35
|
private diagnosticsContextValue?;
|
|
34
36
|
private handlerFiltersValue?;
|
|
35
37
|
private outboundFlowValue?;
|
|
36
38
|
private readonly metricsValue;
|
|
37
|
-
constructor(registration: ZLinkFrameworkRegistration, providerResolver?: ZLinkProviderResolver | undefined, configuredMessageFlowModeCell?: ZLinkMessageFlowModeCell | undefined);
|
|
39
|
+
constructor(registration: ZLinkFrameworkRegistration, providerResolver?: ZLinkProviderResolver | undefined, configuredMessageFlowModeCell?: ZLinkMessageFlowModeCell | undefined, telemetryLease?: ZLinkTelemetryLease);
|
|
38
40
|
metrics(): ZLinkRuntimeMetrics;
|
|
39
41
|
flowCreationEnabled(): boolean;
|
|
40
42
|
dispatchErrorReporter(errorSink: ZLinkRuntimeTaskErrorSink): ZLinkDispatchErrorReporter;
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ZLinkChannelDispatchServices = void 0;
|
|
4
4
|
const diagnostics_1 = require("../diagnostics");
|
|
5
|
+
const message_flow_delivery_1 = require("../diagnostics/message-flow-delivery");
|
|
5
6
|
const dispatch_error_reporter_1 = require("./dispatch-error-reporter");
|
|
6
7
|
const handlers_1 = require("../handlers");
|
|
7
8
|
const handler_instance_scope_1 = require("../handlers/handler-instance-scope");
|
|
@@ -10,16 +11,18 @@ class ZLinkChannelDispatchServices {
|
|
|
10
11
|
registration;
|
|
11
12
|
providerResolver;
|
|
12
13
|
configuredMessageFlowModeCell;
|
|
14
|
+
telemetryLease;
|
|
13
15
|
dispatchErrorReporters = new WeakMap();
|
|
14
16
|
messageFlowModeCellValue;
|
|
15
17
|
diagnosticsContextValue;
|
|
16
18
|
handlerFiltersValue;
|
|
17
19
|
outboundFlowValue;
|
|
18
20
|
metricsValue;
|
|
19
|
-
constructor(registration, providerResolver, configuredMessageFlowModeCell) {
|
|
21
|
+
constructor(registration, providerResolver, configuredMessageFlowModeCell, telemetryLease = (0, message_flow_delivery_1.openTelemetryLease)()) {
|
|
20
22
|
this.registration = registration;
|
|
21
23
|
this.providerResolver = providerResolver;
|
|
22
24
|
this.configuredMessageFlowModeCell = configuredMessageFlowModeCell;
|
|
25
|
+
this.telemetryLease = telemetryLease;
|
|
23
26
|
this.metricsValue = new diagnostics_1.ZLinkRuntimeMetrics(registration.metrics?.meterProvider);
|
|
24
27
|
}
|
|
25
28
|
metrics() {
|
|
@@ -33,7 +36,7 @@ class ZLinkChannelDispatchServices {
|
|
|
33
36
|
if (existing !== undefined) {
|
|
34
37
|
return existing;
|
|
35
38
|
}
|
|
36
|
-
const reporter = new dispatch_error_reporter_1.ZLinkDispatchErrorReporter(
|
|
39
|
+
const reporter = new dispatch_error_reporter_1.ZLinkDispatchErrorReporter(this.diagnosticsContext(), this.metricsValue);
|
|
37
40
|
this.dispatchErrorReporters.set(errorSink, reporter);
|
|
38
41
|
return reporter;
|
|
39
42
|
}
|
|
@@ -167,13 +170,11 @@ class ZLinkChannelDispatchServices {
|
|
|
167
170
|
return this.messageFlowModeCellValue;
|
|
168
171
|
}
|
|
169
172
|
diagnosticsContext() {
|
|
170
|
-
this.diagnosticsContextValue ??= (0, diagnostics_1.createDiagnosticsContext)(this.registration.dispatch, this.providerResolver, this.messageFlowModeCell());
|
|
173
|
+
this.diagnosticsContextValue ??= (0, diagnostics_1.createDiagnosticsContext)(this.registration.dispatch, this.providerResolver, this.messageFlowModeCell(), this.telemetryLease);
|
|
171
174
|
return this.diagnosticsContextValue;
|
|
172
175
|
}
|
|
173
176
|
outboundFlow() {
|
|
174
|
-
this.outboundFlowValue ??= new diagnostics_1.ZLinkMessageFlowTracer(this.diagnosticsContext()
|
|
175
|
-
reportRuntimeTaskException() { }
|
|
176
|
-
});
|
|
177
|
+
this.outboundFlowValue ??= new diagnostics_1.ZLinkMessageFlowTracer(this.diagnosticsContext());
|
|
177
178
|
return this.outboundFlowValue;
|
|
178
179
|
}
|
|
179
180
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { ZLinkHandlerMessageType } from '../../contracts/Common/HandlerMessageType';
|
|
1
2
|
import type { ZLinkMeshDispatchAdmission } from '../admission';
|
|
2
3
|
import type { RoutingId, ZLinkMessageContext, ZLinkHandlerFilter, ZLinkPublishMessageContext, ZLinkRouteMessageContext, ZLinkUnhandledDispatchOptions } from '../../contracts';
|
|
3
4
|
import type { Message } from '../../contracts/Common/Message';
|
|
@@ -8,9 +9,11 @@ import type { ZLinkRuntimeMetrics } from '../diagnostics';
|
|
|
8
9
|
import { type ZLinkChannelEnvelopeCodecRegistry, type ZLinkChannelEnvelopeHeader } from './channel-envelope';
|
|
9
10
|
import { ZLinkDispatchErrorReporter } from './dispatch-error-reporter';
|
|
10
11
|
import { type ZLinkMultipartAsyncSubmitOperation, type ZLinkMultipartOperation, type ZLinkMultipartReplyOperation } from './channel-multipart';
|
|
12
|
+
import { type ZLinkOneWayDispatch, type ZLinkRequestDispatch } from './channel-dispatch-pipeline';
|
|
11
13
|
export interface ZLinkChannelRequestDispatcherOptions {
|
|
12
14
|
readonly meshName?: string;
|
|
13
15
|
readonly channelName: string;
|
|
16
|
+
readonly receivedAtClock?: () => Date;
|
|
14
17
|
/**
|
|
15
18
|
* Mesh channels use the routed message context so a handler can associate
|
|
16
19
|
* a report with the node that sent it.
|
|
@@ -18,8 +21,8 @@ export interface ZLinkChannelRequestDispatcherOptions {
|
|
|
18
21
|
readonly routeMesh?: boolean;
|
|
19
22
|
readonly codecs?: ZLinkChannelEnvelopeCodecRegistry;
|
|
20
23
|
readonly dispatchErrors: ZLinkDispatchErrorReporter;
|
|
21
|
-
readonly handlers: ReadonlyMap<string,
|
|
22
|
-
readonly sendHandlers?: ReadonlyMap<string,
|
|
24
|
+
readonly handlers: ReadonlyMap<string, Pick<ZLinkRequestDispatch<ZLinkMessageContext>, 'handler' | 'messageType'>>;
|
|
25
|
+
readonly sendHandlers?: ReadonlyMap<string, Pick<ZLinkOneWayDispatch<ZLinkMessageContext>, 'handler' | 'messageType'>>;
|
|
23
26
|
readonly filters?: readonly ZLinkHandlerFilter[];
|
|
24
27
|
readonly unhandled?: ZLinkUnhandledDispatchOptions;
|
|
25
28
|
}
|
|
@@ -30,6 +33,7 @@ export interface ZLinkChannelSendHandler {
|
|
|
30
33
|
handle(payload: unknown, context: ZLinkMessageContext): Promise<void> | void;
|
|
31
34
|
}
|
|
32
35
|
export interface ZLinkRouteHandlerRegistration {
|
|
36
|
+
readonly messageType?: ZLinkHandlerMessageType;
|
|
33
37
|
readonly kind: 'send' | 'request';
|
|
34
38
|
readonly packetName: string;
|
|
35
39
|
readonly handler: ZLinkRouteRuntimeSendHandler | ZLinkRouteRuntimeRequestHandler;
|
|
@@ -54,7 +58,7 @@ export declare class ZLinkChannelRequestDispatcher {
|
|
|
54
58
|
send?: () => ZLinkMultipartOperation<ZLinkMultipartAsyncSubmitOperation>;
|
|
55
59
|
}, router: {
|
|
56
60
|
reply(routingId: unknown, replyToken: unknown): ZLinkMultipartReplyOperation;
|
|
57
|
-
}, signal?: AbortSignal, decodedHeader?: ZLinkChannelEnvelopeHeader): Promise<boolean | void>;
|
|
61
|
+
}, signal?: AbortSignal, decodedHeader?: ZLinkChannelEnvelopeHeader, receivedAt?: Date): Promise<boolean | void>;
|
|
58
62
|
dispatchMesh(record: ReceiveRecord, signal?: AbortSignal, admit?: ZLinkMeshDispatchAdmission): void | Promise<void>;
|
|
59
63
|
private submitReply;
|
|
60
64
|
private createMeshContext;
|
|
@@ -62,9 +66,10 @@ export declare class ZLinkChannelRequestDispatcher {
|
|
|
62
66
|
export interface ZLinkChannelPublishDispatcherOptions {
|
|
63
67
|
readonly meshName?: string;
|
|
64
68
|
readonly channelName: string;
|
|
69
|
+
readonly receivedAtClock?: () => Date;
|
|
65
70
|
readonly codecs?: ZLinkChannelEnvelopeCodecRegistry;
|
|
66
71
|
readonly dispatchErrors: ZLinkDispatchErrorReporter;
|
|
67
|
-
readonly handlers: ReadonlyMap<string,
|
|
72
|
+
readonly handlers: ReadonlyMap<string, Pick<ZLinkOneWayDispatch<ZLinkPublishMessageContext>, 'handler' | 'messageType'>>;
|
|
68
73
|
readonly filters?: readonly ZLinkHandlerFilter[];
|
|
69
74
|
readonly unhandled?: ZLinkUnhandledDispatchOptions;
|
|
70
75
|
readonly metrics?: ZLinkRuntimeMetrics;
|
|
@@ -79,10 +84,11 @@ export declare class ZLinkChannelPublishDispatcher {
|
|
|
79
84
|
dispatch(topicMessage: {
|
|
80
85
|
readonly topic: string;
|
|
81
86
|
readonly parts: readonly Message[];
|
|
82
|
-
}, signal?: AbortSignal, decodedHeader?: ZLinkChannelEnvelopeHeader): Promise<void>;
|
|
87
|
+
}, signal?: AbortSignal, decodedHeader?: ZLinkChannelEnvelopeHeader, receivedAt?: Date): Promise<void>;
|
|
83
88
|
}
|
|
84
89
|
export interface ZLinkRoutePacketDispatcherOptions {
|
|
85
90
|
readonly routerChannelId: string;
|
|
91
|
+
readonly receivedAtClock?: () => Date;
|
|
86
92
|
readonly codecs?: ZLinkChannelEnvelopeCodecRegistry;
|
|
87
93
|
readonly dispatchErrors: ZLinkDispatchErrorReporter;
|
|
88
94
|
readonly handlers: readonly ZLinkRouteHandlerRegistration[];
|
|
@@ -95,6 +101,7 @@ export declare class ZLinkRoutePacketDispatcher {
|
|
|
95
101
|
private readonly sendHandlers;
|
|
96
102
|
private readonly requestHandlers;
|
|
97
103
|
private readonly codecs?;
|
|
104
|
+
private readonly receivedAtClock;
|
|
98
105
|
private readonly pipeline;
|
|
99
106
|
constructor(options: ZLinkRoutePacketDispatcherOptions);
|
|
100
107
|
private readonly routerChannelId;
|
|
@@ -117,7 +124,7 @@ export declare class ZLinkRoutePacketDispatcher {
|
|
|
117
124
|
send?: () => ZLinkMultipartOperation<ZLinkMultipartAsyncSubmitOperation>;
|
|
118
125
|
}, router: {
|
|
119
126
|
reply(routingId: unknown, replyToken: unknown): ZLinkMultipartReplyOperation;
|
|
120
|
-
}, signal?: AbortSignal, decodedHeader?: ZLinkChannelEnvelopeHeader, infrastructureChecked?: boolean): Promise<boolean | void>;
|
|
127
|
+
}, signal?: AbortSignal, decodedHeader?: ZLinkChannelEnvelopeHeader, infrastructureChecked?: boolean, receivedAt?: Date): Promise<boolean | void>;
|
|
121
128
|
dispatchMesh(record: ReceiveRecord, signal?: AbortSignal, admit?: ZLinkMeshDispatchAdmission): void | Promise<void>;
|
|
122
129
|
dispatchLocalCommand(parts: readonly Message[], sourceNodeRid: RoutingId, signal?: AbortSignal): Promise<void>;
|
|
123
130
|
private dispatchMeshCommand;
|