@zlink-systems/framework 0.30.0 → 0.30.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +150 -68
- package/dist/.tsbuildinfo +1 -1
- package/dist/contracts/Actors/ZLinkActorClient.d.ts +2 -1
- package/dist/contracts/Channels/Calls.d.ts +2 -1
- package/dist/contracts/Common/ZLinkEncodedPayload.d.ts +6 -0
- package/dist/contracts/Common/ZLinkEncodedPayload.js +18 -3
- package/dist/contracts/Common/ZLinkMessageMetadata.js +11 -5
- package/dist/contracts/Common/encoded-payload-storage.d.ts +1 -1
- package/dist/contracts/Common/encoded-payload-storage.js +5 -2
- package/dist/contracts/Configuration/Builders.d.ts +1 -1
- package/dist/contracts/Configuration/RegistrationBuilderPolicy.d.ts +2 -1
- package/dist/contracts/Configuration/RegistrationBuilderPolicy.js +5 -1
- package/dist/contracts/Configuration/RegistrationBuilders.js +2 -2
- package/dist/contracts/Configuration/RegistrationTypes.d.ts +1 -0
- package/dist/contracts/Dispatch/ZLinkDispatchOptions.d.ts +2 -2
- package/dist/contracts/Handlers/Attributes.d.ts +5 -13
- package/dist/contracts/Handlers/Attributes.js +7 -11
- package/dist/contracts/Handlers/JsonContract.d.ts +2 -46
- package/dist/contracts/Handlers/JsonContract.js +4 -153
- package/dist/contracts/Locations/Rows.d.ts +2 -0
- package/dist/contracts/Spots/Contracts.d.ts +6 -1
- package/dist/contracts/Spots/ZLinkSpot.d.ts +3 -3
- package/dist/nest-integration.d.ts +1 -1
- package/dist/nest-integration.js +2 -1
- package/dist/runtime/abort.d.ts +5 -0
- package/dist/runtime/abort.js +10 -0
- package/dist/runtime/actors/actor-authority-publication.js +3 -2
- package/dist/runtime/actors/actor-client.d.ts +1 -2
- package/dist/runtime/actors/actor-client.js +52 -57
- package/dist/runtime/actors/actor-context.d.ts +2 -0
- package/dist/runtime/actors/actor-context.js +46 -9
- package/dist/runtime/actors/actor-handoff.d.ts +8 -4
- package/dist/runtime/actors/actor-handoff.js +219 -92
- package/dist/runtime/actors/actor-join-relocation.d.ts +3 -0
- package/dist/runtime/actors/actor-local-native-join.js +13 -12
- package/dist/runtime/actors/actor-mailbox.js +27 -1
- package/dist/runtime/actors/actor-remote-joiner.js +3 -1
- package/dist/runtime/actors/actor-remote-wire.js +15 -0
- package/dist/runtime/actors/actor-reply.d.ts +4 -0
- package/dist/runtime/actors/actor-reply.js +29 -0
- package/dist/runtime/actors/actor-routed-join-transport.d.ts +6 -2
- package/dist/runtime/actors/actor-routed-json-request.d.ts +2 -0
- package/dist/runtime/actors/actor-runtime-contracts.d.ts +2 -0
- package/dist/runtime/actors/actor-runtime-state.js +2 -20
- package/dist/runtime/actors/actor-source-transfer.d.ts +1 -17
- package/dist/runtime/actors/index.d.ts +8 -3
- package/dist/runtime/actors/index.js +55 -27
- package/dist/runtime/actors/session-disconnected-wire.d.ts +8 -0
- package/dist/runtime/actors/session-disconnected-wire.js +48 -0
- package/dist/runtime/actors/spot-actor-dispatch.js +2 -2
- package/dist/runtime/admission.d.ts +9 -1
- package/dist/runtime/admission.js +56 -23
- package/dist/runtime/application-jobs/application-ingress-record-owner.d.ts +6 -8
- package/dist/runtime/application-jobs/application-ingress-record-owner.js +39 -22
- package/dist/runtime/application-jobs/application-job-queue-scope.d.ts +15 -1
- package/dist/runtime/application-jobs/application-job-queue-scope.js +61 -20
- package/dist/runtime/application-jobs/contracts.d.ts +12 -1
- package/dist/runtime/backend/contracts/index.d.ts +37 -12
- package/dist/runtime/backend/mesh-actor-session-node-adapter.js +2 -2
- package/dist/runtime/backend/mesh-completion-table.d.ts +9 -1
- package/dist/runtime/backend/mesh-completion-table.js +154 -49
- package/dist/runtime/backend/mesh-dispatch-pump.d.ts +28 -1
- package/dist/runtime/backend/mesh-dispatch-pump.js +208 -101
- package/dist/runtime/backend/node/node-backend-adapter-support.d.ts +2 -2
- package/dist/runtime/backend/node/node-backend-adapter-support.js +16 -9
- package/dist/runtime/backend/node/node-dealer-channel-client-transport.d.ts +1 -1
- package/dist/runtime/backend/node/node-dealer-channel-client-transport.js +5 -2
- package/dist/runtime/backend/node/node-raw-binding-port.js +124 -72
- package/dist/runtime/backend/node/node-raw-mesh-backend.d.ts +46 -13
- package/dist/runtime/backend/node/node-raw-mesh-backend.js +181 -164
- package/dist/runtime/backend/node/node-socket-backend-adapter.d.ts +1 -1
- package/dist/runtime/backend/node/node-socket-backend-adapter.js +11 -11
- package/dist/runtime/backend/raw-binding-port.d.ts +2 -2
- package/dist/runtime/backend/runtime-message.d.ts +1 -0
- package/dist/runtime/backend/runtime-message.js +5 -0
- package/dist/runtime/backend/runtime-values.d.ts +1 -0
- package/dist/runtime/backend/runtime-values.js +2 -1
- package/dist/runtime/channels/channel-clients.d.ts +2 -0
- package/dist/runtime/channels/channel-clients.js +75 -23
- package/dist/runtime/channels/channel-dispatch-pipeline.d.ts +25 -5
- package/dist/runtime/channels/channel-dispatch-pipeline.js +111 -56
- package/dist/runtime/channels/channel-dispatch-services.d.ts +1 -0
- package/dist/runtime/channels/channel-dispatch-services.js +45 -0
- package/dist/runtime/channels/channel-dispatchers.d.ts +4 -3
- package/dist/runtime/channels/channel-dispatchers.js +62 -54
- package/dist/runtime/channels/channel-envelope-inspection.d.ts +1 -2
- package/dist/runtime/channels/channel-envelope-inspection.js +1 -16
- package/dist/runtime/channels/channel-envelope.d.ts +2 -0
- package/dist/runtime/channels/channel-envelope.js +146 -28
- package/dist/runtime/channels/channel-outbound-operations.d.ts +2 -2
- package/dist/runtime/channels/channel-outbound-operations.js +8 -8
- package/dist/runtime/channels/channel-runtime-lifecycle.d.ts +4 -3
- package/dist/runtime/channels/channel-runtime-lifecycle.js +19 -24
- package/dist/runtime/channels/channel-runtime-manager.d.ts +9 -8
- package/dist/runtime/channels/channel-runtime-manager.js +16 -16
- package/dist/runtime/channels/channel-transports.d.ts +18 -16
- package/dist/runtime/channels/channel-transports.js +77 -58
- package/dist/runtime/channels/client-server-location-runtime.js +5 -4
- package/dist/runtime/channels/dispatch-error-reporter.d.ts +2 -1
- package/dist/runtime/channels/dispatch-error-reporter.js +2 -1
- package/dist/runtime/channels/fanout-location-runtime.d.ts +1 -1
- package/dist/runtime/channels/fanout-location-runtime.js +3 -3
- package/dist/runtime/channels/local-spot-route-transport.d.ts +1 -1
- package/dist/runtime/channels/local-spot-route-transport.js +2 -1
- package/dist/runtime/channels/router-socket-spot-route-transport.d.ts +2 -2
- package/dist/runtime/channels/router-socket-spot-route-transport.js +4 -4
- package/dist/runtime/channels/source-spot-router.d.ts +2 -2
- package/dist/runtime/channels/source-spot-router.js +4 -4
- package/dist/runtime/channels/spot-node-route-transport.d.ts +2 -2
- package/dist/runtime/channels/spot-node-route-transport.js +4 -4
- package/dist/runtime/channels/spot-route-bridge-transport.d.ts +2 -2
- package/dist/runtime/channels/spot-route-bridge-transport.js +4 -4
- package/dist/runtime/channels/spot-route-dispatch-strategy.d.ts +5 -4
- package/dist/runtime/channels/spot-route-dispatch-strategy.js +18 -18
- package/dist/runtime/diagnostics/flow-context.js +19 -7
- package/dist/runtime/diagnostics/index.js +4 -9
- package/dist/runtime/diagnostics/message-flow.d.ts +8 -0
- package/dist/runtime/diagnostics/message-flow.js +35 -5
- package/dist/runtime/diagnostics/runtime-metrics.d.ts +2 -2
- package/dist/runtime/diagnostics/runtime-metrics.js +10 -8
- package/dist/runtime/execution/index.d.ts +4 -2
- package/dist/runtime/execution/index.js +33 -10
- package/dist/runtime/execution/serial-execution-queue.d.ts +5 -0
- package/dist/runtime/execution/serial-execution-queue.js +22 -2
- package/dist/runtime/execution/state-lane.d.ts +2 -0
- package/dist/runtime/execution/state-lane.js +5 -0
- package/dist/runtime/foundation/actor-join-recovery-codec.js +2 -2
- package/dist/runtime/foundation/durable-service-request.d.ts +14 -0
- package/dist/runtime/foundation/durable-service-request.js +98 -0
- package/dist/runtime/foundation/operation-identity.d.ts +1 -0
- package/dist/runtime/foundation/operation-identity.js +5 -1
- package/dist/runtime/foundation/operation-registry.d.ts +25 -1
- package/dist/runtime/foundation/operation-registry.js +86 -18
- package/dist/runtime/foundation/raw-service-mesh-runtime.d.ts +61 -8
- package/dist/runtime/foundation/raw-service-mesh-runtime.js +486 -266
- package/dist/runtime/foundation/service-liveness-registry.d.ts +12 -1
- package/dist/runtime/foundation/service-liveness-registry.js +38 -0
- package/dist/runtime/foundation/service-mailbox.d.ts +7 -0
- package/dist/runtime/foundation/service-maintenance-runtime.js +1 -6
- package/dist/runtime/foundation/service-relocation-object-owner.d.ts +3 -3
- package/dist/runtime/foundation/service-relocation-object-owner.js +48 -34
- package/dist/runtime/foundation/service-relocation-runtime.d.ts +2 -0
- package/dist/runtime/foundation/service-relocation-runtime.js +20 -4
- package/dist/runtime/foundation/service-runtime-contracts.d.ts +10 -1
- package/dist/runtime/foundation/service-session-binding-ingress-port.d.ts +2 -1
- package/dist/runtime/foundation/service-stateful-registry.d.ts +5 -4
- package/dist/runtime/foundation/service-stateful-registry.js +24 -26
- package/dist/runtime/foundation/service-stateful-runtime.d.ts +75 -9
- package/dist/runtime/foundation/service-stateful-runtime.js +486 -218
- package/dist/runtime/foundation/service-stateful-wire-codec.d.ts +14 -6
- package/dist/runtime/foundation/service-stateful-wire-codec.js +48 -27
- package/dist/runtime/foundation/service-topology-registry.d.ts +12 -2
- package/dist/runtime/foundation/service-topology-registry.js +61 -27
- package/dist/runtime/foundation/service-wire-binary-primitives.d.ts +6 -1
- package/dist/runtime/foundation/service-wire-binary-primitives.js +27 -11
- package/dist/runtime/foundation/service-wire-constants.generated.d.ts +1 -0
- package/dist/runtime/foundation/service-wire-constants.generated.js +1 -0
- package/dist/runtime/foundation/service-wire-m6a-codec.d.ts +13 -3
- package/dist/runtime/foundation/service-wire-m6a-codec.js +189 -78
- package/dist/runtime/handlers/handler-instance-scope.d.ts +8 -0
- package/dist/runtime/handlers/handler-instance-scope.js +54 -11
- package/dist/runtime/host/actor-packet-relay.d.ts +6 -4
- package/dist/runtime/host/actor-packet-relay.js +59 -72
- package/dist/runtime/host/actor-placement-coordinator.js +25 -8
- package/dist/runtime/host/actor-runtime-options-factory.js +2 -2
- package/dist/runtime/host/actor-transfer-runtime.d.ts +7 -31
- package/dist/runtime/host/actor-transfer-runtime.js +85 -331
- package/dist/runtime/host/application-job-queue.d.ts +40 -7
- package/dist/runtime/host/application-job-queue.js +137 -42
- package/dist/runtime/host/entry-actor-runtime.d.ts +1 -0
- package/dist/runtime/host/entry-actor-runtime.js +3 -0
- package/dist/runtime/host/index.d.ts +12 -2
- package/dist/runtime/host/index.js +300 -202
- package/dist/runtime/host/location-runtime-owner.js +2 -6
- package/dist/runtime/host/mesh-router-resolver.d.ts +4 -0
- package/dist/runtime/host/mesh-router-resolver.js +14 -6
- package/dist/runtime/host/remote-bound-session-relay.d.ts +2 -4
- package/dist/runtime/host/remote-bound-session-relay.js +73 -208
- package/dist/runtime/host/route-mesh-runtime.d.ts +2 -2
- package/dist/runtime/host/route-mesh-runtime.js +6 -4
- package/dist/runtime/host/runtime-shutdown.d.ts +1 -0
- package/dist/runtime/host/runtime-shutdown.js +3 -2
- package/dist/runtime/host/service-relocation-control.d.ts +1 -0
- package/dist/runtime/host/service-relocation-control.js +10 -4
- package/dist/runtime/host/service-relocation-host-runtime.d.ts +22 -14
- package/dist/runtime/host/service-relocation-host-runtime.js +754 -599
- package/dist/runtime/host/spot-address-transport.js +3 -2
- package/dist/runtime/host/spot-runtime-options-factory.js +16 -7
- package/dist/runtime/host/user-spot-creation-coordinator.js +33 -84
- package/dist/runtime/locations/actor-location-claims.d.ts +2 -2
- package/dist/runtime/locations/actor-location-claims.js +34 -19
- package/dist/runtime/locations/auto-connect-loop.d.ts +2 -0
- package/dist/runtime/locations/auto-connect-loop.js +22 -14
- package/dist/runtime/locations/auto-connect-reconciler.js +0 -6
- package/dist/runtime/locations/auto-connect-types.d.ts +0 -1
- package/dist/runtime/locations/descriptor-publication.d.ts +4 -0
- package/dist/runtime/locations/descriptor-publication.js +11 -0
- package/dist/runtime/locations/domain-store-contract.d.ts +1 -0
- package/dist/runtime/locations/in-memory-authority-store.d.ts +7 -1
- package/dist/runtime/locations/in-memory-authority-store.js +56 -19
- package/dist/runtime/locations/in-memory-location-store.js +1 -10
- package/dist/runtime/locations/index.d.ts +1 -0
- package/dist/runtime/locations/index.js +1 -0
- package/dist/runtime/locations/lease-tracker.js +1 -6
- package/dist/runtime/locations/lifecycle.d.ts +1 -2
- package/dist/runtime/locations/lifecycle.js +2 -5
- package/dist/runtime/locations/location-store-repository.d.ts +51 -1
- package/dist/runtime/locations/location-store-repository.js +363 -139
- package/dist/runtime/locations/relocation-blob.d.ts +18 -1
- package/dist/runtime/locations/relocation-blob.js +52 -1
- package/dist/runtime/locations/request-source-resolver.d.ts +37 -0
- package/dist/runtime/locations/request-source-resolver.js +80 -0
- package/dist/runtime/locations/resolvers.js +1 -1
- package/dist/runtime/locations/runtime.d.ts +7 -3
- package/dist/runtime/locations/runtime.js +61 -53
- package/dist/runtime/messaging/framework-json-v1.d.ts +4 -6
- package/dist/runtime/messaging/framework-json-v1.js +38 -294
- package/dist/runtime/messaging/packet-name.d.ts +1 -1
- package/dist/runtime/messaging/packet-name.js +8 -24
- package/dist/runtime/messaging/payload-codec.d.ts +7 -1
- package/dist/runtime/messaging/payload-codec.js +7 -6
- package/dist/runtime/messaging/request-result.d.ts +2 -0
- package/dist/runtime/messaging/request-result.js +57 -0
- package/dist/runtime/messaging/submission-result.d.ts +1 -0
- package/dist/runtime/messaging/submission-result.js +5 -2
- package/dist/runtime/protocol/service_wire_codec.generated.d.ts +34 -1
- package/dist/runtime/protocol/service_wire_codec.generated.js +229 -0
- package/dist/runtime/protocol/service_wire_pilot_codec.generated.d.ts +16 -1
- package/dist/runtime/protocol/service_wire_pilot_codec.generated.js +37 -8
- package/dist/runtime/spots/formal-remote-actor-admission-registry.d.ts +7 -2
- package/dist/runtime/spots/formal-remote-actor-admission-registry.js +36 -21
- package/dist/runtime/spots/index.d.ts +21 -11
- package/dist/runtime/spots/index.js +243 -178
- package/dist/runtime/spots/spot-activation-registry.d.ts +4 -2
- package/dist/runtime/spots/spot-activation-registry.js +21 -11
- package/dist/runtime/spots/spot-activation-state.d.ts +1 -1
- package/dist/runtime/spots/spot-activation-state.js +7 -7
- package/dist/runtime/spots/spot-activation.d.ts +7 -3
- package/dist/runtime/spots/spot-activation.js +140 -52
- package/dist/runtime/spots/spot-actor-admission-coordinator.d.ts +1 -0
- package/dist/runtime/spots/spot-actor-admission-coordinator.js +13 -22
- package/dist/runtime/spots/spot-actor-membership.d.ts +0 -1
- package/dist/runtime/spots/spot-actor-membership.js +0 -8
- package/dist/runtime/spots/spot-actor-packet-dispatch.js +33 -8
- package/dist/runtime/spots/spot-actor-packet-drain.js +5 -33
- package/dist/runtime/spots/spot-entry-activation.d.ts +2 -0
- package/dist/runtime/spots/spot-entry-activation.js +20 -11
- package/dist/runtime/spots/spot-handler-registry.d.ts +7 -4
- package/dist/runtime/spots/spot-handler-registry.js +24 -10
- package/dist/runtime/spots/spot-manager-internal-contracts.d.ts +2 -2
- package/dist/runtime/spots/spot-manager-public.js +2 -2
- package/dist/runtime/spots/spot-node-autoconnect.d.ts +2 -1
- package/dist/runtime/spots/spot-node-autoconnect.js +22 -42
- package/dist/runtime/spots/spot-node-runtime-manager.d.ts +19 -2
- package/dist/runtime/spots/spot-node-runtime-manager.js +115 -50
- package/dist/runtime/spots/spot-outbound.d.ts +3 -0
- package/dist/runtime/spots/spot-outbound.js +27 -18
- package/dist/runtime/spots/spot-remote-codec.js +5 -1
- package/dist/runtime/spots/spot-routed-spot-packet-dispatch.d.ts +1 -0
- package/dist/runtime/spots/spot-routed-spot-packet-dispatch.js +1 -1
- package/dist/runtime/spots/spot-runtime-ports.d.ts +1 -1
- package/dist/runtime/spots/spot-serial-executor.d.ts +10 -0
- package/dist/runtime/spots/spot-serial-executor.js +61 -8
- package/dist/runtime/spots/spot-serial-turn-executor.js +19 -2
- package/dist/runtime/spots/spot-subscription-dispatch.js +1 -4
- package/dist/runtime/spots/spot-timer.d.ts +57 -5
- package/dist/runtime/spots/spot-timer.js +288 -103
- package/dist/runtime/streams/actor-session-binding-registry.d.ts +42 -11
- package/dist/runtime/streams/actor-session-binding-registry.js +165 -48
- package/dist/runtime/streams/actor-session-binding-runtime-owner.d.ts +8 -4
- package/dist/runtime/streams/bound-actor-relay-sender.d.ts +2 -1
- package/dist/runtime/streams/bound-actor-relay-sender.js +15 -8
- package/dist/runtime/streams/bound-session-service.d.ts +1 -1
- package/dist/runtime/streams/bound-session-service.js +6 -11
- package/dist/runtime/streams/index.d.ts +3 -2
- package/dist/runtime/streams/index.js +6 -4
- package/dist/runtime/streams/managed-stream.js +3 -2
- package/dist/runtime/streams/native-fallback-bound-session.js +8 -73
- package/dist/runtime/streams/session-actor-coordinator.d.ts +2 -8
- package/dist/runtime/streams/session-actor-coordinator.js +15 -32
- package/dist/runtime/streams/stream-binding-runtime-ports.d.ts +3 -10
- package/dist/runtime/streams/stream-session-runtime.d.ts +1 -1
- package/dist/runtime/streams/stream-session-runtime.js +14 -31
- package/dist/runtime/workers/index.js +1 -1
- package/package.json +3 -3
- package/src/contracts/Actors/ZLinkActorClient.ts +2 -1
- package/src/contracts/Channels/Calls.ts +2 -1
- package/src/contracts/Common/ZLinkEncodedPayload.ts +24 -4
- package/src/contracts/Common/ZLinkMessageMetadata.ts +13 -8
- package/src/contracts/Common/encoded-payload-storage.ts +6 -3
- package/src/contracts/Configuration/Builders.ts +4 -1
- package/src/contracts/Configuration/RegistrationBuilderPolicy.ts +7 -2
- package/src/contracts/Configuration/RegistrationBuilders.ts +6 -2
- package/src/contracts/Configuration/RegistrationTypes.ts +1 -0
- package/src/contracts/Dispatch/ZLinkDispatchOptions.ts +2 -1
- package/src/contracts/Handlers/Attributes.ts +14 -21
- package/src/contracts/Handlers/JsonContract.ts +8 -216
- package/src/contracts/Locations/Rows.ts +2 -0
- package/src/contracts/Spots/Contracts.ts +10 -1
- package/src/contracts/Spots/ZLinkSpot.ts +3 -3
- package/src/nest-integration.ts +1 -0
- package/src/runtime/abort.ts +12 -0
- package/src/runtime/actors/actor-authority-publication.ts +3 -2
- package/src/runtime/actors/actor-client.ts +100 -85
- package/src/runtime/actors/actor-context.ts +49 -9
- package/src/runtime/actors/actor-handoff.ts +291 -110
- package/src/runtime/actors/actor-join-relocation.ts +3 -0
- package/src/runtime/actors/actor-local-native-join.ts +21 -26
- package/src/runtime/actors/actor-mailbox.ts +40 -2
- package/src/runtime/actors/actor-remote-joiner.ts +6 -1
- package/src/runtime/actors/actor-remote-wire.ts +17 -0
- package/src/runtime/actors/actor-reply.ts +42 -0
- package/src/runtime/actors/actor-routed-join-transport.ts +14 -4
- package/src/runtime/actors/actor-routed-json-request.ts +10 -2
- package/src/runtime/actors/actor-runtime-contracts.ts +2 -0
- package/src/runtime/actors/actor-runtime-state.ts +2 -20
- package/src/runtime/actors/actor-source-transfer.ts +1 -34
- package/src/runtime/actors/index.ts +60 -32
- package/src/runtime/actors/session-disconnected-wire.ts +66 -0
- package/src/runtime/actors/spot-actor-dispatch.ts +4 -2
- package/src/runtime/admission.ts +69 -21
- package/src/runtime/application-jobs/application-ingress-record-owner.ts +41 -25
- package/src/runtime/application-jobs/application-job-queue-scope.ts +83 -22
- package/src/runtime/application-jobs/contracts.ts +16 -1
- package/src/runtime/backend/contracts/index.ts +92 -18
- package/src/runtime/backend/mesh-actor-session-node-adapter.ts +5 -3
- package/src/runtime/backend/mesh-completion-table.ts +160 -57
- package/src/runtime/backend/mesh-dispatch-pump.ts +237 -108
- package/src/runtime/backend/node/node-backend-adapter-support.ts +17 -8
- package/src/runtime/backend/node/node-dealer-channel-client-transport.ts +12 -2
- package/src/runtime/backend/node/node-raw-binding-port.ts +148 -85
- package/src/runtime/backend/node/node-raw-mesh-backend.ts +315 -201
- package/src/runtime/backend/node/node-socket-backend-adapter.ts +26 -11
- package/src/runtime/backend/raw-binding-port.ts +7 -2
- package/src/runtime/backend/runtime-message.ts +6 -0
- package/src/runtime/backend/runtime-values.ts +1 -0
- package/src/runtime/channels/channel-clients.ts +132 -58
- package/src/runtime/channels/channel-dispatch-pipeline.ts +198 -114
- package/src/runtime/channels/channel-dispatch-services.ts +69 -1
- package/src/runtime/channels/channel-dispatchers.ts +136 -90
- package/src/runtime/channels/channel-envelope-inspection.ts +2 -16
- package/src/runtime/channels/channel-envelope.ts +225 -31
- package/src/runtime/channels/channel-outbound-operations.ts +22 -8
- package/src/runtime/channels/channel-runtime-lifecycle.ts +13 -13
- package/src/runtime/channels/channel-runtime-manager.ts +41 -17
- package/src/runtime/channels/channel-transports.ts +171 -112
- package/src/runtime/channels/client-server-location-runtime.ts +11 -10
- package/src/runtime/channels/dispatch-error-reporter.ts +4 -2
- package/src/runtime/channels/fanout-location-runtime.ts +17 -9
- package/src/runtime/channels/local-spot-route-transport.ts +3 -1
- package/src/runtime/channels/router-socket-spot-route-transport.ts +13 -4
- package/src/runtime/channels/source-spot-router.ts +8 -4
- package/src/runtime/channels/spot-node-route-transport.ts +8 -4
- package/src/runtime/channels/spot-route-bridge-transport.ts +6 -4
- package/src/runtime/channels/spot-route-dispatch-strategy.ts +47 -18
- package/src/runtime/diagnostics/flow-context.ts +20 -7
- package/src/runtime/diagnostics/index.ts +1 -7
- package/src/runtime/diagnostics/message-flow.ts +47 -9
- package/src/runtime/diagnostics/runtime-metrics.ts +12 -10
- package/src/runtime/execution/index.ts +40 -14
- package/src/runtime/execution/serial-execution-queue.ts +33 -4
- package/src/runtime/execution/state-lane.ts +7 -0
- package/src/runtime/foundation/actor-join-recovery-codec.ts +2 -2
- package/src/runtime/foundation/durable-service-request.ts +137 -0
- package/src/runtime/foundation/operation-identity.ts +5 -1
- package/src/runtime/foundation/operation-registry.ts +98 -20
- package/src/runtime/foundation/raw-service-mesh-runtime.ts +704 -336
- package/src/runtime/foundation/service-liveness-registry.ts +39 -0
- package/src/runtime/foundation/service-mailbox.ts +8 -0
- package/src/runtime/foundation/service-maintenance-runtime.ts +1 -8
- package/src/runtime/foundation/service-relocation-object-owner.ts +55 -36
- package/src/runtime/foundation/service-relocation-runtime.ts +25 -4
- package/src/runtime/foundation/service-runtime-contracts.ts +19 -2
- package/src/runtime/foundation/service-session-binding-ingress-port.ts +2 -1
- package/src/runtime/foundation/service-stateful-registry.ts +38 -35
- package/src/runtime/foundation/service-stateful-runtime.ts +732 -275
- package/src/runtime/foundation/service-stateful-wire-codec.ts +49 -16
- package/src/runtime/foundation/service-topology-registry.ts +91 -36
- package/src/runtime/foundation/service-wire-binary-primitives.ts +35 -12
- package/src/runtime/foundation/service-wire-constants.generated.ts +1 -0
- package/src/runtime/foundation/service-wire-m6a-codec.ts +231 -76
- package/src/runtime/handlers/handler-instance-scope.ts +67 -16
- package/src/runtime/host/actor-packet-relay.ts +113 -94
- package/src/runtime/host/actor-placement-coordinator.ts +31 -8
- package/src/runtime/host/actor-runtime-options-factory.ts +13 -2
- package/src/runtime/host/actor-transfer-runtime.ts +104 -430
- package/src/runtime/host/application-job-queue.ts +160 -41
- package/src/runtime/host/entry-actor-runtime.ts +4 -0
- package/src/runtime/host/index.ts +473 -271
- package/src/runtime/host/location-runtime-owner.ts +2 -6
- package/src/runtime/host/mesh-router-resolver.ts +13 -5
- package/src/runtime/host/remote-bound-session-relay.ts +88 -271
- package/src/runtime/host/route-mesh-runtime.ts +12 -6
- package/src/runtime/host/runtime-shutdown.ts +15 -4
- package/src/runtime/host/service-relocation-control.ts +11 -5
- package/src/runtime/host/service-relocation-host-runtime.ts +1092 -759
- package/src/runtime/host/spot-address-transport.ts +4 -2
- package/src/runtime/host/spot-runtime-options-factory.ts +20 -7
- package/src/runtime/host/user-spot-creation-coordinator.ts +41 -100
- package/src/runtime/locations/actor-location-claims.ts +52 -30
- package/src/runtime/locations/auto-connect-loop.ts +22 -14
- package/src/runtime/locations/auto-connect-reconciler.ts +0 -6
- package/src/runtime/locations/auto-connect-types.ts +0 -1
- package/src/runtime/locations/descriptor-publication.ts +7 -0
- package/src/runtime/locations/domain-store-contract.ts +5 -0
- package/src/runtime/locations/in-memory-authority-store.ts +85 -23
- package/src/runtime/locations/in-memory-location-store.ts +1 -12
- package/src/runtime/locations/index.ts +1 -0
- package/src/runtime/locations/lease-tracker.ts +2 -9
- package/src/runtime/locations/lifecycle.ts +8 -26
- package/src/runtime/locations/location-store-repository.ts +628 -152
- package/src/runtime/locations/relocation-blob.ts +75 -1
- package/src/runtime/locations/request-source-resolver.ts +138 -0
- package/src/runtime/locations/resolvers.ts +2 -2
- package/src/runtime/locations/runtime.ts +98 -64
- package/src/runtime/messaging/framework-json-v1.ts +5 -325
- package/src/runtime/messaging/packet-name.ts +5 -25
- package/src/runtime/messaging/payload-codec.ts +8 -11
- package/src/runtime/messaging/request-result.ts +62 -0
- package/src/runtime/messaging/submission-result.ts +5 -1
- package/src/runtime/protocol/service_wire_codec.generated.ts +218 -5
- package/src/runtime/protocol/service_wire_pilot_codec.generated.ts +16 -13
- package/src/runtime/spots/formal-remote-actor-admission-registry.ts +46 -25
- package/src/runtime/spots/index.ts +389 -283
- package/src/runtime/spots/spot-activation-registry.ts +25 -13
- package/src/runtime/spots/spot-activation-state.ts +12 -19
- package/src/runtime/spots/spot-activation.ts +198 -96
- package/src/runtime/spots/spot-actor-admission-coordinator.ts +25 -55
- package/src/runtime/spots/spot-actor-membership.ts +0 -15
- package/src/runtime/spots/spot-actor-packet-dispatch.ts +56 -11
- package/src/runtime/spots/spot-actor-packet-drain.ts +9 -52
- package/src/runtime/spots/spot-entry-activation.ts +33 -21
- package/src/runtime/spots/spot-handler-registry.ts +56 -12
- package/src/runtime/spots/spot-manager-internal-contracts.ts +2 -2
- package/src/runtime/spots/spot-manager-public.ts +2 -2
- package/src/runtime/spots/spot-node-autoconnect.ts +28 -47
- package/src/runtime/spots/spot-node-runtime-manager.ts +197 -67
- package/src/runtime/spots/spot-outbound.ts +39 -19
- package/src/runtime/spots/spot-remote-codec.ts +9 -2
- package/src/runtime/spots/spot-routed-spot-packet-dispatch.ts +2 -1
- package/src/runtime/spots/spot-runtime-ports.ts +1 -1
- package/src/runtime/spots/spot-serial-executor.ts +97 -25
- package/src/runtime/spots/spot-serial-turn-executor.ts +22 -3
- package/src/runtime/spots/spot-subscription-dispatch.ts +1 -4
- package/src/runtime/spots/spot-timer.ts +418 -158
- package/src/runtime/streams/actor-session-binding-registry.ts +236 -64
- package/src/runtime/streams/actor-session-binding-runtime-owner.ts +16 -8
- package/src/runtime/streams/bound-actor-relay-sender.ts +23 -9
- package/src/runtime/streams/bound-session-service.ts +7 -10
- package/src/runtime/streams/index.ts +12 -6
- package/src/runtime/streams/managed-stream.ts +4 -2
- package/src/runtime/streams/native-fallback-bound-session.ts +14 -103
- package/src/runtime/streams/session-actor-coordinator.ts +39 -88
- package/src/runtime/streams/stream-binding-runtime-ports.ts +3 -9
- package/src/runtime/streams/stream-session-runtime.ts +13 -34
- package/src/runtime/workers/index.ts +1 -1
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ZLinkFrameworkException,
|
|
3
|
+
ZLinkFrameworkErrorKind
|
|
4
|
+
} from '../../contracts/Errors/ZLinkFrameworkException';
|
|
5
|
+
import { isIndeterminateLocationStoreFailure } from './location-store-failure';
|
|
6
|
+
import type { ZLinkRuntimeMetrics } from '../diagnostics/runtime-metrics';
|
|
1
7
|
import { randomUUID } from 'node:crypto';
|
|
2
8
|
import { awaitWithAbort, macrotaskBoundary } from '../abort';
|
|
3
9
|
import type {
|
|
@@ -19,6 +25,22 @@ export async function putNewRelocationBlob(
|
|
|
19
25
|
readonly reference: ZLinkBlobReference;
|
|
20
26
|
readonly expiresAt: Date;
|
|
21
27
|
readonly storeNow: Date;
|
|
28
|
+
}> {
|
|
29
|
+
if (store instanceof ZLinkProviderRelocationRepository) {
|
|
30
|
+
return store.putNew(payload, retentionMs, signal);
|
|
31
|
+
}
|
|
32
|
+
return putNewRelocationBlobCore(store, payload, retentionMs, signal);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
async function putNewRelocationBlobCore(
|
|
36
|
+
store: ZLinkRelocationStore,
|
|
37
|
+
payload: Uint8Array,
|
|
38
|
+
retentionMs: number,
|
|
39
|
+
signal?: AbortSignal
|
|
40
|
+
): Promise<{
|
|
41
|
+
readonly reference: ZLinkBlobReference;
|
|
42
|
+
readonly expiresAt: Date;
|
|
43
|
+
readonly storeNow: Date;
|
|
22
44
|
}> {
|
|
23
45
|
let reference = relocationBlobReference(randomUUID());
|
|
24
46
|
for (; ; await macrotaskBoundary()) {
|
|
@@ -26,7 +48,8 @@ export async function putNewRelocationBlob(
|
|
|
26
48
|
let result: ZLinkBlobPutResult;
|
|
27
49
|
try {
|
|
28
50
|
result = await awaitWithAbort(store.put(reference, payload, retentionMs, signal), signal);
|
|
29
|
-
} catch {
|
|
51
|
+
} catch (error) {
|
|
52
|
+
if (!isRelocationProviderFailure(error)) throw error;
|
|
30
53
|
signal?.throwIfAborted();
|
|
31
54
|
const read = await awaitWithAbort(store.read(reference, signal), signal);
|
|
32
55
|
if (read.kind === 'found' && Buffer.compare(read.bytes, payload) === 0) {
|
|
@@ -45,3 +68,54 @@ export async function putNewRelocationBlob(
|
|
|
45
68
|
reference = relocationBlobReference(randomUUID());
|
|
46
69
|
}
|
|
47
70
|
}
|
|
71
|
+
|
|
72
|
+
/** Observes provider requests before callers interpret or decode blob contents. */
|
|
73
|
+
export class ZLinkProviderRelocationRepository implements ZLinkRelocationStore {
|
|
74
|
+
constructor(
|
|
75
|
+
private readonly provider: ZLinkRelocationStore,
|
|
76
|
+
private readonly metrics: ZLinkRuntimeMetrics
|
|
77
|
+
) {}
|
|
78
|
+
|
|
79
|
+
putNew(payload: Uint8Array, retentionMs: number, signal?: AbortSignal) {
|
|
80
|
+
return this.observe(
|
|
81
|
+
'relocation_put',
|
|
82
|
+
() => putNewRelocationBlobCore(this.provider, payload, retentionMs, signal),
|
|
83
|
+
signal
|
|
84
|
+
);
|
|
85
|
+
}
|
|
86
|
+
put(...args: Parameters<ZLinkRelocationStore['put']>) {
|
|
87
|
+
return this.observe('relocation_put', () => this.provider.put(...args), args[3]);
|
|
88
|
+
}
|
|
89
|
+
read(...args: Parameters<ZLinkRelocationStore['read']>) {
|
|
90
|
+
return this.observe('relocation_get', () => this.provider.read(...args), args[1]);
|
|
91
|
+
}
|
|
92
|
+
renew(...args: Parameters<ZLinkRelocationStore['renew']>) {
|
|
93
|
+
return this.observe('relocation_put', () => this.provider.renew(...args), args[2]);
|
|
94
|
+
}
|
|
95
|
+
delete(...args: Parameters<ZLinkRelocationStore['delete']>) {
|
|
96
|
+
return this.observe('relocation_delete', () => this.provider.delete(...args), args[1]);
|
|
97
|
+
}
|
|
98
|
+
private async observe<T>(
|
|
99
|
+
operation: 'relocation_put' | 'relocation_get' | 'relocation_delete',
|
|
100
|
+
request: () => Promise<T>,
|
|
101
|
+
signal?: AbortSignal
|
|
102
|
+
): Promise<T> {
|
|
103
|
+
try {
|
|
104
|
+
return await request();
|
|
105
|
+
} catch (error) {
|
|
106
|
+
if (isRelocationProviderFailure(error, signal)) {
|
|
107
|
+
this.metrics.recordLocationStoreError(operation);
|
|
108
|
+
}
|
|
109
|
+
throw error;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
function isRelocationProviderFailure(error: unknown, signal?: AbortSignal): boolean {
|
|
115
|
+
return (
|
|
116
|
+
isIndeterminateLocationStoreFailure(error, signal) &&
|
|
117
|
+
!(
|
|
118
|
+
error instanceof ZLinkFrameworkException && error.kind !== ZLinkFrameworkErrorKind.Unavailable
|
|
119
|
+
)
|
|
120
|
+
);
|
|
121
|
+
}
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import type { RoutingId } from '../../contracts/Common';
|
|
2
|
+
import type { ZLinkMeshNodeDescriptor } from '../../contracts/Locations/Rows';
|
|
3
|
+
import type { ZLinkLocationOwnerToken } from './internal-location-contracts';
|
|
4
|
+
import { encodeRoutingIdStorageHex, routingIdsEqual } from '../routing-id';
|
|
5
|
+
import { awaitWithAbort, throwIfAborted } from '../abort';
|
|
6
|
+
|
|
7
|
+
/** Source request owner values the first accepting owner records (Location runtime §9.3). */
|
|
8
|
+
export interface ZLinkRequestSourceFence {
|
|
9
|
+
readonly ownerId: string;
|
|
10
|
+
readonly leaseGeneration: bigint;
|
|
11
|
+
readonly nodeRid: RoutingId;
|
|
12
|
+
readonly nodeGeneration: bigint;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export interface ZLinkRequestSourceResolverOptions {
|
|
16
|
+
readonly listLiveMeshNodes: (
|
|
17
|
+
meshName: string,
|
|
18
|
+
signal?: AbortSignal
|
|
19
|
+
) => Promise<readonly ZLinkMeshNodeDescriptor[]>;
|
|
20
|
+
readonly remainingOwnerTokenLeaseMs: (
|
|
21
|
+
owner: ZLinkLocationOwnerToken,
|
|
22
|
+
signal?: AbortSignal
|
|
23
|
+
) => Promise<number>;
|
|
24
|
+
readonly monotonicNowMs?: () => number;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
interface PolledSource {
|
|
28
|
+
readonly fence: ZLinkRequestSourceFence;
|
|
29
|
+
readonly leaseDeadlineMs: number;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Chooses the descriptor that supplies the source request owner values (Session·Actor binding
|
|
34
|
+
* §4): the admitted sender's descriptor with the exact RID and node lifecycle generation whose
|
|
35
|
+
* owner lease passes the Location runtime §4.1 check. Auto-connect polling keeps the live
|
|
36
|
+
* descriptors here with the local lease deadline computed from the same lease read. A sender
|
|
37
|
+
* missing from them is read from the Store once and kept with them.
|
|
38
|
+
*/
|
|
39
|
+
export class ZLinkRequestSourceResolver {
|
|
40
|
+
private readonly polled = new Map<string, Map<string, PolledSource>>();
|
|
41
|
+
private readonly monotonicNowMs: () => number;
|
|
42
|
+
|
|
43
|
+
constructor(private readonly options: ZLinkRequestSourceResolverOptions) {
|
|
44
|
+
this.monotonicNowMs = options.monotonicNowMs ?? (() => performance.now());
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/** Replaces the polled descriptors of one mesh with a live descriptor listing. */
|
|
48
|
+
async observeLiveDescriptors(
|
|
49
|
+
meshName: string,
|
|
50
|
+
descriptors: readonly ZLinkMeshNodeDescriptor[],
|
|
51
|
+
signal?: AbortSignal
|
|
52
|
+
): Promise<void> {
|
|
53
|
+
const sources = new Map<string, PolledSource>();
|
|
54
|
+
for (const descriptor of descriptors) {
|
|
55
|
+
const source = await this.polledSource(descriptor, signal);
|
|
56
|
+
if (source !== undefined) sources.set(encodeRoutingIdStorageHex(descriptor.rid), source);
|
|
57
|
+
}
|
|
58
|
+
this.polled.set(meshName, sources);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Returns the recorded values, undefined when the sender has no live descriptor, or a promise
|
|
63
|
+
* while the Store is read once for a sender the polled descriptors do not contain.
|
|
64
|
+
*/
|
|
65
|
+
accept(
|
|
66
|
+
meshName: string,
|
|
67
|
+
nodeRid: RoutingId,
|
|
68
|
+
nodeGeneration: bigint,
|
|
69
|
+
nodeRidStorageHex: string,
|
|
70
|
+
signal?: AbortSignal
|
|
71
|
+
): ZLinkRequestSourceFence | undefined | Promise<ZLinkRequestSourceFence | undefined> {
|
|
72
|
+
throwIfAborted(signal);
|
|
73
|
+
const known = this.polled.get(meshName)?.get(nodeRidStorageHex);
|
|
74
|
+
if (known !== undefined && known.fence.nodeGeneration === nodeGeneration) {
|
|
75
|
+
return this.monotonicNowMs() < known.leaseDeadlineMs ? known.fence : undefined;
|
|
76
|
+
}
|
|
77
|
+
return this.readOnce(meshName, nodeRid, nodeGeneration, nodeRidStorageHex, signal);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
private async readOnce(
|
|
81
|
+
meshName: string,
|
|
82
|
+
nodeRid: RoutingId,
|
|
83
|
+
nodeGeneration: bigint,
|
|
84
|
+
nodeRidStorageHex: string,
|
|
85
|
+
signal?: AbortSignal
|
|
86
|
+
): Promise<ZLinkRequestSourceFence | undefined> {
|
|
87
|
+
// The Store boundary already classifies provider failures as Unavailable. Preserve their
|
|
88
|
+
// cause for the ingress error reporter, and let programming errors propagate unchanged.
|
|
89
|
+
const descriptors = await awaitWithAbort(
|
|
90
|
+
this.options.listLiveMeshNodes(meshName, signal),
|
|
91
|
+
signal
|
|
92
|
+
);
|
|
93
|
+
const descriptor = descriptors.find(
|
|
94
|
+
(value) => routingIdsEqual(value.rid, nodeRid) && value.lifecycleGeneration === nodeGeneration
|
|
95
|
+
);
|
|
96
|
+
const source =
|
|
97
|
+
descriptor === undefined ? undefined : await this.polledSource(descriptor, signal);
|
|
98
|
+
throwIfAborted(signal);
|
|
99
|
+
if (source === undefined) return undefined;
|
|
100
|
+
let sources = this.polled.get(meshName);
|
|
101
|
+
if (sources === undefined) {
|
|
102
|
+
sources = new Map();
|
|
103
|
+
this.polled.set(meshName, sources);
|
|
104
|
+
}
|
|
105
|
+
sources.set(nodeRidStorageHex, source);
|
|
106
|
+
return source.fence;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
private async polledSource(
|
|
110
|
+
descriptor: ZLinkMeshNodeDescriptor,
|
|
111
|
+
signal?: AbortSignal
|
|
112
|
+
): Promise<PolledSource | undefined> {
|
|
113
|
+
if (
|
|
114
|
+
descriptor.ownerId.length === 0 ||
|
|
115
|
+
descriptor.leaseGeneration <= 0n ||
|
|
116
|
+
descriptor.lifecycleGeneration <= 0n
|
|
117
|
+
) {
|
|
118
|
+
return undefined;
|
|
119
|
+
}
|
|
120
|
+
const remainingMs = await awaitWithAbort(
|
|
121
|
+
this.options.remainingOwnerTokenLeaseMs(
|
|
122
|
+
{ ownerId: descriptor.ownerId, leaseGeneration: descriptor.leaseGeneration },
|
|
123
|
+
signal
|
|
124
|
+
),
|
|
125
|
+
signal
|
|
126
|
+
);
|
|
127
|
+
if (remainingMs <= 0) return undefined;
|
|
128
|
+
return {
|
|
129
|
+
fence: {
|
|
130
|
+
ownerId: descriptor.ownerId,
|
|
131
|
+
leaseGeneration: descriptor.leaseGeneration,
|
|
132
|
+
nodeRid: descriptor.rid,
|
|
133
|
+
nodeGeneration: descriptor.lifecycleGeneration
|
|
134
|
+
},
|
|
135
|
+
leaseDeadlineMs: this.monotonicNowMs() + remainingMs
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
}
|
|
@@ -17,7 +17,7 @@ import {
|
|
|
17
17
|
createInternalFrameworkException,
|
|
18
18
|
internalFrameworkErrorKind
|
|
19
19
|
} from '../framework-errors-internal';
|
|
20
|
-
import { routingIdsEqual } from '../routing-id';
|
|
20
|
+
import { encodeRoutingIdStorageHex, routingIdsEqual } from '../routing-id';
|
|
21
21
|
import {
|
|
22
22
|
type SpotHandle,
|
|
23
23
|
type ZLinkActorSpotHandleResolver,
|
|
@@ -282,7 +282,7 @@ export class ZLinkStoreLocationResolvers
|
|
|
282
282
|
descriptor.objectRole === ZLinkObjectRole.Server &&
|
|
283
283
|
descriptor.placementWeight > 0 &&
|
|
284
284
|
!routingIdsEqual(descriptor.rid, excludedNodeRid) &&
|
|
285
|
-
!excludedCandidateRids.has(
|
|
285
|
+
!excludedCandidateRids.has(encodeRoutingIdStorageHex(descriptor.rid)) &&
|
|
286
286
|
capacity.active + capacity.reserved < capacity.limit &&
|
|
287
287
|
descriptor.objectCapabilities.some(
|
|
288
288
|
(candidate) => candidate.objectKind === 'actor' && candidate.stableType === actorType
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { ZLinkDescriptorPublicationUnconfirmedError } from './descriptor-publication';
|
|
2
|
+
import { isIndeterminateLocationStoreFailure } from './location-store-failure';
|
|
1
3
|
import { listAllMeshNodeDescriptors } from './location-store-pages';
|
|
2
4
|
import { MILLISECONDS_PER_SECOND } from '../diagnostics/runtime-metrics';
|
|
3
5
|
import { ZLINK_PROVIDER_MAX_PAGE_SIZE } from '../../contracts/Locations/Stores';
|
|
@@ -148,7 +150,9 @@ export class ZLinkLocationRuntime implements ZLinkLocationRuntimeQuery {
|
|
|
148
150
|
private readonly liveRows: ZLinkLiveRowFilter;
|
|
149
151
|
private readonly leaseTracker: ZLinkOwnerLeaseTracker;
|
|
150
152
|
private readonly ownershipLostHandlers = new Set<(event: ZLinkOwnershipLostEvent) => void>();
|
|
151
|
-
private readonly ownerLeaseRenewedHandlers = new Set<
|
|
153
|
+
private readonly ownerLeaseRenewedHandlers = new Set<
|
|
154
|
+
(renewal: ZLinkOwnerLeaseRenewed, wasOwnerLeaseUsable: boolean) => void
|
|
155
|
+
>();
|
|
152
156
|
private readonly ownerLeaseRenewalFailedHandlers = new Set<() => void>();
|
|
153
157
|
private heartbeatTimer: unknown;
|
|
154
158
|
private heartbeatRenewal?: Promise<unknown>;
|
|
@@ -162,7 +166,7 @@ export class ZLinkLocationRuntime implements ZLinkLocationRuntimeQuery {
|
|
|
162
166
|
readonly name: string;
|
|
163
167
|
}[];
|
|
164
168
|
private readonly rewriteAuthorityPayloadForOwner?: ZLinkLocationRuntimeOptions['rewriteAuthorityPayloadForOwner'];
|
|
165
|
-
private
|
|
169
|
+
private leaseOperationStartedAtMs = 0;
|
|
166
170
|
private ownerToken?: ZLinkLocationOwnerToken;
|
|
167
171
|
private lastOwnerToken?: ZLinkLocationOwnerToken;
|
|
168
172
|
private ownerLeaseDeadlineMs?: number;
|
|
@@ -216,9 +220,22 @@ export class ZLinkLocationRuntime implements ZLinkLocationRuntimeQuery {
|
|
|
216
220
|
return this.ownerToken;
|
|
217
221
|
}
|
|
218
222
|
|
|
223
|
+
/** Location runtime §5: a startup Store request ends within the renew timeout. */
|
|
224
|
+
async writeDescriptor<T>(
|
|
225
|
+
action: (signal?: AbortSignal) => Promise<T>,
|
|
226
|
+
signal?: AbortSignal
|
|
227
|
+
): Promise<T> {
|
|
228
|
+
try {
|
|
229
|
+
return await withTimeout(action, this.options.ownerLeaseRenewTimeoutMs, signal);
|
|
230
|
+
} catch (error) {
|
|
231
|
+
if (!isIndeterminateLocationStoreFailure(error, signal)) throw error;
|
|
232
|
+
throw new ZLinkDescriptorPublicationUnconfirmedError(error);
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
|
|
219
236
|
closeOwnerLeaseAdmission(error: unknown): void {
|
|
220
237
|
this.ownerLeaseDeadlineMs = undefined;
|
|
221
|
-
this.recordFailure(errorMessage(error)
|
|
238
|
+
this.recordFailure(errorMessage(error));
|
|
222
239
|
}
|
|
223
240
|
|
|
224
241
|
async reclaimOwnerAuthorities(signal?: AbortSignal): Promise<void> {
|
|
@@ -308,11 +325,15 @@ export class ZLinkLocationRuntime implements ZLinkLocationRuntimeQuery {
|
|
|
308
325
|
this.ownershipLostHandlers.delete(handler);
|
|
309
326
|
}
|
|
310
327
|
|
|
311
|
-
addOwnerLeaseRenewedHandler(
|
|
328
|
+
addOwnerLeaseRenewedHandler(
|
|
329
|
+
handler: (renewal: ZLinkOwnerLeaseRenewed, wasOwnerLeaseUsable: boolean) => void
|
|
330
|
+
): void {
|
|
312
331
|
this.ownerLeaseRenewedHandlers.add(handler);
|
|
313
332
|
}
|
|
314
333
|
|
|
315
|
-
removeOwnerLeaseRenewedHandler(
|
|
334
|
+
removeOwnerLeaseRenewedHandler(
|
|
335
|
+
handler: (renewal: ZLinkOwnerLeaseRenewed, wasOwnerLeaseUsable: boolean) => void
|
|
336
|
+
): void {
|
|
316
337
|
this.ownerLeaseRenewedHandlers.delete(handler);
|
|
317
338
|
}
|
|
318
339
|
|
|
@@ -342,12 +363,7 @@ export class ZLinkLocationRuntime implements ZLinkLocationRuntimeQuery {
|
|
|
342
363
|
const claim = this.renewOwnerLeaseOnce(signal, shutdownSignal);
|
|
343
364
|
this.heartbeatRenewal = claim;
|
|
344
365
|
try {
|
|
345
|
-
|
|
346
|
-
if (claimed) {
|
|
347
|
-
this.scheduleHeartbeat();
|
|
348
|
-
return;
|
|
349
|
-
}
|
|
350
|
-
this.nextLeaseRenewAtMs = this.monotonicNowMs() + this.options.ownerLeaseRenewIntervalMs;
|
|
366
|
+
await claim;
|
|
351
367
|
this.scheduleHeartbeat();
|
|
352
368
|
} catch (error) {
|
|
353
369
|
this.started = false;
|
|
@@ -362,7 +378,7 @@ export class ZLinkLocationRuntime implements ZLinkLocationRuntimeQuery {
|
|
|
362
378
|
this.clearTimer(this.heartbeatTimer);
|
|
363
379
|
this.heartbeatTimer = undefined;
|
|
364
380
|
}
|
|
365
|
-
this.
|
|
381
|
+
this.leaseOperationStartedAtMs = 0;
|
|
366
382
|
this.ownerLeaseDeadlineMs = undefined;
|
|
367
383
|
await this.cleanupOwner(signal);
|
|
368
384
|
}
|
|
@@ -419,9 +435,9 @@ export class ZLinkLocationRuntime implements ZLinkLocationRuntimeQuery {
|
|
|
419
435
|
return await this.claimFreshOwnerLease(signal, shutdownSignal);
|
|
420
436
|
}
|
|
421
437
|
|
|
422
|
-
const wasOwnerLeaseUsable = this.ownerLeaseUsable;
|
|
423
438
|
try {
|
|
424
439
|
const renewStartedAtMs = this.monotonicNowMs();
|
|
440
|
+
this.leaseOperationStartedAtMs = renewStartedAtMs;
|
|
425
441
|
const result = await withTimeout(
|
|
426
442
|
(renewSignal) =>
|
|
427
443
|
this.stores.ownerLeaseStore.renewOwnerLease(
|
|
@@ -448,6 +464,7 @@ export class ZLinkLocationRuntime implements ZLinkLocationRuntimeQuery {
|
|
|
448
464
|
// another heartbeat interval.
|
|
449
465
|
return await this.claimFreshOwnerLease(signal, shutdownSignal);
|
|
450
466
|
}
|
|
467
|
+
const wasOwnerLeaseUsable = this.ownerLeaseUsable;
|
|
451
468
|
this.ownerLeaseHealthy = true;
|
|
452
469
|
this.ownerLeaseRenewedAt = result.storeNow;
|
|
453
470
|
this.setOwnerLeaseDeadline(
|
|
@@ -457,14 +474,14 @@ export class ZLinkLocationRuntime implements ZLinkLocationRuntimeQuery {
|
|
|
457
474
|
result.storeNow
|
|
458
475
|
);
|
|
459
476
|
this.lastError = undefined;
|
|
460
|
-
|
|
461
|
-
|
|
477
|
+
for (const handler of this.ownerLeaseRenewedHandlers) {
|
|
478
|
+
handler(result, wasOwnerLeaseUsable);
|
|
462
479
|
}
|
|
463
480
|
return true;
|
|
464
481
|
} catch (error) {
|
|
465
482
|
if (signal?.aborted === true) throw error;
|
|
466
483
|
this.recordOwnerLeaseRenewFailure();
|
|
467
|
-
this.recordFailure(errorMessage(error)
|
|
484
|
+
this.recordFailure(errorMessage(error));
|
|
468
485
|
for (const handler of this.ownerLeaseRenewalFailedHandlers) handler();
|
|
469
486
|
return false;
|
|
470
487
|
}
|
|
@@ -475,21 +492,26 @@ export class ZLinkLocationRuntime implements ZLinkLocationRuntimeQuery {
|
|
|
475
492
|
shutdownSignal?: () => AbortSignal
|
|
476
493
|
): Promise<boolean> {
|
|
477
494
|
const claimStartedAtMs = this.monotonicNowMs();
|
|
478
|
-
|
|
495
|
+
this.leaseOperationStartedAtMs = claimStartedAtMs;
|
|
496
|
+
const timeoutStartedAtMs = performance.now();
|
|
479
497
|
let claim: Awaited<ReturnType<ZLinkOwnerLeaseStore['claimOwnerLease']>>;
|
|
480
498
|
try {
|
|
481
|
-
claim = await this.claimOwnerLeaseWithConfirmation(
|
|
499
|
+
claim = await this.claimOwnerLeaseWithConfirmation(
|
|
500
|
+
timeoutStartedAtMs,
|
|
501
|
+
signal,
|
|
502
|
+
shutdownSignal
|
|
503
|
+
);
|
|
482
504
|
} catch (error) {
|
|
483
505
|
if (signal?.aborted === true) throw error;
|
|
484
506
|
if (error instanceof ZLinkOwnerLeaseClaimError) throw error;
|
|
485
507
|
this.recordOwnerLeaseRenewFailure();
|
|
486
|
-
this.recordFailure(errorMessage(error)
|
|
508
|
+
this.recordFailure(errorMessage(error));
|
|
487
509
|
return false;
|
|
488
510
|
}
|
|
489
511
|
const claimCompletedAtMs = this.monotonicNowMs();
|
|
490
512
|
if (claim.kind !== 'claimed') {
|
|
491
513
|
const error = new ZLinkOwnerLeaseClaimError(claim.kind);
|
|
492
|
-
this.recordFailure(error.message
|
|
514
|
+
this.recordFailure(error.message);
|
|
493
515
|
throw error;
|
|
494
516
|
}
|
|
495
517
|
try {
|
|
@@ -508,24 +530,26 @@ export class ZLinkLocationRuntime implements ZLinkLocationRuntimeQuery {
|
|
|
508
530
|
claim.storeNow
|
|
509
531
|
);
|
|
510
532
|
this.lastError = undefined;
|
|
511
|
-
this.nextLeaseRenewAtMs = this.monotonicNowMs() + this.options.ownerLeaseRenewIntervalMs;
|
|
512
533
|
for (const handler of this.ownerLeaseRenewedHandlers) {
|
|
513
|
-
handler(
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
534
|
+
handler(
|
|
535
|
+
{
|
|
536
|
+
kind: 'renewed',
|
|
537
|
+
leaseExpiresAt: claim.leaseExpiresAt,
|
|
538
|
+
storeNow: claim.storeNow
|
|
539
|
+
},
|
|
540
|
+
false
|
|
541
|
+
);
|
|
518
542
|
}
|
|
519
543
|
return true;
|
|
520
544
|
} catch (error) {
|
|
521
545
|
if (signal?.aborted === true) throw error;
|
|
522
|
-
this.recordFailure(errorMessage(error)
|
|
546
|
+
this.recordFailure(errorMessage(error));
|
|
523
547
|
return false;
|
|
524
548
|
}
|
|
525
549
|
}
|
|
526
550
|
|
|
527
551
|
private async claimOwnerLeaseWithConfirmation(
|
|
528
|
-
|
|
552
|
+
timeoutStartedAtMs: number,
|
|
529
553
|
signal?: AbortSignal,
|
|
530
554
|
shutdownSignal?: () => AbortSignal
|
|
531
555
|
): Promise<Awaited<ReturnType<ZLinkOwnerLeaseStore['claimOwnerLease']>>> {
|
|
@@ -540,7 +564,7 @@ export class ZLinkLocationRuntime implements ZLinkLocationRuntimeQuery {
|
|
|
540
564
|
this.options.ownerLeaseTtlMs,
|
|
541
565
|
claimSignal
|
|
542
566
|
)),
|
|
543
|
-
remainingTimeoutMs(
|
|
567
|
+
remainingTimeoutMs(timeoutStartedAtMs, this.options.ownerLeaseRenewTimeoutMs),
|
|
544
568
|
signal
|
|
545
569
|
);
|
|
546
570
|
} catch (error) {
|
|
@@ -550,7 +574,9 @@ export class ZLinkLocationRuntime implements ZLinkLocationRuntimeQuery {
|
|
|
550
574
|
try {
|
|
551
575
|
await withTimeout(
|
|
552
576
|
() => request!,
|
|
553
|
-
cleanupSignal === undefined
|
|
577
|
+
cleanupSignal === undefined
|
|
578
|
+
? remainingTimeoutMs(timeoutStartedAtMs, this.options.ownerLeaseRenewTimeoutMs)
|
|
579
|
+
: undefined,
|
|
554
580
|
cleanupSignal
|
|
555
581
|
);
|
|
556
582
|
} catch (completionError) {
|
|
@@ -561,13 +587,13 @@ export class ZLinkLocationRuntime implements ZLinkLocationRuntimeQuery {
|
|
|
561
587
|
throw new ZLinkOwnerCleanupError(completionError);
|
|
562
588
|
}
|
|
563
589
|
if (!isAbortError(completionError)) {
|
|
564
|
-
this.recordFailure(errorMessage(completionError)
|
|
590
|
+
this.recordFailure(errorMessage(completionError));
|
|
565
591
|
}
|
|
566
592
|
}
|
|
567
593
|
}
|
|
568
594
|
const confirmed = await this.confirmOwnerLease(
|
|
569
595
|
error,
|
|
570
|
-
|
|
596
|
+
timeoutStartedAtMs,
|
|
571
597
|
signal,
|
|
572
598
|
shutdownSignal
|
|
573
599
|
);
|
|
@@ -577,13 +603,13 @@ export class ZLinkLocationRuntime implements ZLinkLocationRuntimeQuery {
|
|
|
577
603
|
if (claim.kind !== 'conflict') return claim;
|
|
578
604
|
const conflict = new ZLinkOwnerLeaseClaimError(claim.kind);
|
|
579
605
|
return (
|
|
580
|
-
(await this.confirmOwnerLease(conflict,
|
|
606
|
+
(await this.confirmOwnerLease(conflict, timeoutStartedAtMs, signal, shutdownSignal)) ?? claim
|
|
581
607
|
);
|
|
582
608
|
}
|
|
583
609
|
|
|
584
610
|
private async confirmOwnerLease(
|
|
585
611
|
originalError: unknown,
|
|
586
|
-
|
|
612
|
+
timeoutStartedAtMs: number,
|
|
587
613
|
signal?: AbortSignal,
|
|
588
614
|
shutdownSignal?: () => AbortSignal
|
|
589
615
|
): Promise<
|
|
@@ -593,7 +619,9 @@ export class ZLinkLocationRuntime implements ZLinkLocationRuntimeQuery {
|
|
|
593
619
|
const cancelled = signal?.aborted === true;
|
|
594
620
|
const cleanupSignal = cancelled ? shutdownSignal?.() : undefined;
|
|
595
621
|
const confirmationTimeoutMs =
|
|
596
|
-
cleanupSignal === undefined
|
|
622
|
+
cleanupSignal === undefined
|
|
623
|
+
? remainingTimeoutMs(timeoutStartedAtMs, this.options.ownerLeaseRenewTimeoutMs)
|
|
624
|
+
: undefined;
|
|
597
625
|
if (confirmationTimeoutMs !== undefined && confirmationTimeoutMs <= 0) throw originalError;
|
|
598
626
|
let confirmed: Awaited<ReturnType<ZLinkOwnerLeaseStore['readOwnerLease']>>;
|
|
599
627
|
try {
|
|
@@ -603,9 +631,9 @@ export class ZLinkLocationRuntime implements ZLinkLocationRuntimeQuery {
|
|
|
603
631
|
cleanupSignal
|
|
604
632
|
);
|
|
605
633
|
} catch (confirmationError) {
|
|
606
|
-
this.recordFailure(errorMessage(confirmationError)
|
|
634
|
+
this.recordFailure(errorMessage(confirmationError));
|
|
607
635
|
if (cancelled) throw new ZLinkOwnerCleanupError(confirmationError);
|
|
608
|
-
throw confirmationError;
|
|
636
|
+
throw originalError instanceof ZLinkOwnerLeaseClaimError ? originalError : confirmationError;
|
|
609
637
|
}
|
|
610
638
|
if (confirmed.kind !== 'found' || confirmed.token.ownerId !== this.ownerId) {
|
|
611
639
|
throw originalError;
|
|
@@ -615,11 +643,13 @@ export class ZLinkLocationRuntime implements ZLinkLocationRuntimeQuery {
|
|
|
615
643
|
await withTimeout(
|
|
616
644
|
(releaseSignal) =>
|
|
617
645
|
this.stores.ownerLeaseStore.releaseOwnerLease(confirmed.token, releaseSignal),
|
|
618
|
-
cleanupSignal === undefined
|
|
646
|
+
cleanupSignal === undefined
|
|
647
|
+
? remainingTimeoutMs(timeoutStartedAtMs, this.options.ownerLeaseRenewTimeoutMs)
|
|
648
|
+
: undefined,
|
|
619
649
|
cleanupSignal
|
|
620
650
|
);
|
|
621
651
|
} catch (releaseError) {
|
|
622
|
-
this.recordFailure(errorMessage(releaseError)
|
|
652
|
+
this.recordFailure(errorMessage(releaseError));
|
|
623
653
|
throw new ZLinkOwnerCleanupError(releaseError);
|
|
624
654
|
}
|
|
625
655
|
throw originalError;
|
|
@@ -687,7 +717,10 @@ export class ZLinkLocationRuntime implements ZLinkLocationRuntimeQuery {
|
|
|
687
717
|
updatedAt: new Date()
|
|
688
718
|
};
|
|
689
719
|
let result = await this.guardWrite(() =>
|
|
690
|
-
this.
|
|
720
|
+
this.writeDescriptor(
|
|
721
|
+
(writeSignal) => this.stores.locationStore.updateMeshNode(stamped, intent, writeSignal),
|
|
722
|
+
signal
|
|
723
|
+
)
|
|
691
724
|
);
|
|
692
725
|
if (
|
|
693
726
|
intent === ZLinkLocationWriteIntent.Renew &&
|
|
@@ -699,7 +732,15 @@ export class ZLinkLocationRuntime implements ZLinkLocationRuntimeQuery {
|
|
|
699
732
|
// NewClaim as a bounded fallback. If another owner has recreated the
|
|
700
733
|
// row, NewClaim remains rejected and the caller keeps the conflict.
|
|
701
734
|
result = await this.guardWrite(() =>
|
|
702
|
-
this.
|
|
735
|
+
this.writeDescriptor(
|
|
736
|
+
(writeSignal) =>
|
|
737
|
+
this.stores.locationStore.updateMeshNode(
|
|
738
|
+
stamped,
|
|
739
|
+
ZLinkLocationWriteIntent.NewClaim,
|
|
740
|
+
writeSignal
|
|
741
|
+
),
|
|
742
|
+
signal
|
|
743
|
+
)
|
|
703
744
|
);
|
|
704
745
|
}
|
|
705
746
|
this.notifyIfStale(
|
|
@@ -906,7 +947,7 @@ export class ZLinkLocationRuntime implements ZLinkLocationRuntimeQuery {
|
|
|
906
947
|
}
|
|
907
948
|
|
|
908
949
|
reportDiscoveryFailure(error: unknown): void {
|
|
909
|
-
this.recordFailure(errorMessage(error)
|
|
950
|
+
this.recordFailure(errorMessage(error));
|
|
910
951
|
}
|
|
911
952
|
|
|
912
953
|
async listPeerLocations(
|
|
@@ -939,6 +980,14 @@ export class ZLinkLocationRuntime implements ZLinkLocationRuntimeQuery {
|
|
|
939
980
|
return live.map((row) => ({ ...row, endpoint: normalizeEndpoint(row.endpoint) }));
|
|
940
981
|
}
|
|
941
982
|
|
|
983
|
+
/** Remaining exact owner lease from the same tracker that filters live descriptors. */
|
|
984
|
+
remainingOwnerTokenLeaseMs(
|
|
985
|
+
owner: ZLinkLocationOwnerToken,
|
|
986
|
+
signal?: AbortSignal
|
|
987
|
+
): Promise<number> {
|
|
988
|
+
return this.leaseTracker.remainingOwnerTokenLeaseMs(owner, signal);
|
|
989
|
+
}
|
|
990
|
+
|
|
942
991
|
async listMeshNodeDescriptors(
|
|
943
992
|
meshName: string,
|
|
944
993
|
page?: ZLinkPageRequest,
|
|
@@ -1250,8 +1299,7 @@ export class ZLinkLocationRuntime implements ZLinkLocationRuntimeQuery {
|
|
|
1250
1299
|
if (!this.started) {
|
|
1251
1300
|
return;
|
|
1252
1301
|
}
|
|
1253
|
-
const scheduledAt =
|
|
1254
|
-
this.nextLeaseRenewAtMs ?? this.monotonicNowMs() + this.options.ownerLeaseRenewIntervalMs;
|
|
1302
|
+
const scheduledAt = this.leaseOperationStartedAtMs + this.options.ownerLeaseRenewIntervalMs;
|
|
1255
1303
|
const delayMs = Math.max(0, scheduledAt - this.monotonicNowMs());
|
|
1256
1304
|
this.heartbeatTimer = this.setTimer(() => {
|
|
1257
1305
|
this.heartbeatTimer = undefined;
|
|
@@ -1259,13 +1307,12 @@ export class ZLinkLocationRuntime implements ZLinkLocationRuntimeQuery {
|
|
|
1259
1307
|
for (const scope of this.leaseScopes) {
|
|
1260
1308
|
this.metrics?.recordOwnerLeaseRenewLateness(lateness, scope.kind, scope.name);
|
|
1261
1309
|
}
|
|
1262
|
-
this.nextLeaseRenewAtMs = this.monotonicNowMs() + this.options.ownerLeaseRenewIntervalMs;
|
|
1263
1310
|
if (
|
|
1264
1311
|
this.ownerLeaseDeadlineMs !== undefined &&
|
|
1265
1312
|
this.monotonicNowMs() >= this.ownerLeaseDeadlineMs
|
|
1266
1313
|
) {
|
|
1267
1314
|
this.ownerLeaseHealthy = false;
|
|
1268
|
-
this.recordFailure('Owner lease expired before renewal completed.'
|
|
1315
|
+
this.recordFailure('Owner lease expired before renewal completed.');
|
|
1269
1316
|
for (const handler of this.ownerLeaseRenewalFailedHandlers) handler();
|
|
1270
1317
|
}
|
|
1271
1318
|
const renewal = this.renewOwnerLeaseOnce()
|
|
@@ -1290,7 +1337,7 @@ export class ZLinkLocationRuntime implements ZLinkLocationRuntimeQuery {
|
|
|
1290
1337
|
try {
|
|
1291
1338
|
return await write();
|
|
1292
1339
|
} catch (error) {
|
|
1293
|
-
this.recordFailure(errorMessage(error)
|
|
1340
|
+
this.recordFailure(errorMessage(error));
|
|
1294
1341
|
throw error;
|
|
1295
1342
|
}
|
|
1296
1343
|
}
|
|
@@ -1301,7 +1348,7 @@ export class ZLinkLocationRuntime implements ZLinkLocationRuntimeQuery {
|
|
|
1301
1348
|
try {
|
|
1302
1349
|
return await write();
|
|
1303
1350
|
} catch (error) {
|
|
1304
|
-
this.recordFailure(errorMessage(error)
|
|
1351
|
+
this.recordFailure(errorMessage(error));
|
|
1305
1352
|
throw error;
|
|
1306
1353
|
}
|
|
1307
1354
|
}
|
|
@@ -1311,12 +1358,6 @@ export class ZLinkLocationRuntime implements ZLinkLocationRuntimeQuery {
|
|
|
1311
1358
|
kind: ZLinkLocationKind,
|
|
1312
1359
|
key: string
|
|
1313
1360
|
): void {
|
|
1314
|
-
if (
|
|
1315
|
-
result.status === ZLinkLocationWriteStatus.IgnoredStale ||
|
|
1316
|
-
result.status === ZLinkLocationWriteStatus.RejectedConflict
|
|
1317
|
-
) {
|
|
1318
|
-
this.metrics?.recordLocationStoreError('compare_exchange');
|
|
1319
|
-
}
|
|
1320
1361
|
if (result.status !== ZLinkLocationWriteStatus.IgnoredStale) {
|
|
1321
1362
|
return;
|
|
1322
1363
|
}
|
|
@@ -1330,12 +1371,6 @@ export class ZLinkLocationRuntime implements ZLinkLocationRuntimeQuery {
|
|
|
1330
1371
|
kind: ZLinkLocationKind,
|
|
1331
1372
|
key: string
|
|
1332
1373
|
): void {
|
|
1333
|
-
if (
|
|
1334
|
-
status === ZLinkLocationWriteStatus.IgnoredStale ||
|
|
1335
|
-
status === ZLinkLocationWriteStatus.RejectedConflict
|
|
1336
|
-
) {
|
|
1337
|
-
this.metrics?.recordLocationStoreError('compare_exchange');
|
|
1338
|
-
}
|
|
1339
1374
|
if (status !== ZLinkLocationWriteStatus.IgnoredStale) {
|
|
1340
1375
|
return;
|
|
1341
1376
|
}
|
|
@@ -1344,8 +1379,7 @@ export class ZLinkLocationRuntime implements ZLinkLocationRuntimeQuery {
|
|
|
1344
1379
|
}
|
|
1345
1380
|
}
|
|
1346
1381
|
|
|
1347
|
-
private recordFailure(message: string
|
|
1348
|
-
this.metrics?.recordLocationStoreError(operation);
|
|
1382
|
+
private recordFailure(message: string): void {
|
|
1349
1383
|
this.ownerLeaseHealthy = false;
|
|
1350
1384
|
this.lastError = message;
|
|
1351
1385
|
}
|
|
@@ -1413,8 +1447,8 @@ class OwnerLeaseRenewTimeoutError extends Error {
|
|
|
1413
1447
|
}
|
|
1414
1448
|
}
|
|
1415
1449
|
|
|
1416
|
-
function remainingTimeoutMs(
|
|
1417
|
-
return Math.max(0,
|
|
1450
|
+
function remainingTimeoutMs(timeoutStartedAtMs: number, timeoutMs: number): number {
|
|
1451
|
+
return Math.max(0, timeoutMs - (performance.now() - timeoutStartedAtMs));
|
|
1418
1452
|
}
|
|
1419
1453
|
|
|
1420
1454
|
function errorMessage(error: unknown): string {
|