@zlink-systems/framework 0.26.0 → 0.27.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/.tsbuildinfo +1 -1
- package/dist/contracts/Common/CoreTypes.d.ts +6 -0
- package/dist/contracts/Common/CoreTypes.js +7 -0
- package/dist/contracts/Common/index.d.ts +1 -1
- package/dist/contracts/Common/index.js +0 -1
- package/dist/contracts/Configuration/InternalDefaults.d.ts +8 -0
- package/dist/contracts/Configuration/InternalDefaults.js +9 -1
- package/dist/contracts/Configuration/Registration.d.ts +13 -2
- package/dist/contracts/Configuration/Registration.js +58 -36
- package/dist/contracts/Configuration/RegistrationBuilderPolicy.d.ts +13 -1
- package/dist/contracts/Configuration/RegistrationBuilderPolicy.js +38 -1
- package/dist/contracts/Configuration/RegistrationBuilders.d.ts +2 -3
- package/dist/contracts/Configuration/RegistrationBuilders.js +27 -32
- package/dist/contracts/Configuration/RegistrationTypes.d.ts +1 -0
- package/dist/contracts/Configuration/RegistrationValidators.js +15 -12
- package/dist/contracts/Configuration/TimerRegistrationValidator.js +3 -2
- package/dist/contracts/Dispatch/ZLinkDispatchOptions.d.ts +1 -1
- package/dist/contracts/Handlers/JsonContract.js +10 -4
- package/dist/contracts/Locations/Authority.d.ts +1 -1
- package/dist/contracts/Locations/Authority.js +3 -2
- package/dist/contracts/Locations/Options.js +1 -1
- package/dist/contracts/Locations/Stores.d.ts +12 -0
- package/dist/contracts/Locations/Stores.js +9 -0
- package/dist/contracts/Spots/Contracts.d.ts +1 -1
- package/dist/internal.d.ts +4 -0
- package/dist/internal.js +15 -1
- package/dist/nest-integration.d.ts +4 -2
- package/dist/nest-integration.js +14 -4
- package/dist/runtime/abort.d.ts +1 -0
- package/dist/runtime/abort.js +8 -5
- package/dist/runtime/activation-admission.d.ts +1 -2
- package/dist/runtime/activation-admission.js +2 -6
- package/dist/runtime/actors/actor-authority-payload-codec.d.ts +1 -2
- package/dist/runtime/actors/actor-authority-payload-codec.js +34 -18
- package/dist/runtime/actors/actor-client.d.ts +2 -2
- package/dist/runtime/actors/actor-client.js +42 -143
- package/dist/runtime/actors/actor-context.d.ts +3 -5
- package/dist/runtime/actors/actor-context.js +13 -11
- package/dist/runtime/actors/actor-handoff.d.ts +4 -4
- package/dist/runtime/actors/actor-handoff.js +8 -8
- package/dist/runtime/actors/actor-lifecycle-snapshot.js +2 -1
- package/dist/runtime/actors/actor-local-native-join.d.ts +11 -6
- package/dist/runtime/actors/actor-local-native-join.js +83 -105
- package/dist/runtime/actors/actor-native-lookup.js +2 -8
- package/dist/runtime/actors/actor-packet-relay-wire.d.ts +3 -3
- package/dist/runtime/actors/actor-packet-relay-wire.js +5 -3
- package/dist/runtime/actors/actor-remote-joiner.d.ts +1 -1
- package/dist/runtime/actors/actor-remote-joiner.js +5 -9
- package/dist/runtime/actors/actor-remote-wire.js +5 -3
- package/dist/runtime/actors/actor-request-deadline.d.ts +3 -0
- package/dist/runtime/actors/actor-request-deadline.js +31 -0
- package/dist/runtime/actors/actor-retry-delay.js +2 -1
- package/dist/runtime/actors/actor-runtime-state.d.ts +9 -21
- package/dist/runtime/actors/actor-runtime-state.js +70 -187
- package/dist/runtime/actors/bound-session-wire.js +2 -7
- package/dist/runtime/actors/deferred-join-completion.d.ts +11 -6
- package/dist/runtime/actors/deferred-join-completion.js +1 -0
- package/dist/runtime/actors/index.d.ts +9 -7
- package/dist/runtime/actors/index.js +87 -69
- package/dist/runtime/actors/spot-actor-dispatch.d.ts +3 -3
- package/dist/runtime/actors/spot-actor-dispatch.js +25 -10
- package/dist/runtime/actors/transferred-actor-rollback.d.ts +3 -5
- package/dist/runtime/actors/transferred-actor-rollback.js +9 -42
- package/dist/runtime/admission.d.ts +2 -0
- package/dist/runtime/admission.js +7 -1
- package/dist/runtime/application-jobs/application-job-queue-scope.d.ts +1 -1
- package/dist/runtime/application-jobs/application-job-queue-scope.js +1 -1
- package/dist/runtime/backend/contracts/index.d.ts +6 -23
- package/dist/runtime/backend/mesh-actor-session-node-adapter.js +1 -17
- package/dist/runtime/backend/mesh-dispatch-pump.d.ts +1 -2
- package/dist/runtime/backend/mesh-dispatch-pump.js +95 -107
- package/dist/runtime/backend/node/node-backend-adapter-support.d.ts +1 -1
- package/dist/runtime/backend/node/node-backend-adapter-support.js +16 -6
- package/dist/runtime/backend/node/node-event-loop-poller.d.ts +2 -2
- package/dist/runtime/backend/node/node-event-loop-poller.js +6 -7
- package/dist/runtime/backend/node/node-monitor-backend-adapter.js +1 -0
- package/dist/runtime/backend/node/node-raw-binding-port.js +40 -16
- package/dist/runtime/backend/node/node-raw-mesh-backend.d.ts +14 -15
- package/dist/runtime/backend/node/node-raw-mesh-backend.js +146 -118
- package/dist/runtime/backend/node/node-socket-backend-adapter.js +3 -2
- package/dist/runtime/backend/raw-binding-port.d.ts +1 -1
- package/dist/runtime/backend/runtime-values.d.ts +4 -1
- package/dist/runtime/backend/runtime-values.js +2 -0
- package/dist/runtime/channels/channel-clients.d.ts +20 -8
- package/dist/runtime/channels/channel-clients.js +68 -52
- package/dist/runtime/channels/channel-envelope-inspection.js +2 -1
- package/dist/runtime/channels/channel-envelope.js +47 -29
- package/dist/runtime/channels/channel-outbound-operations.d.ts +3 -0
- package/dist/runtime/channels/channel-outbound-operations.js +9 -10
- package/dist/runtime/channels/channel-receive-loops.d.ts +8 -3
- package/dist/runtime/channels/channel-receive-loops.js +27 -6
- package/dist/runtime/channels/channel-runtime-lifecycle.d.ts +12 -1
- package/dist/runtime/channels/channel-runtime-lifecycle.js +48 -28
- package/dist/runtime/channels/channel-runtime-manager.js +5 -2
- package/dist/runtime/channels/channel-socket-options.js +3 -2
- package/dist/runtime/channels/channel-socket-registry.d.ts +14 -29
- package/dist/runtime/channels/channel-socket-registry.js +248 -174
- package/dist/runtime/channels/channel-transports.d.ts +11 -17
- package/dist/runtime/channels/channel-transports.js +68 -47
- package/dist/runtime/channels/client-server-location-runtime.d.ts +1 -1
- package/dist/runtime/channels/client-server-location-runtime.js +10 -11
- package/dist/runtime/channels/client-server-service-wire.d.ts +7 -2
- package/dist/runtime/channels/client-server-service-wire.js +32 -11
- package/dist/runtime/channels/dispatch-error-reporter.d.ts +1 -2
- package/dist/runtime/channels/dispatch-error-reporter.js +2 -1
- package/dist/runtime/channels/fanout-location-runtime.d.ts +16 -3
- package/dist/runtime/channels/fanout-location-runtime.js +130 -72
- package/dist/runtime/channels/spot-direct-envelope.d.ts +1 -0
- package/dist/runtime/channels/spot-direct-envelope.js +4 -3
- package/dist/runtime/channels/spot-node-route-transport.js +3 -2
- package/dist/runtime/diagnostics/diagnostic-text.d.ts +2 -0
- package/dist/runtime/diagnostics/diagnostic-text.js +7 -0
- package/dist/runtime/diagnostics/dispatch-error-details.d.ts +3 -0
- package/dist/runtime/diagnostics/dispatch-error-details.js +30 -2
- package/dist/runtime/diagnostics/flow-context.d.ts +6 -0
- package/dist/runtime/diagnostics/flow-context.js +16 -2
- package/dist/runtime/diagnostics/index.d.ts +4 -2
- package/dist/runtime/diagnostics/index.js +14 -4
- package/dist/runtime/diagnostics/message-flow.d.ts +1 -1
- package/dist/runtime/diagnostics/message-flow.js +10 -19
- package/dist/runtime/diagnostics/runtime-metrics.d.ts +94 -31
- package/dist/runtime/diagnostics/runtime-metrics.js +168 -105
- package/dist/runtime/diagnostics/runtime-observation-queue.js +3 -2
- package/dist/runtime/diagnostics/topology-runtime-projections.d.ts +2 -4
- package/dist/runtime/diagnostics/topology-runtime-projections.js +135 -154
- package/dist/runtime/disposal.d.ts +5 -0
- package/dist/runtime/disposal.js +22 -0
- package/dist/runtime/execution/index.d.ts +12 -9
- package/dist/runtime/execution/index.js +58 -14
- package/dist/runtime/execution/serial-execution-queue.d.ts +8 -2
- package/dist/runtime/execution/serial-execution-queue.js +54 -15
- package/dist/runtime/execution/state-lane.d.ts +8 -1
- package/dist/runtime/execution/state-lane.js +118 -3
- package/dist/runtime/foundation/actor-join-recovery-codec.d.ts +3 -0
- package/dist/runtime/foundation/actor-join-recovery-codec.js +15 -11
- package/dist/runtime/foundation/event-loop-resources.d.ts +2 -24
- package/dist/runtime/foundation/event-loop-resources.js +6 -119
- package/dist/runtime/foundation/operation-identity.d.ts +2 -0
- package/dist/runtime/foundation/operation-identity.js +9 -5
- package/dist/runtime/foundation/operation-registry.d.ts +5 -7
- package/dist/runtime/foundation/operation-registry.js +34 -44
- package/dist/runtime/foundation/raw-service-mesh-runtime.d.ts +8 -5
- package/dist/runtime/foundation/raw-service-mesh-runtime.js +62 -83
- package/dist/runtime/foundation/runtime-state-projections.d.ts +3 -1
- package/dist/runtime/foundation/runtime-state-projections.js +8 -0
- package/dist/runtime/foundation/service-authority-payload-codec.js +22 -12
- package/dist/runtime/foundation/service-discovery-registry.d.ts +4 -0
- package/dist/runtime/foundation/service-discovery-registry.js +22 -3
- package/dist/runtime/foundation/service-instance-activation-recovery-codec.js +8 -4
- package/dist/runtime/foundation/service-liveness-registry.js +2 -1
- package/dist/runtime/foundation/service-maintenance-runtime.d.ts +0 -1
- package/dist/runtime/foundation/service-maintenance-runtime.js +0 -6
- package/dist/runtime/foundation/service-metadata-codec.js +3 -3
- package/dist/runtime/foundation/service-relocation-aggregate-committer.d.ts +2 -5
- package/dist/runtime/foundation/service-relocation-aggregate-committer.js +1 -48
- package/dist/runtime/foundation/service-relocation-object-owner.js +3 -2
- package/dist/runtime/foundation/service-relocation-runtime.js +43 -32
- package/dist/runtime/foundation/service-runtime-contracts.d.ts +40 -8
- package/dist/runtime/foundation/service-runtime-contracts.js +25 -1
- package/dist/runtime/foundation/service-session-binding-ingress-port.d.ts +0 -12
- package/dist/runtime/foundation/service-stateful-registry.d.ts +2 -0
- package/dist/runtime/foundation/service-stateful-registry.js +10 -2
- package/dist/runtime/foundation/service-stateful-runtime.d.ts +26 -25
- package/dist/runtime/foundation/service-stateful-runtime.js +217 -204
- package/dist/runtime/foundation/service-stateful-wire-codec.d.ts +3 -3
- package/dist/runtime/foundation/service-stateful-wire-codec.js +89 -55
- package/dist/runtime/foundation/service-topology-registry.d.ts +0 -1
- package/dist/runtime/foundation/service-topology-registry.js +17 -32
- package/dist/runtime/foundation/service-wire-binary-primitives.d.ts +5 -0
- package/dist/runtime/foundation/service-wire-binary-primitives.js +6 -0
- package/dist/runtime/foundation/service-wire-codec.js +10 -8
- package/dist/runtime/foundation/service-wire-constants.generated.d.ts +1 -0
- package/dist/runtime/foundation/service-wire-constants.generated.js +2 -1
- package/dist/runtime/foundation/service-wire-m6a-codec.d.ts +2 -0
- package/dist/runtime/foundation/service-wire-m6a-codec.js +23 -13
- package/dist/runtime/framework-errors-internal.d.ts +2 -1
- package/dist/runtime/framework-errors-internal.js +343 -122
- package/dist/runtime/handlers/handler-instance-scope.d.ts +3 -1
- package/dist/runtime/handlers/handler-instance-scope.js +61 -74
- package/dist/runtime/host/actor-packet-relay.d.ts +9 -6
- package/dist/runtime/host/actor-packet-relay.js +48 -91
- package/dist/runtime/host/actor-placement-coordinator.js +7 -5
- package/dist/runtime/host/actor-runtime-options-factory.d.ts +2 -0
- package/dist/runtime/host/actor-runtime-options-factory.js +17 -4
- package/dist/runtime/host/actor-transfer-runtime.d.ts +16 -18
- package/dist/runtime/host/actor-transfer-runtime.js +143 -176
- package/dist/runtime/host/application-job-queue.js +16 -33
- package/dist/runtime/host/bound-session-relay.js +1 -1
- package/dist/runtime/host/channel-runtime-options-factory.js +1 -1
- package/dist/runtime/host/index.d.ts +14 -13
- package/dist/runtime/host/index.js +190 -157
- package/dist/runtime/host/instance-activation-authority.d.ts +2 -3
- package/dist/runtime/host/instance-activation-authority.js +17 -45
- package/dist/runtime/host/location-runtime-owner.d.ts +1 -1
- package/dist/runtime/host/location-runtime-owner.js +2 -2
- package/dist/runtime/host/remote-actor-join-receiver.d.ts +2 -2
- package/dist/runtime/host/remote-actor-join-receiver.js +1 -14
- package/dist/runtime/host/remote-actor-packet-target-store.d.ts +3 -2
- package/dist/runtime/host/remote-actor-packet-target-store.js +8 -47
- package/dist/runtime/host/remote-bound-session-relay.d.ts +2 -3
- package/dist/runtime/host/remote-bound-session-relay.js +7 -20
- package/dist/runtime/host/route-mesh-runtime.d.ts +13 -11
- package/dist/runtime/host/route-mesh-runtime.js +171 -252
- package/dist/runtime/host/runtime-shutdown.d.ts +2 -0
- package/dist/runtime/host/runtime-shutdown.js +18 -21
- package/dist/runtime/host/service-relocation-control.js +6 -1
- package/dist/runtime/host/service-relocation-host-runtime.d.ts +21 -30
- package/dist/runtime/host/service-relocation-host-runtime.js +508 -416
- package/dist/runtime/host/spot-address-transport.d.ts +2 -3
- package/dist/runtime/host/spot-address-transport.js +34 -136
- package/dist/runtime/host/spot-node-runtime-options-factory.d.ts +1 -1
- package/dist/runtime/host/spot-node-runtime-options-factory.js +3 -2
- package/dist/runtime/host/spot-runtime-options-factory.d.ts +4 -10
- package/dist/runtime/host/spot-runtime-options-factory.js +50 -14
- package/dist/runtime/host/user-spot-creation-coordinator.d.ts +3 -3
- package/dist/runtime/host/user-spot-creation-coordinator.js +11 -8
- package/dist/runtime/locations/aggregate-inventory-store.js +13 -10
- package/dist/runtime/locations/authority-key-codec.js +4 -3
- package/dist/runtime/locations/auto-connect-reconciler.d.ts +4 -0
- package/dist/runtime/locations/auto-connect-reconciler.js +37 -25
- package/dist/runtime/locations/creation-operation-id.js +6 -4
- package/dist/runtime/locations/domain-store-contract.d.ts +3 -3
- package/dist/runtime/locations/in-memory-authority-store.js +31 -15
- package/dist/runtime/locations/in-memory-location-store.d.ts +2 -2
- package/dist/runtime/locations/in-memory-location-store.js +17 -14
- package/dist/runtime/locations/in-memory-provider-location-store.d.ts +1 -0
- package/dist/runtime/locations/in-memory-provider-location-store.js +72 -22
- package/dist/runtime/locations/key-codec.js +3 -2
- package/dist/runtime/locations/lease-tracker.d.ts +3 -5
- package/dist/runtime/locations/lease-tracker.js +7 -11
- package/dist/runtime/locations/lifecycle.d.ts +4 -9
- package/dist/runtime/locations/lifecycle.js +2 -31
- package/dist/runtime/locations/location-store-failure.d.ts +2 -0
- package/dist/runtime/locations/location-store-failure.js +7 -0
- package/dist/runtime/locations/location-store-pages.d.ts +3 -0
- package/dist/runtime/locations/location-store-pages.js +13 -0
- package/dist/runtime/locations/location-store-repository.d.ts +5 -7
- package/dist/runtime/locations/location-store-repository.js +303 -332
- package/dist/runtime/locations/relocation-blob.js +18 -5
- package/dist/runtime/locations/resolvers.d.ts +5 -5
- package/dist/runtime/locations/resolvers.js +37 -28
- package/dist/runtime/locations/runtime.d.ts +5 -4
- package/dist/runtime/locations/runtime.js +123 -92
- package/dist/runtime/locations/spot-location-claims.d.ts +6 -0
- package/dist/runtime/locations/spot-location-claims.js +42 -1
- package/dist/runtime/messaging/payload-codec.js +26 -20
- package/dist/runtime/messaging/submission-result.d.ts +3 -0
- package/dist/runtime/messaging/submission-result.js +48 -0
- package/dist/runtime/protocol/service_wire_codec.generated.d.ts +1 -0
- package/dist/runtime/protocol/service_wire_codec.generated.js +12 -7
- package/dist/runtime/spots/formal-remote-actor-transfer-registry.d.ts +4 -1
- package/dist/runtime/spots/index.d.ts +14 -20
- package/dist/runtime/spots/index.js +302 -176
- package/dist/runtime/spots/spot-activation-registry.d.ts +3 -5
- package/dist/runtime/spots/spot-activation-registry.js +14 -50
- package/dist/runtime/spots/spot-activation-state.d.ts +1 -1
- package/dist/runtime/spots/spot-activation-state.js +2 -2
- package/dist/runtime/spots/spot-activation.d.ts +3 -4
- package/dist/runtime/spots/spot-activation.js +49 -32
- package/dist/runtime/spots/spot-actor-admission-coordinator.d.ts +1 -2
- package/dist/runtime/spots/spot-actor-admission-coordinator.js +3 -40
- package/dist/runtime/spots/spot-actor-join-dispatch.d.ts +10 -18
- package/dist/runtime/spots/spot-actor-join-dispatch.js +4 -52
- package/dist/runtime/spots/spot-actor-membership.d.ts +4 -6
- package/dist/runtime/spots/spot-actor-membership.js +22 -45
- package/dist/runtime/spots/spot-actor-packet-dispatch.d.ts +0 -1
- package/dist/runtime/spots/spot-actor-packet-dispatch.js +0 -9
- package/dist/runtime/spots/spot-actor-packet-relay-dispatch.d.ts +2 -2
- package/dist/runtime/spots/spot-actor-packet-relay-dispatch.js +1 -7
- package/dist/runtime/spots/spot-context.d.ts +2 -2
- package/dist/runtime/spots/spot-entry-activation.d.ts +2 -2
- package/dist/runtime/spots/spot-entry-activation.js +9 -20
- package/dist/runtime/spots/spot-lifecycle-metrics.js +3 -2
- package/dist/runtime/spots/spot-manager-public.d.ts +5 -6
- package/dist/runtime/spots/spot-manager-public.js +5 -4
- package/dist/runtime/spots/spot-node-autoconnect.js +22 -31
- package/dist/runtime/spots/spot-node-runtime-manager.d.ts +19 -18
- package/dist/runtime/spots/spot-node-runtime-manager.js +67 -72
- package/dist/runtime/spots/spot-outbound.d.ts +4 -3
- package/dist/runtime/spots/spot-outbound.js +9 -8
- package/dist/runtime/spots/spot-remote-codec.js +5 -3
- package/dist/runtime/spots/spot-route-packet-dispatch.d.ts +2 -2
- package/dist/runtime/spots/spot-route-packet-dispatch.js +8 -8
- package/dist/runtime/spots/spot-route-replies.d.ts +2 -2
- package/dist/runtime/spots/spot-route-replies.js +3 -1
- package/dist/runtime/spots/spot-routed-actor-admission.d.ts +3 -3
- package/dist/runtime/spots/spot-routed-actor-admission.js +3 -12
- package/dist/runtime/spots/spot-routed-frame-dispatch.d.ts +1 -2
- package/dist/runtime/spots/spot-routed-frame-dispatch.js +0 -1
- package/dist/runtime/spots/spot-routed-spot-packet-dispatch.d.ts +4 -0
- package/dist/runtime/spots/spot-routed-spot-packet-dispatch.js +65 -15
- package/dist/runtime/spots/spot-runtime-ports.d.ts +2 -16
- package/dist/runtime/spots/spot-serial-executor.js +2 -2
- package/dist/runtime/spots/spot-serial-turn-executor.d.ts +27 -7
- package/dist/runtime/spots/spot-serial-turn-executor.js +83 -11
- package/dist/runtime/spots/spot-timer.d.ts +3 -2
- package/dist/runtime/streams/actor-session-binding-registry.d.ts +16 -29
- package/dist/runtime/streams/actor-session-binding-registry.js +142 -212
- package/dist/runtime/streams/actor-session-binding-runtime-owner.d.ts +1 -4
- package/dist/runtime/streams/bound-actor-relay-sender.d.ts +6 -2
- package/dist/runtime/streams/bound-actor-relay-sender.js +57 -33
- package/dist/runtime/streams/bound-session-service.d.ts +7 -0
- package/dist/runtime/streams/bound-session-service.js +11 -1
- package/dist/runtime/streams/index.d.ts +14 -15
- package/dist/runtime/streams/index.js +20 -21
- package/dist/runtime/streams/managed-stream.d.ts +3 -0
- package/dist/runtime/streams/managed-stream.js +17 -8
- package/dist/runtime/streams/native-fallback-bound-session.js +1 -3
- package/dist/runtime/streams/protocol.d.ts +6 -33
- package/dist/runtime/streams/protocol.js +38 -110
- package/dist/runtime/streams/session-actor-coordinator.d.ts +2 -3
- package/dist/runtime/streams/session-actor-coordinator.js +12 -4
- package/dist/runtime/streams/session-calls.d.ts +1 -1
- package/dist/runtime/streams/session-calls.js +5 -4
- package/dist/runtime/streams/session-context.d.ts +6 -6
- package/dist/runtime/streams/session-context.js +22 -4
- package/dist/runtime/streams/session-requests.js +2 -1
- package/dist/runtime/streams/stream-binding-runtime-ports.d.ts +16 -1
- package/dist/runtime/streams/stream-frame-factory.js +2 -2
- package/dist/runtime/streams/stream-session-runtime.d.ts +10 -11
- package/dist/runtime/streams/stream-session-runtime.js +25 -33
- package/dist/runtime/workers/index.d.ts +2 -2
- package/dist/runtime/workers/index.js +5 -4
- package/package.json +3 -3
- package/src/contracts/Common/CoreTypes.ts +7 -0
- package/src/contracts/Common/index.ts +1 -1
- package/src/contracts/Configuration/InternalDefaults.ts +12 -0
- package/src/contracts/Configuration/Registration.ts +92 -48
- package/src/contracts/Configuration/RegistrationBuilderPolicy.ts +44 -2
- package/src/contracts/Configuration/RegistrationBuilders.ts +77 -68
- package/src/contracts/Configuration/RegistrationTypes.ts +1 -0
- package/src/contracts/Configuration/RegistrationValidators.ts +19 -13
- package/src/contracts/Configuration/TimerRegistrationValidator.ts +4 -2
- package/src/contracts/Dispatch/ZLinkDispatchOptions.ts +1 -0
- package/src/contracts/Handlers/JsonContract.ts +14 -4
- package/src/contracts/Locations/Authority.ts +7 -3
- package/src/contracts/Locations/Options.ts +1 -1
- package/src/contracts/Locations/Stores.ts +14 -0
- package/src/contracts/Spots/Contracts.ts +1 -1
- package/src/internal.ts +14 -0
- package/src/nest-integration.ts +28 -10
- package/src/runtime/abort.ts +6 -5
- package/src/runtime/activation-admission.ts +2 -8
- package/src/runtime/actors/actor-authority-payload-codec.ts +58 -20
- package/src/runtime/actors/actor-client.ts +77 -204
- package/src/runtime/actors/actor-context.ts +39 -33
- package/src/runtime/actors/actor-handoff.ts +24 -22
- package/src/runtime/actors/actor-lifecycle-snapshot.ts +2 -1
- package/src/runtime/actors/actor-local-native-join.ts +172 -174
- package/src/runtime/actors/actor-native-lookup.ts +2 -9
- package/src/runtime/actors/actor-packet-relay-wire.ts +18 -12
- package/src/runtime/actors/actor-remote-joiner.ts +9 -11
- package/src/runtime/actors/actor-remote-wire.ts +5 -3
- package/src/runtime/actors/actor-request-deadline.ts +49 -0
- package/src/runtime/actors/actor-retry-delay.ts +2 -1
- package/src/runtime/actors/actor-runtime-state.ts +85 -247
- package/src/runtime/actors/bound-session-wire.ts +2 -8
- package/src/runtime/actors/deferred-join-completion.ts +10 -6
- package/src/runtime/actors/index.ts +100 -79
- package/src/runtime/actors/spot-actor-dispatch.ts +60 -29
- package/src/runtime/actors/transferred-actor-rollback.ts +11 -62
- package/src/runtime/admission.ts +8 -1
- package/src/runtime/application-jobs/application-job-queue-scope.ts +4 -4
- package/src/runtime/backend/contracts/index.ts +13 -29
- package/src/runtime/backend/mesh-actor-session-node-adapter.ts +2 -18
- package/src/runtime/backend/mesh-dispatch-pump.ts +111 -117
- package/src/runtime/backend/node/node-backend-adapter-support.ts +23 -6
- package/src/runtime/backend/node/node-event-loop-poller.ts +8 -12
- package/src/runtime/backend/node/node-monitor-backend-adapter.ts +1 -0
- package/src/runtime/backend/node/node-raw-binding-port.ts +41 -20
- package/src/runtime/backend/node/node-raw-mesh-backend.ts +227 -170
- package/src/runtime/backend/node/node-socket-backend-adapter.ts +3 -2
- package/src/runtime/backend/raw-binding-port.ts +1 -1
- package/src/runtime/backend/runtime-values.ts +4 -1
- package/src/runtime/channels/channel-clients.ts +132 -85
- package/src/runtime/channels/channel-envelope-inspection.ts +2 -1
- package/src/runtime/channels/channel-envelope.ts +58 -29
- package/src/runtime/channels/channel-outbound-operations.ts +10 -23
- package/src/runtime/channels/channel-receive-loops.ts +39 -7
- package/src/runtime/channels/channel-runtime-lifecycle.ts +60 -27
- package/src/runtime/channels/channel-runtime-manager.ts +6 -2
- package/src/runtime/channels/channel-socket-options.ts +8 -2
- package/src/runtime/channels/channel-socket-registry.ts +301 -192
- package/src/runtime/channels/channel-transports.ts +161 -112
- package/src/runtime/channels/client-server-location-runtime.ts +17 -17
- package/src/runtime/channels/client-server-service-wire.ts +40 -12
- package/src/runtime/channels/dispatch-error-reporter.ts +7 -5
- package/src/runtime/channels/fanout-location-runtime.ts +172 -91
- package/src/runtime/channels/spot-direct-envelope.ts +1 -1
- package/src/runtime/channels/spot-node-route-transport.ts +5 -2
- package/src/runtime/diagnostics/diagnostic-text.ts +4 -0
- package/src/runtime/diagnostics/dispatch-error-details.ts +36 -1
- package/src/runtime/diagnostics/flow-context.ts +16 -2
- package/src/runtime/diagnostics/index.ts +27 -17
- package/src/runtime/diagnostics/message-flow.ts +15 -25
- package/src/runtime/diagnostics/runtime-metrics.ts +181 -113
- package/src/runtime/diagnostics/runtime-observation-queue.ts +3 -2
- package/src/runtime/diagnostics/topology-runtime-projections.ts +194 -162
- package/src/runtime/disposal.ts +19 -0
- package/src/runtime/execution/index.ts +60 -20
- package/src/runtime/execution/serial-execution-queue.ts +131 -18
- package/src/runtime/execution/state-lane.ts +142 -4
- package/src/runtime/foundation/actor-join-recovery-codec.ts +13 -8
- package/src/runtime/foundation/event-loop-resources.ts +5 -122
- package/src/runtime/foundation/operation-identity.ts +11 -5
- package/src/runtime/foundation/operation-registry.ts +33 -50
- package/src/runtime/foundation/raw-service-mesh-runtime.ts +110 -111
- package/src/runtime/foundation/runtime-state-projections.ts +9 -1
- package/src/runtime/foundation/service-authority-payload-codec.ts +31 -13
- package/src/runtime/foundation/service-discovery-registry.ts +32 -3
- package/src/runtime/foundation/service-instance-activation-recovery-codec.ts +12 -4
- package/src/runtime/foundation/service-liveness-registry.ts +2 -1
- package/src/runtime/foundation/service-maintenance-runtime.ts +0 -10
- package/src/runtime/foundation/service-metadata-codec.ts +2 -2
- package/src/runtime/foundation/service-relocation-aggregate-committer.ts +3 -66
- package/src/runtime/foundation/service-relocation-object-owner.ts +5 -2
- package/src/runtime/foundation/service-relocation-runtime.ts +57 -35
- package/src/runtime/foundation/service-runtime-contracts.ts +46 -10
- package/src/runtime/foundation/service-session-binding-ingress-port.ts +0 -17
- package/src/runtime/foundation/service-stateful-registry.ts +14 -2
- package/src/runtime/foundation/service-stateful-runtime.ts +322 -276
- package/src/runtime/foundation/service-stateful-wire-codec.ts +128 -80
- package/src/runtime/foundation/service-topology-registry.ts +23 -32
- package/src/runtime/foundation/service-wire-binary-primitives.ts +6 -0
- package/src/runtime/foundation/service-wire-codec.ts +15 -8
- package/src/runtime/foundation/service-wire-constants.generated.ts +1 -0
- package/src/runtime/foundation/service-wire-m6a-codec.ts +29 -15
- package/src/runtime/framework-errors-internal.ts +380 -134
- package/src/runtime/handlers/handler-instance-scope.ts +68 -95
- package/src/runtime/host/actor-packet-relay.ts +57 -147
- package/src/runtime/host/actor-placement-coordinator.ts +8 -5
- package/src/runtime/host/actor-runtime-options-factory.ts +27 -8
- package/src/runtime/host/actor-transfer-runtime.ts +180 -260
- package/src/runtime/host/application-job-queue.ts +28 -34
- package/src/runtime/host/bound-session-relay.ts +1 -2
- package/src/runtime/host/channel-runtime-options-factory.ts +1 -2
- package/src/runtime/host/index.ts +327 -296
- package/src/runtime/host/instance-activation-authority.ts +89 -109
- package/src/runtime/host/location-runtime-owner.ts +4 -2
- package/src/runtime/host/remote-actor-join-receiver.ts +3 -31
- package/src/runtime/host/remote-actor-packet-target-store.ts +17 -58
- package/src/runtime/host/remote-bound-session-relay.ts +8 -41
- package/src/runtime/host/route-mesh-runtime.ts +228 -271
- package/src/runtime/host/runtime-shutdown.ts +17 -21
- package/src/runtime/host/service-relocation-control.ts +14 -1
- package/src/runtime/host/service-relocation-host-runtime.ts +699 -561
- package/src/runtime/host/spot-address-transport.ts +73 -195
- package/src/runtime/host/spot-node-runtime-options-factory.ts +6 -3
- package/src/runtime/host/spot-runtime-options-factory.ts +73 -22
- package/src/runtime/host/user-spot-creation-coordinator.ts +36 -22
- package/src/runtime/locations/aggregate-inventory-store.ts +16 -13
- package/src/runtime/locations/authority-key-codec.ts +7 -3
- package/src/runtime/locations/auto-connect-reconciler.ts +39 -26
- package/src/runtime/locations/creation-operation-id.ts +6 -3
- package/src/runtime/locations/domain-store-contract.ts +12 -3
- package/src/runtime/locations/in-memory-authority-store.ts +44 -15
- package/src/runtime/locations/in-memory-location-store.ts +50 -39
- package/src/runtime/locations/in-memory-provider-location-store.ts +100 -25
- package/src/runtime/locations/key-codec.ts +3 -2
- package/src/runtime/locations/lease-tracker.ts +8 -14
- package/src/runtime/locations/lifecycle.ts +13 -43
- package/src/runtime/locations/location-store-failure.ts +4 -0
- package/src/runtime/locations/location-store-pages.ts +18 -0
- package/src/runtime/locations/location-store-repository.ts +450 -478
- package/src/runtime/locations/relocation-blob.ts +17 -6
- package/src/runtime/locations/resolvers.ts +75 -49
- package/src/runtime/locations/runtime.ts +220 -110
- package/src/runtime/locations/spot-location-claims.ts +58 -1
- package/src/runtime/messaging/payload-codec.ts +35 -24
- package/src/runtime/messaging/submission-result.ts +57 -1
- package/src/runtime/protocol/service_wire_codec.generated.ts +18 -8
- package/src/runtime/protocol/service_wire_pilot_codec.generated.ts +1 -1
- package/src/runtime/spots/formal-remote-actor-transfer-registry.ts +4 -1
- package/src/runtime/spots/index.ts +433 -229
- package/src/runtime/spots/spot-activation-registry.ts +30 -69
- package/src/runtime/spots/spot-activation-state.ts +2 -2
- package/src/runtime/spots/spot-activation.ts +67 -37
- package/src/runtime/spots/spot-actor-admission-coordinator.ts +5 -57
- package/src/runtime/spots/spot-actor-join-dispatch.ts +24 -77
- package/src/runtime/spots/spot-actor-membership.ts +40 -72
- package/src/runtime/spots/spot-actor-packet-dispatch.ts +0 -16
- package/src/runtime/spots/spot-actor-packet-relay-dispatch.ts +3 -15
- package/src/runtime/spots/spot-context.ts +3 -3
- package/src/runtime/spots/spot-entry-activation.ts +13 -30
- package/src/runtime/spots/spot-lifecycle-metrics.ts +3 -2
- package/src/runtime/spots/spot-manager-public.ts +21 -17
- package/src/runtime/spots/spot-node-autoconnect.ts +20 -26
- package/src/runtime/spots/spot-node-runtime-manager.ts +136 -125
- package/src/runtime/spots/spot-outbound.ts +45 -23
- package/src/runtime/spots/spot-remote-codec.ts +7 -3
- package/src/runtime/spots/spot-route-packet-dispatch.ts +25 -24
- package/src/runtime/spots/spot-route-replies.ts +6 -4
- package/src/runtime/spots/spot-routed-actor-admission.ts +13 -26
- package/src/runtime/spots/spot-routed-frame-dispatch.ts +2 -3
- package/src/runtime/spots/spot-routed-spot-packet-dispatch.ts +95 -22
- package/src/runtime/spots/spot-runtime-ports.ts +5 -27
- package/src/runtime/spots/spot-serial-executor.ts +2 -2
- package/src/runtime/spots/spot-serial-turn-executor.ts +112 -11
- package/src/runtime/spots/spot-timer.ts +3 -2
- package/src/runtime/streams/actor-session-binding-registry.ts +179 -269
- package/src/runtime/streams/actor-session-binding-runtime-owner.ts +0 -8
- package/src/runtime/streams/bound-actor-relay-sender.ts +89 -43
- package/src/runtime/streams/bound-session-service.ts +21 -1
- package/src/runtime/streams/index.ts +76 -64
- package/src/runtime/streams/managed-stream.ts +29 -10
- package/src/runtime/streams/native-fallback-bound-session.ts +1 -3
- package/src/runtime/streams/protocol.ts +34 -88
- package/src/runtime/streams/session-actor-coordinator.ts +17 -5
- package/src/runtime/streams/session-calls.ts +6 -5
- package/src/runtime/streams/session-context.ts +54 -10
- package/src/runtime/streams/session-requests.ts +2 -1
- package/src/runtime/streams/stream-binding-runtime-ports.ts +22 -1
- package/src/runtime/streams/stream-frame-factory.ts +2 -3
- package/src/runtime/streams/stream-session-runtime.ts +57 -59
- package/src/runtime/workers/index.ts +13 -12
- package/dist/runtime/actors/post-commit-actor-location.d.ts +0 -19
- package/dist/runtime/actors/post-commit-actor-location.js +0 -72
- package/dist/runtime/spots/spot-native-actor-join-admission.d.ts +0 -26
- package/dist/runtime/spots/spot-native-actor-join-admission.js +0 -106
- package/src/runtime/actors/post-commit-actor-location.ts +0 -121
- package/src/runtime/spots/spot-native-actor-join-admission.ts +0 -155
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ZLinkLocationRuntime = exports.ZLinkOwnerLeaseClaimError = exports.ZLinkOwnerCleanupError = void 0;
|
|
4
|
+
const location_store_pages_1 = require("./location-store-pages");
|
|
5
|
+
const runtime_metrics_1 = require("../diagnostics/runtime-metrics");
|
|
6
|
+
const Stores_1 = require("../../contracts/Locations/Stores");
|
|
4
7
|
const Options_1 = require("../../contracts/Locations/Options");
|
|
5
8
|
const EndpointNotation_1 = require("../../contracts/Configuration/EndpointNotation");
|
|
6
9
|
const node_crypto_1 = require("node:crypto");
|
|
@@ -10,6 +13,7 @@ const authority_key_codec_1 = require("./authority-key-codec");
|
|
|
10
13
|
const canonical_codec_1 = require("./canonical-codec");
|
|
11
14
|
const key_codec_1 = require("./key-codec");
|
|
12
15
|
const lease_tracker_1 = require("./lease-tracker");
|
|
16
|
+
const abort_1 = require("../abort");
|
|
13
17
|
class ZLinkOwnerCleanupError extends Error {
|
|
14
18
|
constructor(cause) {
|
|
15
19
|
super(`Owner cleanup failed: ${errorMessage(cause)}`, { cause });
|
|
@@ -35,6 +39,7 @@ class ZLinkLocationRuntime {
|
|
|
35
39
|
clearTimer;
|
|
36
40
|
monotonicNowMs;
|
|
37
41
|
liveRows;
|
|
42
|
+
leaseTracker;
|
|
38
43
|
ownershipLostHandlers = new Set();
|
|
39
44
|
ownerLeaseRenewedHandlers = new Set();
|
|
40
45
|
ownerLeaseRenewalFailedHandlers = new Set();
|
|
@@ -74,13 +79,14 @@ class ZLinkLocationRuntime {
|
|
|
74
79
|
runtimeOptions.setTimer ?? ((callback, delayMs) => setTimeout(callback, delayMs));
|
|
75
80
|
this.clearTimer =
|
|
76
81
|
runtimeOptions.clearTimer ?? ((handle) => clearTimeout(handle));
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
82
|
+
this.leaseTracker =
|
|
83
|
+
runtimeOptions.leaseTracker ??
|
|
84
|
+
new lease_tracker_1.ZLinkOwnerLeaseTracker({
|
|
85
|
+
store: this.stores.ownerLeaseStore,
|
|
86
|
+
options: this.options,
|
|
87
|
+
monotonicNowMs: this.monotonicNowMs
|
|
88
|
+
});
|
|
89
|
+
this.liveRows = new lease_tracker_1.ZLinkLiveRowFilter();
|
|
84
90
|
}
|
|
85
91
|
get isStarted() {
|
|
86
92
|
return this.started;
|
|
@@ -145,7 +151,7 @@ class ZLinkLocationRuntime {
|
|
|
145
151
|
let cursor;
|
|
146
152
|
let expired = false;
|
|
147
153
|
do {
|
|
148
|
-
const page = await this.stores.authorityStore.listAuthorities('', cursor,
|
|
154
|
+
const page = await this.stores.authorityStore.listAuthorities('', cursor, Stores_1.ZLINK_PROVIDER_MAX_PAGE_SIZE, signal);
|
|
149
155
|
if (page.kind === 'scanExpired') {
|
|
150
156
|
expired = true;
|
|
151
157
|
break;
|
|
@@ -175,15 +181,17 @@ class ZLinkLocationRuntime {
|
|
|
175
181
|
removeOwnerLeaseRenewalFailedHandler(handler) {
|
|
176
182
|
this.ownerLeaseRenewalFailedHandlers.delete(handler);
|
|
177
183
|
}
|
|
178
|
-
async start(nodeRid, signal) {
|
|
184
|
+
async start(nodeRid, signal, shutdownSignal) {
|
|
179
185
|
if (this.started) {
|
|
180
186
|
return;
|
|
181
187
|
}
|
|
182
188
|
this.started = true;
|
|
183
189
|
this.ownerCleanupComplete = false;
|
|
184
190
|
this.nodeRidValue = nodeRid;
|
|
191
|
+
const claim = this.renewOwnerLeaseOnce(signal, shutdownSignal);
|
|
192
|
+
this.heartbeatRenewal = claim;
|
|
185
193
|
try {
|
|
186
|
-
const claimed = await
|
|
194
|
+
const claimed = await claim;
|
|
187
195
|
if (claimed) {
|
|
188
196
|
this.scheduleHeartbeat();
|
|
189
197
|
return;
|
|
@@ -194,13 +202,10 @@ class ZLinkLocationRuntime {
|
|
|
194
202
|
catch (error) {
|
|
195
203
|
this.started = false;
|
|
196
204
|
this.ownerCleanupComplete = true;
|
|
197
|
-
throw error;
|
|
205
|
+
throw signal?.aborted === true ? signal.reason : error;
|
|
198
206
|
}
|
|
199
207
|
}
|
|
200
208
|
async stop(signal) {
|
|
201
|
-
if (!this.started && this.ownerCleanupComplete) {
|
|
202
|
-
return;
|
|
203
|
-
}
|
|
204
209
|
this.started = false;
|
|
205
210
|
if (this.heartbeatTimer !== undefined) {
|
|
206
211
|
this.clearTimer(this.heartbeatTimer);
|
|
@@ -208,10 +213,21 @@ class ZLinkLocationRuntime {
|
|
|
208
213
|
}
|
|
209
214
|
this.nextLeaseRenewAtMs = undefined;
|
|
210
215
|
this.ownerLeaseDeadlineMs = undefined;
|
|
211
|
-
await this.heartbeatRenewal;
|
|
212
216
|
await this.cleanupOwner(signal);
|
|
213
217
|
}
|
|
214
218
|
async cleanupOwner(signal) {
|
|
219
|
+
const pending = this.heartbeatRenewal;
|
|
220
|
+
try {
|
|
221
|
+
await withTimeout(() => pending ?? Promise.resolve(), undefined, signal);
|
|
222
|
+
}
|
|
223
|
+
catch (error) {
|
|
224
|
+
if (!(0, abort_1.isAbortError)(error))
|
|
225
|
+
throw error;
|
|
226
|
+
}
|
|
227
|
+
finally {
|
|
228
|
+
if (this.heartbeatRenewal === pending)
|
|
229
|
+
this.heartbeatRenewal = undefined;
|
|
230
|
+
}
|
|
215
231
|
if (this.ownerCleanupComplete) {
|
|
216
232
|
return;
|
|
217
233
|
}
|
|
@@ -221,11 +237,13 @@ class ZLinkLocationRuntime {
|
|
|
221
237
|
ownerId: this.ownerId,
|
|
222
238
|
leaseGeneration: 0n
|
|
223
239
|
};
|
|
224
|
-
await
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
240
|
+
await withTimeout(async (cleanupSignal) => {
|
|
241
|
+
await this.stores.locationStore.removeAllByOwner(owner, cleanupSignal);
|
|
242
|
+
const currentLease = await this.stores.ownerLeaseStore.readOwnerLease(this.ownerId, cleanupSignal);
|
|
243
|
+
if (currentLease.kind === 'found') {
|
|
244
|
+
await this.stores.ownerLeaseStore.releaseOwnerLease(currentLease.token, cleanupSignal);
|
|
245
|
+
}
|
|
246
|
+
}, undefined, signal);
|
|
229
247
|
this.ownerToken = undefined;
|
|
230
248
|
this.lastOwnerToken = undefined;
|
|
231
249
|
this.ownerCleanupComplete = true;
|
|
@@ -235,12 +253,12 @@ class ZLinkLocationRuntime {
|
|
|
235
253
|
throw new ZLinkOwnerCleanupError(error);
|
|
236
254
|
}
|
|
237
255
|
}
|
|
238
|
-
async renewOwnerLeaseOnce(signal) {
|
|
256
|
+
async renewOwnerLeaseOnce(signal, shutdownSignal) {
|
|
239
257
|
if (!this.started) {
|
|
240
258
|
return false;
|
|
241
259
|
}
|
|
242
260
|
if (this.ownerToken === undefined) {
|
|
243
|
-
return await this.claimFreshOwnerLease(signal);
|
|
261
|
+
return await this.claimFreshOwnerLease(signal, shutdownSignal);
|
|
244
262
|
}
|
|
245
263
|
const wasOwnerLeaseUsable = this.ownerLeaseUsable;
|
|
246
264
|
try {
|
|
@@ -261,7 +279,7 @@ class ZLinkLocationRuntime {
|
|
|
261
279
|
// The store has already told us that this owner token cannot be
|
|
262
280
|
// renewed. Claim immediately so descriptor recovery does not wait for
|
|
263
281
|
// another heartbeat interval.
|
|
264
|
-
return await this.claimFreshOwnerLease(signal);
|
|
282
|
+
return await this.claimFreshOwnerLease(signal, shutdownSignal);
|
|
265
283
|
}
|
|
266
284
|
this.ownerLeaseHealthy = true;
|
|
267
285
|
this.ownerLeaseRenewedAt = result.storeNow;
|
|
@@ -283,12 +301,12 @@ class ZLinkLocationRuntime {
|
|
|
283
301
|
return false;
|
|
284
302
|
}
|
|
285
303
|
}
|
|
286
|
-
async claimFreshOwnerLease(signal) {
|
|
304
|
+
async claimFreshOwnerLease(signal, shutdownSignal) {
|
|
287
305
|
const claimStartedAtMs = this.monotonicNowMs();
|
|
288
306
|
const timeoutDeadline = performance.now() + this.options.ownerLeaseRenewTimeoutMs;
|
|
289
307
|
let claim;
|
|
290
308
|
try {
|
|
291
|
-
claim = await this.claimOwnerLeaseWithConfirmation(timeoutDeadline, signal);
|
|
309
|
+
claim = await this.claimOwnerLeaseWithConfirmation(timeoutDeadline, signal, shutdownSignal);
|
|
292
310
|
}
|
|
293
311
|
catch (error) {
|
|
294
312
|
if (signal?.aborted === true)
|
|
@@ -307,14 +325,7 @@ class ZLinkLocationRuntime {
|
|
|
307
325
|
}
|
|
308
326
|
try {
|
|
309
327
|
if (!this.started) {
|
|
310
|
-
// stop
|
|
311
|
-
// not install a token into a stopped runtime or leave an orphan lease.
|
|
312
|
-
try {
|
|
313
|
-
await withTimeout((releaseSignal) => this.stores.ownerLeaseStore.releaseOwnerLease(claim.token, releaseSignal), remainingTimeoutMs(timeoutDeadline));
|
|
314
|
-
}
|
|
315
|
-
catch (error) {
|
|
316
|
-
this.recordFailure(errorMessage(error), 'owner_lease_release');
|
|
317
|
-
}
|
|
328
|
+
// stop owns confirmation and release under the host shutdown signal.
|
|
318
329
|
return false;
|
|
319
330
|
}
|
|
320
331
|
this.lastOwnerToken = this.ownerToken;
|
|
@@ -340,16 +351,32 @@ class ZLinkLocationRuntime {
|
|
|
340
351
|
return false;
|
|
341
352
|
}
|
|
342
353
|
}
|
|
343
|
-
async claimOwnerLeaseWithConfirmation(timeoutDeadline, signal) {
|
|
354
|
+
async claimOwnerLeaseWithConfirmation(timeoutDeadline, signal, shutdownSignal) {
|
|
344
355
|
signal?.throwIfAborted();
|
|
345
356
|
let claim;
|
|
357
|
+
let request;
|
|
346
358
|
try {
|
|
347
|
-
claim = await withTimeout((claimSignal) => this.stores.ownerLeaseStore.claimOwnerLease(this.ownerId, this.options.ownerLeaseTtlMs, claimSignal), remainingTimeoutMs(timeoutDeadline), signal);
|
|
359
|
+
claim = await withTimeout((claimSignal) => (request = this.stores.ownerLeaseStore.claimOwnerLease(this.ownerId, this.options.ownerLeaseTtlMs, claimSignal)), remainingTimeoutMs(timeoutDeadline), signal);
|
|
348
360
|
}
|
|
349
361
|
catch (error) {
|
|
350
362
|
if (error instanceof OwnerLeaseRenewTimeoutError)
|
|
351
363
|
throw error;
|
|
352
|
-
|
|
364
|
+
if (signal?.aborted === true && request !== undefined) {
|
|
365
|
+
const cleanupSignal = shutdownSignal?.();
|
|
366
|
+
try {
|
|
367
|
+
await withTimeout(() => request, cleanupSignal === undefined ? remainingTimeoutMs(timeoutDeadline) : undefined, cleanupSignal);
|
|
368
|
+
}
|
|
369
|
+
catch (completionError) {
|
|
370
|
+
if (cleanupSignal?.aborted === true ||
|
|
371
|
+
completionError instanceof OwnerLeaseRenewTimeoutError) {
|
|
372
|
+
throw new ZLinkOwnerCleanupError(completionError);
|
|
373
|
+
}
|
|
374
|
+
if (!(0, abort_1.isAbortError)(completionError)) {
|
|
375
|
+
this.recordFailure(errorMessage(completionError), 'owner_lease_claim');
|
|
376
|
+
}
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
const confirmed = await this.confirmOwnerLease(error, timeoutDeadline, signal, shutdownSignal);
|
|
353
380
|
if (confirmed !== undefined)
|
|
354
381
|
return confirmed;
|
|
355
382
|
throw error;
|
|
@@ -357,29 +384,34 @@ class ZLinkLocationRuntime {
|
|
|
357
384
|
if (claim.kind !== 'conflict')
|
|
358
385
|
return claim;
|
|
359
386
|
const conflict = new ZLinkOwnerLeaseClaimError(claim.kind);
|
|
360
|
-
return (await this.confirmOwnerLease(conflict, timeoutDeadline, signal)) ?? claim;
|
|
387
|
+
return ((await this.confirmOwnerLease(conflict, timeoutDeadline, signal, shutdownSignal)) ?? claim);
|
|
361
388
|
}
|
|
362
|
-
async confirmOwnerLease(originalError, timeoutDeadline, signal) {
|
|
363
|
-
const
|
|
364
|
-
|
|
389
|
+
async confirmOwnerLease(originalError, timeoutDeadline, signal, shutdownSignal) {
|
|
390
|
+
const cancelled = signal?.aborted === true;
|
|
391
|
+
const cleanupSignal = cancelled ? shutdownSignal?.() : undefined;
|
|
392
|
+
const confirmationTimeoutMs = cleanupSignal === undefined ? remainingTimeoutMs(timeoutDeadline) : undefined;
|
|
393
|
+
if (confirmationTimeoutMs !== undefined && confirmationTimeoutMs <= 0)
|
|
365
394
|
throw originalError;
|
|
366
395
|
let confirmed;
|
|
367
396
|
try {
|
|
368
|
-
confirmed = await withTimeout((readSignal) => this.stores.ownerLeaseStore.readOwnerLease(this.ownerId, readSignal), confirmationTimeoutMs);
|
|
397
|
+
confirmed = await withTimeout((readSignal) => this.stores.ownerLeaseStore.readOwnerLease(this.ownerId, readSignal), confirmationTimeoutMs, cleanupSignal);
|
|
369
398
|
}
|
|
370
399
|
catch (confirmationError) {
|
|
371
400
|
this.recordFailure(errorMessage(confirmationError), 'owner_lease_claim_confirmation');
|
|
372
|
-
|
|
401
|
+
if (cancelled)
|
|
402
|
+
throw new ZLinkOwnerCleanupError(confirmationError);
|
|
403
|
+
throw confirmationError;
|
|
373
404
|
}
|
|
374
405
|
if (confirmed.kind !== 'found' || confirmed.token.ownerId !== this.ownerId) {
|
|
375
406
|
throw originalError;
|
|
376
407
|
}
|
|
377
408
|
if (signal?.aborted === true) {
|
|
378
409
|
try {
|
|
379
|
-
await withTimeout((releaseSignal) => this.stores.ownerLeaseStore.releaseOwnerLease(confirmed.token, releaseSignal), remainingTimeoutMs(timeoutDeadline));
|
|
410
|
+
await withTimeout((releaseSignal) => this.stores.ownerLeaseStore.releaseOwnerLease(confirmed.token, releaseSignal), cleanupSignal === undefined ? remainingTimeoutMs(timeoutDeadline) : undefined, cleanupSignal);
|
|
380
411
|
}
|
|
381
412
|
catch (releaseError) {
|
|
382
413
|
this.recordFailure(errorMessage(releaseError), 'owner_lease_release');
|
|
414
|
+
throw new ZLinkOwnerCleanupError(releaseError);
|
|
383
415
|
}
|
|
384
416
|
throw originalError;
|
|
385
417
|
}
|
|
@@ -562,7 +594,7 @@ class ZLinkLocationRuntime {
|
|
|
562
594
|
}
|
|
563
595
|
async listPeerLocations(filter, signal) {
|
|
564
596
|
const rows = await this.stores.peerStore.listPeers(filter, signal);
|
|
565
|
-
const live = await this.
|
|
597
|
+
const live = await this.liveRows.filter(rows, (row, signal) => this.leaseTracker.isOwnerLive(row.ownerId, signal), signal);
|
|
566
598
|
// Location Store rows may have been written before this process adopted
|
|
567
599
|
// the endpoint-notation policy, or by another language/version's writer.
|
|
568
600
|
// Normalize on read so every comparison downstream sees the canonical
|
|
@@ -570,13 +602,13 @@ class ZLinkLocationRuntime {
|
|
|
570
602
|
return live.map((row) => ({ ...row, endpoint: (0, EndpointNotation_1.normalizeEndpoint)(row.endpoint) }));
|
|
571
603
|
}
|
|
572
604
|
async listLiveMeshNodes(meshName, signal) {
|
|
573
|
-
const rows =
|
|
574
|
-
const live = await this.
|
|
605
|
+
const rows = await (0, location_store_pages_1.listAllMeshNodeDescriptors)(this.stores.locationStore, meshName, signal);
|
|
606
|
+
const live = await this.liveRows.filter(rows, (row, signal) => this.leaseTracker.isOwnerTokenLive(row, signal), signal);
|
|
575
607
|
return live.map((row) => ({ ...row, endpoint: (0, EndpointNotation_1.normalizeEndpoint)(row.endpoint) }));
|
|
576
608
|
}
|
|
577
609
|
async listMeshNodeDescriptors(meshName, page, signal) {
|
|
578
610
|
const rows = await this.stores.locationStore.listMeshNodes(meshName, this.pageRequest(page), signal);
|
|
579
|
-
const live = await this.
|
|
611
|
+
const live = await this.liveRows.filter(rows.items, (row, signal) => this.leaseTracker.isOwnerTokenLive(row, signal), signal);
|
|
580
612
|
return {
|
|
581
613
|
items: live.map((row) => ({ ...row, endpoint: (0, EndpointNotation_1.normalizeEndpoint)(row.endpoint) })),
|
|
582
614
|
continuationToken: rows.continuationToken
|
|
@@ -589,7 +621,7 @@ class ZLinkLocationRuntime {
|
|
|
589
621
|
}
|
|
590
622
|
const rows = await queryStore.listSpots(filter, this.pageRequest(page), signal);
|
|
591
623
|
return {
|
|
592
|
-
items: await this.
|
|
624
|
+
items: await this.liveRows.filter(rows.items, (row, signal) => this.leaseTracker.isOwnerTokenLive(row, signal), signal),
|
|
593
625
|
continuationToken: rows.continuationToken
|
|
594
626
|
};
|
|
595
627
|
}
|
|
@@ -600,13 +632,13 @@ class ZLinkLocationRuntime {
|
|
|
600
632
|
}
|
|
601
633
|
const rows = await queryStore.listActors(filter, this.pageRequest(page), signal);
|
|
602
634
|
return {
|
|
603
|
-
items: await this.
|
|
635
|
+
items: await this.liveRows.filter(rows.items, (row, signal) => this.leaseTracker.isOwnerTokenLive(row, signal), signal),
|
|
604
636
|
continuationToken: rows.continuationToken
|
|
605
637
|
};
|
|
606
638
|
}
|
|
607
639
|
async listObjectLocations(filter, page = {}, signal) {
|
|
608
640
|
const normalizedPage = this.pageRequest(page);
|
|
609
|
-
const pageSize = normalizedPage.pageSize
|
|
641
|
+
const pageSize = normalizedPage.pageSize;
|
|
610
642
|
const requestedCursor = normalizedPage.continuationToken;
|
|
611
643
|
let cursor = requestedCursor === undefined ? undefined : Authority_1.ZLinkAuthorityScanCursor.from(requestedCursor);
|
|
612
644
|
const items = [];
|
|
@@ -624,7 +656,10 @@ class ZLinkLocationRuntime {
|
|
|
624
656
|
(filter.stableType !== undefined && allocation.stableType !== filter.stableType) ||
|
|
625
657
|
(filter.meshName !== undefined && allocation.descriptor.meshName !== filter.meshName))
|
|
626
658
|
continue;
|
|
627
|
-
const live = (await this.liveRows.resolve(entry, (candidate) =>
|
|
659
|
+
const live = (await this.liveRows.resolve(entry, (candidate, signal) => this.leaseTracker.isOwnerTokenLive({
|
|
660
|
+
ownerId: candidate.snapshot.ownerId,
|
|
661
|
+
leaseGeneration: candidate.snapshot.ownerLeaseGeneration
|
|
662
|
+
}, signal), signal)) !== undefined;
|
|
628
663
|
items.push(this.objectLocationEntry(identity.globalId, entry.snapshot, live));
|
|
629
664
|
if (items.length >= pageSize)
|
|
630
665
|
break;
|
|
@@ -646,14 +681,14 @@ class ZLinkLocationRuntime {
|
|
|
646
681
|
const found = await this.stores.authorityStore.readAuthority((0, authority_key_codec_1.encodeAuthorityKey)('user_spot', String(spotId)), signal);
|
|
647
682
|
if (found.kind === 'missing' || found.allocation.objectKind === 'actor')
|
|
648
683
|
return undefined;
|
|
649
|
-
const live = (await this.liveRows.resolve(found, (snapshot) => snapshot.ownerId, signal)) !== undefined;
|
|
684
|
+
const live = (await this.liveRows.resolve(found, (snapshot, signal) => this.leaseTracker.isOwnerTokenLive({ ownerId: snapshot.ownerId, leaseGeneration: snapshot.ownerLeaseGeneration }, signal), signal)) !== undefined;
|
|
650
685
|
return this.objectLocationEntry(String(spotId), found, live);
|
|
651
686
|
}
|
|
652
687
|
async findObjectLocation(kind, globalId, signal) {
|
|
653
688
|
const found = await this.stores.authorityStore.readAuthority((0, authority_key_codec_1.encodeAuthorityKey)(kind, globalId), signal);
|
|
654
689
|
if (found.kind === 'missing' || found.allocation.objectKind !== kind)
|
|
655
690
|
return undefined;
|
|
656
|
-
const live = (await this.liveRows.resolve(found, (snapshot) => snapshot.ownerId, signal)) !== undefined;
|
|
691
|
+
const live = (await this.liveRows.resolve(found, (snapshot, signal) => this.leaseTracker.isOwnerTokenLive({ ownerId: snapshot.ownerId, leaseGeneration: snapshot.ownerLeaseGeneration }, signal), signal)) !== undefined;
|
|
657
692
|
return this.objectLocationEntry(globalId, found, live);
|
|
658
693
|
}
|
|
659
694
|
objectLocationEntry(globalId, snapshot, ownerLive) {
|
|
@@ -670,15 +705,15 @@ class ZLinkLocationRuntime {
|
|
|
670
705
|
async listRouteLocations(filter, page, signal) {
|
|
671
706
|
const rows = await this.stores.routeStore.listRoutes(filter, this.pageRequest(page), signal);
|
|
672
707
|
return {
|
|
673
|
-
items: await this.
|
|
708
|
+
items: await this.liveRows.filter(rows.items, (row, signal) => this.leaseTracker.isOwnerLive(row.ownerId, signal), signal),
|
|
674
709
|
continuationToken: rows.continuationToken
|
|
675
710
|
};
|
|
676
711
|
}
|
|
677
712
|
async listTopology(filter, page, signal) {
|
|
678
713
|
const entries = [];
|
|
679
714
|
for (const meshName of this.meshNamesOf(filter.meshName)) {
|
|
680
|
-
for (const descriptor of await
|
|
681
|
-
const live =
|
|
715
|
+
for (const descriptor of await (0, location_store_pages_1.listAllMeshNodeDescriptors)(this.stores.locationStore, meshName, signal, this.options.listPageSize)) {
|
|
716
|
+
const live = await this.leaseTracker.isOwnerTokenLive(descriptor, signal);
|
|
682
717
|
const entry = {
|
|
683
718
|
meshName: descriptor.meshName,
|
|
684
719
|
nodeRid: descriptor.rid,
|
|
@@ -702,22 +737,23 @@ class ZLinkLocationRuntime {
|
|
|
702
737
|
return this.pageInMemory(entries, page);
|
|
703
738
|
}
|
|
704
739
|
pageRequest(page) {
|
|
705
|
-
return page?.pageSize === undefined
|
|
740
|
+
return page?.pageSize === undefined
|
|
741
|
+
? { ...page, pageSize: this.options.listPageSize }
|
|
742
|
+
: page;
|
|
706
743
|
}
|
|
707
744
|
async listServiceSummaries(filter, page, signal) {
|
|
708
745
|
const summaries = [];
|
|
709
746
|
for (const meshName of this.meshNamesOf(filter.meshName)) {
|
|
710
|
-
const descriptors = await
|
|
747
|
+
const descriptors = await (0, location_store_pages_1.listAllMeshNodeDescriptors)(this.stores.locationStore, meshName, signal, this.options.listPageSize);
|
|
711
748
|
if (descriptors.length === 0)
|
|
712
749
|
continue;
|
|
713
|
-
const live = await this.
|
|
714
|
-
const liveOwners = new Set(live.map((row) => row.ownerId));
|
|
750
|
+
const live = await this.liveRows.filter(descriptors, (row, signal) => this.leaseTracker.isOwnerTokenLive(row, signal), signal);
|
|
715
751
|
summaries.push({
|
|
716
752
|
meshName,
|
|
717
753
|
totalCount: descriptors.length,
|
|
718
|
-
readyCount:
|
|
754
|
+
readyCount: live.length,
|
|
719
755
|
errorCount: 0,
|
|
720
|
-
stoppedCount: descriptors.
|
|
756
|
+
stoppedCount: descriptors.length - live.length,
|
|
721
757
|
lastUpdatedAt: descriptors.reduce((latest, row) => (row.updatedAt > latest ? row.updatedAt : latest), descriptors[0].updatedAt)
|
|
722
758
|
});
|
|
723
759
|
}
|
|
@@ -726,21 +762,11 @@ class ZLinkLocationRuntime {
|
|
|
726
762
|
meshNamesOf(meshName) {
|
|
727
763
|
return meshName === undefined ? this.meshNames : [meshName];
|
|
728
764
|
}
|
|
729
|
-
async listAllMeshNodeDescriptors(meshName, signal) {
|
|
730
|
-
const rows = [];
|
|
731
|
-
let continuationToken;
|
|
732
|
-
do {
|
|
733
|
-
const result = await this.stores.locationStore.listMeshNodes(meshName, { pageSize: this.options.listPageSize, continuationToken }, signal);
|
|
734
|
-
rows.push(...result.items);
|
|
735
|
-
continuationToken = result.continuationToken;
|
|
736
|
-
} while (continuationToken !== undefined);
|
|
737
|
-
return rows;
|
|
738
|
-
}
|
|
739
765
|
pageInMemory(entries, page) {
|
|
740
766
|
const normalized = this.pageRequest(page);
|
|
741
767
|
const parsedOffset = Number.parseInt(normalized.continuationToken ?? '0', 10);
|
|
742
768
|
const offset = Number.isFinite(parsedOffset) && parsedOffset >= 0 ? parsedOffset : 0;
|
|
743
|
-
const pageSize = normalized.pageSize
|
|
769
|
+
const pageSize = normalized.pageSize;
|
|
744
770
|
const items = entries.slice(offset, offset + pageSize);
|
|
745
771
|
const nextOffset = offset + items.length;
|
|
746
772
|
return {
|
|
@@ -748,9 +774,6 @@ class ZLinkLocationRuntime {
|
|
|
748
774
|
continuationToken: nextOffset < entries.length ? String(nextOffset) : undefined
|
|
749
775
|
};
|
|
750
776
|
}
|
|
751
|
-
async filterLive(rows, ownerIdOf, signal) {
|
|
752
|
-
return await this.liveRows.filter(rows, ownerIdOf, signal);
|
|
753
|
-
}
|
|
754
777
|
scheduleHeartbeat() {
|
|
755
778
|
if (!this.started) {
|
|
756
779
|
return;
|
|
@@ -759,11 +782,11 @@ class ZLinkLocationRuntime {
|
|
|
759
782
|
const delayMs = Math.max(0, scheduledAt - this.monotonicNowMs());
|
|
760
783
|
this.heartbeatTimer = this.setTimer(() => {
|
|
761
784
|
this.heartbeatTimer = undefined;
|
|
762
|
-
const lateness = Math.max(0, this.monotonicNowMs() - scheduledAt) /
|
|
785
|
+
const lateness = Math.max(0, this.monotonicNowMs() - scheduledAt) / runtime_metrics_1.MILLISECONDS_PER_SECOND;
|
|
763
786
|
for (const scope of this.leaseScopes) {
|
|
764
787
|
this.metrics?.recordOwnerLeaseRenewLateness(lateness, scope.kind, scope.name);
|
|
765
788
|
}
|
|
766
|
-
this.nextLeaseRenewAtMs =
|
|
789
|
+
this.nextLeaseRenewAtMs = this.monotonicNowMs() + this.options.ownerLeaseRenewIntervalMs;
|
|
767
790
|
if (this.ownerLeaseDeadlineMs !== undefined &&
|
|
768
791
|
this.monotonicNowMs() >= this.ownerLeaseDeadlineMs) {
|
|
769
792
|
this.ownerLeaseHealthy = false;
|
|
@@ -838,20 +861,24 @@ class ZLinkLocationRuntime {
|
|
|
838
861
|
}
|
|
839
862
|
exports.ZLinkLocationRuntime = ZLinkLocationRuntime;
|
|
840
863
|
async function withTimeout(action, timeoutMs, signal) {
|
|
841
|
-
const timeoutController = new AbortController();
|
|
864
|
+
const timeoutController = timeoutMs === undefined ? undefined : new AbortController();
|
|
842
865
|
const operationSignal = signal === undefined
|
|
843
|
-
? timeoutController
|
|
844
|
-
:
|
|
866
|
+
? timeoutController?.signal
|
|
867
|
+
: timeoutController === undefined
|
|
868
|
+
? signal
|
|
869
|
+
: AbortSignal.any([signal, timeoutController.signal]);
|
|
845
870
|
let timeout;
|
|
846
871
|
let abort;
|
|
847
|
-
const deadline =
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
872
|
+
const deadline = timeoutMs === undefined
|
|
873
|
+
? undefined
|
|
874
|
+
: new Promise((_resolve, reject) => {
|
|
875
|
+
timeout = setTimeout(() => {
|
|
876
|
+
const error = new OwnerLeaseRenewTimeoutError(timeoutMs);
|
|
877
|
+
timeoutController.abort(error);
|
|
878
|
+
reject(error);
|
|
879
|
+
}, timeoutMs);
|
|
880
|
+
timeout.unref();
|
|
881
|
+
});
|
|
855
882
|
const cancellation = signal === undefined
|
|
856
883
|
? undefined
|
|
857
884
|
: new Promise((_resolve, reject) => {
|
|
@@ -860,9 +887,13 @@ async function withTimeout(action, timeoutMs, signal) {
|
|
|
860
887
|
});
|
|
861
888
|
try {
|
|
862
889
|
signal?.throwIfAborted();
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
890
|
+
const operation = action(operationSignal);
|
|
891
|
+
if (deadline === undefined) {
|
|
892
|
+
return cancellation === undefined
|
|
893
|
+
? await operation
|
|
894
|
+
: await Promise.race([operation, cancellation]);
|
|
895
|
+
}
|
|
896
|
+
return await Promise.race(cancellation === undefined ? [operation, deadline] : [operation, deadline, cancellation]);
|
|
866
897
|
}
|
|
867
898
|
finally {
|
|
868
899
|
if (timeout !== undefined)
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { RoutingId } from '../../contracts/Common';
|
|
2
|
+
import type { ZLinkAuthoritySnapshot } from './internal-location-contracts';
|
|
2
3
|
import { ZLinkLocationWriteStatus } from './internal-location-contracts';
|
|
3
4
|
import { ZLinkSpotKind } from '../../contracts/Spots';
|
|
4
5
|
import type { IZLinkLocationLifecycleRuntime, ZLinkOwnershipLostEvent } from './lifecycle-runtime';
|
|
@@ -33,4 +34,9 @@ export interface ZLinkTrackedInstanceAuthority {
|
|
|
33
34
|
}
|
|
34
35
|
export interface ZLinkInstanceClosingAuthority {
|
|
35
36
|
release(): Promise<void>;
|
|
37
|
+
reincarnate?(initialize: (authority: ZLinkAuthoritySnapshot & {
|
|
38
|
+
readonly stableType: string;
|
|
39
|
+
}) => Promise<void>): Promise<ZLinkAuthoritySnapshot & {
|
|
40
|
+
readonly stableType: string;
|
|
41
|
+
}>;
|
|
36
42
|
}
|
|
@@ -118,7 +118,48 @@ class ZLinkSpotLocationClaims {
|
|
|
118
118
|
tracked.storeVersion = result.storeVersion.value;
|
|
119
119
|
onCommitted();
|
|
120
120
|
return {
|
|
121
|
-
release:
|
|
121
|
+
release: () => this.release(meshName, spotId),
|
|
122
|
+
reincarnate: async (initialize) => {
|
|
123
|
+
const reincarnated = await store.compareExchangeAuthority(key, result.storeVersion, {
|
|
124
|
+
kind: 'put',
|
|
125
|
+
generationTransition: 'reincarnate',
|
|
126
|
+
payload: (0, service_relocation_runtime_1.replaceServiceRelocationAuthorityApplicationPayload)(result.payload, (0, service_authority_payload_codec_1.encodeServiceInstanceAuthorityPayload)({ ...decoded, state: 'coldActivating' }))
|
|
127
|
+
});
|
|
128
|
+
if (reincarnated.kind !== 'stored') {
|
|
129
|
+
throw (0, framework_errors_internal_1.createInternalFrameworkException)(reincarnated.kind === 'generationExhausted'
|
|
130
|
+
? framework_errors_internal_1.ZLinkFrameworkInternalErrorKind.InvalidOperation
|
|
131
|
+
: framework_errors_internal_1.ZLinkFrameworkInternalErrorKind.SpotMoving, `Instance Spot '${String(spotId)}' Closing authority changed before reincarnation.`);
|
|
132
|
+
}
|
|
133
|
+
this.trackInstanceAuthority({
|
|
134
|
+
...tracked,
|
|
135
|
+
objectGeneration: reincarnated.objectGeneration,
|
|
136
|
+
authorityOwnerGeneration: reincarnated.authorityOwnerGeneration,
|
|
137
|
+
storeVersion: reincarnated.storeVersion.value
|
|
138
|
+
});
|
|
139
|
+
this.invalidateSpotRoute?.(spotId);
|
|
140
|
+
try {
|
|
141
|
+
await initialize({ ...reincarnated, kind: 'snapshot', stableType: tracked.stableType });
|
|
142
|
+
const ready = await store.compareExchangeAuthority(key, reincarnated.storeVersion, {
|
|
143
|
+
kind: 'put',
|
|
144
|
+
generationTransition: 'preserve',
|
|
145
|
+
payload: (0, service_relocation_runtime_1.replaceServiceRelocationAuthorityApplicationPayload)(reincarnated.payload, (0, service_authority_payload_codec_1.encodeServiceInstanceAuthorityPayload)({ ...decoded, state: 'ready' }))
|
|
146
|
+
});
|
|
147
|
+
if (ready.kind !== 'stored') {
|
|
148
|
+
throw (0, framework_errors_internal_1.createInternalFrameworkException)(ready.kind === 'generationExhausted'
|
|
149
|
+
? framework_errors_internal_1.ZLinkFrameworkInternalErrorKind.InvalidOperation
|
|
150
|
+
: framework_errors_internal_1.ZLinkFrameworkInternalErrorKind.SpotMoving, `Instance Spot '${String(spotId)}' reincarnation authority changed before initialization completed.`);
|
|
151
|
+
}
|
|
152
|
+
const latest = this.spots.get(canonical);
|
|
153
|
+
if (latest?.kind === 'authority' && latest.objectGeneration === ready.objectGeneration) {
|
|
154
|
+
latest.storeVersion = ready.storeVersion.value;
|
|
155
|
+
}
|
|
156
|
+
return { ...ready, kind: 'snapshot', stableType: tracked.stableType };
|
|
157
|
+
}
|
|
158
|
+
catch (error) {
|
|
159
|
+
await this.release(meshName, spotId, reincarnated.objectGeneration);
|
|
160
|
+
throw error;
|
|
161
|
+
}
|
|
162
|
+
}
|
|
122
163
|
};
|
|
123
164
|
}
|
|
124
165
|
onOwnershipLost(event) {
|
|
@@ -9,6 +9,7 @@ exports.wrapFrameworkPayloadMessage = wrapFrameworkPayloadMessage;
|
|
|
9
9
|
exports.selectDefaultSerializer = selectDefaultSerializer;
|
|
10
10
|
exports.selectSerializer = selectSerializer;
|
|
11
11
|
exports.selectSerializerWithContentType = selectSerializerWithContentType;
|
|
12
|
+
const stream_wire_1 = require("@zlink-systems/stream-wire");
|
|
12
13
|
const framework_errors_internal_1 = require("../framework-errors-internal");
|
|
13
14
|
const runtime_message_1 = require("../backend/runtime-message");
|
|
14
15
|
const contracts_1 = require("../../contracts");
|
|
@@ -20,8 +21,11 @@ const Attributes_1 = require("../../contracts/Handlers/Attributes");
|
|
|
20
21
|
const packet_name_1 = require("./packet-name");
|
|
21
22
|
const CodecContentType_1 = require("../../contracts/Configuration/CodecContentType");
|
|
22
23
|
const CodecSerializerSelection_1 = require("../../contracts/Configuration/CodecSerializerSelection");
|
|
24
|
+
const MAX_DECLARED_TYPE_SELECTIONS = 1024;
|
|
23
25
|
const noSerializer = Symbol('noSerializer');
|
|
24
|
-
const JSON_CONTENT_TYPE =
|
|
26
|
+
const JSON_CONTENT_TYPE = stream_wire_1.ZlinkStreamContentType.Json;
|
|
27
|
+
const frameworkJsonReceiveCodec = Symbol('frameworkJsonReceiveCodec');
|
|
28
|
+
const defaultReceiveCodecs = new Map([[JSON_CONTENT_TYPE, frameworkJsonReceiveCodec]]);
|
|
25
29
|
// Registration maps are created during host configuration and are immutable
|
|
26
30
|
// for the runtime lifetime. Compile the candidate list and reverse content
|
|
27
31
|
// type lookup once per map so the message path does not allocate arrays or
|
|
@@ -36,8 +40,8 @@ function encodeFrameworkPayload(payload, registry, packetName, contractPart = 'p
|
|
|
36
40
|
if ((0, contracts_1.isZLinkMessage)(payload)) {
|
|
37
41
|
if (payload.isEncoded()) {
|
|
38
42
|
return {
|
|
39
|
-
message: rememberContentType(toRuntimeMessage(payload.toEncodedPayload()),
|
|
40
|
-
contentType:
|
|
43
|
+
message: rememberContentType(toRuntimeMessage(payload.toEncodedPayload()), stream_wire_1.ZlinkStreamContentType.Raw),
|
|
44
|
+
contentType: stream_wire_1.ZlinkStreamContentType.Raw
|
|
41
45
|
};
|
|
42
46
|
}
|
|
43
47
|
declaredType = (0, ZLinkMessage_1.readZLinkMessageDeclaredType)(payload);
|
|
@@ -72,16 +76,11 @@ function decodeFrameworkTypedPayloadMessage(message, registry, type, contentType
|
|
|
72
76
|
return decodeFrameworkPayload(message, registry, type, contentType, packetName, contractPart);
|
|
73
77
|
}
|
|
74
78
|
function decodeFrameworkPayload(message, registry, type, contentType, packetName, contractPart) {
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
}
|
|
78
|
-
if (contentType !== JSON_CONTENT_TYPE) {
|
|
79
|
-
const serializer = serializerMapOf(registry)?.get(contentType);
|
|
80
|
-
if (serializer === undefined)
|
|
81
|
-
throw unsupportedContentType(contentType);
|
|
79
|
+
const codec = receiveCodecFor(contentType, registry);
|
|
80
|
+
if (codec !== frameworkJsonReceiveCodec) {
|
|
82
81
|
if (message.isEmpty())
|
|
83
82
|
return undefined;
|
|
84
|
-
return
|
|
83
|
+
return codec.deserialize(encodedPayloadFromOwned(message.data()), (type ?? Object));
|
|
85
84
|
}
|
|
86
85
|
if (message.isEmpty())
|
|
87
86
|
return undefined;
|
|
@@ -96,16 +95,11 @@ function wrapFrameworkPayloadMessage(message, registry, contentType = JSON_CONTE
|
|
|
96
95
|
return (0, ZLinkMessage_1.createZLinkMessageFromEncoded)(payload, (type) => decodeFrameworkEncodedPayload(payload, registry, type, contentType, packetName, contractPart));
|
|
97
96
|
}
|
|
98
97
|
function decodeFrameworkEncodedPayload(payload, registry, type, contentType, packetName, contractPart) {
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
}
|
|
102
|
-
if (contentType !== JSON_CONTENT_TYPE) {
|
|
103
|
-
const serializer = serializerMapOf(registry)?.get(contentType);
|
|
104
|
-
if (serializer === undefined)
|
|
105
|
-
throw unsupportedContentType(contentType);
|
|
98
|
+
const codec = receiveCodecFor(contentType, registry);
|
|
99
|
+
if (codec !== frameworkJsonReceiveCodec) {
|
|
106
100
|
if (payload.isEmpty())
|
|
107
101
|
return undefined;
|
|
108
|
-
return
|
|
102
|
+
return codec.deserialize(payload, (type ?? Object));
|
|
109
103
|
}
|
|
110
104
|
if (payload.isEmpty())
|
|
111
105
|
return undefined;
|
|
@@ -117,6 +111,18 @@ function decodeFrameworkEncodedPayload(payload, registry, type, contentType, pac
|
|
|
117
111
|
throw (0, framework_errors_internal_1.createInternalFrameworkException)(framework_errors_internal_1.ZLinkFrameworkInternalErrorKind.PayloadDecodeFailed, 'PayloadDecodeFailed: framework payload is not valid JSON.', false, error);
|
|
118
112
|
}
|
|
119
113
|
}
|
|
114
|
+
function receiveCodecFor(contentType, registry) {
|
|
115
|
+
if (!(0, CodecContentType_1.isCanonicalCodecContentType)(contentType)) {
|
|
116
|
+
throw unsupportedContentType(contentType);
|
|
117
|
+
}
|
|
118
|
+
const registeredCodec = serializerMapOf(registry)?.get(contentType);
|
|
119
|
+
if (registeredCodec !== undefined)
|
|
120
|
+
return registeredCodec;
|
|
121
|
+
const defaultCodec = defaultReceiveCodecs.get(contentType);
|
|
122
|
+
if (defaultCodec !== undefined)
|
|
123
|
+
return defaultCodec;
|
|
124
|
+
throw unsupportedContentType(contentType);
|
|
125
|
+
}
|
|
120
126
|
function schemaForDecode(type, packetName, contractPart) {
|
|
121
127
|
const contract = type === undefined ? undefined : (0, packet_name_1.readFrameworkPacketJsonContract)(type, packetName);
|
|
122
128
|
return (contract ??
|
|
@@ -167,7 +173,7 @@ function serializerSelectionPlanOf(registry) {
|
|
|
167
173
|
return cached === noSerializer ? undefined : cached;
|
|
168
174
|
}
|
|
169
175
|
const selected = selectSerializerFromEntries(frozenEntries, declaredType);
|
|
170
|
-
if (cachedBusinessTypeCount <
|
|
176
|
+
if (cachedBusinessTypeCount < MAX_DECLARED_TYPE_SELECTIONS) {
|
|
171
177
|
outboundByBusinessType.set(declaredType, selected ?? noSerializer);
|
|
172
178
|
cachedBusinessTypeCount += 1;
|
|
173
179
|
}
|