@zlink-systems/framework 0.30.0 → 0.30.2
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/LICENSE +150 -68
- package/dist/.tsbuildinfo +1 -1
- package/dist/contracts/Actors/ZLinkActorClient.d.ts +2 -1
- package/dist/contracts/Channels/Calls.d.ts +2 -1
- package/dist/contracts/Common/ZLinkEncodedPayload.d.ts +6 -0
- package/dist/contracts/Common/ZLinkEncodedPayload.js +18 -3
- package/dist/contracts/Common/ZLinkMessageMetadata.js +11 -5
- package/dist/contracts/Common/encoded-payload-storage.d.ts +1 -1
- package/dist/contracts/Common/encoded-payload-storage.js +5 -2
- package/dist/contracts/Configuration/Builders.d.ts +1 -1
- package/dist/contracts/Configuration/RegistrationBuilderPolicy.d.ts +2 -1
- package/dist/contracts/Configuration/RegistrationBuilderPolicy.js +5 -1
- package/dist/contracts/Configuration/RegistrationBuilders.js +2 -2
- package/dist/contracts/Configuration/RegistrationTypes.d.ts +1 -0
- package/dist/contracts/Dispatch/ZLinkDispatchOptions.d.ts +2 -2
- package/dist/contracts/Handlers/Attributes.d.ts +5 -13
- package/dist/contracts/Handlers/Attributes.js +7 -11
- package/dist/contracts/Handlers/JsonContract.d.ts +2 -46
- package/dist/contracts/Handlers/JsonContract.js +4 -153
- package/dist/contracts/Locations/Rows.d.ts +2 -0
- package/dist/contracts/Spots/Contracts.d.ts +6 -1
- package/dist/contracts/Spots/ZLinkSpot.d.ts +3 -3
- package/dist/nest-integration.d.ts +1 -1
- package/dist/nest-integration.js +2 -1
- package/dist/runtime/abort.d.ts +5 -0
- package/dist/runtime/abort.js +10 -0
- package/dist/runtime/actors/actor-authority-publication.js +3 -2
- package/dist/runtime/actors/actor-client.d.ts +1 -2
- package/dist/runtime/actors/actor-client.js +52 -57
- package/dist/runtime/actors/actor-context.d.ts +2 -0
- package/dist/runtime/actors/actor-context.js +46 -9
- package/dist/runtime/actors/actor-handoff.d.ts +8 -4
- package/dist/runtime/actors/actor-handoff.js +219 -92
- package/dist/runtime/actors/actor-join-relocation.d.ts +3 -0
- package/dist/runtime/actors/actor-local-native-join.js +13 -12
- package/dist/runtime/actors/actor-mailbox.js +27 -1
- package/dist/runtime/actors/actor-remote-joiner.js +3 -1
- package/dist/runtime/actors/actor-remote-wire.js +15 -0
- package/dist/runtime/actors/actor-reply.d.ts +4 -0
- package/dist/runtime/actors/actor-reply.js +29 -0
- package/dist/runtime/actors/actor-routed-join-transport.d.ts +6 -2
- package/dist/runtime/actors/actor-routed-json-request.d.ts +2 -0
- package/dist/runtime/actors/actor-runtime-contracts.d.ts +2 -0
- package/dist/runtime/actors/actor-runtime-state.js +2 -20
- package/dist/runtime/actors/actor-source-transfer.d.ts +1 -17
- package/dist/runtime/actors/index.d.ts +8 -3
- package/dist/runtime/actors/index.js +55 -27
- package/dist/runtime/actors/session-disconnected-wire.d.ts +8 -0
- package/dist/runtime/actors/session-disconnected-wire.js +48 -0
- package/dist/runtime/actors/spot-actor-dispatch.js +2 -2
- package/dist/runtime/admission.d.ts +9 -1
- package/dist/runtime/admission.js +56 -23
- package/dist/runtime/application-jobs/application-ingress-record-owner.d.ts +6 -8
- package/dist/runtime/application-jobs/application-ingress-record-owner.js +39 -22
- package/dist/runtime/application-jobs/application-job-queue-scope.d.ts +15 -1
- package/dist/runtime/application-jobs/application-job-queue-scope.js +61 -20
- package/dist/runtime/application-jobs/contracts.d.ts +12 -1
- package/dist/runtime/backend/contracts/index.d.ts +37 -12
- package/dist/runtime/backend/mesh-actor-session-node-adapter.js +2 -2
- package/dist/runtime/backend/mesh-completion-table.d.ts +9 -1
- package/dist/runtime/backend/mesh-completion-table.js +154 -49
- package/dist/runtime/backend/mesh-dispatch-pump.d.ts +28 -1
- package/dist/runtime/backend/mesh-dispatch-pump.js +208 -101
- package/dist/runtime/backend/node/node-backend-adapter-support.d.ts +2 -2
- package/dist/runtime/backend/node/node-backend-adapter-support.js +16 -9
- package/dist/runtime/backend/node/node-dealer-channel-client-transport.d.ts +1 -1
- package/dist/runtime/backend/node/node-dealer-channel-client-transport.js +5 -2
- package/dist/runtime/backend/node/node-raw-binding-port.js +124 -72
- package/dist/runtime/backend/node/node-raw-mesh-backend.d.ts +46 -13
- package/dist/runtime/backend/node/node-raw-mesh-backend.js +181 -164
- package/dist/runtime/backend/node/node-socket-backend-adapter.d.ts +1 -1
- package/dist/runtime/backend/node/node-socket-backend-adapter.js +11 -11
- package/dist/runtime/backend/raw-binding-port.d.ts +2 -2
- package/dist/runtime/backend/runtime-message.d.ts +1 -0
- package/dist/runtime/backend/runtime-message.js +5 -0
- package/dist/runtime/backend/runtime-values.d.ts +1 -0
- package/dist/runtime/backend/runtime-values.js +2 -1
- package/dist/runtime/channels/channel-clients.d.ts +2 -0
- package/dist/runtime/channels/channel-clients.js +75 -23
- package/dist/runtime/channels/channel-dispatch-pipeline.d.ts +25 -5
- package/dist/runtime/channels/channel-dispatch-pipeline.js +111 -56
- package/dist/runtime/channels/channel-dispatch-services.d.ts +1 -0
- package/dist/runtime/channels/channel-dispatch-services.js +45 -0
- package/dist/runtime/channels/channel-dispatchers.d.ts +4 -3
- package/dist/runtime/channels/channel-dispatchers.js +62 -54
- package/dist/runtime/channels/channel-envelope-inspection.d.ts +1 -2
- package/dist/runtime/channels/channel-envelope-inspection.js +1 -16
- package/dist/runtime/channels/channel-envelope.d.ts +2 -0
- package/dist/runtime/channels/channel-envelope.js +146 -28
- package/dist/runtime/channels/channel-outbound-operations.d.ts +2 -2
- package/dist/runtime/channels/channel-outbound-operations.js +8 -8
- package/dist/runtime/channels/channel-runtime-lifecycle.d.ts +4 -3
- package/dist/runtime/channels/channel-runtime-lifecycle.js +19 -24
- package/dist/runtime/channels/channel-runtime-manager.d.ts +9 -8
- package/dist/runtime/channels/channel-runtime-manager.js +16 -16
- package/dist/runtime/channels/channel-transports.d.ts +18 -16
- package/dist/runtime/channels/channel-transports.js +77 -58
- package/dist/runtime/channels/client-server-location-runtime.js +5 -4
- package/dist/runtime/channels/dispatch-error-reporter.d.ts +2 -1
- package/dist/runtime/channels/dispatch-error-reporter.js +2 -1
- package/dist/runtime/channels/fanout-location-runtime.d.ts +1 -1
- package/dist/runtime/channels/fanout-location-runtime.js +3 -3
- package/dist/runtime/channels/local-spot-route-transport.d.ts +1 -1
- package/dist/runtime/channels/local-spot-route-transport.js +2 -1
- package/dist/runtime/channels/router-socket-spot-route-transport.d.ts +2 -2
- package/dist/runtime/channels/router-socket-spot-route-transport.js +4 -4
- package/dist/runtime/channels/source-spot-router.d.ts +2 -2
- package/dist/runtime/channels/source-spot-router.js +4 -4
- package/dist/runtime/channels/spot-node-route-transport.d.ts +2 -2
- package/dist/runtime/channels/spot-node-route-transport.js +4 -4
- package/dist/runtime/channels/spot-route-bridge-transport.d.ts +2 -2
- package/dist/runtime/channels/spot-route-bridge-transport.js +4 -4
- package/dist/runtime/channels/spot-route-dispatch-strategy.d.ts +5 -4
- package/dist/runtime/channels/spot-route-dispatch-strategy.js +18 -18
- package/dist/runtime/diagnostics/flow-context.js +19 -7
- package/dist/runtime/diagnostics/index.js +4 -9
- package/dist/runtime/diagnostics/message-flow.d.ts +8 -0
- package/dist/runtime/diagnostics/message-flow.js +35 -5
- package/dist/runtime/diagnostics/runtime-metrics.d.ts +2 -2
- package/dist/runtime/diagnostics/runtime-metrics.js +10 -8
- package/dist/runtime/execution/index.d.ts +4 -2
- package/dist/runtime/execution/index.js +33 -10
- package/dist/runtime/execution/serial-execution-queue.d.ts +5 -0
- package/dist/runtime/execution/serial-execution-queue.js +22 -2
- package/dist/runtime/execution/state-lane.d.ts +2 -0
- package/dist/runtime/execution/state-lane.js +5 -0
- package/dist/runtime/foundation/actor-join-recovery-codec.js +2 -2
- package/dist/runtime/foundation/durable-service-request.d.ts +14 -0
- package/dist/runtime/foundation/durable-service-request.js +98 -0
- package/dist/runtime/foundation/operation-identity.d.ts +1 -0
- package/dist/runtime/foundation/operation-identity.js +5 -1
- package/dist/runtime/foundation/operation-registry.d.ts +25 -1
- package/dist/runtime/foundation/operation-registry.js +86 -18
- package/dist/runtime/foundation/raw-service-mesh-runtime.d.ts +61 -8
- package/dist/runtime/foundation/raw-service-mesh-runtime.js +486 -266
- package/dist/runtime/foundation/service-liveness-registry.d.ts +12 -1
- package/dist/runtime/foundation/service-liveness-registry.js +38 -0
- package/dist/runtime/foundation/service-mailbox.d.ts +7 -0
- package/dist/runtime/foundation/service-maintenance-runtime.js +1 -6
- package/dist/runtime/foundation/service-relocation-object-owner.d.ts +3 -3
- package/dist/runtime/foundation/service-relocation-object-owner.js +48 -34
- package/dist/runtime/foundation/service-relocation-runtime.d.ts +2 -0
- package/dist/runtime/foundation/service-relocation-runtime.js +20 -4
- package/dist/runtime/foundation/service-runtime-contracts.d.ts +10 -1
- package/dist/runtime/foundation/service-session-binding-ingress-port.d.ts +2 -1
- package/dist/runtime/foundation/service-stateful-registry.d.ts +5 -4
- package/dist/runtime/foundation/service-stateful-registry.js +24 -26
- package/dist/runtime/foundation/service-stateful-runtime.d.ts +75 -9
- package/dist/runtime/foundation/service-stateful-runtime.js +486 -218
- package/dist/runtime/foundation/service-stateful-wire-codec.d.ts +14 -6
- package/dist/runtime/foundation/service-stateful-wire-codec.js +48 -27
- package/dist/runtime/foundation/service-topology-registry.d.ts +12 -2
- package/dist/runtime/foundation/service-topology-registry.js +61 -27
- package/dist/runtime/foundation/service-wire-binary-primitives.d.ts +6 -1
- package/dist/runtime/foundation/service-wire-binary-primitives.js +27 -11
- package/dist/runtime/foundation/service-wire-constants.generated.d.ts +1 -0
- package/dist/runtime/foundation/service-wire-constants.generated.js +1 -0
- package/dist/runtime/foundation/service-wire-m6a-codec.d.ts +13 -3
- package/dist/runtime/foundation/service-wire-m6a-codec.js +189 -78
- package/dist/runtime/handlers/handler-instance-scope.d.ts +8 -0
- package/dist/runtime/handlers/handler-instance-scope.js +54 -11
- package/dist/runtime/host/actor-packet-relay.d.ts +6 -4
- package/dist/runtime/host/actor-packet-relay.js +59 -72
- package/dist/runtime/host/actor-placement-coordinator.js +25 -8
- package/dist/runtime/host/actor-runtime-options-factory.js +2 -2
- package/dist/runtime/host/actor-transfer-runtime.d.ts +7 -31
- package/dist/runtime/host/actor-transfer-runtime.js +85 -331
- package/dist/runtime/host/application-job-queue.d.ts +40 -7
- package/dist/runtime/host/application-job-queue.js +137 -42
- package/dist/runtime/host/entry-actor-runtime.d.ts +1 -0
- package/dist/runtime/host/entry-actor-runtime.js +3 -0
- package/dist/runtime/host/index.d.ts +12 -2
- package/dist/runtime/host/index.js +300 -202
- package/dist/runtime/host/location-runtime-owner.js +2 -6
- package/dist/runtime/host/mesh-router-resolver.d.ts +4 -0
- package/dist/runtime/host/mesh-router-resolver.js +14 -6
- package/dist/runtime/host/remote-bound-session-relay.d.ts +2 -4
- package/dist/runtime/host/remote-bound-session-relay.js +73 -208
- package/dist/runtime/host/route-mesh-runtime.d.ts +2 -2
- package/dist/runtime/host/route-mesh-runtime.js +6 -4
- package/dist/runtime/host/runtime-shutdown.d.ts +1 -0
- package/dist/runtime/host/runtime-shutdown.js +3 -2
- package/dist/runtime/host/service-relocation-control.d.ts +1 -0
- package/dist/runtime/host/service-relocation-control.js +10 -4
- package/dist/runtime/host/service-relocation-host-runtime.d.ts +22 -14
- package/dist/runtime/host/service-relocation-host-runtime.js +754 -599
- package/dist/runtime/host/spot-address-transport.js +3 -2
- package/dist/runtime/host/spot-runtime-options-factory.js +16 -7
- package/dist/runtime/host/user-spot-creation-coordinator.js +33 -84
- package/dist/runtime/locations/actor-location-claims.d.ts +2 -2
- package/dist/runtime/locations/actor-location-claims.js +34 -19
- package/dist/runtime/locations/auto-connect-loop.d.ts +2 -0
- package/dist/runtime/locations/auto-connect-loop.js +22 -14
- package/dist/runtime/locations/auto-connect-reconciler.js +0 -6
- package/dist/runtime/locations/auto-connect-types.d.ts +0 -1
- package/dist/runtime/locations/descriptor-publication.d.ts +4 -0
- package/dist/runtime/locations/descriptor-publication.js +11 -0
- package/dist/runtime/locations/domain-store-contract.d.ts +1 -0
- package/dist/runtime/locations/in-memory-authority-store.d.ts +7 -1
- package/dist/runtime/locations/in-memory-authority-store.js +56 -19
- package/dist/runtime/locations/in-memory-location-store.js +1 -10
- package/dist/runtime/locations/index.d.ts +1 -0
- package/dist/runtime/locations/index.js +1 -0
- package/dist/runtime/locations/lease-tracker.js +1 -6
- package/dist/runtime/locations/lifecycle.d.ts +1 -2
- package/dist/runtime/locations/lifecycle.js +2 -5
- package/dist/runtime/locations/location-store-repository.d.ts +51 -1
- package/dist/runtime/locations/location-store-repository.js +363 -139
- package/dist/runtime/locations/relocation-blob.d.ts +18 -1
- package/dist/runtime/locations/relocation-blob.js +52 -1
- package/dist/runtime/locations/request-source-resolver.d.ts +37 -0
- package/dist/runtime/locations/request-source-resolver.js +80 -0
- package/dist/runtime/locations/resolvers.js +1 -1
- package/dist/runtime/locations/runtime.d.ts +7 -3
- package/dist/runtime/locations/runtime.js +61 -53
- package/dist/runtime/messaging/framework-json-v1.d.ts +4 -6
- package/dist/runtime/messaging/framework-json-v1.js +38 -294
- package/dist/runtime/messaging/packet-name.d.ts +1 -1
- package/dist/runtime/messaging/packet-name.js +8 -24
- package/dist/runtime/messaging/payload-codec.d.ts +7 -1
- package/dist/runtime/messaging/payload-codec.js +7 -6
- package/dist/runtime/messaging/request-result.d.ts +2 -0
- package/dist/runtime/messaging/request-result.js +57 -0
- package/dist/runtime/messaging/submission-result.d.ts +1 -0
- package/dist/runtime/messaging/submission-result.js +5 -2
- package/dist/runtime/protocol/service_wire_codec.generated.d.ts +34 -1
- package/dist/runtime/protocol/service_wire_codec.generated.js +229 -0
- package/dist/runtime/protocol/service_wire_pilot_codec.generated.d.ts +16 -1
- package/dist/runtime/protocol/service_wire_pilot_codec.generated.js +37 -8
- package/dist/runtime/spots/formal-remote-actor-admission-registry.d.ts +7 -2
- package/dist/runtime/spots/formal-remote-actor-admission-registry.js +36 -21
- package/dist/runtime/spots/index.d.ts +21 -11
- package/dist/runtime/spots/index.js +243 -178
- package/dist/runtime/spots/spot-activation-registry.d.ts +4 -2
- package/dist/runtime/spots/spot-activation-registry.js +21 -11
- package/dist/runtime/spots/spot-activation-state.d.ts +1 -1
- package/dist/runtime/spots/spot-activation-state.js +7 -7
- package/dist/runtime/spots/spot-activation.d.ts +7 -3
- package/dist/runtime/spots/spot-activation.js +140 -52
- package/dist/runtime/spots/spot-actor-admission-coordinator.d.ts +1 -0
- package/dist/runtime/spots/spot-actor-admission-coordinator.js +13 -22
- package/dist/runtime/spots/spot-actor-membership.d.ts +0 -1
- package/dist/runtime/spots/spot-actor-membership.js +0 -8
- package/dist/runtime/spots/spot-actor-packet-dispatch.js +33 -8
- package/dist/runtime/spots/spot-actor-packet-drain.js +5 -33
- package/dist/runtime/spots/spot-entry-activation.d.ts +2 -0
- package/dist/runtime/spots/spot-entry-activation.js +20 -11
- package/dist/runtime/spots/spot-handler-registry.d.ts +7 -4
- package/dist/runtime/spots/spot-handler-registry.js +24 -10
- package/dist/runtime/spots/spot-manager-internal-contracts.d.ts +2 -2
- package/dist/runtime/spots/spot-manager-public.js +2 -2
- package/dist/runtime/spots/spot-node-autoconnect.d.ts +2 -1
- package/dist/runtime/spots/spot-node-autoconnect.js +22 -42
- package/dist/runtime/spots/spot-node-runtime-manager.d.ts +19 -2
- package/dist/runtime/spots/spot-node-runtime-manager.js +115 -50
- package/dist/runtime/spots/spot-outbound.d.ts +3 -0
- package/dist/runtime/spots/spot-outbound.js +27 -18
- package/dist/runtime/spots/spot-remote-codec.js +5 -1
- package/dist/runtime/spots/spot-routed-spot-packet-dispatch.d.ts +1 -0
- package/dist/runtime/spots/spot-routed-spot-packet-dispatch.js +1 -1
- package/dist/runtime/spots/spot-runtime-ports.d.ts +1 -1
- package/dist/runtime/spots/spot-serial-executor.d.ts +10 -0
- package/dist/runtime/spots/spot-serial-executor.js +61 -8
- package/dist/runtime/spots/spot-serial-turn-executor.js +19 -2
- package/dist/runtime/spots/spot-subscription-dispatch.js +1 -4
- package/dist/runtime/spots/spot-timer.d.ts +57 -5
- package/dist/runtime/spots/spot-timer.js +288 -103
- package/dist/runtime/streams/actor-session-binding-registry.d.ts +42 -11
- package/dist/runtime/streams/actor-session-binding-registry.js +165 -48
- package/dist/runtime/streams/actor-session-binding-runtime-owner.d.ts +8 -4
- package/dist/runtime/streams/bound-actor-relay-sender.d.ts +2 -1
- package/dist/runtime/streams/bound-actor-relay-sender.js +15 -8
- package/dist/runtime/streams/bound-session-service.d.ts +1 -1
- package/dist/runtime/streams/bound-session-service.js +6 -11
- package/dist/runtime/streams/index.d.ts +3 -2
- package/dist/runtime/streams/index.js +6 -4
- package/dist/runtime/streams/managed-stream.js +3 -2
- package/dist/runtime/streams/native-fallback-bound-session.js +8 -73
- package/dist/runtime/streams/session-actor-coordinator.d.ts +2 -8
- package/dist/runtime/streams/session-actor-coordinator.js +15 -32
- package/dist/runtime/streams/stream-binding-runtime-ports.d.ts +3 -10
- package/dist/runtime/streams/stream-session-runtime.d.ts +1 -1
- package/dist/runtime/streams/stream-session-runtime.js +14 -31
- package/dist/runtime/workers/index.js +1 -1
- package/package.json +3 -3
- package/src/contracts/Actors/ZLinkActorClient.ts +2 -1
- package/src/contracts/Channels/Calls.ts +2 -1
- package/src/contracts/Common/ZLinkEncodedPayload.ts +24 -4
- package/src/contracts/Common/ZLinkMessageMetadata.ts +13 -8
- package/src/contracts/Common/encoded-payload-storage.ts +6 -3
- package/src/contracts/Configuration/Builders.ts +4 -1
- package/src/contracts/Configuration/RegistrationBuilderPolicy.ts +7 -2
- package/src/contracts/Configuration/RegistrationBuilders.ts +6 -2
- package/src/contracts/Configuration/RegistrationTypes.ts +1 -0
- package/src/contracts/Dispatch/ZLinkDispatchOptions.ts +2 -1
- package/src/contracts/Handlers/Attributes.ts +14 -21
- package/src/contracts/Handlers/JsonContract.ts +8 -216
- package/src/contracts/Locations/Rows.ts +2 -0
- package/src/contracts/Spots/Contracts.ts +10 -1
- package/src/contracts/Spots/ZLinkSpot.ts +3 -3
- package/src/nest-integration.ts +1 -0
- package/src/runtime/abort.ts +12 -0
- package/src/runtime/actors/actor-authority-publication.ts +3 -2
- package/src/runtime/actors/actor-client.ts +100 -85
- package/src/runtime/actors/actor-context.ts +49 -9
- package/src/runtime/actors/actor-handoff.ts +291 -110
- package/src/runtime/actors/actor-join-relocation.ts +3 -0
- package/src/runtime/actors/actor-local-native-join.ts +21 -26
- package/src/runtime/actors/actor-mailbox.ts +40 -2
- package/src/runtime/actors/actor-remote-joiner.ts +6 -1
- package/src/runtime/actors/actor-remote-wire.ts +17 -0
- package/src/runtime/actors/actor-reply.ts +42 -0
- package/src/runtime/actors/actor-routed-join-transport.ts +14 -4
- package/src/runtime/actors/actor-routed-json-request.ts +10 -2
- package/src/runtime/actors/actor-runtime-contracts.ts +2 -0
- package/src/runtime/actors/actor-runtime-state.ts +2 -20
- package/src/runtime/actors/actor-source-transfer.ts +1 -34
- package/src/runtime/actors/index.ts +60 -32
- package/src/runtime/actors/session-disconnected-wire.ts +66 -0
- package/src/runtime/actors/spot-actor-dispatch.ts +4 -2
- package/src/runtime/admission.ts +69 -21
- package/src/runtime/application-jobs/application-ingress-record-owner.ts +41 -25
- package/src/runtime/application-jobs/application-job-queue-scope.ts +83 -22
- package/src/runtime/application-jobs/contracts.ts +16 -1
- package/src/runtime/backend/contracts/index.ts +92 -18
- package/src/runtime/backend/mesh-actor-session-node-adapter.ts +5 -3
- package/src/runtime/backend/mesh-completion-table.ts +160 -57
- package/src/runtime/backend/mesh-dispatch-pump.ts +237 -108
- package/src/runtime/backend/node/node-backend-adapter-support.ts +17 -8
- package/src/runtime/backend/node/node-dealer-channel-client-transport.ts +12 -2
- package/src/runtime/backend/node/node-raw-binding-port.ts +148 -85
- package/src/runtime/backend/node/node-raw-mesh-backend.ts +315 -201
- package/src/runtime/backend/node/node-socket-backend-adapter.ts +26 -11
- package/src/runtime/backend/raw-binding-port.ts +7 -2
- package/src/runtime/backend/runtime-message.ts +6 -0
- package/src/runtime/backend/runtime-values.ts +1 -0
- package/src/runtime/channels/channel-clients.ts +132 -58
- package/src/runtime/channels/channel-dispatch-pipeline.ts +198 -114
- package/src/runtime/channels/channel-dispatch-services.ts +69 -1
- package/src/runtime/channels/channel-dispatchers.ts +136 -90
- package/src/runtime/channels/channel-envelope-inspection.ts +2 -16
- package/src/runtime/channels/channel-envelope.ts +225 -31
- package/src/runtime/channels/channel-outbound-operations.ts +22 -8
- package/src/runtime/channels/channel-runtime-lifecycle.ts +13 -13
- package/src/runtime/channels/channel-runtime-manager.ts +41 -17
- package/src/runtime/channels/channel-transports.ts +171 -112
- package/src/runtime/channels/client-server-location-runtime.ts +11 -10
- package/src/runtime/channels/dispatch-error-reporter.ts +4 -2
- package/src/runtime/channels/fanout-location-runtime.ts +17 -9
- package/src/runtime/channels/local-spot-route-transport.ts +3 -1
- package/src/runtime/channels/router-socket-spot-route-transport.ts +13 -4
- package/src/runtime/channels/source-spot-router.ts +8 -4
- package/src/runtime/channels/spot-node-route-transport.ts +8 -4
- package/src/runtime/channels/spot-route-bridge-transport.ts +6 -4
- package/src/runtime/channels/spot-route-dispatch-strategy.ts +47 -18
- package/src/runtime/diagnostics/flow-context.ts +20 -7
- package/src/runtime/diagnostics/index.ts +1 -7
- package/src/runtime/diagnostics/message-flow.ts +47 -9
- package/src/runtime/diagnostics/runtime-metrics.ts +12 -10
- package/src/runtime/execution/index.ts +40 -14
- package/src/runtime/execution/serial-execution-queue.ts +33 -4
- package/src/runtime/execution/state-lane.ts +7 -0
- package/src/runtime/foundation/actor-join-recovery-codec.ts +2 -2
- package/src/runtime/foundation/durable-service-request.ts +137 -0
- package/src/runtime/foundation/operation-identity.ts +5 -1
- package/src/runtime/foundation/operation-registry.ts +98 -20
- package/src/runtime/foundation/raw-service-mesh-runtime.ts +704 -336
- package/src/runtime/foundation/service-liveness-registry.ts +39 -0
- package/src/runtime/foundation/service-mailbox.ts +8 -0
- package/src/runtime/foundation/service-maintenance-runtime.ts +1 -8
- package/src/runtime/foundation/service-relocation-object-owner.ts +55 -36
- package/src/runtime/foundation/service-relocation-runtime.ts +25 -4
- package/src/runtime/foundation/service-runtime-contracts.ts +19 -2
- package/src/runtime/foundation/service-session-binding-ingress-port.ts +2 -1
- package/src/runtime/foundation/service-stateful-registry.ts +38 -35
- package/src/runtime/foundation/service-stateful-runtime.ts +732 -275
- package/src/runtime/foundation/service-stateful-wire-codec.ts +49 -16
- package/src/runtime/foundation/service-topology-registry.ts +91 -36
- package/src/runtime/foundation/service-wire-binary-primitives.ts +35 -12
- package/src/runtime/foundation/service-wire-constants.generated.ts +1 -0
- package/src/runtime/foundation/service-wire-m6a-codec.ts +231 -76
- package/src/runtime/handlers/handler-instance-scope.ts +67 -16
- package/src/runtime/host/actor-packet-relay.ts +113 -94
- package/src/runtime/host/actor-placement-coordinator.ts +31 -8
- package/src/runtime/host/actor-runtime-options-factory.ts +13 -2
- package/src/runtime/host/actor-transfer-runtime.ts +104 -430
- package/src/runtime/host/application-job-queue.ts +160 -41
- package/src/runtime/host/entry-actor-runtime.ts +4 -0
- package/src/runtime/host/index.ts +473 -271
- package/src/runtime/host/location-runtime-owner.ts +2 -6
- package/src/runtime/host/mesh-router-resolver.ts +13 -5
- package/src/runtime/host/remote-bound-session-relay.ts +88 -271
- package/src/runtime/host/route-mesh-runtime.ts +12 -6
- package/src/runtime/host/runtime-shutdown.ts +15 -4
- package/src/runtime/host/service-relocation-control.ts +11 -5
- package/src/runtime/host/service-relocation-host-runtime.ts +1092 -759
- package/src/runtime/host/spot-address-transport.ts +4 -2
- package/src/runtime/host/spot-runtime-options-factory.ts +20 -7
- package/src/runtime/host/user-spot-creation-coordinator.ts +41 -100
- package/src/runtime/locations/actor-location-claims.ts +52 -30
- package/src/runtime/locations/auto-connect-loop.ts +22 -14
- package/src/runtime/locations/auto-connect-reconciler.ts +0 -6
- package/src/runtime/locations/auto-connect-types.ts +0 -1
- package/src/runtime/locations/descriptor-publication.ts +7 -0
- package/src/runtime/locations/domain-store-contract.ts +5 -0
- package/src/runtime/locations/in-memory-authority-store.ts +85 -23
- package/src/runtime/locations/in-memory-location-store.ts +1 -12
- package/src/runtime/locations/index.ts +1 -0
- package/src/runtime/locations/lease-tracker.ts +2 -9
- package/src/runtime/locations/lifecycle.ts +8 -26
- package/src/runtime/locations/location-store-repository.ts +628 -152
- package/src/runtime/locations/relocation-blob.ts +75 -1
- package/src/runtime/locations/request-source-resolver.ts +138 -0
- package/src/runtime/locations/resolvers.ts +2 -2
- package/src/runtime/locations/runtime.ts +98 -64
- package/src/runtime/messaging/framework-json-v1.ts +5 -325
- package/src/runtime/messaging/packet-name.ts +5 -25
- package/src/runtime/messaging/payload-codec.ts +8 -11
- package/src/runtime/messaging/request-result.ts +62 -0
- package/src/runtime/messaging/submission-result.ts +5 -1
- package/src/runtime/protocol/service_wire_codec.generated.ts +218 -5
- package/src/runtime/protocol/service_wire_pilot_codec.generated.ts +16 -13
- package/src/runtime/spots/formal-remote-actor-admission-registry.ts +46 -25
- package/src/runtime/spots/index.ts +389 -283
- package/src/runtime/spots/spot-activation-registry.ts +25 -13
- package/src/runtime/spots/spot-activation-state.ts +12 -19
- package/src/runtime/spots/spot-activation.ts +198 -96
- package/src/runtime/spots/spot-actor-admission-coordinator.ts +25 -55
- package/src/runtime/spots/spot-actor-membership.ts +0 -15
- package/src/runtime/spots/spot-actor-packet-dispatch.ts +56 -11
- package/src/runtime/spots/spot-actor-packet-drain.ts +9 -52
- package/src/runtime/spots/spot-entry-activation.ts +33 -21
- package/src/runtime/spots/spot-handler-registry.ts +56 -12
- package/src/runtime/spots/spot-manager-internal-contracts.ts +2 -2
- package/src/runtime/spots/spot-manager-public.ts +2 -2
- package/src/runtime/spots/spot-node-autoconnect.ts +28 -47
- package/src/runtime/spots/spot-node-runtime-manager.ts +197 -67
- package/src/runtime/spots/spot-outbound.ts +39 -19
- package/src/runtime/spots/spot-remote-codec.ts +9 -2
- package/src/runtime/spots/spot-routed-spot-packet-dispatch.ts +2 -1
- package/src/runtime/spots/spot-runtime-ports.ts +1 -1
- package/src/runtime/spots/spot-serial-executor.ts +97 -25
- package/src/runtime/spots/spot-serial-turn-executor.ts +22 -3
- package/src/runtime/spots/spot-subscription-dispatch.ts +1 -4
- package/src/runtime/spots/spot-timer.ts +418 -158
- package/src/runtime/streams/actor-session-binding-registry.ts +236 -64
- package/src/runtime/streams/actor-session-binding-runtime-owner.ts +16 -8
- package/src/runtime/streams/bound-actor-relay-sender.ts +23 -9
- package/src/runtime/streams/bound-session-service.ts +7 -10
- package/src/runtime/streams/index.ts +12 -6
- package/src/runtime/streams/managed-stream.ts +4 -2
- package/src/runtime/streams/native-fallback-bound-session.ts +14 -103
- package/src/runtime/streams/session-actor-coordinator.ts +39 -88
- package/src/runtime/streams/stream-binding-runtime-ports.ts +3 -9
- package/src/runtime/streams/stream-session-runtime.ts +13 -34
- package/src/runtime/workers/index.ts +1 -1
|
@@ -155,9 +155,13 @@ export class ZLinkFanoutLocationRuntime {
|
|
|
155
155
|
ownerId: owner.ownerId,
|
|
156
156
|
leaseGeneration: owner.leaseGeneration
|
|
157
157
|
};
|
|
158
|
-
const result = await this.
|
|
159
|
-
|
|
160
|
-
|
|
158
|
+
const result = await this.locationRuntime.writeDescriptor(
|
|
159
|
+
(writeSignal) =>
|
|
160
|
+
this.store.updateFanoutPublisher(
|
|
161
|
+
candidate,
|
|
162
|
+
ZLinkLocationWriteIntent.Takeover,
|
|
163
|
+
writeSignal
|
|
164
|
+
),
|
|
161
165
|
signal
|
|
162
166
|
);
|
|
163
167
|
if (result.status !== ZLinkLocationWriteStatus.Stored) {
|
|
@@ -188,9 +192,9 @@ export class ZLinkFanoutLocationRuntime {
|
|
|
188
192
|
}
|
|
189
193
|
const current = await this.lane.run(() => this.localDescriptors.get(channelName));
|
|
190
194
|
if (current !== undefined) {
|
|
191
|
-
const result = await this.
|
|
192
|
-
|
|
193
|
-
|
|
195
|
+
const result = await this.locationRuntime.writeDescriptor(
|
|
196
|
+
(writeSignal) =>
|
|
197
|
+
this.store.updateFanoutPublisher(current, ZLinkLocationWriteIntent.Renew, writeSignal),
|
|
194
198
|
signal
|
|
195
199
|
);
|
|
196
200
|
if (result.status !== ZLinkLocationWriteStatus.Stored) {
|
|
@@ -231,9 +235,13 @@ export class ZLinkFanoutLocationRuntime {
|
|
|
231
235
|
leaseGeneration: owner.leaseGeneration,
|
|
232
236
|
updatedAt: new Date(0)
|
|
233
237
|
};
|
|
234
|
-
const result = await this.
|
|
235
|
-
|
|
236
|
-
|
|
238
|
+
const result = await this.locationRuntime.writeDescriptor(
|
|
239
|
+
(writeSignal) =>
|
|
240
|
+
this.store.updateFanoutPublisher(
|
|
241
|
+
descriptor,
|
|
242
|
+
ZLinkLocationWriteIntent.NewClaim,
|
|
243
|
+
writeSignal
|
|
244
|
+
),
|
|
237
245
|
signal
|
|
238
246
|
);
|
|
239
247
|
if (result.status !== ZLinkLocationWriteStatus.Stored) {
|
|
@@ -32,7 +32,8 @@ export class ZLinkLocalSpotRouteTransport {
|
|
|
32
32
|
packetName: string | undefined,
|
|
33
33
|
request: unknown,
|
|
34
34
|
timeoutMs: number | undefined,
|
|
35
|
-
signal?: AbortSignal
|
|
35
|
+
signal?: AbortSignal,
|
|
36
|
+
onAdmitted?: () => void
|
|
36
37
|
): Promise<TReply> {
|
|
37
38
|
if (this.dispatcher === undefined) {
|
|
38
39
|
throw new ZLinkConfigurationException(
|
|
@@ -41,6 +42,7 @@ export class ZLinkLocalSpotRouteTransport {
|
|
|
41
42
|
}
|
|
42
43
|
const pending = this.dispatcher.request<TReply>(spotId, packetName, request, {
|
|
43
44
|
channelName: routerChannelId,
|
|
45
|
+
onAdmitted,
|
|
44
46
|
signal
|
|
45
47
|
});
|
|
46
48
|
const effectiveTimeoutMs = timeoutMs ?? this.defaultRequestTimeoutMs;
|
|
@@ -31,11 +31,18 @@ export class ZLinkRouterSocketSpotRouteTransport {
|
|
|
31
31
|
codecs: ZLinkChannelEnvelopeCodecRegistry | undefined,
|
|
32
32
|
flags: ZLinkBackendSendFlags,
|
|
33
33
|
timeoutMs: number | undefined,
|
|
34
|
-
signal?: AbortSignal
|
|
34
|
+
signal?: AbortSignal,
|
|
35
|
+
onAdmitted?: () => void
|
|
35
36
|
): Promise<TReply> {
|
|
36
37
|
const router = this.sockets.routeRouter(target.routerChannelId);
|
|
37
38
|
void flags;
|
|
38
|
-
const operation = router.requestToSpot(
|
|
39
|
+
const operation = router.requestToSpot(
|
|
40
|
+
target.targetNodeRid,
|
|
41
|
+
target.spotId,
|
|
42
|
+
parts,
|
|
43
|
+
timeoutMs,
|
|
44
|
+
onAdmitted
|
|
45
|
+
);
|
|
39
46
|
const replyParts = await awaitWithAbort(operation, signal, () => {
|
|
40
47
|
void operation.then(closeMessages, () => undefined);
|
|
41
48
|
});
|
|
@@ -51,14 +58,16 @@ export class ZLinkRouterSocketSpotRouteTransport {
|
|
|
51
58
|
target: ZLinkSpotRouteTarget,
|
|
52
59
|
request: Message,
|
|
53
60
|
timeoutMs: number | undefined,
|
|
54
|
-
signal?: AbortSignal
|
|
61
|
+
signal?: AbortSignal,
|
|
62
|
+
onAdmitted?: () => void
|
|
55
63
|
): Promise<readonly Message[]> {
|
|
56
64
|
const router = this.sockets.routeRouter(target.routerChannelId);
|
|
57
65
|
const operation = router.requestToSpot(
|
|
58
66
|
target.targetNodeRid,
|
|
59
67
|
target.spotId,
|
|
60
68
|
[request],
|
|
61
|
-
timeoutMs
|
|
69
|
+
timeoutMs,
|
|
70
|
+
onAdmitted
|
|
62
71
|
);
|
|
63
72
|
return await awaitWithAbort(operation, signal, () => {
|
|
64
73
|
void operation.then(closeMessages, () => undefined);
|
|
@@ -14,7 +14,8 @@ export class ZLinkSourceSpotRouter {
|
|
|
14
14
|
packetName: string | undefined,
|
|
15
15
|
request: unknown,
|
|
16
16
|
timeoutMs: number | undefined,
|
|
17
|
-
signal?: AbortSignal
|
|
17
|
+
signal?: AbortSignal,
|
|
18
|
+
onAdmitted?: () => void
|
|
18
19
|
): Promise<TReply> {
|
|
19
20
|
throwIfAborted(signal);
|
|
20
21
|
const parts = [
|
|
@@ -29,7 +30,8 @@ export class ZLinkSourceSpotRouter {
|
|
|
29
30
|
target.targetNodeRid,
|
|
30
31
|
target.spotId,
|
|
31
32
|
parts,
|
|
32
|
-
timeoutMs ?? this.defaultRequestTimeoutMs
|
|
33
|
+
timeoutMs ?? this.defaultRequestTimeoutMs,
|
|
34
|
+
onAdmitted
|
|
33
35
|
);
|
|
34
36
|
const replyParts = await awaitWithAbort(operation, signal, () => {
|
|
35
37
|
void operation.then(closeMessages, () => undefined);
|
|
@@ -70,14 +72,16 @@ export class ZLinkSourceSpotRouter {
|
|
|
70
72
|
target: ZLinkSpotRouteTarget,
|
|
71
73
|
request: Message,
|
|
72
74
|
timeoutMs: number | undefined,
|
|
73
|
-
signal?: AbortSignal
|
|
75
|
+
signal?: AbortSignal,
|
|
76
|
+
onAdmitted?: () => void
|
|
74
77
|
): Promise<readonly Message[]> {
|
|
75
78
|
throwIfAborted(signal);
|
|
76
79
|
const operation = sourceSpot.requestToSpot(
|
|
77
80
|
target.targetNodeRid,
|
|
78
81
|
target.spotId,
|
|
79
82
|
request,
|
|
80
|
-
timeoutMs ?? this.defaultRequestTimeoutMs
|
|
83
|
+
timeoutMs ?? this.defaultRequestTimeoutMs,
|
|
84
|
+
onAdmitted
|
|
81
85
|
);
|
|
82
86
|
return await awaitWithAbort(operation, signal, () => {
|
|
83
87
|
void operation.then(closeMessages, () => undefined);
|
|
@@ -34,7 +34,8 @@ export class ZLinkSpotNodeRouteTransport {
|
|
|
34
34
|
parts: readonly Message[],
|
|
35
35
|
codecs: ZLinkChannelEnvelopeCodecRegistry | undefined,
|
|
36
36
|
timeoutMs: number | undefined,
|
|
37
|
-
signal?: AbortSignal
|
|
37
|
+
signal?: AbortSignal,
|
|
38
|
+
onAdmitted?: () => void
|
|
38
39
|
): Promise<TReply> | undefined {
|
|
39
40
|
const router = this.targets.spotNodeRouter(target.routerChannelId);
|
|
40
41
|
if (router === undefined) {
|
|
@@ -47,7 +48,8 @@ export class ZLinkSpotNodeRouteTransport {
|
|
|
47
48
|
target.targetNodeRid,
|
|
48
49
|
target.spotId,
|
|
49
50
|
parts,
|
|
50
|
-
effectiveTimeoutMs
|
|
51
|
+
effectiveTimeoutMs,
|
|
52
|
+
onAdmitted
|
|
51
53
|
);
|
|
52
54
|
return awaitWithAbort(operation, signal, () => {
|
|
53
55
|
void operation.then(closeMessages, () => undefined);
|
|
@@ -65,7 +67,8 @@ export class ZLinkSpotNodeRouteTransport {
|
|
|
65
67
|
target: ZLinkSpotRouteTarget,
|
|
66
68
|
request: Message,
|
|
67
69
|
timeoutMs: number | undefined,
|
|
68
|
-
signal?: AbortSignal
|
|
70
|
+
signal?: AbortSignal,
|
|
71
|
+
onAdmitted?: () => void
|
|
69
72
|
): Promise<readonly Message[]> | undefined {
|
|
70
73
|
const router = this.targets.spotNodeRouter(target.routerChannelId);
|
|
71
74
|
if (router === undefined) {
|
|
@@ -78,7 +81,8 @@ export class ZLinkSpotNodeRouteTransport {
|
|
|
78
81
|
target.targetNodeRid,
|
|
79
82
|
target.spotId,
|
|
80
83
|
request,
|
|
81
|
-
effectiveTimeoutMs
|
|
84
|
+
effectiveTimeoutMs,
|
|
85
|
+
onAdmitted
|
|
82
86
|
);
|
|
83
87
|
return awaitWithAbort(operation, signal, () => {
|
|
84
88
|
void operation.then(closeMessages, () => undefined);
|
|
@@ -37,7 +37,8 @@ export class ZLinkSpotRouteBridgeTransport {
|
|
|
37
37
|
parts: readonly Message[],
|
|
38
38
|
codecs: ZLinkChannelEnvelopeCodecRegistry | undefined,
|
|
39
39
|
timeoutMs: number | undefined,
|
|
40
|
-
signal?: AbortSignal
|
|
40
|
+
signal?: AbortSignal,
|
|
41
|
+
onAdmitted?: () => void
|
|
41
42
|
): Promise<TReply> {
|
|
42
43
|
const bridge = this.requireBridge(target.routerChannelId);
|
|
43
44
|
const operation = appendParts(
|
|
@@ -45,7 +46,7 @@ export class ZLinkSpotRouteBridgeTransport {
|
|
|
45
46
|
parts
|
|
46
47
|
)
|
|
47
48
|
.timeout(timeoutMs ?? 0)
|
|
48
|
-
.submit();
|
|
49
|
+
.submit(onAdmitted);
|
|
49
50
|
const replyParts = await awaitWithAbort(operation, signal, () => {
|
|
50
51
|
void operation.then(closeMessages, () => undefined);
|
|
51
52
|
});
|
|
@@ -61,14 +62,15 @@ export class ZLinkSpotRouteBridgeTransport {
|
|
|
61
62
|
target: ZLinkSpotRouteTarget,
|
|
62
63
|
request: Message,
|
|
63
64
|
timeoutMs: number | undefined,
|
|
64
|
-
signal?: AbortSignal
|
|
65
|
+
signal?: AbortSignal,
|
|
66
|
+
onAdmitted?: () => void
|
|
65
67
|
): Promise<readonly Message[]> {
|
|
66
68
|
const bridge = this.requireBridge(target.routerChannelId);
|
|
67
69
|
const operation = bridge
|
|
68
70
|
.request(target.routerChannelId, target.targetNodeRid, target.spotId)
|
|
69
71
|
.message(request)
|
|
70
72
|
.timeout(timeoutMs ?? this.defaultRequestTimeoutMs ?? 0)
|
|
71
|
-
.submit();
|
|
73
|
+
.submit(onAdmitted);
|
|
72
74
|
return awaitWithAbort(operation, signal, () => {
|
|
73
75
|
void operation.then(closeMessages, () => undefined);
|
|
74
76
|
});
|
|
@@ -42,6 +42,7 @@ export interface ZLinkLocalSpotRouteDispatcher {
|
|
|
42
42
|
context: {
|
|
43
43
|
readonly channelName: string;
|
|
44
44
|
readonly signal?: AbortSignal;
|
|
45
|
+
readonly onAdmitted?: () => void;
|
|
45
46
|
readonly metadata?: ReadonlyMap<string, string>;
|
|
46
47
|
}
|
|
47
48
|
): Promise<TReply>;
|
|
@@ -163,7 +164,8 @@ export class ZLinkSpotRouteDispatchStrategy {
|
|
|
163
164
|
request: unknown,
|
|
164
165
|
timeoutMs: number | undefined,
|
|
165
166
|
signal?: AbortSignal,
|
|
166
|
-
metadata?: ReadonlyMap<string, string
|
|
167
|
+
metadata?: ReadonlyMap<string, string>,
|
|
168
|
+
onAdmitted?: () => void
|
|
167
169
|
): Promise<TReply> {
|
|
168
170
|
return runWithOutboundFlow(this.options.flowCreationEnabled?.() ?? true, () =>
|
|
169
171
|
this.routeRequestToSpotScoped<TReply>(
|
|
@@ -172,7 +174,8 @@ export class ZLinkSpotRouteDispatchStrategy {
|
|
|
172
174
|
request,
|
|
173
175
|
timeoutMs,
|
|
174
176
|
signal,
|
|
175
|
-
metadata
|
|
177
|
+
metadata,
|
|
178
|
+
onAdmitted
|
|
176
179
|
)
|
|
177
180
|
);
|
|
178
181
|
}
|
|
@@ -183,7 +186,8 @@ export class ZLinkSpotRouteDispatchStrategy {
|
|
|
183
186
|
request: unknown,
|
|
184
187
|
timeoutMs: number | undefined,
|
|
185
188
|
signal?: AbortSignal,
|
|
186
|
-
metadata?: ReadonlyMap<string, string
|
|
189
|
+
metadata?: ReadonlyMap<string, string>,
|
|
190
|
+
onAdmitted?: () => void
|
|
187
191
|
): Promise<TReply> {
|
|
188
192
|
throwIfAborted(signal);
|
|
189
193
|
const localSpotRouteNode = this.targets.localRouteNode(spotRouteTarget);
|
|
@@ -194,7 +198,8 @@ export class ZLinkSpotRouteDispatchStrategy {
|
|
|
194
198
|
packetName,
|
|
195
199
|
request,
|
|
196
200
|
timeoutMs,
|
|
197
|
-
signal
|
|
201
|
+
signal,
|
|
202
|
+
onAdmitted
|
|
198
203
|
);
|
|
199
204
|
}
|
|
200
205
|
const codecs = codecsForFrameworkPacket(packetName, this.options.codecs);
|
|
@@ -216,7 +221,8 @@ export class ZLinkSpotRouteDispatchStrategy {
|
|
|
216
221
|
parts,
|
|
217
222
|
codecs,
|
|
218
223
|
timeoutMs,
|
|
219
|
-
signal
|
|
224
|
+
signal,
|
|
225
|
+
onAdmitted
|
|
220
226
|
);
|
|
221
227
|
if (namedSpotNodeRequest !== undefined) return namedSpotNodeRequest;
|
|
222
228
|
}
|
|
@@ -226,7 +232,8 @@ export class ZLinkSpotRouteDispatchStrategy {
|
|
|
226
232
|
parts,
|
|
227
233
|
codecs,
|
|
228
234
|
timeoutMs,
|
|
229
|
-
signal
|
|
235
|
+
signal,
|
|
236
|
+
onAdmitted
|
|
230
237
|
);
|
|
231
238
|
}
|
|
232
239
|
if (this.targets.hasBoundRouteRouter(spotRouteTarget.routerChannelId)) {
|
|
@@ -236,7 +243,8 @@ export class ZLinkSpotRouteDispatchStrategy {
|
|
|
236
243
|
codecs,
|
|
237
244
|
ZLINK_SEND_DONT_WAIT,
|
|
238
245
|
timeoutMs,
|
|
239
|
-
signal
|
|
246
|
+
signal,
|
|
247
|
+
onAdmitted
|
|
240
248
|
);
|
|
241
249
|
}
|
|
242
250
|
const spotNodeRequest = this.spotNodeTransport.request<TReply>(
|
|
@@ -244,7 +252,8 @@ export class ZLinkSpotRouteDispatchStrategy {
|
|
|
244
252
|
parts,
|
|
245
253
|
codecs,
|
|
246
254
|
timeoutMs,
|
|
247
|
-
signal
|
|
255
|
+
signal,
|
|
256
|
+
onAdmitted
|
|
248
257
|
);
|
|
249
258
|
if (spotNodeRequest !== undefined) {
|
|
250
259
|
return spotNodeRequest;
|
|
@@ -255,7 +264,8 @@ export class ZLinkSpotRouteDispatchStrategy {
|
|
|
255
264
|
codecs,
|
|
256
265
|
0,
|
|
257
266
|
timeoutMs,
|
|
258
|
-
signal
|
|
267
|
+
signal,
|
|
268
|
+
onAdmitted
|
|
259
269
|
);
|
|
260
270
|
}
|
|
261
271
|
|
|
@@ -265,7 +275,8 @@ export class ZLinkSpotRouteDispatchStrategy {
|
|
|
265
275
|
packetName: string | undefined,
|
|
266
276
|
request: unknown,
|
|
267
277
|
timeoutMs: number | undefined,
|
|
268
|
-
signal?: AbortSignal
|
|
278
|
+
signal?: AbortSignal,
|
|
279
|
+
onAdmitted?: () => void
|
|
269
280
|
): Promise<TReply> {
|
|
270
281
|
return this.sourceSpotRouter.request<TReply>(
|
|
271
282
|
sourceSpot,
|
|
@@ -273,7 +284,8 @@ export class ZLinkSpotRouteDispatchStrategy {
|
|
|
273
284
|
packetName,
|
|
274
285
|
request,
|
|
275
286
|
timeoutMs,
|
|
276
|
-
signal
|
|
287
|
+
signal,
|
|
288
|
+
onAdmitted
|
|
277
289
|
);
|
|
278
290
|
}
|
|
279
291
|
|
|
@@ -292,14 +304,16 @@ export class ZLinkSpotRouteDispatchStrategy {
|
|
|
292
304
|
spotRouteTarget: ZLinkSpotRouteTarget,
|
|
293
305
|
request: Message,
|
|
294
306
|
timeoutMs: number | undefined,
|
|
295
|
-
signal?: AbortSignal
|
|
307
|
+
signal?: AbortSignal,
|
|
308
|
+
onAdmitted?: () => void
|
|
296
309
|
): Promise<readonly Message[]> {
|
|
297
310
|
return this.sourceSpotRouter.requestRaw(
|
|
298
311
|
sourceSpot,
|
|
299
312
|
spotRouteTarget,
|
|
300
313
|
request,
|
|
301
314
|
timeoutMs,
|
|
302
|
-
signal
|
|
315
|
+
signal,
|
|
316
|
+
onAdmitted
|
|
303
317
|
);
|
|
304
318
|
}
|
|
305
319
|
|
|
@@ -307,7 +321,8 @@ export class ZLinkSpotRouteDispatchStrategy {
|
|
|
307
321
|
spotRouteTarget: ZLinkSpotRouteTarget,
|
|
308
322
|
request: Message,
|
|
309
323
|
timeoutMs: number | undefined,
|
|
310
|
-
signal?: AbortSignal
|
|
324
|
+
signal?: AbortSignal,
|
|
325
|
+
onAdmitted?: () => void
|
|
311
326
|
): Promise<readonly Message[]> {
|
|
312
327
|
throwIfAborted(signal);
|
|
313
328
|
if (this.targets.hasNamedSpotNode(spotRouteTarget.routerChannelId)) {
|
|
@@ -315,23 +330,37 @@ export class ZLinkSpotRouteDispatchStrategy {
|
|
|
315
330
|
spotRouteTarget,
|
|
316
331
|
request,
|
|
317
332
|
timeoutMs,
|
|
318
|
-
signal
|
|
333
|
+
signal,
|
|
334
|
+
onAdmitted
|
|
319
335
|
);
|
|
320
336
|
if (namedSpotNodeRequest !== undefined) return namedSpotNodeRequest;
|
|
321
337
|
}
|
|
322
338
|
if (this.bridgeTransport.has(spotRouteTarget.routerChannelId)) {
|
|
323
|
-
return this.bridgeTransport.requestRaw(
|
|
339
|
+
return this.bridgeTransport.requestRaw(
|
|
340
|
+
spotRouteTarget,
|
|
341
|
+
request,
|
|
342
|
+
timeoutMs,
|
|
343
|
+
signal,
|
|
344
|
+
onAdmitted
|
|
345
|
+
);
|
|
324
346
|
}
|
|
325
347
|
const spotNodeRequest = this.spotNodeTransport.requestRaw(
|
|
326
348
|
spotRouteTarget,
|
|
327
349
|
request,
|
|
328
350
|
timeoutMs,
|
|
329
|
-
signal
|
|
351
|
+
signal,
|
|
352
|
+
onAdmitted
|
|
330
353
|
);
|
|
331
354
|
if (spotNodeRequest !== undefined) {
|
|
332
355
|
return spotNodeRequest;
|
|
333
356
|
}
|
|
334
357
|
|
|
335
|
-
return this.routerSocketTransport.requestRaw(
|
|
358
|
+
return this.routerSocketTransport.requestRaw(
|
|
359
|
+
spotRouteTarget,
|
|
360
|
+
request,
|
|
361
|
+
timeoutMs,
|
|
362
|
+
signal,
|
|
363
|
+
onAdmitted
|
|
364
|
+
);
|
|
336
365
|
}
|
|
337
366
|
}
|
|
@@ -2,7 +2,6 @@ import { AsyncLocalStorage } from 'node:async_hooks';
|
|
|
2
2
|
import { randomBytes } from 'node:crypto';
|
|
3
3
|
import type { ZLinkFlowOrigin } from '../../contracts';
|
|
4
4
|
const FLOW_UUID_BYTES = 16;
|
|
5
|
-
const FLOW_UUID_VARIANT_BYTE = 8;
|
|
6
5
|
|
|
7
6
|
/**
|
|
8
7
|
* Spec 27 §3 defines the flow_origin value set as lowercase
|
|
@@ -97,13 +96,27 @@ export function createInboundFlow(
|
|
|
97
96
|
return { flowId: flowId ?? createFlowId(), flowOrigin: flowOrigin ?? 'Inbound', streamSessionId };
|
|
98
97
|
}
|
|
99
98
|
|
|
99
|
+
/**
|
|
100
|
+
* UUIDv7 with a dedicated counter (RFC 9562 §6.2 method 1): the 48-bit
|
|
101
|
+
* millisecond timestamp, then a 42-bit counter that starts at a random value
|
|
102
|
+
* and spans `rand_a` and the top of `rand_b`, then 32 random bits drawn once
|
|
103
|
+
* per process. Flow ids stay unique within the process without drawing
|
|
104
|
+
* random bytes for every message.
|
|
105
|
+
*/
|
|
106
|
+
const flowRandom = randomBytes(FLOW_UUID_BYTES);
|
|
107
|
+
const FLOW_COUNTER_SPAN = 2 ** 42;
|
|
108
|
+
let flowCounter = flowRandom.readUIntBE(0, 6) % FLOW_COUNTER_SPAN;
|
|
109
|
+
const FLOW_ID_TAIL = flowRandom.toString('hex', FLOW_UUID_BYTES - 4);
|
|
110
|
+
|
|
100
111
|
function createFlowId(): string {
|
|
101
|
-
const
|
|
112
|
+
const counter = flowCounter;
|
|
113
|
+
flowCounter = (flowCounter + 1) % FLOW_COUNTER_SPAN;
|
|
102
114
|
// Date.now() is always within 48 bits, which is exactly the UUIDv7
|
|
103
115
|
// timestamp field.
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
const
|
|
108
|
-
|
|
116
|
+
const timestamp = Date.now().toString(16).padStart(12, '0');
|
|
117
|
+
const randA = Math.floor(counter / 2 ** 30); // 12 bits
|
|
118
|
+
const randB = counter % 2 ** 30; // 30 bits after the 2 variant bits
|
|
119
|
+
const variantHigh = (0x8000 | Math.floor(randB / 2 ** 16)).toString(16);
|
|
120
|
+
const randBLow = (randB % 2 ** 16).toString(16).padStart(4, '0');
|
|
121
|
+
return `${timestamp.slice(0, 8)}-${timestamp.slice(8)}-7${randA.toString(16).padStart(3, '0')}-${variantHigh}-${randBLow}${FLOW_ID_TAIL}`;
|
|
109
122
|
}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { AsyncResource } from 'node:async_hooks';
|
|
2
1
|
import type {
|
|
3
2
|
ZLinkLocationRuntimeQuery,
|
|
4
3
|
ZLinkLocationRuntimeStatus,
|
|
@@ -18,7 +17,7 @@ import type {
|
|
|
18
17
|
ZLinkSpotLocation
|
|
19
18
|
} from '../../contracts/Locations/Rows';
|
|
20
19
|
import type { ZLinkBackendSocketMonitor, ZLinkBackendSocketMonitorEvent } from '../backend';
|
|
21
|
-
import { ZLinkStateLane } from '../execution/state-lane';
|
|
20
|
+
import { startOutsideStateLane, ZLinkStateLane } from '../execution/state-lane';
|
|
22
21
|
import { normalizeOpaqueRoutingId } from '../routing-id';
|
|
23
22
|
import {
|
|
24
23
|
ZLinkLocationActorEventKind as ActorLocationEventKind,
|
|
@@ -54,7 +53,6 @@ export {
|
|
|
54
53
|
} from './internal-event-contracts';
|
|
55
54
|
|
|
56
55
|
const ZLINK_DISCONNECT_REASON_HANDSHAKE_FAILED = 3;
|
|
57
|
-
const detachedStateLaneResource = new AsyncResource('zlink:location-runtime-monitoring-source');
|
|
58
56
|
|
|
59
57
|
export interface ZLinkActorOwnerLeaseObservation {
|
|
60
58
|
readonly actorId: string;
|
|
@@ -461,10 +459,6 @@ async function publishLocationRuntimeChange<T>(
|
|
|
461
459
|
await publisher.publish(runtimeEvent);
|
|
462
460
|
}
|
|
463
461
|
|
|
464
|
-
function startOutsideStateLane<T>(work: () => T): T {
|
|
465
|
-
return detachedStateLaneResource.runInAsyncScope(work);
|
|
466
|
-
}
|
|
467
|
-
|
|
468
462
|
function stableSnapshot(value: unknown): string {
|
|
469
463
|
return JSON.stringify(value, (_key, item) => (typeof item === 'bigint' ? item.toString() : item));
|
|
470
464
|
}
|
|
@@ -13,7 +13,7 @@ import {
|
|
|
13
13
|
type ZLinkRuntimeMessageFlowEvent,
|
|
14
14
|
type ZLinkRuntimeMessageFlowResult
|
|
15
15
|
} from '../../contracts/Dispatch/ZLinkDispatchOptions';
|
|
16
|
-
import { ERROR_MESSAGE_MAX_LENGTH } from './dispatch-error-details';
|
|
16
|
+
import { ERROR_MESSAGE_MAX_LENGTH, dispatchErrorDetails } from './dispatch-error-details';
|
|
17
17
|
import type { ZLinkDispatchErrorSink } from './dispatch-error-port';
|
|
18
18
|
import { currentFlowContext, FLOW_ORIGIN_VALUES } from './flow-context';
|
|
19
19
|
const MESSAGE_FLOW_EVENT_ID = 'zlink.message_flow';
|
|
@@ -41,6 +41,7 @@ const telemetryTracer = openTelemetryTrace.getTracer('@zlink-systems/framework')
|
|
|
41
41
|
let diagnosticsGeneration = 0n;
|
|
42
42
|
|
|
43
43
|
interface ZLinkTelemetryRecord {
|
|
44
|
+
readonly severity?: 'warning';
|
|
44
45
|
readonly eventId: typeof MESSAGE_FLOW_EVENT_ID | typeof DISPATCH_ERROR_EVENT_ID;
|
|
45
46
|
readonly timestamp: Date;
|
|
46
47
|
readonly phase?: string;
|
|
@@ -86,6 +87,15 @@ export function effectiveMessageFlow(ctx: ZLinkDiagnosticsContext): ZLinkMessage
|
|
|
86
87
|
return ctx.liveMode.mode;
|
|
87
88
|
}
|
|
88
89
|
|
|
90
|
+
/**
|
|
91
|
+
* Message-flow tracing is on at Normal and Detailed only (04-flow-correlation
|
|
92
|
+
* §4). Below it no flow ID is created, validated, captured or propagated. This
|
|
93
|
+
* is the one decision every flow processing point reads.
|
|
94
|
+
*/
|
|
95
|
+
export function messageFlowTracingEnabled(mode: ZLinkMessageFlowLogMode): boolean {
|
|
96
|
+
return MESSAGE_FLOW_MODE_RANK[mode] >= MESSAGE_FLOW_MODE_RANK.normal;
|
|
97
|
+
}
|
|
98
|
+
|
|
89
99
|
export function createMessageFlowModeCell(
|
|
90
100
|
dispatch: { diagnostics?: ZLinkDiagnosticsOptions } | undefined
|
|
91
101
|
): ZLinkMessageFlowModeCell {
|
|
@@ -137,10 +147,33 @@ export interface ZLinkMessageFlowTracePoint {
|
|
|
137
147
|
trace(flowInput: MessageFlowInput): void;
|
|
138
148
|
}
|
|
139
149
|
|
|
150
|
+
export function traceSessionBindingControlDrop(
|
|
151
|
+
flow: ZLinkMessageFlowTracer | undefined,
|
|
152
|
+
sourceRid: string,
|
|
153
|
+
actorId: string,
|
|
154
|
+
packetName: string,
|
|
155
|
+
errorReason: 'location_unavailable' | 'stale_target',
|
|
156
|
+
error?: unknown
|
|
157
|
+
): void {
|
|
158
|
+
const point = flowIfEnabled(flow, ZLinkMessageFlowOutcome.Dropped);
|
|
159
|
+
if (point === undefined) return;
|
|
160
|
+
point.trace({
|
|
161
|
+
outcome: ZLinkMessageFlowOutcome.Dropped,
|
|
162
|
+
surface: ZLinkDispatchErrorSurface.StreamSession,
|
|
163
|
+
messageKind: ZLinkDispatchMessageKind.Control,
|
|
164
|
+
sourceRid,
|
|
165
|
+
actorId,
|
|
166
|
+
packetName,
|
|
167
|
+
errorReason,
|
|
168
|
+
...dispatchErrorDetails(error)
|
|
169
|
+
});
|
|
170
|
+
}
|
|
171
|
+
|
|
140
172
|
type MessageFlowInput = Omit<
|
|
141
173
|
ZLinkRuntimeMessageFlowEvent,
|
|
142
174
|
'effectiveMode' | 'flowId' | 'flowOrigin'
|
|
143
175
|
> & {
|
|
176
|
+
readonly severity?: 'warning';
|
|
144
177
|
readonly effectiveMode?: ZLinkMessageFlowLogMode;
|
|
145
178
|
readonly flowId?: string;
|
|
146
179
|
readonly flowOrigin?: import('../../contracts').ZLinkFlowOrigin;
|
|
@@ -201,7 +234,7 @@ export class ZLinkMessageFlowTracer {
|
|
|
201
234
|
}
|
|
202
235
|
|
|
203
236
|
flowCreationEnabled(): boolean {
|
|
204
|
-
return effectiveMessageFlow(this.ctx)
|
|
237
|
+
return messageFlowTracingEnabled(effectiveMessageFlow(this.ctx));
|
|
205
238
|
}
|
|
206
239
|
|
|
207
240
|
trace(flowInput: MessageFlowInput): void {
|
|
@@ -234,7 +267,7 @@ export class ZLinkMessageFlowTracer {
|
|
|
234
267
|
const ambient = currentFlowContext();
|
|
235
268
|
const flowId = flowInput.flowId ?? acceptedFlowId ?? ambient?.flowId;
|
|
236
269
|
const flowOrigin = flowInput.flowOrigin ?? acceptedFlowOrigin ?? ambient?.flowOrigin;
|
|
237
|
-
const flow:
|
|
270
|
+
const flow: MessageFlowInput = {
|
|
238
271
|
...flowInput,
|
|
239
272
|
...(flowId === undefined ? {} : { flowId, flowOrigin }),
|
|
240
273
|
streamSessionId: flowInput.streamSessionId ?? ambient?.streamSessionId,
|
|
@@ -302,13 +335,17 @@ export class ZLinkMessageFlowTracer {
|
|
|
302
335
|
|
|
303
336
|
private publishToLogger(record: ZLinkTelemetryRecord): void {
|
|
304
337
|
try {
|
|
305
|
-
const
|
|
306
|
-
record.
|
|
338
|
+
const severity =
|
|
339
|
+
record.severity === 'warning'
|
|
340
|
+
? 'WARN'
|
|
341
|
+
: record.eventId === DISPATCH_ERROR_EVENT_ID
|
|
342
|
+
? 'ERROR'
|
|
343
|
+
: 'INFO';
|
|
307
344
|
telemetryLogger.emit({
|
|
308
345
|
eventName: record.eventId,
|
|
309
346
|
timestamp: record.timestamp,
|
|
310
|
-
severityNumber,
|
|
311
|
-
severityText:
|
|
347
|
+
severityNumber: SeverityNumber[severity],
|
|
348
|
+
severityText: severity,
|
|
312
349
|
body: structuredLogBody(record),
|
|
313
350
|
attributes: structuredLogAttributes(record)
|
|
314
351
|
});
|
|
@@ -342,11 +379,12 @@ export class ZLinkMessageFlowTracer {
|
|
|
342
379
|
}
|
|
343
380
|
|
|
344
381
|
function toTelemetryRecord(
|
|
345
|
-
flow:
|
|
382
|
+
flow: MessageFlowInput,
|
|
346
383
|
messageSizeBytes: number | undefined,
|
|
347
384
|
durationSeconds: number | undefined
|
|
348
385
|
): ZLinkTelemetryRecord {
|
|
349
386
|
return {
|
|
387
|
+
severity: flow.severity,
|
|
350
388
|
eventId:
|
|
351
389
|
flow.outcome === ZLinkMessageFlowOutcome.Error
|
|
352
390
|
? DISPATCH_ERROR_EVENT_ID
|
|
@@ -387,7 +425,7 @@ function toTelemetryRecord(
|
|
|
387
425
|
function traceAttributes(record: ZLinkTelemetryRecord): Attributes {
|
|
388
426
|
const attributes: Attributes = {};
|
|
389
427
|
for (const [name, value] of Object.entries(record)) {
|
|
390
|
-
if (value === undefined || name === 'timestamp') continue;
|
|
428
|
+
if (value === undefined || name === 'timestamp' || name === 'severity') continue;
|
|
391
429
|
attributes[toSnakeCase(name)] = value instanceof Date ? value.toISOString() : value;
|
|
392
430
|
}
|
|
393
431
|
return attributes;
|
|
@@ -51,8 +51,8 @@ export interface ZLinkRuntimeMetricMeshSnapshot {
|
|
|
51
51
|
readonly channelName: string;
|
|
52
52
|
readonly readyMembers: number;
|
|
53
53
|
}>;
|
|
54
|
-
readonly actorCapacity
|
|
55
|
-
readonly spotCapacity
|
|
54
|
+
readonly actorCapacity?: ZLinkRuntimeMetricCapacity;
|
|
55
|
+
readonly spotCapacity?: ZLinkRuntimeMetricCapacity;
|
|
56
56
|
readonly spotTypeCapacities: ReadonlyArray<ZLinkRuntimeMetricSpotTypeCapacity>;
|
|
57
57
|
readonly activation: { readonly active: number; readonly limit: number };
|
|
58
58
|
readonly instanceSpots: ReadonlyArray<{
|
|
@@ -383,14 +383,16 @@ class MetricRegistry {
|
|
|
383
383
|
}
|
|
384
384
|
} else if (name.startsWith('zlink.object.capacity.')) {
|
|
385
385
|
const field = metricSuffix(name);
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
386
|
+
if (snapshot.actorCapacity !== undefined)
|
|
387
|
+
result.observe(capacityValue(snapshot.actorCapacity, field), {
|
|
388
|
+
...mesh,
|
|
389
|
+
capacity_scope: 'actor'
|
|
390
|
+
});
|
|
391
|
+
if (snapshot.spotCapacity !== undefined)
|
|
392
|
+
result.observe(capacityValue(snapshot.spotCapacity, field), {
|
|
393
|
+
...mesh,
|
|
394
|
+
capacity_scope: 'spot'
|
|
395
|
+
});
|
|
394
396
|
} else if (name.startsWith('zlink.spot.type.capacity.')) {
|
|
395
397
|
const field = metricSuffix(name);
|
|
396
398
|
for (const capacity of snapshot.spotTypeCapacities) {
|