@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,7 +1,24 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ZLinkRuntimeMetrics } from '../diagnostics/runtime-metrics';
|
|
2
|
+
import type { ZLinkBlobReference, ZLinkBlobPutResult, ZLinkRelocationStore } from '../../contracts/Locations/RelocationStore';
|
|
2
3
|
export declare function relocationBlobReference(value: string): ZLinkBlobReference;
|
|
3
4
|
export declare function putNewRelocationBlob(store: ZLinkRelocationStore, payload: Uint8Array, retentionMs: number, signal?: AbortSignal): Promise<{
|
|
4
5
|
readonly reference: ZLinkBlobReference;
|
|
5
6
|
readonly expiresAt: Date;
|
|
6
7
|
readonly storeNow: Date;
|
|
7
8
|
}>;
|
|
9
|
+
/** Observes provider requests before callers interpret or decode blob contents. */
|
|
10
|
+
export declare class ZLinkProviderRelocationRepository implements ZLinkRelocationStore {
|
|
11
|
+
private readonly provider;
|
|
12
|
+
private readonly metrics;
|
|
13
|
+
constructor(provider: ZLinkRelocationStore, metrics: ZLinkRuntimeMetrics);
|
|
14
|
+
putNew(payload: Uint8Array, retentionMs: number, signal?: AbortSignal): Promise<{
|
|
15
|
+
readonly reference: ZLinkBlobReference;
|
|
16
|
+
readonly expiresAt: Date;
|
|
17
|
+
readonly storeNow: Date;
|
|
18
|
+
}>;
|
|
19
|
+
put(...args: Parameters<ZLinkRelocationStore['put']>): Promise<ZLinkBlobPutResult>;
|
|
20
|
+
read(...args: Parameters<ZLinkRelocationStore['read']>): Promise<import("../../contracts/Locations/RelocationStore").ZLinkBlobReadResult>;
|
|
21
|
+
renew(...args: Parameters<ZLinkRelocationStore['renew']>): Promise<import("../../contracts/Locations/RelocationStore").ZLinkBlobRenewResult>;
|
|
22
|
+
delete(...args: Parameters<ZLinkRelocationStore['delete']>): Promise<void>;
|
|
23
|
+
private observe;
|
|
24
|
+
}
|
|
@@ -1,13 +1,22 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ZLinkProviderRelocationRepository = void 0;
|
|
3
4
|
exports.relocationBlobReference = relocationBlobReference;
|
|
4
5
|
exports.putNewRelocationBlob = putNewRelocationBlob;
|
|
6
|
+
const ZLinkFrameworkException_1 = require("../../contracts/Errors/ZLinkFrameworkException");
|
|
7
|
+
const location_store_failure_1 = require("./location-store-failure");
|
|
5
8
|
const node_crypto_1 = require("node:crypto");
|
|
6
9
|
const abort_1 = require("../abort");
|
|
7
10
|
function relocationBlobReference(value) {
|
|
8
11
|
return { value };
|
|
9
12
|
}
|
|
10
13
|
async function putNewRelocationBlob(store, payload, retentionMs, signal) {
|
|
14
|
+
if (store instanceof ZLinkProviderRelocationRepository) {
|
|
15
|
+
return store.putNew(payload, retentionMs, signal);
|
|
16
|
+
}
|
|
17
|
+
return putNewRelocationBlobCore(store, payload, retentionMs, signal);
|
|
18
|
+
}
|
|
19
|
+
async function putNewRelocationBlobCore(store, payload, retentionMs, signal) {
|
|
11
20
|
let reference = relocationBlobReference((0, node_crypto_1.randomUUID)());
|
|
12
21
|
for (;; await (0, abort_1.macrotaskBoundary)()) {
|
|
13
22
|
signal?.throwIfAborted();
|
|
@@ -15,7 +24,9 @@ async function putNewRelocationBlob(store, payload, retentionMs, signal) {
|
|
|
15
24
|
try {
|
|
16
25
|
result = await (0, abort_1.awaitWithAbort)(store.put(reference, payload, retentionMs, signal), signal);
|
|
17
26
|
}
|
|
18
|
-
catch {
|
|
27
|
+
catch (error) {
|
|
28
|
+
if (!isRelocationProviderFailure(error))
|
|
29
|
+
throw error;
|
|
19
30
|
signal?.throwIfAborted();
|
|
20
31
|
const read = await (0, abort_1.awaitWithAbort)(store.read(reference, signal), signal);
|
|
21
32
|
if (read.kind === 'found' && Buffer.compare(read.bytes, payload) === 0) {
|
|
@@ -35,3 +46,43 @@ async function putNewRelocationBlob(store, payload, retentionMs, signal) {
|
|
|
35
46
|
reference = relocationBlobReference((0, node_crypto_1.randomUUID)());
|
|
36
47
|
}
|
|
37
48
|
}
|
|
49
|
+
/** Observes provider requests before callers interpret or decode blob contents. */
|
|
50
|
+
class ZLinkProviderRelocationRepository {
|
|
51
|
+
provider;
|
|
52
|
+
metrics;
|
|
53
|
+
constructor(provider, metrics) {
|
|
54
|
+
this.provider = provider;
|
|
55
|
+
this.metrics = metrics;
|
|
56
|
+
}
|
|
57
|
+
putNew(payload, retentionMs, signal) {
|
|
58
|
+
return this.observe('relocation_put', () => putNewRelocationBlobCore(this.provider, payload, retentionMs, signal), signal);
|
|
59
|
+
}
|
|
60
|
+
put(...args) {
|
|
61
|
+
return this.observe('relocation_put', () => this.provider.put(...args), args[3]);
|
|
62
|
+
}
|
|
63
|
+
read(...args) {
|
|
64
|
+
return this.observe('relocation_get', () => this.provider.read(...args), args[1]);
|
|
65
|
+
}
|
|
66
|
+
renew(...args) {
|
|
67
|
+
return this.observe('relocation_put', () => this.provider.renew(...args), args[2]);
|
|
68
|
+
}
|
|
69
|
+
delete(...args) {
|
|
70
|
+
return this.observe('relocation_delete', () => this.provider.delete(...args), args[1]);
|
|
71
|
+
}
|
|
72
|
+
async observe(operation, request, signal) {
|
|
73
|
+
try {
|
|
74
|
+
return await request();
|
|
75
|
+
}
|
|
76
|
+
catch (error) {
|
|
77
|
+
if (isRelocationProviderFailure(error, signal)) {
|
|
78
|
+
this.metrics.recordLocationStoreError(operation);
|
|
79
|
+
}
|
|
80
|
+
throw error;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
exports.ZLinkProviderRelocationRepository = ZLinkProviderRelocationRepository;
|
|
85
|
+
function isRelocationProviderFailure(error, signal) {
|
|
86
|
+
return ((0, location_store_failure_1.isIndeterminateLocationStoreFailure)(error, signal) &&
|
|
87
|
+
!(error instanceof ZLinkFrameworkException_1.ZLinkFrameworkException && error.kind !== ZLinkFrameworkException_1.ZLinkFrameworkErrorKind.Unavailable));
|
|
88
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { RoutingId } from '../../contracts/Common';
|
|
2
|
+
import type { ZLinkMeshNodeDescriptor } from '../../contracts/Locations/Rows';
|
|
3
|
+
import type { ZLinkLocationOwnerToken } from './internal-location-contracts';
|
|
4
|
+
/** Source request owner values the first accepting owner records (Location runtime §9.3). */
|
|
5
|
+
export interface ZLinkRequestSourceFence {
|
|
6
|
+
readonly ownerId: string;
|
|
7
|
+
readonly leaseGeneration: bigint;
|
|
8
|
+
readonly nodeRid: RoutingId;
|
|
9
|
+
readonly nodeGeneration: bigint;
|
|
10
|
+
}
|
|
11
|
+
export interface ZLinkRequestSourceResolverOptions {
|
|
12
|
+
readonly listLiveMeshNodes: (meshName: string, signal?: AbortSignal) => Promise<readonly ZLinkMeshNodeDescriptor[]>;
|
|
13
|
+
readonly remainingOwnerTokenLeaseMs: (owner: ZLinkLocationOwnerToken, signal?: AbortSignal) => Promise<number>;
|
|
14
|
+
readonly monotonicNowMs?: () => number;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Chooses the descriptor that supplies the source request owner values (Session·Actor binding
|
|
18
|
+
* §4): the admitted sender's descriptor with the exact RID and node lifecycle generation whose
|
|
19
|
+
* owner lease passes the Location runtime §4.1 check. Auto-connect polling keeps the live
|
|
20
|
+
* descriptors here with the local lease deadline computed from the same lease read. A sender
|
|
21
|
+
* missing from them is read from the Store once and kept with them.
|
|
22
|
+
*/
|
|
23
|
+
export declare class ZLinkRequestSourceResolver {
|
|
24
|
+
private readonly options;
|
|
25
|
+
private readonly polled;
|
|
26
|
+
private readonly monotonicNowMs;
|
|
27
|
+
constructor(options: ZLinkRequestSourceResolverOptions);
|
|
28
|
+
/** Replaces the polled descriptors of one mesh with a live descriptor listing. */
|
|
29
|
+
observeLiveDescriptors(meshName: string, descriptors: readonly ZLinkMeshNodeDescriptor[], signal?: AbortSignal): Promise<void>;
|
|
30
|
+
/**
|
|
31
|
+
* Returns the recorded values, undefined when the sender has no live descriptor, or a promise
|
|
32
|
+
* while the Store is read once for a sender the polled descriptors do not contain.
|
|
33
|
+
*/
|
|
34
|
+
accept(meshName: string, nodeRid: RoutingId, nodeGeneration: bigint, nodeRidStorageHex: string, signal?: AbortSignal): ZLinkRequestSourceFence | undefined | Promise<ZLinkRequestSourceFence | undefined>;
|
|
35
|
+
private readOnce;
|
|
36
|
+
private polledSource;
|
|
37
|
+
}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ZLinkRequestSourceResolver = void 0;
|
|
4
|
+
const routing_id_1 = require("../routing-id");
|
|
5
|
+
const abort_1 = require("../abort");
|
|
6
|
+
/**
|
|
7
|
+
* Chooses the descriptor that supplies the source request owner values (Session·Actor binding
|
|
8
|
+
* §4): the admitted sender's descriptor with the exact RID and node lifecycle generation whose
|
|
9
|
+
* owner lease passes the Location runtime §4.1 check. Auto-connect polling keeps the live
|
|
10
|
+
* descriptors here with the local lease deadline computed from the same lease read. A sender
|
|
11
|
+
* missing from them is read from the Store once and kept with them.
|
|
12
|
+
*/
|
|
13
|
+
class ZLinkRequestSourceResolver {
|
|
14
|
+
options;
|
|
15
|
+
polled = new Map();
|
|
16
|
+
monotonicNowMs;
|
|
17
|
+
constructor(options) {
|
|
18
|
+
this.options = options;
|
|
19
|
+
this.monotonicNowMs = options.monotonicNowMs ?? (() => performance.now());
|
|
20
|
+
}
|
|
21
|
+
/** Replaces the polled descriptors of one mesh with a live descriptor listing. */
|
|
22
|
+
async observeLiveDescriptors(meshName, descriptors, signal) {
|
|
23
|
+
const sources = new Map();
|
|
24
|
+
for (const descriptor of descriptors) {
|
|
25
|
+
const source = await this.polledSource(descriptor, signal);
|
|
26
|
+
if (source !== undefined)
|
|
27
|
+
sources.set((0, routing_id_1.encodeRoutingIdStorageHex)(descriptor.rid), source);
|
|
28
|
+
}
|
|
29
|
+
this.polled.set(meshName, sources);
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Returns the recorded values, undefined when the sender has no live descriptor, or a promise
|
|
33
|
+
* while the Store is read once for a sender the polled descriptors do not contain.
|
|
34
|
+
*/
|
|
35
|
+
accept(meshName, nodeRid, nodeGeneration, nodeRidStorageHex, signal) {
|
|
36
|
+
(0, abort_1.throwIfAborted)(signal);
|
|
37
|
+
const known = this.polled.get(meshName)?.get(nodeRidStorageHex);
|
|
38
|
+
if (known !== undefined && known.fence.nodeGeneration === nodeGeneration) {
|
|
39
|
+
return this.monotonicNowMs() < known.leaseDeadlineMs ? known.fence : undefined;
|
|
40
|
+
}
|
|
41
|
+
return this.readOnce(meshName, nodeRid, nodeGeneration, nodeRidStorageHex, signal);
|
|
42
|
+
}
|
|
43
|
+
async readOnce(meshName, nodeRid, nodeGeneration, nodeRidStorageHex, signal) {
|
|
44
|
+
// The Store boundary already classifies provider failures as Unavailable. Preserve their
|
|
45
|
+
// cause for the ingress error reporter, and let programming errors propagate unchanged.
|
|
46
|
+
const descriptors = await (0, abort_1.awaitWithAbort)(this.options.listLiveMeshNodes(meshName, signal), signal);
|
|
47
|
+
const descriptor = descriptors.find((value) => (0, routing_id_1.routingIdsEqual)(value.rid, nodeRid) && value.lifecycleGeneration === nodeGeneration);
|
|
48
|
+
const source = descriptor === undefined ? undefined : await this.polledSource(descriptor, signal);
|
|
49
|
+
(0, abort_1.throwIfAborted)(signal);
|
|
50
|
+
if (source === undefined)
|
|
51
|
+
return undefined;
|
|
52
|
+
let sources = this.polled.get(meshName);
|
|
53
|
+
if (sources === undefined) {
|
|
54
|
+
sources = new Map();
|
|
55
|
+
this.polled.set(meshName, sources);
|
|
56
|
+
}
|
|
57
|
+
sources.set(nodeRidStorageHex, source);
|
|
58
|
+
return source.fence;
|
|
59
|
+
}
|
|
60
|
+
async polledSource(descriptor, signal) {
|
|
61
|
+
if (descriptor.ownerId.length === 0 ||
|
|
62
|
+
descriptor.leaseGeneration <= 0n ||
|
|
63
|
+
descriptor.lifecycleGeneration <= 0n) {
|
|
64
|
+
return undefined;
|
|
65
|
+
}
|
|
66
|
+
const remainingMs = await (0, abort_1.awaitWithAbort)(this.options.remainingOwnerTokenLeaseMs({ ownerId: descriptor.ownerId, leaseGeneration: descriptor.leaseGeneration }, signal), signal);
|
|
67
|
+
if (remainingMs <= 0)
|
|
68
|
+
return undefined;
|
|
69
|
+
return {
|
|
70
|
+
fence: {
|
|
71
|
+
ownerId: descriptor.ownerId,
|
|
72
|
+
leaseGeneration: descriptor.leaseGeneration,
|
|
73
|
+
nodeRid: descriptor.rid,
|
|
74
|
+
nodeGeneration: descriptor.lifecycleGeneration
|
|
75
|
+
},
|
|
76
|
+
leaseDeadlineMs: this.monotonicNowMs() + remainingMs
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
exports.ZLinkRequestSourceResolver = ZLinkRequestSourceResolver;
|
|
@@ -104,7 +104,7 @@ class ZLinkStoreLocationResolvers {
|
|
|
104
104
|
descriptor.objectRole === internal_location_contracts_1.ZLinkObjectRole.Server &&
|
|
105
105
|
descriptor.placementWeight > 0 &&
|
|
106
106
|
!(0, routing_id_1.routingIdsEqual)(descriptor.rid, excludedNodeRid) &&
|
|
107
|
-
!excludedCandidateRids.has(
|
|
107
|
+
!excludedCandidateRids.has((0, routing_id_1.encodeRoutingIdStorageHex)(descriptor.rid)) &&
|
|
108
108
|
capacity.active + capacity.reserved < capacity.limit &&
|
|
109
109
|
descriptor.objectCapabilities.some((candidate) => candidate.objectKind === 'actor' && candidate.stableType === actorType));
|
|
110
110
|
});
|
|
@@ -83,7 +83,7 @@ export declare class ZLinkLocationRuntime implements ZLinkLocationRuntimeQuery {
|
|
|
83
83
|
private readonly meshNames;
|
|
84
84
|
private readonly leaseScopes;
|
|
85
85
|
private readonly rewriteAuthorityPayloadForOwner?;
|
|
86
|
-
private
|
|
86
|
+
private leaseOperationStartedAtMs;
|
|
87
87
|
private ownerToken?;
|
|
88
88
|
private lastOwnerToken?;
|
|
89
89
|
private ownerLeaseDeadlineMs?;
|
|
@@ -95,13 +95,15 @@ export declare class ZLinkLocationRuntime implements ZLinkLocationRuntimeQuery {
|
|
|
95
95
|
get isStarted(): boolean;
|
|
96
96
|
get nodeRid(): RoutingId | undefined;
|
|
97
97
|
get currentOwnerToken(): ZLinkLocationOwnerToken | undefined;
|
|
98
|
+
/** Location runtime §5: a startup Store request ends within the renew timeout. */
|
|
99
|
+
writeDescriptor<T>(action: (signal?: AbortSignal) => Promise<T>, signal?: AbortSignal): Promise<T>;
|
|
98
100
|
closeOwnerLeaseAdmission(error: unknown): void;
|
|
99
101
|
reclaimOwnerAuthorities(signal?: AbortSignal): Promise<void>;
|
|
100
102
|
private readAllAuthorityEntries;
|
|
101
103
|
addOwnershipLostHandler(handler: (event: ZLinkOwnershipLostEvent) => void): void;
|
|
102
104
|
removeOwnershipLostHandler(handler: (event: ZLinkOwnershipLostEvent) => void): void;
|
|
103
|
-
addOwnerLeaseRenewedHandler(handler: (renewal: ZLinkOwnerLeaseRenewed) => void): void;
|
|
104
|
-
removeOwnerLeaseRenewedHandler(handler: (renewal: ZLinkOwnerLeaseRenewed) => void): void;
|
|
105
|
+
addOwnerLeaseRenewedHandler(handler: (renewal: ZLinkOwnerLeaseRenewed, wasOwnerLeaseUsable: boolean) => void): void;
|
|
106
|
+
removeOwnerLeaseRenewedHandler(handler: (renewal: ZLinkOwnerLeaseRenewed, wasOwnerLeaseUsable: boolean) => void): void;
|
|
105
107
|
addOwnerLeaseRenewalFailedHandler(handler: () => void): void;
|
|
106
108
|
removeOwnerLeaseRenewalFailedHandler(handler: () => void): void;
|
|
107
109
|
start(nodeRid: RoutingId): Promise<void>;
|
|
@@ -128,6 +130,8 @@ export declare class ZLinkLocationRuntime implements ZLinkLocationRuntimeQuery {
|
|
|
128
130
|
reportDiscoveryFailure(error: unknown): void;
|
|
129
131
|
listPeerLocations(filter: ZLinkPeerLocationFilter, signal?: AbortSignal): Promise<readonly ZLinkPeerLocation[]>;
|
|
130
132
|
listLiveMeshNodes(meshName: string, signal?: AbortSignal): Promise<readonly ZLinkMeshNodeDescriptor[]>;
|
|
133
|
+
/** Remaining exact owner lease from the same tracker that filters live descriptors. */
|
|
134
|
+
remainingOwnerTokenLeaseMs(owner: ZLinkLocationOwnerToken, signal?: AbortSignal): Promise<number>;
|
|
131
135
|
listMeshNodeDescriptors(meshName: string, page?: ZLinkPageRequest, signal?: AbortSignal): Promise<ZLinkLocationPage<ZLinkMeshNodeDescriptor>>;
|
|
132
136
|
listSpotLocations(filter: ZLinkSpotLocationFilter, page?: ZLinkPageRequest, signal?: AbortSignal): Promise<ZLinkLocationPage<ZLinkSpotLocation>>;
|
|
133
137
|
listActorLocations(filter: ZLinkActorLocationFilter, page?: ZLinkPageRequest, signal?: AbortSignal): Promise<ZLinkLocationPage<ZLinkActorLocation>>;
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ZLinkLocationRuntime = exports.ZLinkOwnerLeaseClaimError = exports.ZLinkOwnerCleanupError = void 0;
|
|
4
|
+
const descriptor_publication_1 = require("./descriptor-publication");
|
|
5
|
+
const location_store_failure_1 = require("./location-store-failure");
|
|
4
6
|
const location_store_pages_1 = require("./location-store-pages");
|
|
5
7
|
const runtime_metrics_1 = require("../diagnostics/runtime-metrics");
|
|
6
8
|
const Stores_1 = require("../../contracts/Locations/Stores");
|
|
@@ -52,7 +54,7 @@ class ZLinkLocationRuntime {
|
|
|
52
54
|
meshNames;
|
|
53
55
|
leaseScopes;
|
|
54
56
|
rewriteAuthorityPayloadForOwner;
|
|
55
|
-
|
|
57
|
+
leaseOperationStartedAtMs = 0;
|
|
56
58
|
ownerToken;
|
|
57
59
|
lastOwnerToken;
|
|
58
60
|
ownerLeaseDeadlineMs;
|
|
@@ -97,9 +99,20 @@ class ZLinkLocationRuntime {
|
|
|
97
99
|
get currentOwnerToken() {
|
|
98
100
|
return this.ownerToken;
|
|
99
101
|
}
|
|
102
|
+
/** Location runtime §5: a startup Store request ends within the renew timeout. */
|
|
103
|
+
async writeDescriptor(action, signal) {
|
|
104
|
+
try {
|
|
105
|
+
return await withTimeout(action, this.options.ownerLeaseRenewTimeoutMs, signal);
|
|
106
|
+
}
|
|
107
|
+
catch (error) {
|
|
108
|
+
if (!(0, location_store_failure_1.isIndeterminateLocationStoreFailure)(error, signal))
|
|
109
|
+
throw error;
|
|
110
|
+
throw new descriptor_publication_1.ZLinkDescriptorPublicationUnconfirmedError(error);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
100
113
|
closeOwnerLeaseAdmission(error) {
|
|
101
114
|
this.ownerLeaseDeadlineMs = undefined;
|
|
102
|
-
this.recordFailure(errorMessage(error)
|
|
115
|
+
this.recordFailure(errorMessage(error));
|
|
103
116
|
}
|
|
104
117
|
async reclaimOwnerAuthorities(signal) {
|
|
105
118
|
const owner = this.ownerToken;
|
|
@@ -191,12 +204,7 @@ class ZLinkLocationRuntime {
|
|
|
191
204
|
const claim = this.renewOwnerLeaseOnce(signal, shutdownSignal);
|
|
192
205
|
this.heartbeatRenewal = claim;
|
|
193
206
|
try {
|
|
194
|
-
|
|
195
|
-
if (claimed) {
|
|
196
|
-
this.scheduleHeartbeat();
|
|
197
|
-
return;
|
|
198
|
-
}
|
|
199
|
-
this.nextLeaseRenewAtMs = this.monotonicNowMs() + this.options.ownerLeaseRenewIntervalMs;
|
|
207
|
+
await claim;
|
|
200
208
|
this.scheduleHeartbeat();
|
|
201
209
|
}
|
|
202
210
|
catch (error) {
|
|
@@ -211,7 +219,7 @@ class ZLinkLocationRuntime {
|
|
|
211
219
|
this.clearTimer(this.heartbeatTimer);
|
|
212
220
|
this.heartbeatTimer = undefined;
|
|
213
221
|
}
|
|
214
|
-
this.
|
|
222
|
+
this.leaseOperationStartedAtMs = 0;
|
|
215
223
|
this.ownerLeaseDeadlineMs = undefined;
|
|
216
224
|
await this.cleanupOwner(signal);
|
|
217
225
|
}
|
|
@@ -260,9 +268,9 @@ class ZLinkLocationRuntime {
|
|
|
260
268
|
if (this.ownerToken === undefined) {
|
|
261
269
|
return await this.claimFreshOwnerLease(signal, shutdownSignal);
|
|
262
270
|
}
|
|
263
|
-
const wasOwnerLeaseUsable = this.ownerLeaseUsable;
|
|
264
271
|
try {
|
|
265
272
|
const renewStartedAtMs = this.monotonicNowMs();
|
|
273
|
+
this.leaseOperationStartedAtMs = renewStartedAtMs;
|
|
266
274
|
const result = await withTimeout((renewSignal) => this.stores.ownerLeaseStore.renewOwnerLease(this.ownerToken, this.options.ownerLeaseTtlMs, renewSignal), this.options.ownerLeaseRenewTimeoutMs, signal);
|
|
267
275
|
const renewCompletedAtMs = this.monotonicNowMs();
|
|
268
276
|
if (result.kind !== 'renewed') {
|
|
@@ -281,13 +289,13 @@ class ZLinkLocationRuntime {
|
|
|
281
289
|
// another heartbeat interval.
|
|
282
290
|
return await this.claimFreshOwnerLease(signal, shutdownSignal);
|
|
283
291
|
}
|
|
292
|
+
const wasOwnerLeaseUsable = this.ownerLeaseUsable;
|
|
284
293
|
this.ownerLeaseHealthy = true;
|
|
285
294
|
this.ownerLeaseRenewedAt = result.storeNow;
|
|
286
295
|
this.setOwnerLeaseDeadline(renewStartedAtMs, renewCompletedAtMs, result.leaseExpiresAt, result.storeNow);
|
|
287
296
|
this.lastError = undefined;
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
handler(result);
|
|
297
|
+
for (const handler of this.ownerLeaseRenewedHandlers) {
|
|
298
|
+
handler(result, wasOwnerLeaseUsable);
|
|
291
299
|
}
|
|
292
300
|
return true;
|
|
293
301
|
}
|
|
@@ -295,7 +303,7 @@ class ZLinkLocationRuntime {
|
|
|
295
303
|
if (signal?.aborted === true)
|
|
296
304
|
throw error;
|
|
297
305
|
this.recordOwnerLeaseRenewFailure();
|
|
298
|
-
this.recordFailure(errorMessage(error)
|
|
306
|
+
this.recordFailure(errorMessage(error));
|
|
299
307
|
for (const handler of this.ownerLeaseRenewalFailedHandlers)
|
|
300
308
|
handler();
|
|
301
309
|
return false;
|
|
@@ -303,10 +311,11 @@ class ZLinkLocationRuntime {
|
|
|
303
311
|
}
|
|
304
312
|
async claimFreshOwnerLease(signal, shutdownSignal) {
|
|
305
313
|
const claimStartedAtMs = this.monotonicNowMs();
|
|
306
|
-
|
|
314
|
+
this.leaseOperationStartedAtMs = claimStartedAtMs;
|
|
315
|
+
const timeoutStartedAtMs = performance.now();
|
|
307
316
|
let claim;
|
|
308
317
|
try {
|
|
309
|
-
claim = await this.claimOwnerLeaseWithConfirmation(
|
|
318
|
+
claim = await this.claimOwnerLeaseWithConfirmation(timeoutStartedAtMs, signal, shutdownSignal);
|
|
310
319
|
}
|
|
311
320
|
catch (error) {
|
|
312
321
|
if (signal?.aborted === true)
|
|
@@ -314,13 +323,13 @@ class ZLinkLocationRuntime {
|
|
|
314
323
|
if (error instanceof ZLinkOwnerLeaseClaimError)
|
|
315
324
|
throw error;
|
|
316
325
|
this.recordOwnerLeaseRenewFailure();
|
|
317
|
-
this.recordFailure(errorMessage(error)
|
|
326
|
+
this.recordFailure(errorMessage(error));
|
|
318
327
|
return false;
|
|
319
328
|
}
|
|
320
329
|
const claimCompletedAtMs = this.monotonicNowMs();
|
|
321
330
|
if (claim.kind !== 'claimed') {
|
|
322
331
|
const error = new ZLinkOwnerLeaseClaimError(claim.kind);
|
|
323
|
-
this.recordFailure(error.message
|
|
332
|
+
this.recordFailure(error.message);
|
|
324
333
|
throw error;
|
|
325
334
|
}
|
|
326
335
|
try {
|
|
@@ -334,29 +343,28 @@ class ZLinkLocationRuntime {
|
|
|
334
343
|
this.ownerLeaseRenewedAt = claim.storeNow;
|
|
335
344
|
this.setOwnerLeaseDeadline(claimStartedAtMs, claimCompletedAtMs, claim.leaseExpiresAt, claim.storeNow);
|
|
336
345
|
this.lastError = undefined;
|
|
337
|
-
this.nextLeaseRenewAtMs = this.monotonicNowMs() + this.options.ownerLeaseRenewIntervalMs;
|
|
338
346
|
for (const handler of this.ownerLeaseRenewedHandlers) {
|
|
339
347
|
handler({
|
|
340
348
|
kind: 'renewed',
|
|
341
349
|
leaseExpiresAt: claim.leaseExpiresAt,
|
|
342
350
|
storeNow: claim.storeNow
|
|
343
|
-
});
|
|
351
|
+
}, false);
|
|
344
352
|
}
|
|
345
353
|
return true;
|
|
346
354
|
}
|
|
347
355
|
catch (error) {
|
|
348
356
|
if (signal?.aborted === true)
|
|
349
357
|
throw error;
|
|
350
|
-
this.recordFailure(errorMessage(error)
|
|
358
|
+
this.recordFailure(errorMessage(error));
|
|
351
359
|
return false;
|
|
352
360
|
}
|
|
353
361
|
}
|
|
354
|
-
async claimOwnerLeaseWithConfirmation(
|
|
362
|
+
async claimOwnerLeaseWithConfirmation(timeoutStartedAtMs, signal, shutdownSignal) {
|
|
355
363
|
signal?.throwIfAborted();
|
|
356
364
|
let claim;
|
|
357
365
|
let request;
|
|
358
366
|
try {
|
|
359
|
-
claim = await withTimeout((claimSignal) => (request = this.stores.ownerLeaseStore.claimOwnerLease(this.ownerId, this.options.ownerLeaseTtlMs, claimSignal)), remainingTimeoutMs(
|
|
367
|
+
claim = await withTimeout((claimSignal) => (request = this.stores.ownerLeaseStore.claimOwnerLease(this.ownerId, this.options.ownerLeaseTtlMs, claimSignal)), remainingTimeoutMs(timeoutStartedAtMs, this.options.ownerLeaseRenewTimeoutMs), signal);
|
|
360
368
|
}
|
|
361
369
|
catch (error) {
|
|
362
370
|
if (error instanceof OwnerLeaseRenewTimeoutError)
|
|
@@ -364,7 +372,9 @@ class ZLinkLocationRuntime {
|
|
|
364
372
|
if (signal?.aborted === true && request !== undefined) {
|
|
365
373
|
const cleanupSignal = shutdownSignal?.();
|
|
366
374
|
try {
|
|
367
|
-
await withTimeout(() => request, cleanupSignal === undefined
|
|
375
|
+
await withTimeout(() => request, cleanupSignal === undefined
|
|
376
|
+
? remainingTimeoutMs(timeoutStartedAtMs, this.options.ownerLeaseRenewTimeoutMs)
|
|
377
|
+
: undefined, cleanupSignal);
|
|
368
378
|
}
|
|
369
379
|
catch (completionError) {
|
|
370
380
|
if (cleanupSignal?.aborted === true ||
|
|
@@ -372,11 +382,11 @@ class ZLinkLocationRuntime {
|
|
|
372
382
|
throw new ZLinkOwnerCleanupError(completionError);
|
|
373
383
|
}
|
|
374
384
|
if (!(0, abort_1.isAbortError)(completionError)) {
|
|
375
|
-
this.recordFailure(errorMessage(completionError)
|
|
385
|
+
this.recordFailure(errorMessage(completionError));
|
|
376
386
|
}
|
|
377
387
|
}
|
|
378
388
|
}
|
|
379
|
-
const confirmed = await this.confirmOwnerLease(error,
|
|
389
|
+
const confirmed = await this.confirmOwnerLease(error, timeoutStartedAtMs, signal, shutdownSignal);
|
|
380
390
|
if (confirmed !== undefined)
|
|
381
391
|
return confirmed;
|
|
382
392
|
throw error;
|
|
@@ -384,12 +394,14 @@ class ZLinkLocationRuntime {
|
|
|
384
394
|
if (claim.kind !== 'conflict')
|
|
385
395
|
return claim;
|
|
386
396
|
const conflict = new ZLinkOwnerLeaseClaimError(claim.kind);
|
|
387
|
-
return ((await this.confirmOwnerLease(conflict,
|
|
397
|
+
return ((await this.confirmOwnerLease(conflict, timeoutStartedAtMs, signal, shutdownSignal)) ?? claim);
|
|
388
398
|
}
|
|
389
|
-
async confirmOwnerLease(originalError,
|
|
399
|
+
async confirmOwnerLease(originalError, timeoutStartedAtMs, signal, shutdownSignal) {
|
|
390
400
|
const cancelled = signal?.aborted === true;
|
|
391
401
|
const cleanupSignal = cancelled ? shutdownSignal?.() : undefined;
|
|
392
|
-
const confirmationTimeoutMs = cleanupSignal === undefined
|
|
402
|
+
const confirmationTimeoutMs = cleanupSignal === undefined
|
|
403
|
+
? remainingTimeoutMs(timeoutStartedAtMs, this.options.ownerLeaseRenewTimeoutMs)
|
|
404
|
+
: undefined;
|
|
393
405
|
if (confirmationTimeoutMs !== undefined && confirmationTimeoutMs <= 0)
|
|
394
406
|
throw originalError;
|
|
395
407
|
let confirmed;
|
|
@@ -397,20 +409,22 @@ class ZLinkLocationRuntime {
|
|
|
397
409
|
confirmed = await withTimeout((readSignal) => this.stores.ownerLeaseStore.readOwnerLease(this.ownerId, readSignal), confirmationTimeoutMs, cleanupSignal);
|
|
398
410
|
}
|
|
399
411
|
catch (confirmationError) {
|
|
400
|
-
this.recordFailure(errorMessage(confirmationError)
|
|
412
|
+
this.recordFailure(errorMessage(confirmationError));
|
|
401
413
|
if (cancelled)
|
|
402
414
|
throw new ZLinkOwnerCleanupError(confirmationError);
|
|
403
|
-
throw confirmationError;
|
|
415
|
+
throw originalError instanceof ZLinkOwnerLeaseClaimError ? originalError : confirmationError;
|
|
404
416
|
}
|
|
405
417
|
if (confirmed.kind !== 'found' || confirmed.token.ownerId !== this.ownerId) {
|
|
406
418
|
throw originalError;
|
|
407
419
|
}
|
|
408
420
|
if (signal?.aborted === true) {
|
|
409
421
|
try {
|
|
410
|
-
await withTimeout((releaseSignal) => this.stores.ownerLeaseStore.releaseOwnerLease(confirmed.token, releaseSignal), cleanupSignal === undefined
|
|
422
|
+
await withTimeout((releaseSignal) => this.stores.ownerLeaseStore.releaseOwnerLease(confirmed.token, releaseSignal), cleanupSignal === undefined
|
|
423
|
+
? remainingTimeoutMs(timeoutStartedAtMs, this.options.ownerLeaseRenewTimeoutMs)
|
|
424
|
+
: undefined, cleanupSignal);
|
|
411
425
|
}
|
|
412
426
|
catch (releaseError) {
|
|
413
|
-
this.recordFailure(errorMessage(releaseError)
|
|
427
|
+
this.recordFailure(errorMessage(releaseError));
|
|
414
428
|
throw new ZLinkOwnerCleanupError(releaseError);
|
|
415
429
|
}
|
|
416
430
|
throw originalError;
|
|
@@ -464,7 +478,7 @@ class ZLinkLocationRuntime {
|
|
|
464
478
|
// in-process result after the write completes.
|
|
465
479
|
updatedAt: new Date()
|
|
466
480
|
};
|
|
467
|
-
let result = await this.guardWrite(() => this.stores.locationStore.updateMeshNode(stamped, intent, signal));
|
|
481
|
+
let result = await this.guardWrite(() => this.writeDescriptor((writeSignal) => this.stores.locationStore.updateMeshNode(stamped, intent, writeSignal), signal));
|
|
468
482
|
if (intent === internal_location_contracts_1.ZLinkLocationWriteIntent.Renew &&
|
|
469
483
|
(result.status === internal_location_contracts_1.ZLinkLocationWriteStatus.RejectedConflict ||
|
|
470
484
|
result.status === internal_location_contracts_1.ZLinkLocationWriteStatus.IgnoredStale)) {
|
|
@@ -472,7 +486,7 @@ class ZLinkLocationRuntime {
|
|
|
472
486
|
// in-process owner token. Renew cannot recreate an absent row, so use
|
|
473
487
|
// NewClaim as a bounded fallback. If another owner has recreated the
|
|
474
488
|
// row, NewClaim remains rejected and the caller keeps the conflict.
|
|
475
|
-
result = await this.guardWrite(() => this.stores.locationStore.updateMeshNode(stamped, internal_location_contracts_1.ZLinkLocationWriteIntent.NewClaim, signal));
|
|
489
|
+
result = await this.guardWrite(() => this.writeDescriptor((writeSignal) => this.stores.locationStore.updateMeshNode(stamped, internal_location_contracts_1.ZLinkLocationWriteIntent.NewClaim, writeSignal), signal));
|
|
476
490
|
}
|
|
477
491
|
this.notifyIfStale(result, internal_location_contracts_1.ZLinkLocationKind.Peer, `${descriptor.meshName}\0${String(descriptor.rid)}`);
|
|
478
492
|
return result;
|
|
@@ -590,7 +604,7 @@ class ZLinkLocationRuntime {
|
|
|
590
604
|
};
|
|
591
605
|
}
|
|
592
606
|
reportDiscoveryFailure(error) {
|
|
593
|
-
this.recordFailure(errorMessage(error)
|
|
607
|
+
this.recordFailure(errorMessage(error));
|
|
594
608
|
}
|
|
595
609
|
async listPeerLocations(filter, signal) {
|
|
596
610
|
const rows = await this.stores.peerStore.listPeers(filter, signal);
|
|
@@ -606,6 +620,10 @@ class ZLinkLocationRuntime {
|
|
|
606
620
|
const live = await this.liveRows.filter(rows, (row, signal) => this.leaseTracker.isOwnerTokenLive(row, signal), signal);
|
|
607
621
|
return live.map((row) => ({ ...row, endpoint: (0, EndpointNotation_1.normalizeEndpoint)(row.endpoint) }));
|
|
608
622
|
}
|
|
623
|
+
/** Remaining exact owner lease from the same tracker that filters live descriptors. */
|
|
624
|
+
remainingOwnerTokenLeaseMs(owner, signal) {
|
|
625
|
+
return this.leaseTracker.remainingOwnerTokenLeaseMs(owner, signal);
|
|
626
|
+
}
|
|
609
627
|
async listMeshNodeDescriptors(meshName, page, signal) {
|
|
610
628
|
const rows = await this.stores.locationStore.listMeshNodes(meshName, this.pageRequest(page), signal);
|
|
611
629
|
const live = await this.liveRows.filter(rows.items, (row, signal) => this.leaseTracker.isOwnerTokenLive(row, signal), signal);
|
|
@@ -778,7 +796,7 @@ class ZLinkLocationRuntime {
|
|
|
778
796
|
if (!this.started) {
|
|
779
797
|
return;
|
|
780
798
|
}
|
|
781
|
-
const scheduledAt = this.
|
|
799
|
+
const scheduledAt = this.leaseOperationStartedAtMs + this.options.ownerLeaseRenewIntervalMs;
|
|
782
800
|
const delayMs = Math.max(0, scheduledAt - this.monotonicNowMs());
|
|
783
801
|
this.heartbeatTimer = this.setTimer(() => {
|
|
784
802
|
this.heartbeatTimer = undefined;
|
|
@@ -786,11 +804,10 @@ class ZLinkLocationRuntime {
|
|
|
786
804
|
for (const scope of this.leaseScopes) {
|
|
787
805
|
this.metrics?.recordOwnerLeaseRenewLateness(lateness, scope.kind, scope.name);
|
|
788
806
|
}
|
|
789
|
-
this.nextLeaseRenewAtMs = this.monotonicNowMs() + this.options.ownerLeaseRenewIntervalMs;
|
|
790
807
|
if (this.ownerLeaseDeadlineMs !== undefined &&
|
|
791
808
|
this.monotonicNowMs() >= this.ownerLeaseDeadlineMs) {
|
|
792
809
|
this.ownerLeaseHealthy = false;
|
|
793
|
-
this.recordFailure('Owner lease expired before renewal completed.'
|
|
810
|
+
this.recordFailure('Owner lease expired before renewal completed.');
|
|
794
811
|
for (const handler of this.ownerLeaseRenewalFailedHandlers)
|
|
795
812
|
handler();
|
|
796
813
|
}
|
|
@@ -811,7 +828,7 @@ class ZLinkLocationRuntime {
|
|
|
811
828
|
return await write();
|
|
812
829
|
}
|
|
813
830
|
catch (error) {
|
|
814
|
-
this.recordFailure(errorMessage(error)
|
|
831
|
+
this.recordFailure(errorMessage(error));
|
|
815
832
|
throw error;
|
|
816
833
|
}
|
|
817
834
|
}
|
|
@@ -820,15 +837,11 @@ class ZLinkLocationRuntime {
|
|
|
820
837
|
return await write();
|
|
821
838
|
}
|
|
822
839
|
catch (error) {
|
|
823
|
-
this.recordFailure(errorMessage(error)
|
|
840
|
+
this.recordFailure(errorMessage(error));
|
|
824
841
|
throw error;
|
|
825
842
|
}
|
|
826
843
|
}
|
|
827
844
|
notifyIfStale(result, kind, key) {
|
|
828
|
-
if (result.status === internal_location_contracts_1.ZLinkLocationWriteStatus.IgnoredStale ||
|
|
829
|
-
result.status === internal_location_contracts_1.ZLinkLocationWriteStatus.RejectedConflict) {
|
|
830
|
-
this.metrics?.recordLocationStoreError('compare_exchange');
|
|
831
|
-
}
|
|
832
845
|
if (result.status !== internal_location_contracts_1.ZLinkLocationWriteStatus.IgnoredStale) {
|
|
833
846
|
return;
|
|
834
847
|
}
|
|
@@ -837,10 +850,6 @@ class ZLinkLocationRuntime {
|
|
|
837
850
|
}
|
|
838
851
|
}
|
|
839
852
|
notifyIfStaleStatus(status, kind, key) {
|
|
840
|
-
if (status === internal_location_contracts_1.ZLinkLocationWriteStatus.IgnoredStale ||
|
|
841
|
-
status === internal_location_contracts_1.ZLinkLocationWriteStatus.RejectedConflict) {
|
|
842
|
-
this.metrics?.recordLocationStoreError('compare_exchange');
|
|
843
|
-
}
|
|
844
853
|
if (status !== internal_location_contracts_1.ZLinkLocationWriteStatus.IgnoredStale) {
|
|
845
854
|
return;
|
|
846
855
|
}
|
|
@@ -848,8 +857,7 @@ class ZLinkLocationRuntime {
|
|
|
848
857
|
handler({ kind, key });
|
|
849
858
|
}
|
|
850
859
|
}
|
|
851
|
-
recordFailure(message
|
|
852
|
-
this.metrics?.recordLocationStoreError(operation);
|
|
860
|
+
recordFailure(message) {
|
|
853
861
|
this.ownerLeaseHealthy = false;
|
|
854
862
|
this.lastError = message;
|
|
855
863
|
}
|
|
@@ -908,8 +916,8 @@ class OwnerLeaseRenewTimeoutError extends Error {
|
|
|
908
916
|
this.name = 'OwnerLeaseRenewTimeoutError';
|
|
909
917
|
}
|
|
910
918
|
}
|
|
911
|
-
function remainingTimeoutMs(
|
|
912
|
-
return Math.max(0,
|
|
919
|
+
function remainingTimeoutMs(timeoutStartedAtMs, timeoutMs) {
|
|
920
|
+
return Math.max(0, timeoutMs - (performance.now() - timeoutStartedAtMs));
|
|
913
921
|
}
|
|
914
922
|
function errorMessage(error) {
|
|
915
923
|
return error instanceof Error ? error.message : String(error);
|
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as profile from '@zlink-systems/stream-wire/internal/json';
|
|
2
2
|
export declare const FRAMEWORK_JSON_V1_PROFILE = "framework-json-v1";
|
|
3
|
-
export
|
|
4
|
-
|
|
5
|
-
}
|
|
6
|
-
export declare function stringifyFrameworkJsonV1(value: unknown, schema?: ZLinkJsonSchema): string;
|
|
7
|
-
export declare function parseFrameworkJsonV1(text: string, options?: FrameworkJsonParseOptions, schema?: ZLinkJsonSchema): unknown;
|
|
3
|
+
export declare const stringifyFrameworkJsonV1: typeof profile.stringifyFrameworkJsonV1;
|
|
4
|
+
export declare const parseFrameworkJsonV1: typeof profile.parseFrameworkJsonV1;
|
|
5
|
+
export type { FrameworkJsonParseOptions } from '@zlink-systems/stream-wire/internal/json';
|