@zlink-systems/framework 0.30.3 → 0.32.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/.tsbuildinfo +1 -1
- package/dist/contracts/Actors/ZLinkActor.d.ts +2 -0
- package/dist/contracts/Actors/ZLinkSessionBindingIdentity.d.ts +6 -0
- package/dist/contracts/Actors/ZLinkSessionBindingIdentity.js +2 -0
- package/dist/contracts/Actors/index.d.ts +1 -0
- package/dist/contracts/Actors/index.js +1 -0
- package/dist/contracts/Common/CoreTypes.d.ts +1 -0
- package/dist/contracts/Common/HandlerMessageType.d.ts +8 -0
- package/dist/contracts/Common/HandlerMessageType.js +41 -0
- package/dist/contracts/Common/ZLinkEncodedPayload.d.ts +1 -1
- package/dist/contracts/Common/ZLinkEncodedPayload.js +12 -20
- package/dist/contracts/Common/ZLinkMessage.js +11 -7
- package/dist/contracts/Common/encoded-payload-storage.d.ts +0 -2
- package/dist/contracts/Common/encoded-payload-storage.js +4 -16
- package/dist/contracts/Common/index.d.ts +1 -1
- package/dist/contracts/Common/payload-slab.d.ts +4 -0
- package/dist/contracts/Common/payload-slab.js +30 -0
- package/dist/contracts/Configuration/RegistrationBuilders.js +15 -9
- package/dist/contracts/Configuration/RegistrationTypes.d.ts +19 -0
- package/dist/contracts/Handlers/Contexts.d.ts +1 -0
- package/dist/contracts/Locations/Authority.d.ts +2 -0
- package/dist/internal.d.ts +9 -0
- package/dist/internal.js +23 -1
- package/dist/nest-integration.d.ts +1 -0
- package/dist/nest-integration.js +3 -1
- package/dist/runtime/actors/actor-client.d.ts +6 -2
- package/dist/runtime/actors/actor-client.js +120 -82
- package/dist/runtime/actors/actor-context.js +16 -5
- package/dist/runtime/actors/actor-execution-context.js +2 -2
- package/dist/runtime/actors/actor-handoff.d.ts +12 -1
- package/dist/runtime/actors/actor-handoff.js +79 -34
- package/dist/runtime/actors/actor-join-deferred-scope.js +6 -6
- package/dist/runtime/actors/actor-local-native-join.d.ts +2 -2
- package/dist/runtime/actors/actor-local-native-join.js +19 -17
- package/dist/runtime/actors/actor-mailbox.d.ts +1 -1
- package/dist/runtime/actors/actor-remote-joiner.d.ts +2 -2
- package/dist/runtime/actors/actor-remote-joiner.js +4 -4
- package/dist/runtime/actors/actor-routed-join-transport.d.ts +9 -3
- package/dist/runtime/actors/actor-routed-json-request.d.ts +3 -0
- package/dist/runtime/actors/actor-runtime-contracts.d.ts +2 -2
- package/dist/runtime/actors/actor-runtime-state.d.ts +1 -1
- package/dist/runtime/actors/spot-actor-dispatch.d.ts +9 -5
- package/dist/runtime/actors/spot-actor-dispatch.js +60 -38
- package/dist/runtime/admission.d.ts +6 -4
- package/dist/runtime/admission.js +21 -10
- package/dist/runtime/application-jobs/application-ingress-record-owner.d.ts +1 -0
- package/dist/runtime/application-jobs/application-ingress-record-owner.js +3 -0
- package/dist/runtime/backend/contracts/index.d.ts +26 -10
- package/dist/runtime/backend/mesh-completion-table.d.ts +7 -1
- package/dist/runtime/backend/mesh-completion-table.js +84 -20
- package/dist/runtime/backend/mesh-dispatch-pump.d.ts +19 -6
- package/dist/runtime/backend/mesh-dispatch-pump.js +246 -147
- package/dist/runtime/backend/node/node-backend-adapter-support.d.ts +3 -2
- package/dist/runtime/backend/node/node-backend-adapter-support.js +27 -19
- package/dist/runtime/backend/node/node-dealer-channel-client-transport.d.ts +5 -2
- package/dist/runtime/backend/node/node-dealer-channel-client-transport.js +70 -13
- package/dist/runtime/backend/node/node-event-loop-poller.d.ts +2 -2
- package/dist/runtime/backend/node/node-event-loop-poller.js +4 -3
- package/dist/runtime/backend/node/node-mesh-backend-adapter.js +5 -1
- package/dist/runtime/backend/node/node-raw-binding-port.d.ts +7 -2
- package/dist/runtime/backend/node/node-raw-binding-port.js +99 -63
- package/dist/runtime/backend/node/node-raw-mesh-backend.d.ts +34 -16
- package/dist/runtime/backend/node/node-raw-mesh-backend.js +210 -106
- package/dist/runtime/backend/node/node-socket-backend-adapter.js +20 -6
- package/dist/runtime/backend/raw-binding-port.d.ts +6 -3
- package/dist/runtime/channels/channel-clients.js +3 -3
- package/dist/runtime/channels/channel-dispatch-pipeline.d.ts +11 -7
- package/dist/runtime/channels/channel-dispatch-pipeline.js +40 -22
- package/dist/runtime/channels/channel-dispatch-services.d.ts +3 -1
- package/dist/runtime/channels/channel-dispatch-services.js +7 -6
- package/dist/runtime/channels/channel-dispatchers.d.ts +13 -6
- package/dist/runtime/channels/channel-dispatchers.js +57 -36
- package/dist/runtime/channels/channel-envelope.d.ts +2 -2
- package/dist/runtime/channels/channel-envelope.js +609 -83
- package/dist/runtime/channels/channel-multipart.d.ts +1 -0
- package/dist/runtime/channels/channel-multipart.js +10 -6
- package/dist/runtime/channels/channel-outbound-operations.d.ts +6 -9
- package/dist/runtime/channels/channel-outbound-operations.js +107 -105
- package/dist/runtime/channels/channel-receive-loops.d.ts +9 -7
- package/dist/runtime/channels/channel-receive-loops.js +126 -90
- package/dist/runtime/channels/channel-runtime-lifecycle.d.ts +23 -6
- package/dist/runtime/channels/channel-runtime-lifecycle.js +47 -38
- package/dist/runtime/channels/channel-runtime-manager.d.ts +13 -6
- package/dist/runtime/channels/channel-runtime-manager.js +32 -14
- package/dist/runtime/channels/channel-socket-registry.d.ts +28 -4
- package/dist/runtime/channels/channel-socket-registry.js +9 -1
- package/dist/runtime/channels/channel-transports.d.ts +23 -16
- package/dist/runtime/channels/channel-transports.js +139 -119
- package/dist/runtime/channels/dispatch-error-reporter.d.ts +4 -4
- package/dist/runtime/channels/dispatch-error-reporter.js +5 -5
- package/dist/runtime/channels/fanout-location-runtime.d.ts +1 -1
- package/dist/runtime/channels/local-spot-route-transport.d.ts +5 -2
- package/dist/runtime/channels/local-spot-route-transport.js +15 -18
- package/dist/runtime/channels/router-socket-spot-route-transport.d.ts +6 -3
- package/dist/runtime/channels/router-socket-spot-route-transport.js +33 -19
- package/dist/runtime/channels/source-spot-router.d.ts +6 -3
- package/dist/runtime/channels/source-spot-router.js +34 -23
- package/dist/runtime/channels/spot-node-route-transport.d.ts +6 -3
- package/dist/runtime/channels/spot-node-route-transport.js +23 -17
- package/dist/runtime/channels/spot-route-bridge-transport.d.ts +6 -3
- package/dist/runtime/channels/spot-route-bridge-transport.js +38 -24
- package/dist/runtime/channels/spot-route-dispatch-strategy.d.ts +8 -4
- package/dist/runtime/channels/spot-route-dispatch-strategy.js +36 -23
- package/dist/runtime/diagnostics/dispatch-error-details.js +9 -3
- package/dist/runtime/diagnostics/message-flow-bootstrap.d.ts +1 -0
- package/dist/runtime/diagnostics/message-flow-bootstrap.js +8 -0
- package/dist/runtime/diagnostics/message-flow-delivery.d.ts +47 -0
- package/dist/runtime/diagnostics/message-flow-delivery.js +149 -0
- package/dist/runtime/diagnostics/message-flow-record.d.ts +50 -0
- package/dist/runtime/diagnostics/message-flow-record.js +228 -0
- package/dist/runtime/diagnostics/message-flow-worker.d.ts +1 -0
- package/dist/runtime/diagnostics/message-flow-worker.js +118 -0
- package/dist/runtime/diagnostics/message-flow.d.ts +7 -19
- package/dist/runtime/diagnostics/message-flow.js +42 -290
- package/dist/runtime/diagnostics/runtime-metrics.d.ts +4 -3
- package/dist/runtime/diagnostics/runtime-metrics.js +8 -4
- package/dist/runtime/execution/index.d.ts +1 -0
- package/dist/runtime/execution/index.js +6 -3
- package/dist/runtime/execution/serial-execution-queue.d.ts +26 -13
- package/dist/runtime/execution/serial-execution-queue.js +75 -71
- package/dist/runtime/foundation/durable-service-request.d.ts +12 -3
- package/dist/runtime/foundation/durable-service-request.js +158 -73
- package/dist/runtime/foundation/operation-registry.d.ts +33 -3
- package/dist/runtime/foundation/operation-registry.js +272 -33
- package/dist/runtime/foundation/raw-service-mesh-runtime.d.ts +62 -23
- package/dist/runtime/foundation/raw-service-mesh-runtime.js +373 -194
- package/dist/runtime/foundation/request-runtime.d.ts +17 -0
- package/dist/runtime/foundation/request-runtime.js +163 -0
- package/dist/runtime/foundation/service-discovery-registry.d.ts +4 -0
- package/dist/runtime/foundation/service-discovery-registry.js +6 -0
- package/dist/runtime/foundation/service-liveness-registry.d.ts +1 -1
- package/dist/runtime/foundation/service-mailbox.d.ts +4 -2
- package/dist/runtime/foundation/service-mailbox.js +4 -1
- package/dist/runtime/foundation/service-relocation-object-owner.d.ts +2 -2
- package/dist/runtime/foundation/service-relocation-object-owner.js +12 -5
- package/dist/runtime/foundation/service-runtime-contracts.d.ts +7 -2
- package/dist/runtime/foundation/service-stateful-registry.d.ts +6 -2
- package/dist/runtime/foundation/service-stateful-registry.js +38 -17
- package/dist/runtime/foundation/service-stateful-runtime.d.ts +91 -26
- package/dist/runtime/foundation/service-stateful-runtime.js +245 -120
- package/dist/runtime/foundation/service-stateful-wire-codec.d.ts +3 -0
- package/dist/runtime/foundation/service-stateful-wire-codec.js +15 -0
- package/dist/runtime/foundation/service-topology-registry.d.ts +2 -0
- package/dist/runtime/foundation/service-topology-registry.js +13 -3
- package/dist/runtime/foundation/service-wire-constants.generated.d.ts +1 -0
- package/dist/runtime/foundation/service-wire-constants.generated.js +12 -0
- package/dist/runtime/foundation/service-wire-m6a-codec.d.ts +5 -1
- package/dist/runtime/foundation/service-wire-m6a-codec.js +50 -15
- package/dist/runtime/host/actor-packet-relay.d.ts +5 -6
- package/dist/runtime/host/actor-packet-relay.js +58 -57
- package/dist/runtime/host/actor-placement-coordinator.d.ts +1 -1
- package/dist/runtime/host/actor-runtime-options-factory.d.ts +2 -0
- package/dist/runtime/host/actor-runtime-options-factory.js +3 -2
- package/dist/runtime/host/actor-transfer-runtime.d.ts +3 -3
- package/dist/runtime/host/application-job-queue.d.ts +7 -5
- package/dist/runtime/host/application-job-queue.js +33 -21
- package/dist/runtime/host/bound-session-relay.js +0 -1
- package/dist/runtime/host/channel-runtime-options-factory.d.ts +2 -0
- package/dist/runtime/host/channel-runtime-options-factory.js +1 -0
- package/dist/runtime/host/entry-actor-runtime.d.ts +5 -2
- package/dist/runtime/host/entry-actor-runtime.js +2 -2
- package/dist/runtime/host/index.d.ts +106 -37
- package/dist/runtime/host/index.js +303 -151
- package/dist/runtime/host/location-runtime-owner.d.ts +2 -2
- package/dist/runtime/host/location-runtime-owner.js +1 -1
- package/dist/runtime/host/service-relocation-host-runtime.d.ts +195 -45
- package/dist/runtime/host/service-relocation-host-runtime.js +257 -144
- package/dist/runtime/host/spot-address-transport.d.ts +3 -0
- package/dist/runtime/host/spot-address-transport.js +73 -76
- package/dist/runtime/host/spot-runtime-options-factory.js +2 -0
- package/dist/runtime/host/user-spot-creation-coordinator.d.ts +3 -1
- package/dist/runtime/host/user-spot-creation-coordinator.js +49 -21
- package/dist/runtime/internal-observation.d.ts +1 -0
- package/dist/runtime/internal-observation.js +5 -0
- package/dist/runtime/locations/actor-location-claims.d.ts +1 -1
- package/dist/runtime/locations/actor-location-claims.js +15 -6
- package/dist/runtime/locations/auto-connect-loop.d.ts +0 -1
- package/dist/runtime/locations/auto-connect-loop.js +25 -19
- package/dist/runtime/locations/auto-connect-planner.js +2 -5
- package/dist/runtime/locations/auto-connect-reconciler.d.ts +1 -0
- package/dist/runtime/locations/auto-connect-reconciler.js +35 -23
- package/dist/runtime/locations/in-memory-authority-store.d.ts +1 -0
- package/dist/runtime/locations/in-memory-authority-store.js +15 -5
- package/dist/runtime/locations/in-memory-location-store.d.ts +0 -2
- package/dist/runtime/locations/in-memory-location-store.js +1 -38
- package/dist/runtime/locations/lifecycle.d.ts +1 -1
- package/dist/runtime/locations/lifecycle.js +2 -2
- package/dist/runtime/locations/location-store-repository.d.ts +0 -1
- package/dist/runtime/locations/location-store-repository.js +163 -246
- package/dist/runtime/locations/resolvers.d.ts +8 -1
- package/dist/runtime/locations/resolvers.js +16 -2
- package/dist/runtime/locations/runtime.d.ts +3 -3
- package/dist/runtime/locations/runtime.js +12 -16
- package/dist/runtime/messaging/creation-payload-codec.js +8 -7
- package/dist/runtime/messaging/framework-json-v1.d.ts +1 -1
- package/dist/runtime/messaging/framework-json-v1.js +6 -2
- package/dist/runtime/messaging/payload-codec.js +21 -35
- package/dist/runtime/messaging/request-deadline.d.ts +4 -2
- package/dist/runtime/messaging/request-deadline.js +40 -25
- package/dist/runtime/messaging/request-result.d.ts +14 -1
- package/dist/runtime/messaging/request-result.js +74 -13
- package/dist/runtime/protocol/service_wire_codec.generated.d.ts +4 -0
- package/dist/runtime/protocol/service_wire_codec.generated.js +17 -7
- package/dist/runtime/spots/index.d.ts +28 -7
- package/dist/runtime/spots/index.js +31 -6
- package/dist/runtime/spots/spot-activation-registry.d.ts +3 -2
- package/dist/runtime/spots/spot-activation-registry.js +13 -8
- package/dist/runtime/spots/spot-activation-state.d.ts +2 -0
- package/dist/runtime/spots/spot-activation-state.js +1 -0
- package/dist/runtime/spots/spot-actor-admission-coordinator.d.ts +9 -4
- package/dist/runtime/spots/spot-actor-admission-coordinator.js +33 -12
- package/dist/runtime/spots/spot-actor-ingress-admission.d.ts +40 -0
- package/dist/runtime/spots/spot-actor-ingress-admission.js +78 -0
- package/dist/runtime/spots/spot-actor-membership.js +3 -3
- package/dist/runtime/spots/spot-actor-packet-dispatch.d.ts +16 -43
- package/dist/runtime/spots/spot-actor-packet-dispatch.js +56 -113
- package/dist/runtime/spots/spot-actor-packet-drain.d.ts +1 -0
- package/dist/runtime/spots/spot-actor-packet-drain.js +12 -5
- package/dist/runtime/spots/spot-entry-activation.d.ts +4 -3
- package/dist/runtime/spots/spot-entry-activation.js +7 -12
- package/dist/runtime/spots/spot-handler-registry.d.ts +5 -1
- package/dist/runtime/spots/spot-handler-registry.js +31 -15
- package/dist/runtime/spots/spot-manager-public.js +3 -2
- package/dist/runtime/spots/spot-node-runtime-manager.d.ts +11 -6
- package/dist/runtime/spots/spot-node-runtime-manager.js +6 -1
- package/dist/runtime/spots/spot-outbound.d.ts +8 -2
- package/dist/runtime/spots/spot-outbound.js +5 -5
- package/dist/runtime/spots/spot-route-packet-dispatch.js +13 -8
- package/dist/runtime/spots/spot-routed-spot-packet-dispatch.d.ts +3 -3
- package/dist/runtime/spots/spot-routed-spot-packet-dispatch.js +9 -5
- package/dist/runtime/spots/spot-runtime-ports.d.ts +2 -2
- package/dist/runtime/spots/spot-serial-executor.d.ts +2 -1
- package/dist/runtime/spots/spot-serial-turn-executor.js +20 -26
- package/dist/runtime/spots/spot-subscription-dispatch.js +5 -2
- package/dist/runtime/spots/spot-timer.d.ts +1 -1
- package/dist/runtime/streams/actor-session-binding-registry.d.ts +11 -3
- package/dist/runtime/streams/actor-session-binding-registry.js +28 -0
- package/dist/runtime/streams/bound-actor-relay-sender.d.ts +2 -2
- package/dist/runtime/streams/bound-actor-relay-sender.js +3 -4
- package/dist/runtime/streams/bound-session-service.js +6 -7
- package/dist/runtime/streams/index.d.ts +3 -3
- package/dist/runtime/streams/index.js +22 -2
- package/dist/runtime/streams/managed-stream.js +2 -1
- package/dist/runtime/streams/session-calls.d.ts +1 -1
- package/dist/runtime/streams/session-calls.js +3 -9
- package/dist/runtime/streams/session-context.d.ts +2 -2
- package/dist/runtime/streams/session-context.js +2 -2
- package/dist/runtime/streams/stream-session-runtime.d.ts +1 -0
- package/dist/runtime/streams/stream-session-runtime.js +64 -33
- package/package.json +3 -3
- package/src/contracts/Actors/ZLinkActor.ts +6 -0
- package/src/contracts/Actors/ZLinkSessionBindingIdentity.ts +7 -0
- package/src/contracts/Actors/index.ts +1 -0
- package/src/contracts/Common/CoreTypes.ts +1 -0
- package/src/contracts/Common/HandlerMessageType.ts +50 -0
- package/src/contracts/Common/ZLinkEncodedPayload.ts +13 -25
- package/src/contracts/Common/ZLinkMessage.ts +11 -7
- package/src/contracts/Common/encoded-payload-storage.ts +4 -16
- package/src/contracts/Common/index.ts +1 -1
- package/src/contracts/Common/payload-slab.ts +29 -0
- package/src/contracts/Configuration/RegistrationBuilders.ts +29 -15
- package/src/contracts/Configuration/RegistrationTypes.ts +19 -0
- package/src/contracts/Handlers/Contexts.ts +1 -0
- package/src/contracts/Locations/Authority.ts +7 -1
- package/src/internal.ts +17 -0
- package/src/nest-integration.ts +1 -0
- package/src/runtime/actors/actor-client.ts +257 -163
- package/src/runtime/actors/actor-context.ts +26 -14
- package/src/runtime/actors/actor-execution-context.ts +2 -2
- package/src/runtime/actors/actor-handoff.ts +86 -51
- package/src/runtime/actors/actor-join-deferred-scope.ts +6 -6
- package/src/runtime/actors/actor-local-native-join.ts +38 -17
- package/src/runtime/actors/actor-mailbox.ts +1 -1
- package/src/runtime/actors/actor-remote-joiner.ts +8 -4
- package/src/runtime/actors/actor-routed-join-transport.ts +13 -5
- package/src/runtime/actors/actor-routed-json-request.ts +3 -0
- package/src/runtime/actors/actor-runtime-contracts.ts +4 -2
- package/src/runtime/actors/actor-runtime-state.ts +1 -1
- package/src/runtime/actors/spot-actor-dispatch.ts +70 -68
- package/src/runtime/admission.ts +42 -15
- package/src/runtime/application-jobs/application-ingress-record-owner.ts +4 -0
- package/src/runtime/backend/contracts/index.ts +77 -10
- package/src/runtime/backend/mesh-completion-table.ts +106 -15
- package/src/runtime/backend/mesh-dispatch-pump.ts +294 -146
- package/src/runtime/backend/node/node-backend-adapter-support.ts +42 -32
- package/src/runtime/backend/node/node-dealer-channel-client-transport.ts +91 -34
- package/src/runtime/backend/node/node-event-loop-poller.ts +14 -5
- package/src/runtime/backend/node/node-mesh-backend-adapter.ts +5 -1
- package/src/runtime/backend/node/node-raw-binding-port.ts +180 -69
- package/src/runtime/backend/node/node-raw-mesh-backend.ts +386 -157
- package/src/runtime/backend/node/node-socket-backend-adapter.ts +56 -11
- package/src/runtime/backend/raw-binding-port.ts +13 -5
- package/src/runtime/channels/channel-clients.ts +26 -11
- package/src/runtime/channels/channel-dispatch-pipeline.ts +77 -65
- package/src/runtime/channels/channel-dispatch-services.ts +7 -12
- package/src/runtime/channels/channel-dispatchers.ts +93 -39
- package/src/runtime/channels/channel-envelope.ts +680 -144
- package/src/runtime/channels/channel-multipart.ts +17 -13
- package/src/runtime/channels/channel-outbound-operations.ts +204 -178
- package/src/runtime/channels/channel-receive-loops.ts +160 -107
- package/src/runtime/channels/channel-runtime-lifecycle.ts +64 -59
- package/src/runtime/channels/channel-runtime-manager.ts +74 -27
- package/src/runtime/channels/channel-socket-registry.ts +20 -5
- package/src/runtime/channels/channel-transports.ts +414 -287
- package/src/runtime/channels/dispatch-error-reporter.ts +4 -9
- package/src/runtime/channels/local-spot-route-transport.ts +27 -29
- package/src/runtime/channels/router-socket-spot-route-transport.ts +63 -32
- package/src/runtime/channels/source-spot-router.ts +75 -38
- package/src/runtime/channels/spot-node-route-transport.ts +67 -37
- package/src/runtime/channels/spot-route-bridge-transport.ts +62 -30
- package/src/runtime/channels/spot-route-dispatch-strategy.ts +105 -34
- package/src/runtime/diagnostics/dispatch-error-details.ts +10 -2
- package/src/runtime/diagnostics/message-flow-bootstrap.ts +6 -0
- package/src/runtime/diagnostics/message-flow-delivery.ts +171 -0
- package/src/runtime/diagnostics/message-flow-record.ts +295 -0
- package/src/runtime/diagnostics/message-flow-worker.ts +146 -0
- package/src/runtime/diagnostics/message-flow.ts +49 -362
- package/src/runtime/diagnostics/runtime-metrics.ts +10 -4
- package/src/runtime/execution/index.ts +6 -0
- package/src/runtime/execution/serial-execution-queue.ts +94 -96
- package/src/runtime/foundation/durable-service-request.ts +212 -89
- package/src/runtime/foundation/operation-registry.ts +287 -38
- package/src/runtime/foundation/raw-service-mesh-runtime.ts +617 -292
- package/src/runtime/foundation/request-runtime.ts +227 -0
- package/src/runtime/foundation/service-discovery-registry.ts +7 -0
- package/src/runtime/foundation/service-liveness-registry.ts +1 -1
- package/src/runtime/foundation/service-mailbox.ts +7 -2
- package/src/runtime/foundation/service-relocation-object-owner.ts +21 -6
- package/src/runtime/foundation/service-runtime-contracts.ts +12 -2
- package/src/runtime/foundation/service-stateful-registry.ts +52 -19
- package/src/runtime/foundation/service-stateful-runtime.ts +365 -198
- package/src/runtime/foundation/service-stateful-wire-codec.ts +18 -0
- package/src/runtime/foundation/service-topology-registry.ts +21 -3
- package/src/runtime/foundation/service-wire-constants.generated.ts +10 -0
- package/src/runtime/foundation/service-wire-m6a-codec.ts +69 -17
- package/src/runtime/host/actor-packet-relay.ts +160 -156
- package/src/runtime/host/actor-placement-coordinator.ts +1 -1
- package/src/runtime/host/actor-runtime-options-factory.ts +7 -2
- package/src/runtime/host/actor-transfer-runtime.ts +3 -3
- package/src/runtime/host/application-job-queue.ts +56 -27
- package/src/runtime/host/bound-session-relay.ts +0 -1
- package/src/runtime/host/channel-runtime-options-factory.ts +3 -0
- package/src/runtime/host/entry-actor-runtime.ts +14 -6
- package/src/runtime/host/index.ts +388 -113
- package/src/runtime/host/location-runtime-owner.ts +3 -3
- package/src/runtime/host/service-relocation-host-runtime.ts +380 -252
- package/src/runtime/host/spot-address-transport.ts +110 -95
- package/src/runtime/host/spot-runtime-options-factory.ts +3 -0
- package/src/runtime/host/user-spot-creation-coordinator.ts +69 -22
- package/src/runtime/internal-observation.ts +2 -0
- package/src/runtime/locations/actor-location-claims.ts +42 -16
- package/src/runtime/locations/auto-connect-loop.ts +24 -16
- package/src/runtime/locations/auto-connect-planner.ts +2 -5
- package/src/runtime/locations/auto-connect-reconciler.ts +37 -24
- package/src/runtime/locations/in-memory-authority-store.ts +27 -7
- package/src/runtime/locations/in-memory-location-store.ts +1 -74
- package/src/runtime/locations/lifecycle.ts +4 -2
- package/src/runtime/locations/location-store-repository.ts +228 -308
- package/src/runtime/locations/resolvers.ts +20 -8
- package/src/runtime/locations/runtime.ts +16 -28
- package/src/runtime/messaging/creation-payload-codec.ts +12 -10
- package/src/runtime/messaging/framework-json-v1.ts +10 -1
- package/src/runtime/messaging/payload-codec.ts +50 -75
- package/src/runtime/messaging/request-deadline.ts +47 -39
- package/src/runtime/messaging/request-result.ts +88 -17
- package/src/runtime/protocol/service_wire_codec.generated.ts +18 -8
- package/src/runtime/protocol/service_wire_pilot_codec.generated.ts +1 -1
- package/src/runtime/spots/index.ts +57 -10
- package/src/runtime/spots/spot-activation-registry.ts +12 -8
- package/src/runtime/spots/spot-activation-state.ts +2 -0
- package/src/runtime/spots/spot-actor-admission-coordinator.ts +62 -37
- package/src/runtime/spots/spot-actor-ingress-admission.ts +157 -0
- package/src/runtime/spots/spot-actor-membership.ts +8 -5
- package/src/runtime/spots/spot-actor-packet-dispatch.ts +122 -206
- package/src/runtime/spots/spot-actor-packet-drain.ts +21 -6
- package/src/runtime/spots/spot-entry-activation.ts +25 -35
- package/src/runtime/spots/spot-handler-registry.ts +72 -15
- package/src/runtime/spots/spot-manager-public.ts +4 -2
- package/src/runtime/spots/spot-node-runtime-manager.ts +16 -7
- package/src/runtime/spots/spot-outbound.ts +26 -10
- package/src/runtime/spots/spot-route-packet-dispatch.ts +18 -8
- package/src/runtime/spots/spot-routed-spot-packet-dispatch.ts +14 -8
- package/src/runtime/spots/spot-runtime-ports.ts +5 -2
- package/src/runtime/spots/spot-serial-executor.ts +1 -1
- package/src/runtime/spots/spot-serial-turn-executor.ts +25 -40
- package/src/runtime/spots/spot-subscription-dispatch.ts +9 -2
- package/src/runtime/spots/spot-timer.ts +1 -1
- package/src/runtime/streams/actor-session-binding-registry.ts +46 -3
- package/src/runtime/streams/bound-actor-relay-sender.ts +16 -5
- package/src/runtime/streams/bound-session-service.ts +10 -7
- package/src/runtime/streams/index.ts +30 -4
- package/src/runtime/streams/managed-stream.ts +2 -1
- package/src/runtime/streams/session-calls.ts +9 -14
- package/src/runtime/streams/session-context.ts +6 -11
- package/src/runtime/streams/stream-session-runtime.ts +79 -40
- package/dist/runtime/spots/spot-lifecycle-metrics.d.ts +0 -8
- package/dist/runtime/spots/spot-lifecycle-metrics.js +0 -17
- package/src/runtime/spots/spot-lifecycle-metrics.ts +0 -16
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ZLinkMessageFlowDelivery = exports.TELEMETRY_STATE_BYTES = exports.TelemetryCounter = exports.TelemetryState = exports.TELEMETRY_WORKER_AVAILABLE = exports.MESSAGE_FLOW_PENDING_LIMIT = void 0;
|
|
4
|
+
exports.openTelemetryLease = openTelemetryLease;
|
|
5
|
+
exports.renewTelemetryLease = renewTelemetryLease;
|
|
6
|
+
exports.messageFlowDelivery = messageFlowDelivery;
|
|
7
|
+
exports.telemetryProviderFailureCount = telemetryProviderFailureCount;
|
|
8
|
+
exports.retireTelemetryLease = retireTelemetryLease;
|
|
9
|
+
const node_worker_threads_1 = require("node:worker_threads");
|
|
10
|
+
// The process owner counts records until the worker takes them, including batches
|
|
11
|
+
// already posted to its port. Only the worker decrements in-transit records.
|
|
12
|
+
exports.MESSAGE_FLOW_PENDING_LIMIT = 8192;
|
|
13
|
+
exports.TELEMETRY_WORKER_AVAILABLE = 'zlink.telemetry.available';
|
|
14
|
+
var TelemetryState;
|
|
15
|
+
(function (TelemetryState) {
|
|
16
|
+
TelemetryState[TelemetryState["Pending"] = 0] = "Pending";
|
|
17
|
+
TelemetryState[TelemetryState["Enabled"] = 1] = "Enabled";
|
|
18
|
+
TelemetryState[TelemetryState["Length"] = 2] = "Length";
|
|
19
|
+
})(TelemetryState || (exports.TelemetryState = TelemetryState = {}));
|
|
20
|
+
var TelemetryCounter;
|
|
21
|
+
(function (TelemetryCounter) {
|
|
22
|
+
TelemetryCounter[TelemetryCounter["Overflow"] = 0] = "Overflow";
|
|
23
|
+
TelemetryCounter[TelemetryCounter["LoggerFailures"] = 1] = "LoggerFailures";
|
|
24
|
+
TelemetryCounter[TelemetryCounter["TraceFailures"] = 2] = "TraceFailures";
|
|
25
|
+
TelemetryCounter[TelemetryCounter["FallbackFailures"] = 3] = "FallbackFailures";
|
|
26
|
+
TelemetryCounter[TelemetryCounter["WorkerFailures"] = 4] = "WorkerFailures";
|
|
27
|
+
TelemetryCounter[TelemetryCounter["Length"] = 5] = "Length";
|
|
28
|
+
})(TelemetryCounter || (exports.TelemetryCounter = TelemetryCounter = {}));
|
|
29
|
+
exports.TELEMETRY_STATE_BYTES = Math.ceil((TelemetryState.Length * Int32Array.BYTES_PER_ELEMENT) / BigUint64Array.BYTES_PER_ELEMENT) * BigUint64Array.BYTES_PER_ELEMENT;
|
|
30
|
+
function openTelemetryLease() {
|
|
31
|
+
return { retired: new Int32Array(new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT)) };
|
|
32
|
+
}
|
|
33
|
+
function renewTelemetryLease(lease) {
|
|
34
|
+
return lease === undefined || Atomics.load(lease.retired, 0) !== 0 ? openTelemetryLease() : lease;
|
|
35
|
+
}
|
|
36
|
+
let processOwner;
|
|
37
|
+
function messageFlowDelivery() {
|
|
38
|
+
return (processOwner ??= new ZLinkMessageFlowDelivery());
|
|
39
|
+
}
|
|
40
|
+
function telemetryProviderFailureCount() {
|
|
41
|
+
return processOwner === undefined
|
|
42
|
+
? 0
|
|
43
|
+
: Number(Atomics.load(processOwner.counters, TelemetryCounter.LoggerFailures) +
|
|
44
|
+
Atomics.load(processOwner.counters, TelemetryCounter.TraceFailures));
|
|
45
|
+
}
|
|
46
|
+
function retireTelemetryLease(lease) {
|
|
47
|
+
Atomics.store(lease.retired, 0, 1);
|
|
48
|
+
processOwner?.retire(lease);
|
|
49
|
+
}
|
|
50
|
+
class ZLinkMessageFlowDelivery {
|
|
51
|
+
sharedState = new SharedArrayBuffer(exports.TELEMETRY_STATE_BYTES + TelemetryCounter.Length * BigUint64Array.BYTES_PER_ELEMENT);
|
|
52
|
+
state = new Int32Array(this.sharedState, 0, TelemetryState.Length);
|
|
53
|
+
counters = new BigUint64Array(this.sharedState, exports.TELEMETRY_STATE_BYTES, TelemetryCounter.Length);
|
|
54
|
+
ready;
|
|
55
|
+
worker;
|
|
56
|
+
failure;
|
|
57
|
+
pending = [];
|
|
58
|
+
executing = false;
|
|
59
|
+
workerReady = false;
|
|
60
|
+
scheduled;
|
|
61
|
+
constructor() {
|
|
62
|
+
let published;
|
|
63
|
+
// A failed bootstrap leaves this incomplete. Runtime processing never waits
|
|
64
|
+
// for it, and no rejected promise can escape into the host process.
|
|
65
|
+
this.ready = new Promise((resolve) => {
|
|
66
|
+
published = resolve;
|
|
67
|
+
});
|
|
68
|
+
// NODE_OPTIONS preloads precede execArgv preloads. Keep both application
|
|
69
|
+
// lists intact and capture the public default provider before either list.
|
|
70
|
+
try {
|
|
71
|
+
const bootstrap = require.resolve('./message-flow-bootstrap').replace(/\\/g, '/');
|
|
72
|
+
this.worker = new node_worker_threads_1.Worker(require.resolve('./message-flow-worker'), {
|
|
73
|
+
workerData: this.state.buffer,
|
|
74
|
+
env: {
|
|
75
|
+
...process.env,
|
|
76
|
+
NODE_OPTIONS: `--require "${bootstrap}" ${process.env.NODE_OPTIONS ?? ''}`
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
this.worker.once('error', (error) => this.workerFailed(error));
|
|
80
|
+
this.worker.once('exit', (code) => {
|
|
81
|
+
if (this.failure === undefined)
|
|
82
|
+
this.workerFailed(new Error(`Telemetry worker exited with code ${code}.`));
|
|
83
|
+
});
|
|
84
|
+
this.worker.on('message', (message) => {
|
|
85
|
+
if (message !== exports.TELEMETRY_WORKER_AVAILABLE || this.failure !== undefined)
|
|
86
|
+
return;
|
|
87
|
+
this.workerReady = true;
|
|
88
|
+
this.executing = false;
|
|
89
|
+
this.flush();
|
|
90
|
+
published();
|
|
91
|
+
});
|
|
92
|
+
this.worker.unref();
|
|
93
|
+
}
|
|
94
|
+
catch (error) {
|
|
95
|
+
this.workerFailed(error instanceof Error ? error : new Error(String(error)));
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
workerFailed(error) {
|
|
99
|
+
if (this.failure !== undefined)
|
|
100
|
+
return;
|
|
101
|
+
this.failure = error;
|
|
102
|
+
Atomics.add(this.counters, TelemetryCounter.WorkerFailures, 1n);
|
|
103
|
+
Atomics.store(this.state, TelemetryState.Enabled, 0);
|
|
104
|
+
this.workerReady = false;
|
|
105
|
+
this.executing = false;
|
|
106
|
+
this.pending = [];
|
|
107
|
+
Atomics.store(this.state, TelemetryState.Pending, 0);
|
|
108
|
+
}
|
|
109
|
+
enabled() {
|
|
110
|
+
return Atomics.load(this.state, TelemetryState.Enabled) !== 0;
|
|
111
|
+
}
|
|
112
|
+
accepts(lease) {
|
|
113
|
+
return this.enabled() && Atomics.load(lease.retired, 0) === 0;
|
|
114
|
+
}
|
|
115
|
+
submit(lease, record) {
|
|
116
|
+
if (!this.accepts(lease))
|
|
117
|
+
return;
|
|
118
|
+
if (Atomics.load(this.state, TelemetryState.Pending) === exports.MESSAGE_FLOW_PENDING_LIMIT) {
|
|
119
|
+
Atomics.add(this.counters, TelemetryCounter.Overflow, 1n);
|
|
120
|
+
return;
|
|
121
|
+
}
|
|
122
|
+
Atomics.add(this.state, TelemetryState.Pending, 1);
|
|
123
|
+
this.pending.push({ lease: lease.retired.buffer, record });
|
|
124
|
+
if (this.workerReady && !this.executing && this.scheduled === undefined) {
|
|
125
|
+
this.scheduled = setImmediate(() => {
|
|
126
|
+
this.scheduled = undefined;
|
|
127
|
+
this.flush();
|
|
128
|
+
});
|
|
129
|
+
this.scheduled.unref();
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
retire(lease) {
|
|
133
|
+
const retained = this.pending.filter((item) => item.lease !== lease.retired.buffer);
|
|
134
|
+
Atomics.sub(this.state, TelemetryState.Pending, this.pending.length - retained.length);
|
|
135
|
+
this.pending = retained;
|
|
136
|
+
}
|
|
137
|
+
flush() {
|
|
138
|
+
if (this.worker === undefined ||
|
|
139
|
+
!this.workerReady ||
|
|
140
|
+
this.executing ||
|
|
141
|
+
this.pending.length === 0)
|
|
142
|
+
return;
|
|
143
|
+
const batch = this.pending;
|
|
144
|
+
this.pending = [];
|
|
145
|
+
this.executing = true;
|
|
146
|
+
this.worker.postMessage(batch);
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
exports.ZLinkMessageFlowDelivery = ZLinkMessageFlowDelivery;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import type { Attributes } from '@opentelemetry/api';
|
|
2
|
+
import type { ZLinkMessageFlowLogMode } from '../../contracts';
|
|
3
|
+
import { type ZLinkRuntimeMessageFlowEvent, type ZLinkRuntimeMessageFlowResult } from '../../contracts/Dispatch/ZLinkDispatchOptions';
|
|
4
|
+
export declare const TELEMETRY_INSTRUMENTATION_NAME = "@zlink-systems/framework";
|
|
5
|
+
export declare const MESSAGE_FLOW_EVENT_ID = "zlink.message_flow";
|
|
6
|
+
export declare const DISPATCH_ERROR_EVENT_ID = "zlink.dispatch_error";
|
|
7
|
+
export interface ZLinkTelemetryRecord {
|
|
8
|
+
readonly severity?: 'warning';
|
|
9
|
+
readonly eventId: typeof MESSAGE_FLOW_EVENT_ID | typeof DISPATCH_ERROR_EVENT_ID;
|
|
10
|
+
readonly timestamp: Date;
|
|
11
|
+
readonly phase?: string;
|
|
12
|
+
readonly outcome: ZLinkRuntimeMessageFlowResult;
|
|
13
|
+
readonly surface: 'node' | 'channel' | 'spot' | 'instance_spot' | 'actor' | 'stream' | 'actor_relocation' | 'classic_fanout';
|
|
14
|
+
readonly messageKind: 'request' | 'send' | 'response' | 'error' | 'control';
|
|
15
|
+
readonly reason?: string;
|
|
16
|
+
readonly action?: string;
|
|
17
|
+
readonly packetName?: string;
|
|
18
|
+
readonly channelName?: string;
|
|
19
|
+
readonly channelRouteKind?: 'route_mesh' | 'client_server';
|
|
20
|
+
readonly meshName?: string;
|
|
21
|
+
readonly topic?: string;
|
|
22
|
+
readonly correlationId?: string;
|
|
23
|
+
readonly sourceRid?: string;
|
|
24
|
+
readonly targetRid?: string;
|
|
25
|
+
readonly serverRid?: string;
|
|
26
|
+
readonly flowId?: string;
|
|
27
|
+
readonly flowOrigin?: string;
|
|
28
|
+
readonly spotId?: string;
|
|
29
|
+
readonly instanceSpotType?: string;
|
|
30
|
+
readonly activationState?: string;
|
|
31
|
+
readonly actorId?: string;
|
|
32
|
+
readonly streamSessionId?: string;
|
|
33
|
+
readonly commandId?: number;
|
|
34
|
+
readonly messageSizeBytes?: number;
|
|
35
|
+
readonly durationSeconds?: number;
|
|
36
|
+
readonly errorType?: string;
|
|
37
|
+
readonly errorMessage?: string;
|
|
38
|
+
readonly errorCauseType?: string;
|
|
39
|
+
readonly errorCauseMessage?: string;
|
|
40
|
+
}
|
|
41
|
+
export type MessageFlowInput = Omit<ZLinkRuntimeMessageFlowEvent, 'effectiveMode' | 'flowId' | 'flowOrigin'> & {
|
|
42
|
+
readonly severity?: 'warning';
|
|
43
|
+
readonly effectiveMode?: ZLinkMessageFlowLogMode;
|
|
44
|
+
readonly flowId?: string;
|
|
45
|
+
readonly flowOrigin?: import('../../contracts').ZLinkFlowOrigin;
|
|
46
|
+
};
|
|
47
|
+
export declare function toTelemetryRecord(flow: MessageFlowInput, messageSizeBytes: number | undefined, durationSeconds: number | undefined): ZLinkTelemetryRecord;
|
|
48
|
+
export declare function traceAttributes(record: ZLinkTelemetryRecord): Attributes;
|
|
49
|
+
export declare function structuredLogAttributes(record: ZLinkTelemetryRecord): Attributes;
|
|
50
|
+
export declare function structuredLogBody(record: ZLinkTelemetryRecord): string;
|
|
@@ -0,0 +1,228 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DISPATCH_ERROR_EVENT_ID = exports.MESSAGE_FLOW_EVENT_ID = exports.TELEMETRY_INSTRUMENTATION_NAME = void 0;
|
|
4
|
+
exports.toTelemetryRecord = toTelemetryRecord;
|
|
5
|
+
exports.traceAttributes = traceAttributes;
|
|
6
|
+
exports.structuredLogAttributes = structuredLogAttributes;
|
|
7
|
+
exports.structuredLogBody = structuredLogBody;
|
|
8
|
+
const ZLinkDispatchOptions_1 = require("../../contracts/Dispatch/ZLinkDispatchOptions");
|
|
9
|
+
const dispatch_error_details_1 = require("./dispatch-error-details");
|
|
10
|
+
const flow_context_1 = require("./flow-context");
|
|
11
|
+
exports.TELEMETRY_INSTRUMENTATION_NAME = '@zlink-systems/framework';
|
|
12
|
+
exports.MESSAGE_FLOW_EVENT_ID = 'zlink.message_flow';
|
|
13
|
+
exports.DISPATCH_ERROR_EVENT_ID = 'zlink.dispatch_error';
|
|
14
|
+
function toTelemetryRecord(flow, messageSizeBytes, durationSeconds) {
|
|
15
|
+
return {
|
|
16
|
+
severity: flow.severity,
|
|
17
|
+
eventId: flow.outcome === ZLinkDispatchOptions_1.ZLinkRuntimeMessageFlowOutcome.Error
|
|
18
|
+
? exports.DISPATCH_ERROR_EVENT_ID
|
|
19
|
+
: exports.MESSAGE_FLOW_EVENT_ID,
|
|
20
|
+
timestamp: new Date(),
|
|
21
|
+
phase: messageFlowPhase(flow.outcome),
|
|
22
|
+
outcome: flow.result ?? messageFlowOutcome(flow.outcome),
|
|
23
|
+
surface: messageFlowSurface(flow.surface),
|
|
24
|
+
messageKind: messageFlowKind(flow.messageKind),
|
|
25
|
+
reason: flow.errorReason,
|
|
26
|
+
action: flow.errorAction,
|
|
27
|
+
packetName: flow.packetName,
|
|
28
|
+
channelName: flow.channelName,
|
|
29
|
+
channelRouteKind: flow.channelRouteKind ?? channelRouteKind(flow.surface),
|
|
30
|
+
meshName: flow.meshName,
|
|
31
|
+
topic: flow.topic,
|
|
32
|
+
correlationId: flow.correlationId,
|
|
33
|
+
sourceRid: flow.sourceRid,
|
|
34
|
+
targetRid: flow.targetRid,
|
|
35
|
+
serverRid: flow.serverRid,
|
|
36
|
+
flowId: flow.flowId,
|
|
37
|
+
flowOrigin: flow.flowOrigin === undefined ? undefined : flow_context_1.FLOW_ORIGIN_VALUES[flow.flowOrigin],
|
|
38
|
+
spotId: flow.spotId,
|
|
39
|
+
instanceSpotType: flow.instanceSpotType,
|
|
40
|
+
activationState: flow.activationState,
|
|
41
|
+
actorId: flow.actorId,
|
|
42
|
+
streamSessionId: flow.streamSessionId,
|
|
43
|
+
commandId: flow.commandId,
|
|
44
|
+
messageSizeBytes,
|
|
45
|
+
durationSeconds,
|
|
46
|
+
errorType: flow.errorType,
|
|
47
|
+
errorMessage: flow.errorMessage,
|
|
48
|
+
errorCauseType: flow.errorCauseType,
|
|
49
|
+
errorCauseMessage: boundedText(flow.errorCauseMessage)
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
function traceAttributes(record) {
|
|
53
|
+
const attributes = {};
|
|
54
|
+
for (const [name, value] of Object.entries(record)) {
|
|
55
|
+
if (value === undefined || name === 'timestamp' || name === 'severity')
|
|
56
|
+
continue;
|
|
57
|
+
attributes[toSnakeCase(name)] = value instanceof Date ? value.toISOString() : value;
|
|
58
|
+
}
|
|
59
|
+
return attributes;
|
|
60
|
+
}
|
|
61
|
+
function structuredLogAttributes(record) {
|
|
62
|
+
// 기록의 attribute 이름은 Message flow tracing 3.2가 고정한다. 로그 본문의
|
|
63
|
+
// `zlink flow:` 축약 key(`kind`, `mesh` …)와 다른 집합이다 —
|
|
64
|
+
// structuredLogBodyAttributes를 참고.
|
|
65
|
+
return compactAttributes({
|
|
66
|
+
event_id: record.eventId,
|
|
67
|
+
timestamp: record.timestamp.toISOString(),
|
|
68
|
+
phase: record.phase,
|
|
69
|
+
surface: record.surface,
|
|
70
|
+
message_kind: record.messageKind,
|
|
71
|
+
mesh_name: record.meshName,
|
|
72
|
+
channel_name: record.channelName,
|
|
73
|
+
channel_route_kind: record.channelRouteKind,
|
|
74
|
+
source_rid: record.sourceRid,
|
|
75
|
+
target_rid: record.targetRid,
|
|
76
|
+
server_rid: record.serverRid,
|
|
77
|
+
packet_name: record.packetName,
|
|
78
|
+
topic: record.topic,
|
|
79
|
+
spot_id: record.spotId,
|
|
80
|
+
instance_spot_type: record.instanceSpotType,
|
|
81
|
+
activation_state: record.activationState,
|
|
82
|
+
actor_id: record.actorId,
|
|
83
|
+
stream_session_id: record.streamSessionId,
|
|
84
|
+
correlation_id: record.correlationId,
|
|
85
|
+
flow_id: record.flowId,
|
|
86
|
+
flow_origin: record.flowOrigin,
|
|
87
|
+
outcome: record.outcome,
|
|
88
|
+
reason: record.reason,
|
|
89
|
+
action: record.action,
|
|
90
|
+
command_id: record.commandId,
|
|
91
|
+
error_type: record.errorType,
|
|
92
|
+
error_message: record.errorMessage,
|
|
93
|
+
error_cause_type: record.errorCauseType,
|
|
94
|
+
error_cause_message: record.errorCauseMessage,
|
|
95
|
+
message_size_bytes: record.messageSizeBytes,
|
|
96
|
+
duration_seconds: record.durationSeconds
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
function structuredLogBodyAttributes(record) {
|
|
100
|
+
// `zlink flow:` 본문 전용 축약 key — Message flow tracing "Structured log 대체 표기".
|
|
101
|
+
return compactAttributes({
|
|
102
|
+
event: record.eventId,
|
|
103
|
+
phase: record.phase,
|
|
104
|
+
surface: record.surface,
|
|
105
|
+
kind: record.messageKind,
|
|
106
|
+
mesh: record.meshName,
|
|
107
|
+
channel: record.channelName,
|
|
108
|
+
channel_route: record.channelRouteKind,
|
|
109
|
+
source_rid: record.sourceRid,
|
|
110
|
+
target_rid: record.targetRid,
|
|
111
|
+
server_rid: record.serverRid,
|
|
112
|
+
packet: record.packetName,
|
|
113
|
+
topic: record.topic,
|
|
114
|
+
spot: record.spotId,
|
|
115
|
+
instance_type: record.instanceSpotType,
|
|
116
|
+
activation_state: record.activationState,
|
|
117
|
+
actor: record.actorId,
|
|
118
|
+
session: record.streamSessionId,
|
|
119
|
+
corr: record.correlationId,
|
|
120
|
+
flow: record.flowId,
|
|
121
|
+
origin: record.flowOrigin,
|
|
122
|
+
outcome: record.outcome,
|
|
123
|
+
reason: record.reason,
|
|
124
|
+
action: record.action,
|
|
125
|
+
error_type: record.errorType,
|
|
126
|
+
error_message: record.errorMessage,
|
|
127
|
+
size: record.messageSizeBytes
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
function structuredLogBody(record) {
|
|
131
|
+
return `zlink flow: ${Object.entries(structuredLogBodyAttributes(record))
|
|
132
|
+
.map(([key, value]) => `${key}=${String(value)}`)
|
|
133
|
+
.join(' ')}`;
|
|
134
|
+
}
|
|
135
|
+
function compactAttributes(values) {
|
|
136
|
+
const attributes = {};
|
|
137
|
+
for (const [key, value] of Object.entries(values)) {
|
|
138
|
+
if (value !== undefined)
|
|
139
|
+
attributes[key] = value;
|
|
140
|
+
}
|
|
141
|
+
return attributes;
|
|
142
|
+
}
|
|
143
|
+
function messageFlowPhase(outcome) {
|
|
144
|
+
switch (outcome) {
|
|
145
|
+
case ZLinkDispatchOptions_1.ZLinkRuntimeMessageFlowOutcome.Received:
|
|
146
|
+
return 'received';
|
|
147
|
+
case ZLinkDispatchOptions_1.ZLinkRuntimeMessageFlowOutcome.Admitted:
|
|
148
|
+
return 'admitted';
|
|
149
|
+
case ZLinkDispatchOptions_1.ZLinkRuntimeMessageFlowOutcome.Dispatched:
|
|
150
|
+
return 'dispatched';
|
|
151
|
+
case ZLinkDispatchOptions_1.ZLinkRuntimeMessageFlowOutcome.Completed:
|
|
152
|
+
return 'completed';
|
|
153
|
+
case ZLinkDispatchOptions_1.ZLinkRuntimeMessageFlowOutcome.Replied:
|
|
154
|
+
return 'replied';
|
|
155
|
+
case ZLinkDispatchOptions_1.ZLinkRuntimeMessageFlowOutcome.Dropped:
|
|
156
|
+
return 'dropped';
|
|
157
|
+
case ZLinkDispatchOptions_1.ZLinkRuntimeMessageFlowOutcome.Sent:
|
|
158
|
+
return 'sent';
|
|
159
|
+
case ZLinkDispatchOptions_1.ZLinkRuntimeMessageFlowOutcome.ReplyReceived:
|
|
160
|
+
return 'reply_received';
|
|
161
|
+
case ZLinkDispatchOptions_1.ZLinkRuntimeMessageFlowOutcome.Backpressured:
|
|
162
|
+
return 'backpressured';
|
|
163
|
+
case ZLinkDispatchOptions_1.ZLinkRuntimeMessageFlowOutcome.Error:
|
|
164
|
+
return undefined;
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
function messageFlowOutcome(outcome) {
|
|
168
|
+
if (outcome === ZLinkDispatchOptions_1.ZLinkRuntimeMessageFlowOutcome.Error)
|
|
169
|
+
return 'failed';
|
|
170
|
+
if (outcome === ZLinkDispatchOptions_1.ZLinkRuntimeMessageFlowOutcome.Backpressured)
|
|
171
|
+
return 'backpressured';
|
|
172
|
+
if (outcome === ZLinkDispatchOptions_1.ZLinkRuntimeMessageFlowOutcome.Dropped)
|
|
173
|
+
return 'dropped';
|
|
174
|
+
return 'succeeded';
|
|
175
|
+
}
|
|
176
|
+
function messageFlowSurface(surface) {
|
|
177
|
+
switch (surface) {
|
|
178
|
+
case ZLinkDispatchOptions_1.ZLinkDispatchErrorSurface.Node:
|
|
179
|
+
return 'node';
|
|
180
|
+
case ZLinkDispatchOptions_1.ZLinkDispatchErrorSurface.Channel:
|
|
181
|
+
case ZLinkDispatchOptions_1.ZLinkDispatchErrorSurface.RouteMeshChannel:
|
|
182
|
+
return 'channel';
|
|
183
|
+
case ZLinkDispatchOptions_1.ZLinkDispatchErrorSurface.SpotRoute:
|
|
184
|
+
case ZLinkDispatchOptions_1.ZLinkDispatchErrorSurface.SpotSubscription:
|
|
185
|
+
return 'spot';
|
|
186
|
+
case ZLinkDispatchOptions_1.ZLinkDispatchErrorSurface.InstanceSpot:
|
|
187
|
+
return 'instance_spot';
|
|
188
|
+
case ZLinkDispatchOptions_1.ZLinkDispatchErrorSurface.SpotActor:
|
|
189
|
+
return 'actor';
|
|
190
|
+
case ZLinkDispatchOptions_1.ZLinkDispatchErrorSurface.StreamSession:
|
|
191
|
+
return 'stream';
|
|
192
|
+
case ZLinkDispatchOptions_1.ZLinkDispatchErrorSurface.ActorRelocation:
|
|
193
|
+
return 'actor_relocation';
|
|
194
|
+
case ZLinkDispatchOptions_1.ZLinkDispatchErrorSurface.ClassicFanout:
|
|
195
|
+
return 'classic_fanout';
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
function messageFlowKind(kind) {
|
|
199
|
+
switch (kind) {
|
|
200
|
+
case ZLinkDispatchOptions_1.ZLinkDispatchMessageKind.Request:
|
|
201
|
+
case ZLinkDispatchOptions_1.ZLinkDispatchMessageKind.ActorRequest:
|
|
202
|
+
return 'request';
|
|
203
|
+
case ZLinkDispatchOptions_1.ZLinkDispatchMessageKind.Send:
|
|
204
|
+
case ZLinkDispatchOptions_1.ZLinkDispatchMessageKind.ActorSend:
|
|
205
|
+
return 'send';
|
|
206
|
+
case ZLinkDispatchOptions_1.ZLinkDispatchMessageKind.Response:
|
|
207
|
+
return 'response';
|
|
208
|
+
case ZLinkDispatchOptions_1.ZLinkDispatchMessageKind.Error:
|
|
209
|
+
return 'error';
|
|
210
|
+
case ZLinkDispatchOptions_1.ZLinkDispatchMessageKind.Control:
|
|
211
|
+
return 'control';
|
|
212
|
+
case ZLinkDispatchOptions_1.ZLinkDispatchMessageKind.Publish:
|
|
213
|
+
throw new Error('Classic fanout publish must not create a normal message-flow record.');
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
function channelRouteKind(surface) {
|
|
217
|
+
if (surface === ZLinkDispatchOptions_1.ZLinkDispatchErrorSurface.RouteMeshChannel)
|
|
218
|
+
return 'route_mesh';
|
|
219
|
+
if (surface === ZLinkDispatchOptions_1.ZLinkDispatchErrorSurface.Channel)
|
|
220
|
+
return 'client_server';
|
|
221
|
+
return undefined;
|
|
222
|
+
}
|
|
223
|
+
function boundedText(value) {
|
|
224
|
+
return value === undefined ? undefined : value.slice(0, dispatch_error_details_1.ERROR_MESSAGE_MAX_LENGTH);
|
|
225
|
+
}
|
|
226
|
+
function toSnakeCase(value) {
|
|
227
|
+
return value.replace(/[A-Z]/g, (letter) => `_${letter.toLowerCase()}`);
|
|
228
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const node_worker_threads_1 = require("node:worker_threads");
|
|
4
|
+
const api_1 = require("@opentelemetry/api");
|
|
5
|
+
const api_logs_1 = require("@opentelemetry/api-logs");
|
|
6
|
+
const message_flow_bootstrap_1 = require("./message-flow-bootstrap");
|
|
7
|
+
const message_flow_delivery_1 = require("./message-flow-delivery");
|
|
8
|
+
const runtime_metrics_1 = require("./runtime-metrics");
|
|
9
|
+
const Metrics_1 = require("../../contracts/Eventing/Metrics");
|
|
10
|
+
const message_flow_record_1 = require("./message-flow-record");
|
|
11
|
+
const state = new Int32Array(node_worker_threads_1.workerData, 0, message_flow_delivery_1.TelemetryState.Length);
|
|
12
|
+
const counters = new BigUint64Array(node_worker_threads_1.workerData, message_flow_delivery_1.TELEMETRY_STATE_BYTES, message_flow_delivery_1.TelemetryCounter.Length);
|
|
13
|
+
let logger;
|
|
14
|
+
let tracer;
|
|
15
|
+
let overflow;
|
|
16
|
+
const overflowAttributes = { source: 'message_flow' };
|
|
17
|
+
let reportedOverflow = 0n;
|
|
18
|
+
function failed(role, error) {
|
|
19
|
+
if (Atomics.add(counters, role, 1n) !== 0n ||
|
|
20
|
+
Atomics.load(counters, message_flow_delivery_1.TelemetryCounter.FallbackFailures) !== 0n)
|
|
21
|
+
return;
|
|
22
|
+
try {
|
|
23
|
+
const description = error instanceof Error ? `${error.name}: ${error.message}` : String(error);
|
|
24
|
+
process.stderr.write(`ZLink telemetry ${role === message_flow_delivery_1.TelemetryCounter.LoggerFailures ? 'logger' : 'trace'} provider failed: ${description}\n`, (error) => {
|
|
25
|
+
if (error !== undefined && error !== null)
|
|
26
|
+
Atomics.store(counters, message_flow_delivery_1.TelemetryCounter.FallbackFailures, 1n);
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
catch {
|
|
30
|
+
Atomics.store(counters, message_flow_delivery_1.TelemetryCounter.FallbackFailures, 1n);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
function deliver(record) {
|
|
34
|
+
if (logger !== undefined) {
|
|
35
|
+
try {
|
|
36
|
+
const severity = record.severity === 'warning'
|
|
37
|
+
? 'WARN'
|
|
38
|
+
: record.eventId === message_flow_record_1.DISPATCH_ERROR_EVENT_ID
|
|
39
|
+
? 'ERROR'
|
|
40
|
+
: 'INFO';
|
|
41
|
+
logger.emit({
|
|
42
|
+
eventName: record.eventId,
|
|
43
|
+
timestamp: record.timestamp,
|
|
44
|
+
severityNumber: api_logs_1.SeverityNumber[severity],
|
|
45
|
+
severityText: severity,
|
|
46
|
+
body: (0, message_flow_record_1.structuredLogBody)(record),
|
|
47
|
+
attributes: (0, message_flow_record_1.structuredLogAttributes)(record)
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
catch (error) {
|
|
51
|
+
failed(message_flow_delivery_1.TelemetryCounter.LoggerFailures, error);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
if (tracer === undefined)
|
|
55
|
+
return;
|
|
56
|
+
try {
|
|
57
|
+
const span = tracer.startSpan(record.eventId, { attributes: (0, message_flow_record_1.traceAttributes)(record) });
|
|
58
|
+
if (record.eventId === message_flow_record_1.DISPATCH_ERROR_EVENT_ID) {
|
|
59
|
+
span.setStatus({ code: api_1.SpanStatusCode.ERROR, message: record.reason });
|
|
60
|
+
}
|
|
61
|
+
span.end();
|
|
62
|
+
}
|
|
63
|
+
catch (error) {
|
|
64
|
+
failed(message_flow_delivery_1.TelemetryCounter.TraceFailures, error);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
process.stderr.once('error', () => Atomics.store(counters, message_flow_delivery_1.TelemetryCounter.FallbackFailures, 1n));
|
|
68
|
+
const hasLoggerProvider = api_logs_1.logs.getLoggerProvider() !== message_flow_bootstrap_1.initialLoggerProvider;
|
|
69
|
+
if (hasLoggerProvider) {
|
|
70
|
+
try {
|
|
71
|
+
logger = api_logs_1.logs.getLogger(message_flow_record_1.TELEMETRY_INSTRUMENTATION_NAME);
|
|
72
|
+
}
|
|
73
|
+
catch (error) {
|
|
74
|
+
failed(message_flow_delivery_1.TelemetryCounter.LoggerFailures, error);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
let hasTraceProvider = false;
|
|
78
|
+
try {
|
|
79
|
+
const provider = api_1.trace.getTracerProvider();
|
|
80
|
+
tracer =
|
|
81
|
+
provider instanceof api_1.ProxyTracerProvider
|
|
82
|
+
? provider.getDelegateTracer(message_flow_record_1.TELEMETRY_INSTRUMENTATION_NAME)
|
|
83
|
+
: provider.getTracer(message_flow_record_1.TELEMETRY_INSTRUMENTATION_NAME);
|
|
84
|
+
hasTraceProvider = tracer !== undefined;
|
|
85
|
+
}
|
|
86
|
+
catch (error) {
|
|
87
|
+
// The no-provider proxy returns undefined. A delegate throwing getTracer is
|
|
88
|
+
// still a registered provider, and its failure stays in this worker.
|
|
89
|
+
hasTraceProvider = true;
|
|
90
|
+
failed(message_flow_delivery_1.TelemetryCounter.TraceFailures, error);
|
|
91
|
+
}
|
|
92
|
+
// enabled() is an event filter, not a provider-registration test. In particular,
|
|
93
|
+
// an ERROR-only processor may reject an unspecified-severity enabled() query.
|
|
94
|
+
Atomics.store(state, message_flow_delivery_1.TelemetryState.Enabled, hasLoggerProvider || hasTraceProvider ? 1 : 0);
|
|
95
|
+
node_worker_threads_1.parentPort.postMessage(message_flow_delivery_1.TELEMETRY_WORKER_AVAILABLE);
|
|
96
|
+
node_worker_threads_1.parentPort.on('message', (batch) => {
|
|
97
|
+
for (const item of batch) {
|
|
98
|
+
Atomics.sub(state, message_flow_delivery_1.TelemetryState.Pending, 1);
|
|
99
|
+
if (Atomics.load(new Int32Array(item.lease), 0) === 0)
|
|
100
|
+
deliver(item.record);
|
|
101
|
+
}
|
|
102
|
+
const dropped = Atomics.load(counters, message_flow_delivery_1.TelemetryCounter.Overflow);
|
|
103
|
+
if (dropped !== reportedOverflow) {
|
|
104
|
+
try {
|
|
105
|
+
overflow ??= api_1.metrics
|
|
106
|
+
.getMeter(Metrics_1.ZLinkMeters.Framework)
|
|
107
|
+
.createCounter(runtime_metrics_1.METRIC_NAMES.ObservabilityEventsOverflow, {
|
|
108
|
+
unit: runtime_metrics_1.COUNTER_UNITS[runtime_metrics_1.METRIC_NAMES.ObservabilityEventsOverflow]
|
|
109
|
+
});
|
|
110
|
+
overflow.add(Number(dropped - reportedOverflow), overflowAttributes);
|
|
111
|
+
}
|
|
112
|
+
catch (error) {
|
|
113
|
+
failed(message_flow_delivery_1.TelemetryCounter.TraceFailures, error);
|
|
114
|
+
}
|
|
115
|
+
reportedOverflow = dropped;
|
|
116
|
+
}
|
|
117
|
+
node_worker_threads_1.parentPort.postMessage(message_flow_delivery_1.TELEMETRY_WORKER_AVAILABLE);
|
|
118
|
+
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { type ZLinkDiagnosticsOptions, type ZLinkMessageFlowLogMode } from '../../contracts';
|
|
2
|
-
import {
|
|
3
|
-
import type
|
|
1
|
+
import { type ZLinkDiagnosticsOptions, type ZLinkMessageFlowLogMode, ZLinkRuntimeMessageFlowOutcome as ZLinkMessageFlowOutcome, type ZLinkRuntimeMessageFlowResult } from '../../contracts/Dispatch/ZLinkDispatchOptions';
|
|
2
|
+
import { type MessageFlowInput } from './message-flow-record';
|
|
3
|
+
import { type ZLinkTelemetryLease } from './message-flow-delivery';
|
|
4
4
|
export interface ZLinkMessageFlowModeCell {
|
|
5
5
|
mode: ZLinkMessageFlowLogMode;
|
|
6
6
|
}
|
|
@@ -8,9 +8,9 @@ export interface ZLinkDiagnosticsContext {
|
|
|
8
8
|
readonly diagnostics: ZLinkDiagnosticsOptions;
|
|
9
9
|
readonly liveMode: ZLinkMessageFlowModeCell;
|
|
10
10
|
readonly sourceMeshGeneration: bigint;
|
|
11
|
+
readonly telemetryLease?: ZLinkTelemetryLease;
|
|
11
12
|
}
|
|
12
13
|
export declare const DEFAULT_ZLINK_DIAGNOSTICS: ZLinkDiagnosticsOptions;
|
|
13
|
-
export declare const telemetryLogger: import("@opentelemetry/api-logs").Logger;
|
|
14
14
|
export declare function effectiveMessageFlow(ctx: ZLinkDiagnosticsContext): ZLinkMessageFlowLogMode;
|
|
15
15
|
/**
|
|
16
16
|
* Message-flow tracing is on at Normal and Detailed only (04-flow-correlation
|
|
@@ -23,28 +23,21 @@ export declare function createMessageFlowModeCell(dispatch: {
|
|
|
23
23
|
} | undefined): ZLinkMessageFlowModeCell;
|
|
24
24
|
export declare function createDiagnosticsContext(dispatch: {
|
|
25
25
|
diagnostics?: ZLinkDiagnosticsOptions;
|
|
26
|
-
} | undefined, _providerResolver: unknown, liveMode: ZLinkMessageFlowModeCell): ZLinkDiagnosticsContext;
|
|
26
|
+
} | undefined, _providerResolver: unknown, liveMode: ZLinkMessageFlowModeCell, telemetryLease?: ZLinkTelemetryLease): ZLinkDiagnosticsContext;
|
|
27
27
|
export declare function flowIfEnabled(flow: ZLinkMessageFlowTracer | undefined, outcome: ZLinkMessageFlowOutcome, result?: ZLinkRuntimeMessageFlowResult, flowId?: string, sourceMeshGeneration?: bigint | string): ZLinkMessageFlowTracePoint | undefined;
|
|
28
28
|
export interface ZLinkMessageFlowTracePoint {
|
|
29
29
|
trace(flowInput: MessageFlowInput): void;
|
|
30
30
|
}
|
|
31
31
|
export declare function traceSessionBindingControlDrop(flow: ZLinkMessageFlowTracer | undefined, sourceRid: string, actorId: string, packetName: string, errorReason: 'location_unavailable' | 'stale_target', error?: unknown): void;
|
|
32
|
-
type MessageFlowInput = Omit<ZLinkRuntimeMessageFlowEvent, 'effectiveMode' | 'flowId' | 'flowOrigin'> & {
|
|
33
|
-
readonly severity?: 'warning';
|
|
34
|
-
readonly effectiveMode?: ZLinkMessageFlowLogMode;
|
|
35
|
-
readonly flowId?: string;
|
|
36
|
-
readonly flowOrigin?: import('../../contracts').ZLinkFlowOrigin;
|
|
37
|
-
};
|
|
38
32
|
export declare class ZLinkMessageFlowTracer {
|
|
39
33
|
private readonly ctx;
|
|
40
|
-
private readonly errorSink;
|
|
41
34
|
private tracedEvents;
|
|
42
|
-
private
|
|
35
|
+
private readonly telemetryLease;
|
|
43
36
|
private localSamplingSequence;
|
|
44
37
|
private errorsTracePoint?;
|
|
45
38
|
private normalTracePoint?;
|
|
46
39
|
private detailedTracePoint?;
|
|
47
|
-
constructor(ctx: ZLinkDiagnosticsContext
|
|
40
|
+
constructor(ctx: ZLinkDiagnosticsContext);
|
|
48
41
|
enabled(outcome: ZLinkMessageFlowOutcome): boolean;
|
|
49
42
|
accepts(outcome: ZLinkMessageFlowOutcome): boolean;
|
|
50
43
|
begin(outcome: ZLinkMessageFlowOutcome, result?: ZLinkRuntimeMessageFlowResult, flowId?: string, sourceMeshGeneration?: bigint | string): ZLinkMessageFlowTracePoint | undefined;
|
|
@@ -56,9 +49,4 @@ export declare class ZLinkMessageFlowTracer {
|
|
|
56
49
|
get providerFailureCount(): number;
|
|
57
50
|
private sample;
|
|
58
51
|
private nextSamplingSequence;
|
|
59
|
-
private publish;
|
|
60
|
-
private publishToLogger;
|
|
61
|
-
private publishToTrace;
|
|
62
|
-
private reportProviderFailure;
|
|
63
52
|
}
|
|
64
|
-
export {};
|