@zlink-systems/framework 0.30.1 → 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/dist/.tsbuildinfo +1 -1
- package/dist/contracts/Common/ZLinkEncodedPayload.d.ts +6 -0
- package/dist/contracts/Common/ZLinkEncodedPayload.js +18 -3
- 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/Locations/Rows.d.ts +2 -0
- package/dist/contracts/Spots/Contracts.d.ts +4 -0
- package/dist/contracts/Spots/ZLinkSpot.d.ts +3 -3
- 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 +0 -1
- package/dist/runtime/actors/actor-client.js +38 -45
- 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 +7 -3
- package/dist/runtime/actors/actor-handoff.js +212 -88
- package/dist/runtime/actors/actor-join-relocation.d.ts +2 -0
- package/dist/runtime/actors/actor-local-native-join.js +4 -0
- package/dist/runtime/actors/actor-mailbox.js +27 -1
- package/dist/runtime/actors/actor-remote-joiner.js +3 -1
- package/dist/runtime/actors/actor-reply.d.ts +4 -0
- package/dist/runtime/actors/actor-reply.js +29 -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 +6 -2
- package/dist/runtime/actors/index.js +37 -21
- package/dist/runtime/actors/session-disconnected-wire.d.ts +8 -0
- package/dist/runtime/actors/session-disconnected-wire.js +48 -0
- package/dist/runtime/admission.d.ts +9 -1
- package/dist/runtime/admission.js +55 -32
- package/dist/runtime/application-jobs/application-job-queue-scope.d.ts +13 -0
- package/dist/runtime/application-jobs/application-job-queue-scope.js +27 -1
- package/dist/runtime/application-jobs/contracts.d.ts +2 -0
- package/dist/runtime/backend/contracts/index.d.ts +19 -3
- package/dist/runtime/backend/mesh-actor-session-node-adapter.js +2 -2
- package/dist/runtime/backend/mesh-completion-table.js +5 -0
- package/dist/runtime/backend/mesh-dispatch-pump.d.ts +26 -2
- package/dist/runtime/backend/mesh-dispatch-pump.js +193 -107
- package/dist/runtime/backend/node/node-raw-binding-port.js +90 -58
- package/dist/runtime/backend/node/node-raw-mesh-backend.d.ts +33 -8
- package/dist/runtime/backend/node/node-raw-mesh-backend.js +142 -143
- package/dist/runtime/backend/node/node-socket-backend-adapter.d.ts +1 -1
- package/dist/runtime/backend/node/node-socket-backend-adapter.js +5 -5
- package/dist/runtime/channels/channel-clients.d.ts +1 -0
- package/dist/runtime/channels/channel-clients.js +20 -5
- package/dist/runtime/channels/channel-dispatch-pipeline.d.ts +22 -3
- package/dist/runtime/channels/channel-dispatch-pipeline.js +103 -57
- package/dist/runtime/channels/channel-dispatchers.d.ts +3 -2
- package/dist/runtime/channels/channel-dispatchers.js +44 -37
- package/dist/runtime/channels/channel-envelope.d.ts +1 -0
- package/dist/runtime/channels/channel-envelope.js +74 -31
- 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 +3 -2
- package/dist/runtime/channels/channel-runtime-manager.js +4 -4
- package/dist/runtime/channels/channel-transports.d.ts +0 -1
- package/dist/runtime/channels/channel-transports.js +35 -33
- 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/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 +4 -0
- package/dist/runtime/execution/serial-execution-queue.js +21 -2
- package/dist/runtime/execution/state-lane.d.ts +2 -0
- package/dist/runtime/execution/state-lane.js +5 -0
- 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 +39 -3
- package/dist/runtime/foundation/raw-service-mesh-runtime.js +151 -55
- 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 +2 -3
- package/dist/runtime/foundation/service-relocation-object-owner.js +48 -35
- package/dist/runtime/foundation/service-relocation-runtime.js +7 -3
- package/dist/runtime/foundation/service-runtime-contracts.d.ts +8 -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 +72 -6
- package/dist/runtime/foundation/service-stateful-runtime.js +444 -117
- package/dist/runtime/foundation/service-stateful-wire-codec.d.ts +14 -1
- package/dist/runtime/foundation/service-stateful-wire-codec.js +48 -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 +10 -0
- package/dist/runtime/foundation/service-wire-m6a-codec.js +166 -53
- 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-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 +24 -3
- package/dist/runtime/host/application-job-queue.js +28 -41
- package/dist/runtime/host/index.d.ts +5 -1
- package/dist/runtime/host/index.js +171 -97
- 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 +71 -190
- package/dist/runtime/host/route-mesh-runtime.d.ts +2 -2
- package/dist/runtime/host/route-mesh-runtime.js +5 -3
- 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-host-runtime.d.ts +17 -7
- package/dist/runtime/host/service-relocation-host-runtime.js +550 -367
- package/dist/runtime/host/spot-runtime-options-factory.js +15 -7
- package/dist/runtime/host/user-spot-creation-coordinator.js +33 -84
- 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/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 +6 -2
- package/dist/runtime/locations/runtime.js +37 -30
- 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.js +29 -26
- package/dist/runtime/protocol/service_wire_codec.generated.d.ts +19 -1
- package/dist/runtime/protocol/service_wire_codec.generated.js +85 -0
- package/dist/runtime/protocol/service_wire_pilot_codec.generated.d.ts +7 -1
- package/dist/runtime/protocol/service_wire_pilot_codec.generated.js +23 -7
- package/dist/runtime/spots/formal-remote-actor-admission-registry.js +3 -2
- package/dist/runtime/spots/index.d.ts +18 -11
- package/dist/runtime/spots/index.js +234 -176
- 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 +6 -3
- package/dist/runtime/spots/spot-activation.js +123 -44
- 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 +14 -9
- package/dist/runtime/spots/spot-handler-registry.d.ts +4 -3
- package/dist/runtime/spots/spot-handler-registry.js +6 -2
- 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 +18 -39
- 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.js +3 -3
- package/dist/runtime/spots/spot-remote-codec.js +5 -1
- package/dist/runtime/spots/spot-runtime-ports.d.ts +0 -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 -1
- package/dist/runtime/spots/spot-timer.d.ts +57 -5
- package/dist/runtime/spots/spot-timer.js +287 -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.js +1 -4
- package/dist/runtime/workers/index.js +1 -1
- package/package.json +3 -3
- package/src/contracts/Common/ZLinkEncodedPayload.ts +24 -4
- 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/Locations/Rows.ts +2 -0
- package/src/contracts/Spots/Contracts.ts +8 -0
- package/src/contracts/Spots/ZLinkSpot.ts +3 -3
- package/src/runtime/abort.ts +12 -0
- package/src/runtime/actors/actor-authority-publication.ts +3 -2
- package/src/runtime/actors/actor-client.ts +61 -70
- package/src/runtime/actors/actor-context.ts +49 -9
- package/src/runtime/actors/actor-handoff.ts +282 -106
- package/src/runtime/actors/actor-join-relocation.ts +2 -0
- package/src/runtime/actors/actor-local-native-join.ts +4 -0
- package/src/runtime/actors/actor-mailbox.ts +40 -2
- package/src/runtime/actors/actor-remote-joiner.ts +6 -1
- package/src/runtime/actors/actor-reply.ts +42 -0
- 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 +41 -27
- package/src/runtime/actors/session-disconnected-wire.ts +66 -0
- package/src/runtime/admission.ts +69 -34
- package/src/runtime/application-jobs/application-job-queue-scope.ts +33 -1
- package/src/runtime/application-jobs/contracts.ts +2 -0
- package/src/runtime/backend/contracts/index.ts +39 -4
- package/src/runtime/backend/mesh-actor-session-node-adapter.ts +5 -3
- package/src/runtime/backend/mesh-completion-table.ts +4 -0
- package/src/runtime/backend/mesh-dispatch-pump.ts +223 -124
- package/src/runtime/backend/node/node-raw-binding-port.ts +106 -70
- package/src/runtime/backend/node/node-raw-mesh-backend.ts +221 -170
- package/src/runtime/backend/node/node-socket-backend-adapter.ts +5 -5
- package/src/runtime/channels/channel-clients.ts +49 -24
- package/src/runtime/channels/channel-dispatch-pipeline.ts +173 -124
- package/src/runtime/channels/channel-dispatchers.ts +116 -72
- package/src/runtime/channels/channel-envelope.ts +105 -36
- package/src/runtime/channels/channel-runtime-lifecycle.ts +13 -13
- package/src/runtime/channels/channel-runtime-manager.ts +12 -5
- package/src/runtime/channels/channel-transports.ts +49 -58
- 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/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 +31 -4
- package/src/runtime/execution/state-lane.ts +7 -0
- package/src/runtime/foundation/operation-registry.ts +98 -20
- package/src/runtime/foundation/raw-service-mesh-runtime.ts +244 -67
- 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 +54 -37
- package/src/runtime/foundation/service-relocation-runtime.ts +7 -3
- package/src/runtime/foundation/service-runtime-contracts.ts +12 -1
- 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 +667 -152
- package/src/runtime/foundation/service-stateful-wire-codec.ts +49 -11
- 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 +187 -51
- 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-transfer-runtime.ts +104 -430
- package/src/runtime/host/application-job-queue.ts +29 -44
- package/src/runtime/host/index.ts +286 -129
- 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 +86 -248
- package/src/runtime/host/route-mesh-runtime.ts +11 -5
- package/src/runtime/host/runtime-shutdown.ts +15 -4
- package/src/runtime/host/service-relocation-host-runtime.ts +784 -475
- package/src/runtime/host/spot-runtime-options-factory.ts +18 -7
- package/src/runtime/host/user-spot-creation-coordinator.ts +41 -100
- 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/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 +70 -40
- package/src/runtime/messaging/payload-codec.ts +8 -11
- package/src/runtime/messaging/request-result.ts +33 -29
- package/src/runtime/protocol/service_wire_codec.generated.ts +87 -4
- package/src/runtime/protocol/service_wire_pilot_codec.generated.ts +13 -10
- package/src/runtime/spots/formal-remote-actor-admission-registry.ts +3 -2
- package/src/runtime/spots/index.ts +375 -281
- 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 +170 -86
- 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 +24 -19
- package/src/runtime/spots/spot-handler-registry.ts +15 -4
- 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 +22 -45
- package/src/runtime/spots/spot-node-runtime-manager.ts +197 -67
- package/src/runtime/spots/spot-outbound.ts +3 -3
- package/src/runtime/spots/spot-remote-codec.ts +9 -2
- package/src/runtime/spots/spot-runtime-ports.ts +0 -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 -1
- package/src/runtime/spots/spot-timer.ts +413 -157
- 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 +1 -5
- package/src/runtime/workers/index.ts +1 -1
|
@@ -488,17 +488,15 @@ export class ZLinkRuntimeRouteTransport implements ZLinkRouteClientTransport {
|
|
|
488
488
|
metadata,
|
|
489
489
|
correlationId
|
|
490
490
|
);
|
|
491
|
-
const
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
timeoutMs: remainingTimeoutMs
|
|
501
|
-
});
|
|
491
|
+
const requestOptions = { flags: 1, onAdmitted, timeoutMs: requestTimeoutBudget(timeoutMs) };
|
|
492
|
+
let completion: ZLinkMeshCompletion;
|
|
493
|
+
try {
|
|
494
|
+
completion = await this.completionTable(meshName).submit(() => {
|
|
495
|
+
const operationId = node.requestToNode(
|
|
496
|
+
toBackendRoutingId(targetNodeRid),
|
|
497
|
+
parts,
|
|
498
|
+
requestOptions
|
|
499
|
+
);
|
|
502
500
|
this.traceNodeRequest(
|
|
503
501
|
ZLinkMessageFlowOutcome.Sent,
|
|
504
502
|
undefined,
|
|
@@ -508,8 +506,13 @@ export class ZLinkRuntimeRouteTransport implements ZLinkRouteClientTransport {
|
|
|
508
506
|
correlationId
|
|
509
507
|
);
|
|
510
508
|
return operationId;
|
|
511
|
-
}
|
|
512
|
-
)
|
|
509
|
+
}, signal);
|
|
510
|
+
} catch (error) {
|
|
511
|
+
throw mapMeshSubmissionError(
|
|
512
|
+
error,
|
|
513
|
+
`MeshNode '${meshName}' request to node '${targetNodeRid}'`
|
|
514
|
+
);
|
|
515
|
+
}
|
|
513
516
|
const reply = this.decodeMeshReply<TReply>(meshName, completion);
|
|
514
517
|
this.traceNodeRequest(
|
|
515
518
|
ZLinkMessageFlowOutcome.ReplyReceived,
|
|
@@ -658,58 +661,34 @@ export class ZLinkRuntimeRouteTransport implements ZLinkRouteClientTransport {
|
|
|
658
661
|
);
|
|
659
662
|
const metric = this.metrics?.startRequest(meshName, 'channel');
|
|
660
663
|
try {
|
|
661
|
-
const
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
}
|
|
672
|
-
|
|
664
|
+
const requestOptions = { flags: 1, timeoutMs: requestTimeoutBudget(timeoutMs), onAdmitted };
|
|
665
|
+
let completion: ZLinkMeshCompletion;
|
|
666
|
+
try {
|
|
667
|
+
completion = await this.completionTable(meshName).submit(
|
|
668
|
+
() => node.requestToChannel(channelName, parts, requestOptions),
|
|
669
|
+
signal
|
|
670
|
+
);
|
|
671
|
+
} catch (error) {
|
|
672
|
+
throw mapMeshSubmissionError(
|
|
673
|
+
error,
|
|
674
|
+
`MeshNode '${meshName}' request to channel '${channelName}'`
|
|
675
|
+
);
|
|
676
|
+
}
|
|
673
677
|
const reply = this.decodeMeshReply<TReply>(meshName, completion);
|
|
674
678
|
metric?.complete('completed');
|
|
675
679
|
return reply;
|
|
676
680
|
} catch (error) {
|
|
677
|
-
metric?.complete(requestMetricOutcome(error));
|
|
678
|
-
if (
|
|
681
|
+
metric?.complete(requestMetricOutcome(error, signal));
|
|
682
|
+
if (
|
|
683
|
+
error instanceof ZLinkFrameworkException &&
|
|
684
|
+
internalFrameworkErrorKind(error) === ZLinkFrameworkInternalErrorKind.RequestTargetNotFound
|
|
685
|
+
) {
|
|
679
686
|
this.metrics?.recordChannelSelectionFailure(meshName, channelName, 'no_ready_target');
|
|
680
687
|
}
|
|
681
688
|
throw error;
|
|
682
689
|
}
|
|
683
690
|
}
|
|
684
691
|
|
|
685
|
-
private async submitRequestOperation(
|
|
686
|
-
meshName: string,
|
|
687
|
-
timeoutMs: number | undefined,
|
|
688
|
-
signal: AbortSignal | undefined,
|
|
689
|
-
operation: string,
|
|
690
|
-
attempt: (
|
|
691
|
-
remainingTimeoutMs: number
|
|
692
|
-
) => ReturnType<Parameters<ZLinkMeshCompletionTable['submit']>[0]>
|
|
693
|
-
): Promise<ZLinkMeshCompletion> {
|
|
694
|
-
const effectiveTimeoutMs = Math.max(1, timeoutMs ?? DEFAULT_REQUEST_TIMEOUT_MS);
|
|
695
|
-
const deadlineMs = performance.now() + effectiveTimeoutMs;
|
|
696
|
-
const remainingTimeoutMs = deadlineMs - performance.now();
|
|
697
|
-
if (remainingTimeoutMs <= 0) {
|
|
698
|
-
throw createInternalFrameworkException(
|
|
699
|
-
ZLinkFrameworkInternalErrorKind.DeadlineExceeded,
|
|
700
|
-
`${operation} timed out before submission.`
|
|
701
|
-
);
|
|
702
|
-
}
|
|
703
|
-
try {
|
|
704
|
-
return await this.completionTable(meshName).submit(
|
|
705
|
-
() => attempt(Math.max(1, Math.ceil(remainingTimeoutMs))),
|
|
706
|
-
signal
|
|
707
|
-
);
|
|
708
|
-
} catch (error) {
|
|
709
|
-
throw mapMeshSubmissionError(error, operation);
|
|
710
|
-
}
|
|
711
|
-
}
|
|
712
|
-
|
|
713
692
|
sendToSpot(
|
|
714
693
|
spotRouteTarget: ZLinkSpotRouteTarget,
|
|
715
694
|
message: unknown,
|
|
@@ -1169,6 +1148,14 @@ function instanceSpotRouteFence(target: ZLinkSpotRouteTarget): ServiceInstanceRo
|
|
|
1169
1148
|
};
|
|
1170
1149
|
}
|
|
1171
1150
|
|
|
1151
|
+
/**
|
|
1152
|
+
* The binding request timeout for one submission. The binding owns the
|
|
1153
|
+
* deadline after submit; the completion table slot only waits for it.
|
|
1154
|
+
*/
|
|
1155
|
+
function requestTimeoutBudget(timeoutMs: number | undefined): number {
|
|
1156
|
+
return Math.max(1, Math.ceil(timeoutMs ?? DEFAULT_REQUEST_TIMEOUT_MS));
|
|
1157
|
+
}
|
|
1158
|
+
|
|
1172
1159
|
function mapMeshSubmitResult(result: number): ZLinkSubmitResult {
|
|
1173
1160
|
return classifySubmitResult(result, 'Mesh submission');
|
|
1174
1161
|
}
|
|
@@ -1260,14 +1247,18 @@ export function meshRequestFailure(
|
|
|
1260
1247
|
return error;
|
|
1261
1248
|
}
|
|
1262
1249
|
|
|
1263
|
-
function requestMetricOutcome(error: unknown): string {
|
|
1250
|
+
function requestMetricOutcome(error: unknown, signal?: AbortSignal): string {
|
|
1264
1251
|
if (error instanceof ZLinkFrameworkException) {
|
|
1265
|
-
if (internalFrameworkErrorKind(error) === ZLinkFrameworkInternalErrorKind.RequestTargetNotFound)
|
|
1266
|
-
return 'target_not_found';
|
|
1267
1252
|
if (internalFrameworkErrorKind(error) === ZLinkFrameworkInternalErrorKind.DeadlineExceeded)
|
|
1268
1253
|
return 'timed_out';
|
|
1269
1254
|
if (internalFrameworkErrorKind(error) === ZLinkFrameworkInternalErrorKind.RuntimeShutdown)
|
|
1270
1255
|
return 'shutdown';
|
|
1271
1256
|
}
|
|
1257
|
+
if (
|
|
1258
|
+
signal?.aborted === true &&
|
|
1259
|
+
(error === signal.reason ||
|
|
1260
|
+
(error instanceof Error && (error.cause === signal.reason || error.name === 'AbortError')))
|
|
1261
|
+
)
|
|
1262
|
+
return 'cancelled';
|
|
1272
1263
|
return 'failed';
|
|
1273
1264
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { routingIdsEqual } from '../routing-id';
|
|
1
2
|
import type { Message } from '../../contracts/Common/Message';
|
|
2
3
|
import { ZLINK_DEFAULT_PUBLIC_WEIGHT } from '../../contracts/Configuration/RegistrationBuilderPolicy';
|
|
3
4
|
import {
|
|
@@ -121,9 +122,9 @@ export class ZLinkClientServerLocationRuntime {
|
|
|
121
122
|
ownerId: owner.ownerId,
|
|
122
123
|
leaseGeneration: owner.leaseGeneration
|
|
123
124
|
};
|
|
124
|
-
const result = await this.
|
|
125
|
-
|
|
126
|
-
|
|
125
|
+
const result = await this.locationRuntime.writeDescriptor(
|
|
126
|
+
(writeSignal) =>
|
|
127
|
+
this.store.updateClientServer(candidate, ZLinkLocationWriteIntent.Takeover, writeSignal),
|
|
127
128
|
signal
|
|
128
129
|
);
|
|
129
130
|
if (result.status !== ZLinkLocationWriteStatus.Stored) {
|
|
@@ -152,9 +153,9 @@ export class ZLinkClientServerLocationRuntime {
|
|
|
152
153
|
descriptorRevision: current.descriptorRevision + 1n,
|
|
153
154
|
weight: runtimeWeight
|
|
154
155
|
};
|
|
155
|
-
const result = await this.
|
|
156
|
-
|
|
157
|
-
|
|
156
|
+
const result = await this.locationRuntime.writeDescriptor(
|
|
157
|
+
(writeSignal) =>
|
|
158
|
+
this.store.updateClientServer(candidate, ZLinkLocationWriteIntent.Renew, writeSignal),
|
|
158
159
|
signal
|
|
159
160
|
);
|
|
160
161
|
if (result.status !== ZLinkLocationWriteStatus.Stored) {
|
|
@@ -181,9 +182,9 @@ export class ZLinkClientServerLocationRuntime {
|
|
|
181
182
|
leaseGeneration: owner.leaseGeneration,
|
|
182
183
|
updatedAt: new Date(0)
|
|
183
184
|
};
|
|
184
|
-
const result = await this.
|
|
185
|
-
|
|
186
|
-
|
|
185
|
+
const result = await this.locationRuntime.writeDescriptor(
|
|
186
|
+
(writeSignal) =>
|
|
187
|
+
this.store.updateClientServer(descriptor, ZLinkLocationWriteIntent.NewClaim, writeSignal),
|
|
187
188
|
signal
|
|
188
189
|
);
|
|
189
190
|
if (result.status !== ZLinkLocationWriteStatus.Stored) {
|
|
@@ -587,7 +588,7 @@ function requireMatchingAdmission(
|
|
|
587
588
|
): void {
|
|
588
589
|
if (
|
|
589
590
|
actual.channelName !== expected.channelName ||
|
|
590
|
-
actual.serverRid
|
|
591
|
+
!routingIdsEqual(actual.serverRid, expected.serverRid) ||
|
|
591
592
|
actual.lifecycleGeneration !== expected.lifecycleGeneration ||
|
|
592
593
|
actual.descriptorRevision !== expected.descriptorRevision ||
|
|
593
594
|
actual.weight !== expected.weight ||
|
|
@@ -21,6 +21,7 @@ export type { ZLinkDispatchErrorSink } from '../diagnostics/dispatch-error-port'
|
|
|
21
21
|
|
|
22
22
|
type ZLinkRuntimeDispatchFailure = ZLinkDispatchFailure & {
|
|
23
23
|
readonly error?: unknown;
|
|
24
|
+
readonly severity?: 'warning';
|
|
24
25
|
};
|
|
25
26
|
|
|
26
27
|
export class ZLinkDispatchErrorReporter {
|
|
@@ -37,7 +38,7 @@ export class ZLinkDispatchErrorReporter {
|
|
|
37
38
|
_providerResolver: unknown,
|
|
38
39
|
errorSink: ZLinkDispatchErrorSink,
|
|
39
40
|
ctx?: ZLinkDiagnosticsContext,
|
|
40
|
-
|
|
41
|
+
readonly metrics?: ZLinkRuntimeMetrics
|
|
41
42
|
) {
|
|
42
43
|
const flowCtx: ZLinkDiagnosticsContext = ctx ?? {
|
|
43
44
|
diagnostics: DEFAULT_ZLINK_DIAGNOSTICS,
|
|
@@ -86,7 +87,8 @@ export class ZLinkDispatchErrorReporter {
|
|
|
86
87
|
errorType: errorInfo.errorType,
|
|
87
88
|
errorMessage: errorInfo.errorMessage,
|
|
88
89
|
errorCauseType: errorInfo.errorCauseType,
|
|
89
|
-
errorCauseMessage: errorInfo.errorCauseMessage
|
|
90
|
+
errorCauseMessage: errorInfo.errorCauseMessage,
|
|
91
|
+
severity: normalized.severity
|
|
90
92
|
});
|
|
91
93
|
}
|
|
92
94
|
|
|
@@ -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) {
|
|
@@ -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) {
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { AsyncLocalStorage } from 'node:async_hooks';
|
|
2
|
-
import { ZLinkConfigurationException } from '../configuration';
|
|
3
2
|
import { isAbortError } from '../abort';
|
|
4
3
|
import {
|
|
5
4
|
ZLinkFrameworkInternalErrorKind,
|
|
@@ -53,6 +52,7 @@ export class ZLinkSpotSerialTurn {
|
|
|
53
52
|
private suspendedResolve: (() => void) | undefined;
|
|
54
53
|
private suspendedPromise: Promise<void> | undefined;
|
|
55
54
|
private suspendSignaled = false;
|
|
55
|
+
private yieldUsed = false;
|
|
56
56
|
private owner: Promise<unknown> | undefined;
|
|
57
57
|
private frameworkOperationsBlocked = false;
|
|
58
58
|
|
|
@@ -115,26 +115,41 @@ export class ZLinkSpotSerialTurn {
|
|
|
115
115
|
}
|
|
116
116
|
|
|
117
117
|
resetSuspension(): void {
|
|
118
|
+
this.yieldUsed = false;
|
|
118
119
|
this.suspendSignaled = false;
|
|
119
120
|
this.suspendedResolve = undefined;
|
|
120
121
|
this.suspendedPromise = undefined;
|
|
121
122
|
}
|
|
122
123
|
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
124
|
+
admitYield(): void {
|
|
125
|
+
const current = spotSerialTurnStorage.getStore();
|
|
126
|
+
if (
|
|
127
|
+
current?.turn !== this ||
|
|
128
|
+
!this.yieldAllowed ||
|
|
129
|
+
!current.executor.isActiveTurn(this, current.turnId) ||
|
|
130
|
+
this.yieldUsed
|
|
131
|
+
) {
|
|
132
|
+
throw createInternalFrameworkException(
|
|
133
|
+
ZLinkFrameworkInternalErrorKind.InvalidOperation,
|
|
134
|
+
'Yield requires the current SpotWide application turn and may be used only once per turn.'
|
|
127
135
|
);
|
|
128
136
|
}
|
|
137
|
+
this.yieldUsed = true;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
async yieldPromise<T>(pending: Promise<T>): Promise<T> {
|
|
141
|
+
this.admitYield();
|
|
129
142
|
return await this.yieldFrameworkPromise(pending);
|
|
130
143
|
}
|
|
131
144
|
|
|
132
145
|
/** Suspends a turn only for a Framework-owned lifecycle boundary. */
|
|
133
146
|
async yieldFrameworkPromise<T>(pending: Promise<T>): Promise<T> {
|
|
134
147
|
this.signalSuspended();
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
148
|
+
try {
|
|
149
|
+
return await pending;
|
|
150
|
+
} finally {
|
|
151
|
+
await this.awaitResumePermit();
|
|
152
|
+
}
|
|
138
153
|
}
|
|
139
154
|
|
|
140
155
|
async resumeOwnerUntilNextYield(): Promise<void> {
|
|
@@ -204,16 +219,18 @@ export function currentZLinkSpotSerialSourceId(): unknown {
|
|
|
204
219
|
|
|
205
220
|
export function requireZLinkYieldTurn(capturedTurn?: ZLinkSpotSerialTurn): ZLinkSpotSerialTurn {
|
|
206
221
|
const turn = capturedTurn ?? captureZLinkSpotSerialTurn();
|
|
207
|
-
if (turn === undefined
|
|
208
|
-
throw
|
|
209
|
-
|
|
222
|
+
if (turn === undefined) {
|
|
223
|
+
throw createInternalFrameworkException(
|
|
224
|
+
ZLinkFrameworkInternalErrorKind.InvalidOperation,
|
|
225
|
+
'Yield requires a current SpotWide application turn.'
|
|
210
226
|
);
|
|
211
227
|
}
|
|
228
|
+
turn.admitYield();
|
|
212
229
|
return turn;
|
|
213
230
|
}
|
|
214
231
|
|
|
215
232
|
export interface ZLinkCapturedExecutionTurn {
|
|
216
|
-
yieldPromise<T>(
|
|
233
|
+
yieldPromise<T>(operation: () => Promise<T>): Promise<T>;
|
|
217
234
|
post(callback: () => void): void;
|
|
218
235
|
}
|
|
219
236
|
|
|
@@ -223,7 +240,16 @@ export function captureZLinkExecutionTurn(): ZLinkCapturedExecutionTurn | undefi
|
|
|
223
240
|
return undefined;
|
|
224
241
|
}
|
|
225
242
|
return {
|
|
226
|
-
yieldPromise: <T>(
|
|
243
|
+
yieldPromise: <T>(operation: () => Promise<T>) => {
|
|
244
|
+
const turn = requireZLinkYieldTurn(current.turn);
|
|
245
|
+
let pending: Promise<T>;
|
|
246
|
+
try {
|
|
247
|
+
pending = operation();
|
|
248
|
+
} catch (error) {
|
|
249
|
+
pending = Promise.reject(error);
|
|
250
|
+
}
|
|
251
|
+
return turn.yieldFrameworkPromise(pending);
|
|
252
|
+
},
|
|
227
253
|
post: (callback: () => void) => {
|
|
228
254
|
void current.executor.post(callback);
|
|
229
255
|
}
|
|
@@ -241,7 +267,7 @@ export function isCurrentZLinkSpotSerialTurn(executor: ZLinkSpotSerialTurnExecut
|
|
|
241
267
|
|
|
242
268
|
export interface ZLinkExecutionBarrierSeal {
|
|
243
269
|
readonly generation: bigint;
|
|
244
|
-
readonly kind: 'close' | 'relocation';
|
|
270
|
+
readonly kind: 'close' | 'relocation' | 'activation';
|
|
245
271
|
}
|
|
246
272
|
|
|
247
273
|
export interface ZLinkExecutionBarrierClaim {
|