@zlink-systems/framework 0.10.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/LICENSE +105 -0
- package/dist/.tsbuildinfo +1 -0
- package/dist/contracts/Actors/ZLinkActor.d.ts +7 -0
- package/dist/contracts/Actors/ZLinkActor.js +2 -0
- package/dist/contracts/Actors/ZLinkActorClient.d.ts +15 -0
- package/dist/contracts/Actors/ZLinkActorClient.js +2 -0
- package/dist/contracts/Actors/ZLinkActorContext.d.ts +14 -0
- package/dist/contracts/Actors/ZLinkActorContext.js +2 -0
- package/dist/contracts/Actors/ZLinkActorFactory.d.ts +34 -0
- package/dist/contracts/Actors/ZLinkActorFactory.js +2 -0
- package/dist/contracts/Actors/ZLinkActorManager.d.ts +34 -0
- package/dist/contracts/Actors/ZLinkActorManager.js +2 -0
- package/dist/contracts/Actors/index.d.ts +5 -0
- package/dist/contracts/Actors/index.js +21 -0
- package/dist/contracts/Channels/Calls.d.ts +28 -0
- package/dist/contracts/Channels/Calls.js +2 -0
- package/dist/contracts/Channels/IZLinkChannelClient.d.ts +5 -0
- package/dist/contracts/Channels/IZLinkChannelClient.js +2 -0
- package/dist/contracts/Channels/IZLinkFanoutClient.d.ts +11 -0
- package/dist/contracts/Channels/IZLinkFanoutClient.js +2 -0
- package/dist/contracts/Channels/RouteCalls.d.ts +11 -0
- package/dist/contracts/Channels/RouteCalls.js +2 -0
- package/dist/contracts/Channels/index.d.ts +4 -0
- package/dist/contracts/Channels/index.js +20 -0
- package/dist/contracts/Codecs/IZLinkCodecRegistryBuilder.d.ts +14 -0
- package/dist/contracts/Codecs/IZLinkCodecRegistryBuilder.js +2 -0
- package/dist/contracts/Codecs/ZLinkMessageSerializer.d.ts +5 -0
- package/dist/contracts/Codecs/ZLinkMessageSerializer.js +2 -0
- package/dist/contracts/Codecs/index.d.ts +2 -0
- package/dist/contracts/Codecs/index.js +18 -0
- package/dist/contracts/Common/ActorRef.d.ts +7 -0
- package/dist/contracts/Common/ActorRef.js +2 -0
- package/dist/contracts/Common/CoreTypes.d.ts +6 -0
- package/dist/contracts/Common/CoreTypes.js +2 -0
- package/dist/contracts/Common/Message.d.ts +9 -0
- package/dist/contracts/Common/Message.js +2 -0
- package/dist/contracts/Common/ZLinkEncodedPayload.d.ts +12 -0
- package/dist/contracts/Common/ZLinkEncodedPayload.js +41 -0
- package/dist/contracts/Common/ZLinkMessage.d.ts +25 -0
- package/dist/contracts/Common/ZLinkMessage.js +127 -0
- package/dist/contracts/Common/ZLinkMessageMetadata.d.ts +10 -0
- package/dist/contracts/Common/ZLinkMessageMetadata.js +49 -0
- package/dist/contracts/Common/ZLinkProviderResolver.d.ts +5 -0
- package/dist/contracts/Common/ZLinkProviderResolver.js +2 -0
- package/dist/contracts/Common/encoded-payload-storage.d.ts +3 -0
- package/dist/contracts/Common/encoded-payload-storage.js +18 -0
- package/dist/contracts/Common/index.d.ts +5 -0
- package/dist/contracts/Common/index.js +24 -0
- package/dist/contracts/Configuration/Builders.d.ts +153 -0
- package/dist/contracts/Configuration/Builders.js +2 -0
- package/dist/contracts/Configuration/CodecContentType.d.ts +2 -0
- package/dist/contracts/Configuration/CodecContentType.js +68 -0
- package/dist/contracts/Configuration/CodecSerializerSelection.d.ts +9 -0
- package/dist/contracts/Configuration/CodecSerializerSelection.js +15 -0
- package/dist/contracts/Configuration/Configs.d.ts +23 -0
- package/dist/contracts/Configuration/Configs.js +2 -0
- package/dist/contracts/Configuration/ConfigurationException.d.ts +3 -0
- package/dist/contracts/Configuration/ConfigurationException.js +10 -0
- package/dist/contracts/Configuration/Connections.d.ts +5 -0
- package/dist/contracts/Configuration/Connections.js +2 -0
- package/dist/contracts/Configuration/DiagnosticsValidation.d.ts +3 -0
- package/dist/contracts/Configuration/DiagnosticsValidation.js +23 -0
- package/dist/contracts/Configuration/EndpointNotation.d.ts +77 -0
- package/dist/contracts/Configuration/EndpointNotation.js +218 -0
- package/dist/contracts/Configuration/InternalDefaults.d.ts +7 -0
- package/dist/contracts/Configuration/InternalDefaults.js +47 -0
- package/dist/contracts/Configuration/ObjectRoles.d.ts +38 -0
- package/dist/contracts/Configuration/ObjectRoles.js +13 -0
- package/dist/contracts/Configuration/Registration.d.ts +11 -0
- package/dist/contracts/Configuration/Registration.js +162 -0
- package/dist/contracts/Configuration/RegistrationBuilderPolicy.d.ts +14 -0
- package/dist/contracts/Configuration/RegistrationBuilderPolicy.js +61 -0
- package/dist/contracts/Configuration/RegistrationBuilders.d.ts +61 -0
- package/dist/contracts/Configuration/RegistrationBuilders.js +1181 -0
- package/dist/contracts/Configuration/RegistrationCodecRegistry.d.ts +19 -0
- package/dist/contracts/Configuration/RegistrationCodecRegistry.js +79 -0
- package/dist/contracts/Configuration/RegistrationNormalizers.d.ts +23 -0
- package/dist/contracts/Configuration/RegistrationNormalizers.js +319 -0
- package/dist/contracts/Configuration/RegistrationTypes.d.ts +414 -0
- package/dist/contracts/Configuration/RegistrationTypes.js +2 -0
- package/dist/contracts/Configuration/RegistrationValidators.d.ts +2 -0
- package/dist/contracts/Configuration/RegistrationValidators.js +461 -0
- package/dist/contracts/Configuration/RouteChannelInternalState.d.ts +10 -0
- package/dist/contracts/Configuration/RouteChannelInternalState.js +39 -0
- package/dist/contracts/Configuration/RuntimeEndpointConnections.d.ts +9 -0
- package/dist/contracts/Configuration/RuntimeEndpointConnections.js +80 -0
- package/dist/contracts/Configuration/SendTimeoutValidation.d.ts +2 -0
- package/dist/contracts/Configuration/SendTimeoutValidation.js +16 -0
- package/dist/contracts/Configuration/TimerRegistrationValidator.d.ts +2 -0
- package/dist/contracts/Configuration/TimerRegistrationValidator.js +24 -0
- package/dist/contracts/Configuration/index.d.ts +5 -0
- package/dist/contracts/Configuration/index.js +18 -0
- package/dist/contracts/Dispatch/ZLinkDispatchOptions.d.ts +181 -0
- package/dist/contracts/Dispatch/ZLinkDispatchOptions.js +89 -0
- package/dist/contracts/Dispatch/ZLinkFlowOrigin.d.ts +1 -0
- package/dist/contracts/Dispatch/ZLinkFlowOrigin.js +2 -0
- package/dist/contracts/Dispatch/index.d.ts +2 -0
- package/dist/contracts/Dispatch/index.js +18 -0
- package/dist/contracts/Errors/ZLinkFrameworkException.d.ts +20 -0
- package/dist/contracts/Errors/ZLinkFrameworkException.js +29 -0
- package/dist/contracts/Errors/index.d.ts +1 -0
- package/dist/contracts/Errors/index.js +6 -0
- package/dist/contracts/Eventing/Metrics.d.ts +29 -0
- package/dist/contracts/Eventing/Metrics.js +4 -0
- package/dist/contracts/Eventing/index.d.ts +1 -0
- package/dist/contracts/Eventing/index.js +17 -0
- package/dist/contracts/Handlers/Attributes.d.ts +24 -0
- package/dist/contracts/Handlers/Attributes.js +84 -0
- package/dist/contracts/Handlers/Contexts.d.ts +18 -0
- package/dist/contracts/Handlers/Contexts.js +2 -0
- package/dist/contracts/Handlers/IZLinkChannelHandlers.d.ts +43 -0
- package/dist/contracts/Handlers/IZLinkChannelHandlers.js +2 -0
- package/dist/contracts/Handlers/IZLinkHandlerFilter.d.ts +15 -0
- package/dist/contracts/Handlers/IZLinkHandlerFilter.js +11 -0
- package/dist/contracts/Handlers/JsonContract.d.ts +46 -0
- package/dist/contracts/Handlers/JsonContract.js +137 -0
- package/dist/contracts/Handlers/ZLinkHandlerFilterNext.d.ts +1 -0
- package/dist/contracts/Handlers/ZLinkHandlerFilterNext.js +2 -0
- package/dist/contracts/Handlers/index.d.ts +5 -0
- package/dist/contracts/Handlers/index.js +33 -0
- package/dist/contracts/Locations/ActorTransfer.d.ts +41 -0
- package/dist/contracts/Locations/ActorTransfer.js +2 -0
- package/dist/contracts/Locations/Authority.d.ts +296 -0
- package/dist/contracts/Locations/Authority.js +17 -0
- package/dist/contracts/Locations/Diagnostics.d.ts +42 -0
- package/dist/contracts/Locations/Diagnostics.js +12 -0
- package/dist/contracts/Locations/Keys.d.ts +86 -0
- package/dist/contracts/Locations/Keys.js +2 -0
- package/dist/contracts/Locations/Models.d.ts +7 -0
- package/dist/contracts/Locations/Models.js +23 -0
- package/dist/contracts/Locations/Options.d.ts +23 -0
- package/dist/contracts/Locations/Options.js +20 -0
- package/dist/contracts/Locations/Readiness.d.ts +5 -0
- package/dist/contracts/Locations/Readiness.js +2 -0
- package/dist/contracts/Locations/RelocationStore.d.ts +38 -0
- package/dist/contracts/Locations/RelocationStore.js +2 -0
- package/dist/contracts/Locations/Resolvers.d.ts +4 -0
- package/dist/contracts/Locations/Resolvers.js +2 -0
- package/dist/contracts/Locations/Rows.d.ts +152 -0
- package/dist/contracts/Locations/Rows.js +19 -0
- package/dist/contracts/Locations/RuntimeQuery.d.ts +25 -0
- package/dist/contracts/Locations/RuntimeQuery.js +2 -0
- package/dist/contracts/Locations/Stores.d.ts +88 -0
- package/dist/contracts/Locations/Stores.js +2 -0
- package/dist/contracts/Locations/Values.d.ts +27 -0
- package/dist/contracts/Locations/Values.js +36 -0
- package/dist/contracts/Locations/Watch.d.ts +14 -0
- package/dist/contracts/Locations/Watch.js +12 -0
- package/dist/contracts/Locations/Writes.d.ts +48 -0
- package/dist/contracts/Locations/Writes.js +15 -0
- package/dist/contracts/Locations/index.d.ts +12 -0
- package/dist/contracts/Locations/index.js +30 -0
- package/dist/contracts/RouteMesh/Contracts.d.ts +102 -0
- package/dist/contracts/RouteMesh/Contracts.js +39 -0
- package/dist/contracts/RouteMesh/RuntimeTopology.d.ts +165 -0
- package/dist/contracts/RouteMesh/RuntimeTopology.js +38 -0
- package/dist/contracts/RouteMesh/index.d.ts +2 -0
- package/dist/contracts/RouteMesh/index.js +18 -0
- package/dist/contracts/Spots/Builders.d.ts +10 -0
- package/dist/contracts/Spots/Builders.js +2 -0
- package/dist/contracts/Spots/Contracts.d.ts +110 -0
- package/dist/contracts/Spots/Contracts.js +9 -0
- package/dist/contracts/Spots/SpotKind.d.ts +8 -0
- package/dist/contracts/Spots/SpotKind.js +28 -0
- package/dist/contracts/Spots/ZLinkSpot.d.ts +62 -0
- package/dist/contracts/Spots/ZLinkSpot.js +15 -0
- package/dist/contracts/Spots/index.d.ts +3 -0
- package/dist/contracts/Spots/index.js +19 -0
- package/dist/contracts/Streams/BoundSessionContracts.d.ts +8 -0
- package/dist/contracts/Streams/BoundSessionContracts.js +2 -0
- package/dist/contracts/Streams/IZLinkSession.d.ts +44 -0
- package/dist/contracts/Streams/IZLinkSession.js +2 -0
- package/dist/contracts/Streams/IZLinkSessionActor.d.ts +15 -0
- package/dist/contracts/Streams/IZLinkSessionActor.js +2 -0
- package/dist/contracts/Streams/IZLinkSessionPacketHandler.d.ts +9 -0
- package/dist/contracts/Streams/IZLinkSessionPacketHandler.js +2 -0
- package/dist/contracts/Streams/IZLinkStream.d.ts +9 -0
- package/dist/contracts/Streams/IZLinkStream.js +2 -0
- package/dist/contracts/Streams/ZLinkMessageMetadata.d.ts +1 -0
- package/dist/contracts/Streams/ZLinkMessageMetadata.js +2 -0
- package/dist/contracts/Streams/ZLinkStreamCompression.d.ts +8 -0
- package/dist/contracts/Streams/ZLinkStreamCompression.js +2 -0
- package/dist/contracts/Streams/ZLinkStreamError.d.ts +8 -0
- package/dist/contracts/Streams/ZLinkStreamError.js +8 -0
- package/dist/contracts/Streams/index.d.ts +8 -0
- package/dist/contracts/Streams/index.js +24 -0
- package/dist/contracts/Timers/IZLinkTimer.d.ts +5 -0
- package/dist/contracts/Timers/IZLinkTimer.js +2 -0
- package/dist/contracts/Timers/ZLinkTimerOptions.d.ts +10 -0
- package/dist/contracts/Timers/ZLinkTimerOptions.js +9 -0
- package/dist/contracts/Timers/ZLinkTimerTick.d.ts +12 -0
- package/dist/contracts/Timers/ZLinkTimerTick.js +2 -0
- package/dist/contracts/Timers/index.d.ts +3 -0
- package/dist/contracts/Timers/index.js +19 -0
- package/dist/contracts/index.d.ts +25 -0
- package/dist/contracts/index.js +45 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +17 -0
- package/dist/internal.d.ts +26 -0
- package/dist/internal.js +48 -0
- package/dist/location-store-integration.d.ts +5 -0
- package/dist/location-store-integration.js +31 -0
- package/dist/nest-integration.d.ts +49 -0
- package/dist/nest-integration.js +143 -0
- package/dist/runtime/abort.d.ts +13 -0
- package/dist/runtime/abort.js +71 -0
- package/dist/runtime/actors/actor-authority-payload-codec.d.ts +33 -0
- package/dist/runtime/actors/actor-authority-payload-codec.js +366 -0
- package/dist/runtime/actors/actor-authority-publication.d.ts +28 -0
- package/dist/runtime/actors/actor-authority-publication.js +207 -0
- package/dist/runtime/actors/actor-client.d.ts +36 -0
- package/dist/runtime/actors/actor-client.js +612 -0
- package/dist/runtime/actors/actor-context.d.ts +26 -0
- package/dist/runtime/actors/actor-context.js +433 -0
- package/dist/runtime/actors/actor-creation.d.ts +19 -0
- package/dist/runtime/actors/actor-creation.js +158 -0
- package/dist/runtime/actors/actor-execution-context.d.ts +6 -0
- package/dist/runtime/actors/actor-execution-context.js +27 -0
- package/dist/runtime/actors/actor-handoff.d.ts +191 -0
- package/dist/runtime/actors/actor-handoff.js +1252 -0
- package/dist/runtime/actors/actor-join-deferred-scope.d.ts +11 -0
- package/dist/runtime/actors/actor-join-deferred-scope.js +144 -0
- package/dist/runtime/actors/actor-join-relocation.d.ts +38 -0
- package/dist/runtime/actors/actor-join-relocation.js +2 -0
- package/dist/runtime/actors/actor-lifecycle-snapshot.d.ts +21 -0
- package/dist/runtime/actors/actor-lifecycle-snapshot.js +58 -0
- package/dist/runtime/actors/actor-local-native-join.d.ts +27 -0
- package/dist/runtime/actors/actor-local-native-join.js +409 -0
- package/dist/runtime/actors/actor-mailbox.d.ts +10 -0
- package/dist/runtime/actors/actor-mailbox.js +53 -0
- package/dist/runtime/actors/actor-message-follow-context.d.ts +46 -0
- package/dist/runtime/actors/actor-message-follow-context.js +257 -0
- package/dist/runtime/actors/actor-native-lookup.d.ts +4 -0
- package/dist/runtime/actors/actor-native-lookup.js +30 -0
- package/dist/runtime/actors/actor-packet-relay-wire.d.ts +73 -0
- package/dist/runtime/actors/actor-packet-relay-wire.js +144 -0
- package/dist/runtime/actors/actor-remote-joiner.d.ts +37 -0
- package/dist/runtime/actors/actor-remote-joiner.js +122 -0
- package/dist/runtime/actors/actor-remote-wire.d.ts +73 -0
- package/dist/runtime/actors/actor-remote-wire.js +84 -0
- package/dist/runtime/actors/actor-retry-delay.d.ts +5 -0
- package/dist/runtime/actors/actor-retry-delay.js +40 -0
- package/dist/runtime/actors/actor-routed-join-transport.d.ts +33 -0
- package/dist/runtime/actors/actor-routed-join-transport.js +2 -0
- package/dist/runtime/actors/actor-routed-json-request.d.ts +11 -0
- package/dist/runtime/actors/actor-routed-json-request.js +39 -0
- package/dist/runtime/actors/actor-runtime-contracts.d.ts +63 -0
- package/dist/runtime/actors/actor-runtime-contracts.js +2 -0
- package/dist/runtime/actors/actor-runtime-state.d.ts +152 -0
- package/dist/runtime/actors/actor-runtime-state.js +545 -0
- package/dist/runtime/actors/actor-source-transfer.d.ts +27 -0
- package/dist/runtime/actors/actor-source-transfer.js +2 -0
- package/dist/runtime/actors/actor-transfer-registry.d.ts +18 -0
- package/dist/runtime/actors/actor-transfer-registry.js +71 -0
- package/dist/runtime/actors/actor-transport-delivery-gate.d.ts +6 -0
- package/dist/runtime/actors/actor-transport-delivery-gate.js +4 -0
- package/dist/runtime/actors/bound-session-wire.d.ts +81 -0
- package/dist/runtime/actors/bound-session-wire.js +184 -0
- package/dist/runtime/actors/deferred-join-accepted-journal.d.ts +47 -0
- package/dist/runtime/actors/deferred-join-accepted-journal.js +962 -0
- package/dist/runtime/actors/index.d.ts +79 -0
- package/dist/runtime/actors/index.js +639 -0
- package/dist/runtime/actors/post-commit-actor-binder.d.ts +18 -0
- package/dist/runtime/actors/post-commit-actor-binder.js +68 -0
- package/dist/runtime/actors/post-commit-actor-location.d.ts +19 -0
- package/dist/runtime/actors/post-commit-actor-location.js +72 -0
- package/dist/runtime/actors/spot-actor-dispatch.d.ts +59 -0
- package/dist/runtime/actors/spot-actor-dispatch.js +179 -0
- package/dist/runtime/actors/transferred-actor-rollback.d.ts +16 -0
- package/dist/runtime/actors/transferred-actor-rollback.js +91 -0
- package/dist/runtime/admission.d.ts +20 -0
- package/dist/runtime/admission.js +166 -0
- package/dist/runtime/application-jobs/application-ingress-record-owner.d.ts +57 -0
- package/dist/runtime/application-jobs/application-ingress-record-owner.js +185 -0
- package/dist/runtime/application-jobs/application-job-queue-handler-start-gate.d.ts +8 -0
- package/dist/runtime/application-jobs/application-job-queue-handler-start-gate.js +8 -0
- package/dist/runtime/application-jobs/application-job-queue-scope.d.ts +17 -0
- package/dist/runtime/application-jobs/application-job-queue-scope.js +57 -0
- package/dist/runtime/application-jobs/contracts.d.ts +19 -0
- package/dist/runtime/application-jobs/contracts.js +2 -0
- package/dist/runtime/application-jobs/receive-flow-controller.d.ts +32 -0
- package/dist/runtime/application-jobs/receive-flow-controller.js +165 -0
- package/dist/runtime/backend/contracts/index.d.ts +487 -0
- package/dist/runtime/backend/contracts/index.js +29 -0
- package/dist/runtime/backend/index.d.ts +9 -0
- package/dist/runtime/backend/index.js +25 -0
- package/dist/runtime/backend/mesh-actor-session-node-adapter.d.ts +3 -0
- package/dist/runtime/backend/mesh-actor-session-node-adapter.js +51 -0
- package/dist/runtime/backend/mesh-completion-table.d.ts +34 -0
- package/dist/runtime/backend/mesh-completion-table.js +124 -0
- package/dist/runtime/backend/mesh-dispatch-pump.d.ts +48 -0
- package/dist/runtime/backend/mesh-dispatch-pump.js +322 -0
- package/dist/runtime/backend/mesh-record-dispatcher.d.ts +19 -0
- package/dist/runtime/backend/mesh-record-dispatcher.js +53 -0
- package/dist/runtime/backend/node/index.d.ts +4 -0
- package/dist/runtime/backend/node/index.js +22 -0
- package/dist/runtime/backend/node/node-backend-adapter-factory.d.ts +12 -0
- package/dist/runtime/backend/node/node-backend-adapter-factory.js +161 -0
- package/dist/runtime/backend/node/node-backend-adapter-support.d.ts +52 -0
- package/dist/runtime/backend/node/node-backend-adapter-support.js +203 -0
- package/dist/runtime/backend/node/node-dealer-channel-client-transport.d.ts +13 -0
- package/dist/runtime/backend/node/node-dealer-channel-client-transport.js +52 -0
- package/dist/runtime/backend/node/node-mesh-backend-adapter.d.ts +11 -0
- package/dist/runtime/backend/node/node-mesh-backend-adapter.js +23 -0
- package/dist/runtime/backend/node/node-monitor-backend-adapter.d.ts +6 -0
- package/dist/runtime/backend/node/node-monitor-backend-adapter.js +38 -0
- package/dist/runtime/backend/node/node-raw-binding-port.d.ts +8 -0
- package/dist/runtime/backend/node/node-raw-binding-port.js +411 -0
- package/dist/runtime/backend/node/node-raw-mesh-backend.d.ts +266 -0
- package/dist/runtime/backend/node/node-raw-mesh-backend.js +1707 -0
- package/dist/runtime/backend/node/node-socket-backend-adapter.d.ts +9 -0
- package/dist/runtime/backend/node/node-socket-backend-adapter.js +286 -0
- package/dist/runtime/backend/node-backend-adapter.d.ts +9 -0
- package/dist/runtime/backend/node-backend-adapter.js +12 -0
- package/dist/runtime/backend/raw-binding-port.d.ts +58 -0
- package/dist/runtime/backend/raw-binding-port.js +2 -0
- package/dist/runtime/backend/runtime-message.d.ts +14 -0
- package/dist/runtime/backend/runtime-message.js +44 -0
- package/dist/runtime/backend/runtime-values.d.ts +78 -0
- package/dist/runtime/backend/runtime-values.js +66 -0
- package/dist/runtime/channels/channel-autoconnect.d.ts +14 -0
- package/dist/runtime/channels/channel-autoconnect.js +23 -0
- package/dist/runtime/channels/channel-clients.d.ts +50 -0
- package/dist/runtime/channels/channel-clients.js +329 -0
- package/dist/runtime/channels/channel-dispatch-pipeline.d.ts +76 -0
- package/dist/runtime/channels/channel-dispatch-pipeline.js +237 -0
- package/dist/runtime/channels/channel-dispatch-services.d.ts +52 -0
- package/dist/runtime/channels/channel-dispatch-services.js +132 -0
- package/dist/runtime/channels/channel-dispatchers.d.ts +125 -0
- package/dist/runtime/channels/channel-dispatchers.js +575 -0
- package/dist/runtime/channels/channel-envelope-inspection.d.ts +25 -0
- package/dist/runtime/channels/channel-envelope-inspection.js +96 -0
- package/dist/runtime/channels/channel-envelope.d.ts +73 -0
- package/dist/runtime/channels/channel-envelope.js +546 -0
- package/dist/runtime/channels/channel-framework-packets.d.ts +2 -0
- package/dist/runtime/channels/channel-framework-packets.js +6 -0
- package/dist/runtime/channels/channel-multipart.d.ts +16 -0
- package/dist/runtime/channels/channel-multipart.js +31 -0
- package/dist/runtime/channels/channel-outbound-operations.d.ts +33 -0
- package/dist/runtime/channels/channel-outbound-operations.js +343 -0
- package/dist/runtime/channels/channel-receive-loops.d.ts +151 -0
- package/dist/runtime/channels/channel-receive-loops.js +728 -0
- package/dist/runtime/channels/channel-receive-task-tracker.d.ts +14 -0
- package/dist/runtime/channels/channel-receive-task-tracker.js +37 -0
- package/dist/runtime/channels/channel-runtime-lifecycle.d.ts +77 -0
- package/dist/runtime/channels/channel-runtime-lifecycle.js +630 -0
- package/dist/runtime/channels/channel-runtime-manager.d.ts +84 -0
- package/dist/runtime/channels/channel-runtime-manager.js +193 -0
- package/dist/runtime/channels/channel-socket-options.d.ts +18 -0
- package/dist/runtime/channels/channel-socket-options.js +119 -0
- package/dist/runtime/channels/channel-socket-registry.d.ts +157 -0
- package/dist/runtime/channels/channel-socket-registry.js +1428 -0
- package/dist/runtime/channels/channel-transports.d.ts +126 -0
- package/dist/runtime/channels/channel-transports.js +448 -0
- package/dist/runtime/channels/client-server-location-runtime.d.ts +41 -0
- package/dist/runtime/channels/client-server-location-runtime.js +465 -0
- package/dist/runtime/channels/client-server-service-wire.d.ts +48 -0
- package/dist/runtime/channels/client-server-service-wire.js +306 -0
- package/dist/runtime/channels/dispatch-error-reporter.d.ts +22 -0
- package/dist/runtime/channels/dispatch-error-reporter.js +133 -0
- package/dist/runtime/channels/fanout-location-runtime.d.ts +38 -0
- package/dist/runtime/channels/fanout-location-runtime.js +356 -0
- package/dist/runtime/channels/fanout-service-wire.d.ts +12 -0
- package/dist/runtime/channels/fanout-service-wire.js +29 -0
- package/dist/runtime/channels/handler-filter-scope.d.ts +8 -0
- package/dist/runtime/channels/handler-filter-scope.js +11 -0
- package/dist/runtime/channels/index.d.ts +9 -0
- package/dist/runtime/channels/index.js +30 -0
- package/dist/runtime/channels/local-spot-route-transport.d.ts +9 -0
- package/dist/runtime/channels/local-spot-route-transport.js +40 -0
- package/dist/runtime/channels/route-disconnected-error.d.ts +3 -0
- package/dist/runtime/channels/route-disconnected-error.js +10 -0
- package/dist/runtime/channels/route-member-snapshot.d.ts +10 -0
- package/dist/runtime/channels/route-member-snapshot.js +55 -0
- package/dist/runtime/channels/router-socket-spot-route-transport.d.ts +12 -0
- package/dist/runtime/channels/router-socket-spot-route-transport.js +43 -0
- package/dist/runtime/channels/source-spot-router.d.ts +10 -0
- package/dist/runtime/channels/source-spot-router.js +46 -0
- package/dist/runtime/channels/spot-direct-envelope.d.ts +5 -0
- package/dist/runtime/channels/spot-direct-envelope.js +29 -0
- package/dist/runtime/channels/spot-node-route-transport.d.ts +13 -0
- package/dist/runtime/channels/spot-node-route-transport.js +60 -0
- package/dist/runtime/channels/spot-route-bridge-transport.d.ts +14 -0
- package/dist/runtime/channels/spot-route-bridge-transport.js +58 -0
- package/dist/runtime/channels/spot-route-dispatch-strategy.d.ts +50 -0
- package/dist/runtime/channels/spot-route-dispatch-strategy.js +128 -0
- package/dist/runtime/channels/spot-route-target-resolver.d.ts +16 -0
- package/dist/runtime/channels/spot-route-target-resolver.js +92 -0
- package/dist/runtime/codecs/index.d.ts +14 -0
- package/dist/runtime/codecs/index.js +44 -0
- package/dist/runtime/configuration/index.d.ts +1 -0
- package/dist/runtime/configuration/index.js +17 -0
- package/dist/runtime/diagnostics/dispatch-error-port.d.ts +8 -0
- package/dist/runtime/diagnostics/dispatch-error-port.js +2 -0
- package/dist/runtime/diagnostics/flow-context.d.ts +21 -0
- package/dist/runtime/diagnostics/flow-context.js +68 -0
- package/dist/runtime/diagnostics/index.d.ts +82 -0
- package/dist/runtime/diagnostics/index.js +335 -0
- package/dist/runtime/diagnostics/internal-event-contracts.d.ts +139 -0
- package/dist/runtime/diagnostics/internal-event-contracts.js +68 -0
- package/dist/runtime/diagnostics/message-flow.d.ts +55 -0
- package/dist/runtime/diagnostics/message-flow.js +420 -0
- package/dist/runtime/diagnostics/runtime-metrics.d.ts +123 -0
- package/dist/runtime/diagnostics/runtime-metrics.js +454 -0
- package/dist/runtime/diagnostics/runtime-observation-queue.d.ts +58 -0
- package/dist/runtime/diagnostics/runtime-observation-queue.js +324 -0
- package/dist/runtime/diagnostics/topology-runtime-projections.d.ts +33 -0
- package/dist/runtime/diagnostics/topology-runtime-projections.js +255 -0
- package/dist/runtime/execution/index.d.ts +114 -0
- package/dist/runtime/execution/index.js +363 -0
- package/dist/runtime/execution/serial-execution-queue.d.ts +94 -0
- package/dist/runtime/execution/serial-execution-queue.js +411 -0
- package/dist/runtime/execution/serial-work-size.d.ts +4 -0
- package/dist/runtime/execution/serial-work-size.js +28 -0
- package/dist/runtime/execution/state-lane.d.ts +28 -0
- package/dist/runtime/execution/state-lane.js +105 -0
- package/dist/runtime/foundation/actor-join-recovery-codec.d.ts +72 -0
- package/dist/runtime/foundation/actor-join-recovery-codec.js +333 -0
- package/dist/runtime/foundation/event-loop-resources.d.ts +37 -0
- package/dist/runtime/foundation/event-loop-resources.js +163 -0
- package/dist/runtime/foundation/index.d.ts +18 -0
- package/dist/runtime/foundation/index.js +34 -0
- package/dist/runtime/foundation/message-follow-suppression-registry.d.ts +38 -0
- package/dist/runtime/foundation/message-follow-suppression-registry.js +89 -0
- package/dist/runtime/foundation/operation-identity.d.ts +12 -0
- package/dist/runtime/foundation/operation-identity.js +33 -0
- package/dist/runtime/foundation/operation-registry.d.ts +42 -0
- package/dist/runtime/foundation/operation-registry.js +146 -0
- package/dist/runtime/foundation/raw-service-mesh-runtime.d.ts +143 -0
- package/dist/runtime/foundation/raw-service-mesh-runtime.js +1349 -0
- package/dist/runtime/foundation/route-mesh-connection-policy.d.ts +3 -0
- package/dist/runtime/foundation/route-mesh-connection-policy.js +13 -0
- package/dist/runtime/foundation/runtime-state-projections.d.ts +13 -0
- package/dist/runtime/foundation/runtime-state-projections.js +44 -0
- package/dist/runtime/foundation/service-authority-payload-codec.d.ts +56 -0
- package/dist/runtime/foundation/service-authority-payload-codec.js +411 -0
- package/dist/runtime/foundation/service-discovery-registry.d.ts +42 -0
- package/dist/runtime/foundation/service-discovery-registry.js +175 -0
- package/dist/runtime/foundation/service-instance-activation-recovery-codec.d.ts +19 -0
- package/dist/runtime/foundation/service-instance-activation-recovery-codec.js +287 -0
- package/dist/runtime/foundation/service-liveness-registry.d.ts +28 -0
- package/dist/runtime/foundation/service-liveness-registry.js +109 -0
- package/dist/runtime/foundation/service-mailbox.d.ts +60 -0
- package/dist/runtime/foundation/service-mailbox.js +283 -0
- package/dist/runtime/foundation/service-maintenance-runtime.d.ts +45 -0
- package/dist/runtime/foundation/service-maintenance-runtime.js +198 -0
- package/dist/runtime/foundation/service-metadata-codec.d.ts +2 -0
- package/dist/runtime/foundation/service-metadata-codec.js +69 -0
- package/dist/runtime/foundation/service-relocation-aggregate-committer.d.ts +35 -0
- package/dist/runtime/foundation/service-relocation-aggregate-committer.js +139 -0
- package/dist/runtime/foundation/service-relocation-coordinator.d.ts +19 -0
- package/dist/runtime/foundation/service-relocation-coordinator.js +16 -0
- package/dist/runtime/foundation/service-relocation-object-owner.d.ts +71 -0
- package/dist/runtime/foundation/service-relocation-object-owner.js +242 -0
- package/dist/runtime/foundation/service-relocation-runtime.d.ts +143 -0
- package/dist/runtime/foundation/service-relocation-runtime.js +1080 -0
- package/dist/runtime/foundation/service-runtime-contracts.d.ts +332 -0
- package/dist/runtime/foundation/service-runtime-contracts.js +66 -0
- package/dist/runtime/foundation/service-session-binding-ingress-port.d.ts +23 -0
- package/dist/runtime/foundation/service-session-binding-ingress-port.js +11 -0
- package/dist/runtime/foundation/service-stateful-registry.d.ts +142 -0
- package/dist/runtime/foundation/service-stateful-registry.js +465 -0
- package/dist/runtime/foundation/service-stateful-runtime.d.ts +393 -0
- package/dist/runtime/foundation/service-stateful-runtime.js +3898 -0
- package/dist/runtime/foundation/service-stateful-wire-codec.d.ts +597 -0
- package/dist/runtime/foundation/service-stateful-wire-codec.js +2006 -0
- package/dist/runtime/foundation/service-topology-registry.d.ts +68 -0
- package/dist/runtime/foundation/service-topology-registry.js +393 -0
- package/dist/runtime/foundation/service-weighted-selection.d.ts +14 -0
- package/dist/runtime/foundation/service-weighted-selection.js +128 -0
- package/dist/runtime/foundation/service-wire-binary-primitives.d.ts +10 -0
- package/dist/runtime/foundation/service-wire-binary-primitives.js +53 -0
- package/dist/runtime/foundation/service-wire-codec.d.ts +22 -0
- package/dist/runtime/foundation/service-wire-codec.js +67 -0
- package/dist/runtime/foundation/service-wire-constants.generated.d.ts +110 -0
- package/dist/runtime/foundation/service-wire-constants.generated.js +132 -0
- package/dist/runtime/foundation/service-wire-m6a-codec.d.ts +102 -0
- package/dist/runtime/foundation/service-wire-m6a-codec.js +568 -0
- package/dist/runtime/framework-errors-internal.d.ts +95 -0
- package/dist/runtime/framework-errors-internal.js +301 -0
- package/dist/runtime/handlers/handler-instance-scope.d.ts +11 -0
- package/dist/runtime/handlers/handler-instance-scope.js +284 -0
- package/dist/runtime/handlers/index.d.ts +13 -0
- package/dist/runtime/handlers/index.js +57 -0
- package/dist/runtime/host/actor-packet-relay.d.ts +60 -0
- package/dist/runtime/host/actor-packet-relay.js +664 -0
- package/dist/runtime/host/actor-placement-coordinator.d.ts +32 -0
- package/dist/runtime/host/actor-placement-coordinator.js +386 -0
- package/dist/runtime/host/actor-runtime-options-factory.d.ts +65 -0
- package/dist/runtime/host/actor-runtime-options-factory.js +160 -0
- package/dist/runtime/host/actor-transfer-authority-runtime.d.ts +26 -0
- package/dist/runtime/host/actor-transfer-authority-runtime.js +138 -0
- package/dist/runtime/host/actor-transfer-runtime.d.ts +149 -0
- package/dist/runtime/host/actor-transfer-runtime.js +1245 -0
- package/dist/runtime/host/application-job-queue.d.ts +99 -0
- package/dist/runtime/host/application-job-queue.js +409 -0
- package/dist/runtime/host/bound-session-relay.d.ts +41 -0
- package/dist/runtime/host/bound-session-relay.js +52 -0
- package/dist/runtime/host/bounded-replay-map.d.ts +12 -0
- package/dist/runtime/host/bounded-replay-map.js +42 -0
- package/dist/runtime/host/channel-runtime-options-factory.d.ts +22 -0
- package/dist/runtime/host/channel-runtime-options-factory.js +76 -0
- package/dist/runtime/host/entry-actor-runtime.d.ts +30 -0
- package/dist/runtime/host/entry-actor-runtime.js +80 -0
- package/dist/runtime/host/host-capacity-status.d.ts +11 -0
- package/dist/runtime/host/host-capacity-status.js +85 -0
- package/dist/runtime/host/index.d.ts +188 -0
- package/dist/runtime/host/index.js +2552 -0
- package/dist/runtime/host/instance-activation-authority.d.ts +33 -0
- package/dist/runtime/host/instance-activation-authority.js +496 -0
- package/dist/runtime/host/location-runtime-owner.d.ts +48 -0
- package/dist/runtime/host/location-runtime-owner.js +227 -0
- package/dist/runtime/host/mesh-router-resolver.d.ts +16 -0
- package/dist/runtime/host/mesh-router-resolver.js +108 -0
- package/dist/runtime/host/relocation-direct-transfer.d.ts +81 -0
- package/dist/runtime/host/relocation-direct-transfer.js +240 -0
- package/dist/runtime/host/relocation-integrity-fault-gate.d.ts +6 -0
- package/dist/runtime/host/relocation-integrity-fault-gate.js +5 -0
- package/dist/runtime/host/relocation-state-adapter.d.ts +8 -0
- package/dist/runtime/host/relocation-state-adapter.js +13 -0
- package/dist/runtime/host/remote-actor-join-receiver.d.ts +47 -0
- package/dist/runtime/host/remote-actor-join-receiver.js +161 -0
- package/dist/runtime/host/remote-actor-packet-target-store.d.ts +29 -0
- package/dist/runtime/host/remote-actor-packet-target-store.js +185 -0
- package/dist/runtime/host/remote-bound-session-relay.d.ts +58 -0
- package/dist/runtime/host/remote-bound-session-relay.js +540 -0
- package/dist/runtime/host/route-mesh-runtime-options.d.ts +9 -0
- package/dist/runtime/host/route-mesh-runtime-options.js +41 -0
- package/dist/runtime/host/route-mesh-runtime.d.ts +76 -0
- package/dist/runtime/host/route-mesh-runtime.js +746 -0
- package/dist/runtime/host/runtime-shutdown.d.ts +33 -0
- package/dist/runtime/host/runtime-shutdown.js +68 -0
- package/dist/runtime/host/service-relocation-control.d.ts +7 -0
- package/dist/runtime/host/service-relocation-control.js +24 -0
- package/dist/runtime/host/service-relocation-host-runtime.d.ts +241 -0
- package/dist/runtime/host/service-relocation-host-runtime.js +4113 -0
- package/dist/runtime/host/spot-address-transport.d.ts +47 -0
- package/dist/runtime/host/spot-address-transport.js +601 -0
- package/dist/runtime/host/spot-node-runtime-options-factory.d.ts +38 -0
- package/dist/runtime/host/spot-node-runtime-options-factory.js +36 -0
- package/dist/runtime/host/spot-runtime-options-factory.d.ts +48 -0
- package/dist/runtime/host/spot-runtime-options-factory.js +169 -0
- package/dist/runtime/host/stateful-authority-route-runtime.d.ts +34 -0
- package/dist/runtime/host/stateful-authority-route-runtime.js +440 -0
- package/dist/runtime/host/user-spot-creation-coordinator.d.ts +69 -0
- package/dist/runtime/host/user-spot-creation-coordinator.js +759 -0
- package/dist/runtime/locations/actor-location-claims.d.ts +43 -0
- package/dist/runtime/locations/actor-location-claims.js +319 -0
- package/dist/runtime/locations/actor-session-route-claims.d.ts +10 -0
- package/dist/runtime/locations/actor-session-route-claims.js +51 -0
- package/dist/runtime/locations/aggregate-inventory-store.d.ts +18 -0
- package/dist/runtime/locations/aggregate-inventory-store.js +399 -0
- package/dist/runtime/locations/authority-key-codec.d.ts +6 -0
- package/dist/runtime/locations/authority-key-codec.js +78 -0
- package/dist/runtime/locations/auto-connect-loop.d.ts +37 -0
- package/dist/runtime/locations/auto-connect-loop.js +112 -0
- package/dist/runtime/locations/auto-connect-planner.d.ts +9 -0
- package/dist/runtime/locations/auto-connect-planner.js +137 -0
- package/dist/runtime/locations/auto-connect-reconciler.d.ts +57 -0
- package/dist/runtime/locations/auto-connect-reconciler.js +358 -0
- package/dist/runtime/locations/auto-connect-types.d.ts +42 -0
- package/dist/runtime/locations/auto-connect-types.js +2 -0
- package/dist/runtime/locations/auto-connect.d.ts +4 -0
- package/dist/runtime/locations/auto-connect.js +20 -0
- package/dist/runtime/locations/canonical-codec.d.ts +7 -0
- package/dist/runtime/locations/canonical-codec.js +48 -0
- package/dist/runtime/locations/domain-store-contract.d.ts +34 -0
- package/dist/runtime/locations/domain-store-contract.js +2 -0
- package/dist/runtime/locations/in-memory-authority-store.d.ts +51 -0
- package/dist/runtime/locations/in-memory-authority-store.js +895 -0
- package/dist/runtime/locations/in-memory-location-store.d.ts +78 -0
- package/dist/runtime/locations/in-memory-location-store.js +1008 -0
- package/dist/runtime/locations/in-memory-provider-location-store.d.ts +19 -0
- package/dist/runtime/locations/in-memory-provider-location-store.js +183 -0
- package/dist/runtime/locations/index.d.ts +11 -0
- package/dist/runtime/locations/index.js +27 -0
- package/dist/runtime/locations/internal-location-contracts.d.ts +7 -0
- package/dist/runtime/locations/internal-location-contracts.js +21 -0
- package/dist/runtime/locations/internal-store-contracts.d.ts +35 -0
- package/dist/runtime/locations/internal-store-contracts.js +2 -0
- package/dist/runtime/locations/key-codec.d.ts +13 -0
- package/dist/runtime/locations/key-codec.js +41 -0
- package/dist/runtime/locations/lease-tracker.d.ts +36 -0
- package/dist/runtime/locations/lease-tracker.js +155 -0
- package/dist/runtime/locations/lifecycle-runtime.d.ts +19 -0
- package/dist/runtime/locations/lifecycle-runtime.js +2 -0
- package/dist/runtime/locations/lifecycle.d.ts +40 -0
- package/dist/runtime/locations/lifecycle.js +120 -0
- package/dist/runtime/locations/location-store-repository.d.ts +72 -0
- package/dist/runtime/locations/location-store-repository.js +3198 -0
- package/dist/runtime/locations/relocation-blob.d.ts +7 -0
- package/dist/runtime/locations/relocation-blob.js +24 -0
- package/dist/runtime/locations/resolvers.d.ts +145 -0
- package/dist/runtime/locations/resolvers.js +693 -0
- package/dist/runtime/locations/runtime.d.ts +144 -0
- package/dist/runtime/locations/runtime.js +792 -0
- package/dist/runtime/locations/spot-location-claims.d.ts +36 -0
- package/dist/runtime/locations/spot-location-claims.js +305 -0
- package/dist/runtime/messaging/creation-payload-codec.d.ts +4 -0
- package/dist/runtime/messaging/creation-payload-codec.js +40 -0
- package/dist/runtime/messaging/framework-json-v1.d.ts +7 -0
- package/dist/runtime/messaging/framework-json-v1.js +296 -0
- package/dist/runtime/messaging/index.d.ts +1 -0
- package/dist/runtime/messaging/index.js +2 -0
- package/dist/runtime/messaging/packet-name.d.ts +4 -0
- package/dist/runtime/messaging/packet-name.js +79 -0
- package/dist/runtime/messaging/payload-codec.d.ts +25 -0
- package/dist/runtime/messaging/payload-codec.js +255 -0
- package/dist/runtime/messaging/submission-result.d.ts +15 -0
- package/dist/runtime/messaging/submission-result.js +37 -0
- package/dist/runtime/protocol/service_wire_pilot_codec.generated.d.ts +395 -0
- package/dist/runtime/protocol/service_wire_pilot_codec.generated.js +645 -0
- package/dist/runtime/routing-id.d.ts +8 -0
- package/dist/runtime/routing-id.js +112 -0
- package/dist/runtime/spots/formal-remote-actor-admission-registry.d.ts +124 -0
- package/dist/runtime/spots/formal-remote-actor-admission-registry.js +269 -0
- package/dist/runtime/spots/formal-remote-actor-transfer-registry.d.ts +33 -0
- package/dist/runtime/spots/formal-remote-actor-transfer-registry.js +94 -0
- package/dist/runtime/spots/index.d.ts +247 -0
- package/dist/runtime/spots/index.js +2090 -0
- package/dist/runtime/spots/spot-activation-registry.d.ts +47 -0
- package/dist/runtime/spots/spot-activation-registry.js +272 -0
- package/dist/runtime/spots/spot-activation-state.d.ts +104 -0
- package/dist/runtime/spots/spot-activation-state.js +288 -0
- package/dist/runtime/spots/spot-activation.d.ts +89 -0
- package/dist/runtime/spots/spot-activation.js +601 -0
- package/dist/runtime/spots/spot-actor-admission-coordinator.d.ts +20 -0
- package/dist/runtime/spots/spot-actor-admission-coordinator.js +194 -0
- package/dist/runtime/spots/spot-actor-join-dispatch.d.ts +83 -0
- package/dist/runtime/spots/spot-actor-join-dispatch.js +185 -0
- package/dist/runtime/spots/spot-actor-lifecycle-drain.d.ts +22 -0
- package/dist/runtime/spots/spot-actor-lifecycle-drain.js +51 -0
- package/dist/runtime/spots/spot-actor-membership.d.ts +39 -0
- package/dist/runtime/spots/spot-actor-membership.js +179 -0
- package/dist/runtime/spots/spot-actor-packet-dispatch.d.ts +91 -0
- package/dist/runtime/spots/spot-actor-packet-dispatch.js +315 -0
- package/dist/runtime/spots/spot-actor-packet-drain.d.ts +40 -0
- package/dist/runtime/spots/spot-actor-packet-drain.js +235 -0
- package/dist/runtime/spots/spot-actor-packet-relay-dispatch.d.ts +18 -0
- package/dist/runtime/spots/spot-actor-packet-relay-dispatch.js +110 -0
- package/dist/runtime/spots/spot-closing.d.ts +2 -0
- package/dist/runtime/spots/spot-closing.js +30 -0
- package/dist/runtime/spots/spot-context.d.ts +46 -0
- package/dist/runtime/spots/spot-context.js +113 -0
- package/dist/runtime/spots/spot-entry-activation.d.ts +107 -0
- package/dist/runtime/spots/spot-entry-activation.js +342 -0
- package/dist/runtime/spots/spot-handle.d.ts +28 -0
- package/dist/runtime/spots/spot-handle.js +38 -0
- package/dist/runtime/spots/spot-handler-registry.d.ts +52 -0
- package/dist/runtime/spots/spot-handler-registry.js +155 -0
- package/dist/runtime/spots/spot-lifecycle-metrics.d.ts +8 -0
- package/dist/runtime/spots/spot-lifecycle-metrics.js +16 -0
- package/dist/runtime/spots/spot-location-claim.d.ts +25 -0
- package/dist/runtime/spots/spot-location-claim.js +55 -0
- package/dist/runtime/spots/spot-manager-internal-contracts.d.ts +10 -0
- package/dist/runtime/spots/spot-manager-internal-contracts.js +2 -0
- package/dist/runtime/spots/spot-manager-public.d.ts +32 -0
- package/dist/runtime/spots/spot-manager-public.js +219 -0
- package/dist/runtime/spots/spot-native-actor-join-admission.d.ts +26 -0
- package/dist/runtime/spots/spot-native-actor-join-admission.js +105 -0
- package/dist/runtime/spots/spot-native-flags.d.ts +2 -0
- package/dist/runtime/spots/spot-native-flags.js +5 -0
- package/dist/runtime/spots/spot-node-autoconnect.d.ts +23 -0
- package/dist/runtime/spots/spot-node-autoconnect.js +246 -0
- package/dist/runtime/spots/spot-node-runtime-manager.d.ts +137 -0
- package/dist/runtime/spots/spot-node-runtime-manager.js +1111 -0
- package/dist/runtime/spots/spot-outbound.d.ts +78 -0
- package/dist/runtime/spots/spot-outbound.js +460 -0
- package/dist/runtime/spots/spot-provider.d.ts +4 -0
- package/dist/runtime/spots/spot-provider.js +28 -0
- package/dist/runtime/spots/spot-publisher-transport.d.ts +14 -0
- package/dist/runtime/spots/spot-publisher-transport.js +28 -0
- package/dist/runtime/spots/spot-remote-codec.d.ts +50 -0
- package/dist/runtime/spots/spot-remote-codec.js +190 -0
- package/dist/runtime/spots/spot-remote-route-codec.d.ts +47 -0
- package/dist/runtime/spots/spot-remote-route-codec.js +168 -0
- package/dist/runtime/spots/spot-route-packet-dispatch.d.ts +25 -0
- package/dist/runtime/spots/spot-route-packet-dispatch.js +238 -0
- package/dist/runtime/spots/spot-route-replies.d.ts +17 -0
- package/dist/runtime/spots/spot-route-replies.js +76 -0
- package/dist/runtime/spots/spot-route-reply-wire.d.ts +10 -0
- package/dist/runtime/spots/spot-route-reply-wire.js +6 -0
- package/dist/runtime/spots/spot-routed-actor-admission.d.ts +36 -0
- package/dist/runtime/spots/spot-routed-actor-admission.js +240 -0
- package/dist/runtime/spots/spot-routed-bound-session-dispatch.d.ts +19 -0
- package/dist/runtime/spots/spot-routed-bound-session-dispatch.js +46 -0
- package/dist/runtime/spots/spot-routed-frame-dispatch.d.ts +54 -0
- package/dist/runtime/spots/spot-routed-frame-dispatch.js +162 -0
- package/dist/runtime/spots/spot-routed-spot-packet-dispatch.d.ts +43 -0
- package/dist/runtime/spots/spot-routed-spot-packet-dispatch.js +152 -0
- package/dist/runtime/spots/spot-routing-internal.d.ts +28 -0
- package/dist/runtime/spots/spot-routing-internal.js +2 -0
- package/dist/runtime/spots/spot-runtime-ports.d.ts +64 -0
- package/dist/runtime/spots/spot-runtime-ports.js +2 -0
- package/dist/runtime/spots/spot-serial-executor.d.ts +38 -0
- package/dist/runtime/spots/spot-serial-executor.js +133 -0
- package/dist/runtime/spots/spot-serial-turn-executor.d.ts +54 -0
- package/dist/runtime/spots/spot-serial-turn-executor.js +219 -0
- package/dist/runtime/spots/spot-subscription-dispatch.d.ts +32 -0
- package/dist/runtime/spots/spot-subscription-dispatch.js +194 -0
- package/dist/runtime/spots/spot-timer.d.ts +110 -0
- package/dist/runtime/spots/spot-timer.js +419 -0
- package/dist/runtime/streams/actor-session-binding-registry.d.ts +193 -0
- package/dist/runtime/streams/actor-session-binding-registry.js +1127 -0
- package/dist/runtime/streams/actor-session-binding-runtime-owner.d.ts +20 -0
- package/dist/runtime/streams/actor-session-binding-runtime-owner.js +19 -0
- package/dist/runtime/streams/actor-session-lifecycle-coordinator.d.ts +4 -0
- package/dist/runtime/streams/actor-session-lifecycle-coordinator.js +24 -0
- package/dist/runtime/streams/bound-actor-relay-sender.d.ts +29 -0
- package/dist/runtime/streams/bound-actor-relay-sender.js +181 -0
- package/dist/runtime/streams/bound-session-response-target.d.ts +25 -0
- package/dist/runtime/streams/bound-session-response-target.js +54 -0
- package/dist/runtime/streams/bound-session-service.d.ts +48 -0
- package/dist/runtime/streams/bound-session-service.js +201 -0
- package/dist/runtime/streams/index.d.ts +152 -0
- package/dist/runtime/streams/index.js +338 -0
- package/dist/runtime/streams/managed-stream.d.ts +53 -0
- package/dist/runtime/streams/managed-stream.js +329 -0
- package/dist/runtime/streams/native-fallback-bound-session.d.ts +24 -0
- package/dist/runtime/streams/native-fallback-bound-session.js +201 -0
- package/dist/runtime/streams/protocol.d.ts +67 -0
- package/dist/runtime/streams/protocol.js +244 -0
- package/dist/runtime/streams/session-actor-coordinator.d.ts +56 -0
- package/dist/runtime/streams/session-actor-coordinator.js +371 -0
- package/dist/runtime/streams/session-calls.d.ts +59 -0
- package/dist/runtime/streams/session-calls.js +123 -0
- package/dist/runtime/streams/session-context.d.ts +108 -0
- package/dist/runtime/streams/session-context.js +377 -0
- package/dist/runtime/streams/session-local-actors.d.ts +10 -0
- package/dist/runtime/streams/session-local-actors.js +26 -0
- package/dist/runtime/streams/session-provider.d.ts +4 -0
- package/dist/runtime/streams/session-provider.js +30 -0
- package/dist/runtime/streams/session-requests.d.ts +25 -0
- package/dist/runtime/streams/session-requests.js +100 -0
- package/dist/runtime/streams/session-serial-executor.d.ts +12 -0
- package/dist/runtime/streams/session-serial-executor.js +58 -0
- package/dist/runtime/streams/stream-binding-runtime-ports.d.ts +62 -0
- package/dist/runtime/streams/stream-binding-runtime-ports.js +2 -0
- package/dist/runtime/streams/stream-frame-factory.d.ts +44 -0
- package/dist/runtime/streams/stream-frame-factory.js +149 -0
- package/dist/runtime/streams/stream-message-utils.d.ts +5 -0
- package/dist/runtime/streams/stream-message-utils.js +74 -0
- package/dist/runtime/streams/stream-session-runtime.d.ts +166 -0
- package/dist/runtime/streams/stream-session-runtime.js +1144 -0
- package/dist/runtime/workers/index.d.ts +38 -0
- package/dist/runtime/workers/index.js +474 -0
- package/package.json +19 -0
- package/src/contracts/Actors/ZLinkActor.ts +8 -0
- package/src/contracts/Actors/ZLinkActorClient.ts +18 -0
- package/src/contracts/Actors/ZLinkActorContext.ts +15 -0
- package/src/contracts/Actors/ZLinkActorFactory.ts +41 -0
- package/src/contracts/Actors/ZLinkActorManager.ts +31 -0
- package/src/contracts/Actors/index.ts +5 -0
- package/src/contracts/Channels/Calls.ts +33 -0
- package/src/contracts/Channels/IZLinkChannelClient.ts +6 -0
- package/src/contracts/Channels/IZLinkFanoutClient.ts +13 -0
- package/src/contracts/Channels/RouteCalls.ts +13 -0
- package/src/contracts/Channels/index.ts +4 -0
- package/src/contracts/Codecs/IZLinkCodecRegistryBuilder.ts +22 -0
- package/src/contracts/Codecs/ZLinkMessageSerializer.ts +6 -0
- package/src/contracts/Codecs/index.ts +2 -0
- package/src/contracts/Common/ActorRef.ts +8 -0
- package/src/contracts/Common/CoreTypes.ts +6 -0
- package/src/contracts/Common/Message.ts +9 -0
- package/src/contracts/Common/ZLinkEncodedPayload.ts +47 -0
- package/src/contracts/Common/ZLinkMessage.ts +135 -0
- package/src/contracts/Common/ZLinkMessageMetadata.ts +77 -0
- package/src/contracts/Common/ZLinkProviderResolver.ts +6 -0
- package/src/contracts/Common/encoded-payload-storage.ts +16 -0
- package/src/contracts/Common/index.ts +5 -0
- package/src/contracts/Configuration/Builders.ts +200 -0
- package/src/contracts/Configuration/CodecContentType.ts +68 -0
- package/src/contracts/Configuration/CodecSerializerSelection.ts +28 -0
- package/src/contracts/Configuration/Configs.ts +27 -0
- package/src/contracts/Configuration/ConfigurationException.ts +6 -0
- package/src/contracts/Configuration/Connections.ts +5 -0
- package/src/contracts/Configuration/DiagnosticsValidation.ts +25 -0
- package/src/contracts/Configuration/EndpointNotation.ts +232 -0
- package/src/contracts/Configuration/InternalDefaults.ts +13 -0
- package/src/contracts/Configuration/ObjectRoles.ts +47 -0
- package/src/contracts/Configuration/Registration.ts +191 -0
- package/src/contracts/Configuration/RegistrationBuilderPolicy.ts +76 -0
- package/src/contracts/Configuration/RegistrationBuilders.ts +1705 -0
- package/src/contracts/Configuration/RegistrationCodecRegistry.ts +118 -0
- package/src/contracts/Configuration/RegistrationNormalizers.ts +404 -0
- package/src/contracts/Configuration/RegistrationTypes.ts +499 -0
- package/src/contracts/Configuration/RegistrationValidators.ts +698 -0
- package/src/contracts/Configuration/RouteChannelInternalState.ts +50 -0
- package/src/contracts/Configuration/RuntimeEndpointConnections.ts +91 -0
- package/src/contracts/Configuration/SendTimeoutValidation.ts +15 -0
- package/src/contracts/Configuration/TimerRegistrationValidator.ts +37 -0
- package/src/contracts/Configuration/index.ts +35 -0
- package/src/contracts/Dispatch/ZLinkDispatchOptions.ts +222 -0
- package/src/contracts/Dispatch/ZLinkFlowOrigin.ts +1 -0
- package/src/contracts/Dispatch/index.ts +2 -0
- package/src/contracts/Errors/ZLinkFrameworkException.ts +27 -0
- package/src/contracts/Errors/index.ts +4 -0
- package/src/contracts/Eventing/Metrics.ts +27 -0
- package/src/contracts/Eventing/index.ts +1 -0
- package/src/contracts/Handlers/Attributes.ts +111 -0
- package/src/contracts/Handlers/Contexts.ts +21 -0
- package/src/contracts/Handlers/IZLinkChannelHandlers.ts +69 -0
- package/src/contracts/Handlers/IZLinkHandlerFilter.ts +22 -0
- package/src/contracts/Handlers/JsonContract.ts +172 -0
- package/src/contracts/Handlers/ZLinkHandlerFilterNext.ts +1 -0
- package/src/contracts/Handlers/index.ts +17 -0
- package/src/contracts/Locations/ActorTransfer.ts +84 -0
- package/src/contracts/Locations/Authority.ts +308 -0
- package/src/contracts/Locations/Diagnostics.ts +48 -0
- package/src/contracts/Locations/Keys.ts +93 -0
- package/src/contracts/Locations/Models.ts +7 -0
- package/src/contracts/Locations/Options.ts +42 -0
- package/src/contracts/Locations/Readiness.ts +11 -0
- package/src/contracts/Locations/RelocationStore.ts +51 -0
- package/src/contracts/Locations/Resolvers.ts +8 -0
- package/src/contracts/Locations/Rows.ts +164 -0
- package/src/contracts/Locations/RuntimeQuery.ts +56 -0
- package/src/contracts/Locations/Stores.ts +92 -0
- package/src/contracts/Locations/Values.ts +32 -0
- package/src/contracts/Locations/Watch.ts +16 -0
- package/src/contracts/Locations/Writes.ts +56 -0
- package/src/contracts/Locations/index.ts +48 -0
- package/src/contracts/RouteMesh/Contracts.ts +145 -0
- package/src/contracts/RouteMesh/RuntimeTopology.ts +201 -0
- package/src/contracts/RouteMesh/index.ts +2 -0
- package/src/contracts/Spots/Builders.ts +11 -0
- package/src/contracts/Spots/Contracts.ts +150 -0
- package/src/contracts/Spots/SpotKind.ts +24 -0
- package/src/contracts/Spots/ZLinkSpot.ts +88 -0
- package/src/contracts/Spots/index.ts +3 -0
- package/src/contracts/Streams/BoundSessionContracts.ts +9 -0
- package/src/contracts/Streams/IZLinkSession.ts +52 -0
- package/src/contracts/Streams/IZLinkSessionActor.ts +17 -0
- package/src/contracts/Streams/IZLinkSessionPacketHandler.ts +11 -0
- package/src/contracts/Streams/IZLinkStream.ts +10 -0
- package/src/contracts/Streams/ZLinkMessageMetadata.ts +1 -0
- package/src/contracts/Streams/ZLinkStreamCompression.ts +9 -0
- package/src/contracts/Streams/ZLinkStreamError.ts +9 -0
- package/src/contracts/Streams/index.ts +8 -0
- package/src/contracts/Timers/IZLinkTimer.ts +5 -0
- package/src/contracts/Timers/ZLinkTimerOptions.ts +11 -0
- package/src/contracts/Timers/ZLinkTimerTick.ts +12 -0
- package/src/contracts/Timers/index.ts +3 -0
- package/src/contracts/index.ts +71 -0
- package/src/index.ts +1 -0
- package/src/internal.ts +29 -0
- package/src/location-store-integration.ts +51 -0
- package/src/nest-integration.ts +251 -0
- package/src/runtime/abort.ts +70 -0
- package/src/runtime/actors/actor-authority-payload-codec.ts +454 -0
- package/src/runtime/actors/actor-authority-publication.ts +277 -0
- package/src/runtime/actors/actor-client.ts +1018 -0
- package/src/runtime/actors/actor-context.ts +583 -0
- package/src/runtime/actors/actor-creation.ts +254 -0
- package/src/runtime/actors/actor-execution-context.ts +38 -0
- package/src/runtime/actors/actor-handoff.ts +1911 -0
- package/src/runtime/actors/actor-join-deferred-scope.ts +183 -0
- package/src/runtime/actors/actor-join-relocation.ts +39 -0
- package/src/runtime/actors/actor-lifecycle-snapshot.ts +90 -0
- package/src/runtime/actors/actor-local-native-join.ts +725 -0
- package/src/runtime/actors/actor-mailbox.ts +92 -0
- package/src/runtime/actors/actor-message-follow-context.ts +347 -0
- package/src/runtime/actors/actor-native-lookup.ts +38 -0
- package/src/runtime/actors/actor-packet-relay-wire.ts +223 -0
- package/src/runtime/actors/actor-remote-joiner.ts +238 -0
- package/src/runtime/actors/actor-remote-wire.ts +169 -0
- package/src/runtime/actors/actor-retry-delay.ts +37 -0
- package/src/runtime/actors/actor-routed-join-transport.ts +58 -0
- package/src/runtime/actors/actor-routed-json-request.ts +44 -0
- package/src/runtime/actors/actor-runtime-contracts.ts +126 -0
- package/src/runtime/actors/actor-runtime-state.ts +805 -0
- package/src/runtime/actors/actor-source-transfer.ts +62 -0
- package/src/runtime/actors/actor-transfer-registry.ts +112 -0
- package/src/runtime/actors/actor-transport-delivery-gate.ts +17 -0
- package/src/runtime/actors/bound-session-wire.ts +257 -0
- package/src/runtime/actors/deferred-join-accepted-journal.ts +1319 -0
- package/src/runtime/actors/index.ts +972 -0
- package/src/runtime/actors/post-commit-actor-binder.ts +70 -0
- package/src/runtime/actors/post-commit-actor-location.ts +114 -0
- package/src/runtime/actors/spot-actor-dispatch.ts +362 -0
- package/src/runtime/actors/transferred-actor-rollback.ts +123 -0
- package/src/runtime/admission.ts +192 -0
- package/src/runtime/application-jobs/application-ingress-record-owner.ts +216 -0
- package/src/runtime/application-jobs/application-job-queue-handler-start-gate.ts +10 -0
- package/src/runtime/application-jobs/application-job-queue-scope.ts +64 -0
- package/src/runtime/application-jobs/contracts.ts +26 -0
- package/src/runtime/application-jobs/receive-flow-controller.ts +188 -0
- package/src/runtime/backend/contracts/index.ts +765 -0
- package/src/runtime/backend/index.ts +9 -0
- package/src/runtime/backend/mesh-actor-session-node-adapter.ts +73 -0
- package/src/runtime/backend/mesh-completion-table.ts +165 -0
- package/src/runtime/backend/mesh-dispatch-pump.ts +363 -0
- package/src/runtime/backend/mesh-record-dispatcher.ts +65 -0
- package/src/runtime/backend/node/index.ts +4 -0
- package/src/runtime/backend/node/node-backend-adapter-factory.ts +204 -0
- package/src/runtime/backend/node/node-backend-adapter-support.ts +257 -0
- package/src/runtime/backend/node/node-dealer-channel-client-transport.ts +133 -0
- package/src/runtime/backend/node/node-mesh-backend-adapter.ts +44 -0
- package/src/runtime/backend/node/node-monitor-backend-adapter.ts +39 -0
- package/src/runtime/backend/node/node-raw-binding-port.contract.ts +21 -0
- package/src/runtime/backend/node/node-raw-binding-port.ts +518 -0
- package/src/runtime/backend/node/node-raw-mesh-backend.ts +2669 -0
- package/src/runtime/backend/node/node-socket-backend-adapter.ts +372 -0
- package/src/runtime/backend/node-backend-adapter.ts +19 -0
- package/src/runtime/backend/raw-binding-port.ts +69 -0
- package/src/runtime/backend/runtime-message.ts +51 -0
- package/src/runtime/backend/runtime-values.ts +107 -0
- package/src/runtime/channels/channel-autoconnect.ts +46 -0
- package/src/runtime/channels/channel-clients.ts +527 -0
- package/src/runtime/channels/channel-dispatch-pipeline.ts +408 -0
- package/src/runtime/channels/channel-dispatch-services.ts +234 -0
- package/src/runtime/channels/channel-dispatchers.ts +790 -0
- package/src/runtime/channels/channel-envelope-inspection.ts +125 -0
- package/src/runtime/channels/channel-envelope.ts +743 -0
- package/src/runtime/channels/channel-framework-packets.ts +8 -0
- package/src/runtime/channels/channel-multipart.ts +61 -0
- package/src/runtime/channels/channel-outbound-operations.ts +584 -0
- package/src/runtime/channels/channel-receive-loops.ts +901 -0
- package/src/runtime/channels/channel-receive-task-tracker.ts +39 -0
- package/src/runtime/channels/channel-runtime-lifecycle.ts +969 -0
- package/src/runtime/channels/channel-runtime-manager.ts +444 -0
- package/src/runtime/channels/channel-socket-options.ts +153 -0
- package/src/runtime/channels/channel-socket-registry.ts +1837 -0
- package/src/runtime/channels/channel-transports.ts +1154 -0
- package/src/runtime/channels/client-server-location-runtime.ts +576 -0
- package/src/runtime/channels/client-server-service-wire.ts +390 -0
- package/src/runtime/channels/dispatch-error-reporter.ts +165 -0
- package/src/runtime/channels/fanout-location-runtime.ts +459 -0
- package/src/runtime/channels/fanout-service-wire.ts +43 -0
- package/src/runtime/channels/handler-filter-scope.ts +29 -0
- package/src/runtime/channels/index.ts +45 -0
- package/src/runtime/channels/local-spot-route-transport.ts +59 -0
- package/src/runtime/channels/route-disconnected-error.ts +6 -0
- package/src/runtime/channels/route-member-snapshot.ts +55 -0
- package/src/runtime/channels/router-socket-spot-route-transport.ts +77 -0
- package/src/runtime/channels/source-spot-router.ts +89 -0
- package/src/runtime/channels/spot-direct-envelope.ts +44 -0
- package/src/runtime/channels/spot-node-route-transport.ts +92 -0
- package/src/runtime/channels/spot-route-bridge-transport.ts +75 -0
- package/src/runtime/channels/spot-route-dispatch-strategy.ts +329 -0
- package/src/runtime/channels/spot-route-target-resolver.ts +101 -0
- package/src/runtime/codecs/index.ts +69 -0
- package/src/runtime/configuration/index.ts +1 -0
- package/src/runtime/diagnostics/dispatch-error-port.ts +8 -0
- package/src/runtime/diagnostics/flow-context.ts +84 -0
- package/src/runtime/diagnostics/index.ts +441 -0
- package/src/runtime/diagnostics/internal-event-contracts.ts +135 -0
- package/src/runtime/diagnostics/message-flow.ts +560 -0
- package/src/runtime/diagnostics/runtime-metrics.ts +601 -0
- package/src/runtime/diagnostics/runtime-observation-queue.ts +362 -0
- package/src/runtime/diagnostics/topology-runtime-projections.ts +298 -0
- package/src/runtime/execution/index.ts +466 -0
- package/src/runtime/execution/serial-execution-queue.ts +534 -0
- package/src/runtime/execution/serial-work-size.ts +31 -0
- package/src/runtime/execution/state-lane.ts +116 -0
- package/src/runtime/foundation/actor-join-recovery-codec.ts +465 -0
- package/src/runtime/foundation/event-loop-resources.ts +162 -0
- package/src/runtime/foundation/index.ts +18 -0
- package/src/runtime/foundation/message-follow-suppression-registry.ts +130 -0
- package/src/runtime/foundation/operation-identity.ts +49 -0
- package/src/runtime/foundation/operation-registry.ts +162 -0
- package/src/runtime/foundation/raw-service-mesh-runtime.ts +1771 -0
- package/src/runtime/foundation/route-mesh-connection-policy.ts +28 -0
- package/src/runtime/foundation/runtime-state-projections.ts +68 -0
- package/src/runtime/foundation/service-authority-payload-codec.ts +566 -0
- package/src/runtime/foundation/service-discovery-registry.ts +263 -0
- package/src/runtime/foundation/service-instance-activation-recovery-codec.ts +329 -0
- package/src/runtime/foundation/service-liveness-registry.ts +144 -0
- package/src/runtime/foundation/service-mailbox.ts +369 -0
- package/src/runtime/foundation/service-maintenance-runtime.ts +242 -0
- package/src/runtime/foundation/service-metadata-codec.ts +75 -0
- package/src/runtime/foundation/service-relocation-aggregate-committer.ts +218 -0
- package/src/runtime/foundation/service-relocation-coordinator.ts +37 -0
- package/src/runtime/foundation/service-relocation-object-owner.ts +428 -0
- package/src/runtime/foundation/service-relocation-runtime.ts +1407 -0
- package/src/runtime/foundation/service-runtime-contracts.ts +423 -0
- package/src/runtime/foundation/service-session-binding-ingress-port.ts +45 -0
- package/src/runtime/foundation/service-stateful-registry.ts +664 -0
- package/src/runtime/foundation/service-stateful-runtime.ts +5753 -0
- package/src/runtime/foundation/service-stateful-wire-codec.ts +3008 -0
- package/src/runtime/foundation/service-topology-registry.ts +599 -0
- package/src/runtime/foundation/service-weighted-selection.ts +166 -0
- package/src/runtime/foundation/service-wire-binary-primitives.ts +80 -0
- package/src/runtime/foundation/service-wire-codec.ts +91 -0
- package/src/runtime/foundation/service-wire-constants.generated.ts +131 -0
- package/src/runtime/foundation/service-wire-m6a-codec.ts +647 -0
- package/src/runtime/framework-errors-internal.ts +338 -0
- package/src/runtime/handlers/handler-instance-scope.ts +372 -0
- package/src/runtime/handlers/index.ts +93 -0
- package/src/runtime/host/actor-packet-relay.ts +1070 -0
- package/src/runtime/host/actor-placement-coordinator.ts +573 -0
- package/src/runtime/host/actor-runtime-options-factory.ts +282 -0
- package/src/runtime/host/actor-transfer-authority-runtime.ts +225 -0
- package/src/runtime/host/actor-transfer-runtime.ts +1958 -0
- package/src/runtime/host/application-job-queue.ts +518 -0
- package/src/runtime/host/bound-session-relay.ts +94 -0
- package/src/runtime/host/bounded-replay-map.ts +42 -0
- package/src/runtime/host/channel-runtime-options-factory.ts +104 -0
- package/src/runtime/host/entry-actor-runtime.ts +115 -0
- package/src/runtime/host/host-capacity-status.ts +103 -0
- package/src/runtime/host/index.ts +3492 -0
- package/src/runtime/host/instance-activation-authority.ts +658 -0
- package/src/runtime/host/location-runtime-owner.ts +313 -0
- package/src/runtime/host/mesh-router-resolver.ts +114 -0
- package/src/runtime/host/relocation-direct-transfer.ts +273 -0
- package/src/runtime/host/relocation-integrity-fault-gate.ts +8 -0
- package/src/runtime/host/relocation-state-adapter.ts +24 -0
- package/src/runtime/host/remote-actor-join-receiver.ts +264 -0
- package/src/runtime/host/remote-actor-packet-target-store.ts +244 -0
- package/src/runtime/host/remote-bound-session-relay.ts +900 -0
- package/src/runtime/host/route-mesh-runtime-options.ts +46 -0
- package/src/runtime/host/route-mesh-runtime.ts +891 -0
- package/src/runtime/host/runtime-shutdown.ts +101 -0
- package/src/runtime/host/service-relocation-control.ts +28 -0
- package/src/runtime/host/service-relocation-host-runtime.ts +5817 -0
- package/src/runtime/host/spot-address-transport.ts +997 -0
- package/src/runtime/host/spot-node-runtime-options-factory.ts +82 -0
- package/src/runtime/host/spot-runtime-options-factory.ts +286 -0
- package/src/runtime/host/stateful-authority-route-runtime.ts +662 -0
- package/src/runtime/host/user-spot-creation-coordinator.ts +1176 -0
- package/src/runtime/locations/actor-location-claims.ts +426 -0
- package/src/runtime/locations/actor-session-route-claims.ts +64 -0
- package/src/runtime/locations/aggregate-inventory-store.ts +581 -0
- package/src/runtime/locations/authority-key-codec.ts +80 -0
- package/src/runtime/locations/auto-connect-loop.ts +131 -0
- package/src/runtime/locations/auto-connect-planner.ts +178 -0
- package/src/runtime/locations/auto-connect-reconciler.ts +425 -0
- package/src/runtime/locations/auto-connect-types.ts +62 -0
- package/src/runtime/locations/auto-connect.ts +4 -0
- package/src/runtime/locations/canonical-codec.ts +54 -0
- package/src/runtime/locations/domain-store-contract.ts +149 -0
- package/src/runtime/locations/in-memory-authority-store.ts +1172 -0
- package/src/runtime/locations/in-memory-location-store.ts +1467 -0
- package/src/runtime/locations/in-memory-provider-location-store.ts +213 -0
- package/src/runtime/locations/index.ts +11 -0
- package/src/runtime/locations/internal-location-contracts.ts +22 -0
- package/src/runtime/locations/internal-store-contracts.ts +90 -0
- package/src/runtime/locations/key-codec.ts +61 -0
- package/src/runtime/locations/lease-tracker.ts +221 -0
- package/src/runtime/locations/lifecycle-runtime.ts +44 -0
- package/src/runtime/locations/lifecycle.ts +272 -0
- package/src/runtime/locations/location-store-repository.ts +4211 -0
- package/src/runtime/locations/relocation-blob.ts +36 -0
- package/src/runtime/locations/resolvers.ts +1054 -0
- package/src/runtime/locations/runtime.ts +1126 -0
- package/src/runtime/locations/spot-location-claims.ts +435 -0
- package/src/runtime/messaging/creation-payload-codec.ts +59 -0
- package/src/runtime/messaging/framework-json-v1.ts +307 -0
- package/src/runtime/messaging/index.ts +1 -0
- package/src/runtime/messaging/packet-name.ts +94 -0
- package/src/runtime/messaging/payload-codec.ts +418 -0
- package/src/runtime/messaging/submission-result.ts +61 -0
- package/src/runtime/protocol/service_wire_pilot_codec.generated.ts +189 -0
- package/src/runtime/routing-id.ts +125 -0
- package/src/runtime/spots/formal-remote-actor-admission-registry.ts +418 -0
- package/src/runtime/spots/formal-remote-actor-transfer-registry.ts +147 -0
- package/src/runtime/spots/index.ts +3303 -0
- package/src/runtime/spots/spot-activation-registry.ts +335 -0
- package/src/runtime/spots/spot-activation-state.ts +414 -0
- package/src/runtime/spots/spot-activation.ts +1027 -0
- package/src/runtime/spots/spot-actor-admission-coordinator.ts +354 -0
- package/src/runtime/spots/spot-actor-join-dispatch.ts +303 -0
- package/src/runtime/spots/spot-actor-lifecycle-drain.ts +79 -0
- package/src/runtime/spots/spot-actor-membership.ts +266 -0
- package/src/runtime/spots/spot-actor-packet-dispatch.ts +593 -0
- package/src/runtime/spots/spot-actor-packet-drain.ts +328 -0
- package/src/runtime/spots/spot-actor-packet-relay-dispatch.ts +162 -0
- package/src/runtime/spots/spot-closing.ts +34 -0
- package/src/runtime/spots/spot-context.ts +259 -0
- package/src/runtime/spots/spot-entry-activation.ts +551 -0
- package/src/runtime/spots/spot-handle.ts +101 -0
- package/src/runtime/spots/spot-handler-registry.ts +273 -0
- package/src/runtime/spots/spot-lifecycle-metrics.ts +15 -0
- package/src/runtime/spots/spot-location-claim.ts +86 -0
- package/src/runtime/spots/spot-manager-internal-contracts.ts +11 -0
- package/src/runtime/spots/spot-manager-public.ts +361 -0
- package/src/runtime/spots/spot-native-actor-join-admission.ts +151 -0
- package/src/runtime/spots/spot-native-flags.ts +4 -0
- package/src/runtime/spots/spot-node-autoconnect.ts +325 -0
- package/src/runtime/spots/spot-node-runtime-manager.ts +1573 -0
- package/src/runtime/spots/spot-outbound.ts +761 -0
- package/src/runtime/spots/spot-provider.ts +36 -0
- package/src/runtime/spots/spot-publisher-transport.ts +69 -0
- package/src/runtime/spots/spot-remote-codec.ts +308 -0
- package/src/runtime/spots/spot-remote-route-codec.ts +284 -0
- package/src/runtime/spots/spot-route-packet-dispatch.ts +359 -0
- package/src/runtime/spots/spot-route-replies.ts +126 -0
- package/src/runtime/spots/spot-route-reply-wire.ts +15 -0
- package/src/runtime/spots/spot-routed-actor-admission.ts +351 -0
- package/src/runtime/spots/spot-routed-bound-session-dispatch.ts +132 -0
- package/src/runtime/spots/spot-routed-frame-dispatch.ts +250 -0
- package/src/runtime/spots/spot-routed-spot-packet-dispatch.ts +254 -0
- package/src/runtime/spots/spot-routing-internal.ts +33 -0
- package/src/runtime/spots/spot-runtime-ports.ts +196 -0
- package/src/runtime/spots/spot-serial-executor.ts +170 -0
- package/src/runtime/spots/spot-serial-turn-executor.ts +319 -0
- package/src/runtime/spots/spot-subscription-dispatch.ts +252 -0
- package/src/runtime/spots/spot-timer.ts +609 -0
- package/src/runtime/streams/actor-session-binding-registry.ts +1691 -0
- package/src/runtime/streams/actor-session-binding-runtime-owner.ts +78 -0
- package/src/runtime/streams/actor-session-lifecycle-coordinator.ts +20 -0
- package/src/runtime/streams/bound-actor-relay-sender.ts +275 -0
- package/src/runtime/streams/bound-session-response-target.ts +91 -0
- package/src/runtime/streams/bound-session-service.ts +500 -0
- package/src/runtime/streams/index.ts +706 -0
- package/src/runtime/streams/managed-stream.ts +509 -0
- package/src/runtime/streams/native-fallback-bound-session.ts +321 -0
- package/src/runtime/streams/protocol.ts +291 -0
- package/src/runtime/streams/session-actor-coordinator.ts +605 -0
- package/src/runtime/streams/session-calls.ts +221 -0
- package/src/runtime/streams/session-context.ts +609 -0
- package/src/runtime/streams/session-local-actors.ts +30 -0
- package/src/runtime/streams/session-provider.ts +50 -0
- package/src/runtime/streams/session-requests.ts +109 -0
- package/src/runtime/streams/session-serial-executor.ts +97 -0
- package/src/runtime/streams/stream-binding-runtime-ports.ts +106 -0
- package/src/runtime/streams/stream-frame-factory.ts +255 -0
- package/src/runtime/streams/stream-message-utils.ts +89 -0
- package/src/runtime/streams/stream-session-runtime.ts +1420 -0
- package/src/runtime/workers/index.ts +580 -0
- package/tsconfig.json +17 -0
|
@@ -0,0 +1,3008 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
ServiceActorRef,
|
|
3
|
+
ServiceSessionBinding,
|
|
4
|
+
ServiceSpotRef
|
|
5
|
+
} from './service-stateful-registry';
|
|
6
|
+
import { operationRequiresReply } from './service-runtime-contracts';
|
|
7
|
+
import { ServiceWireProtocolError } from './service-wire-m6a-codec';
|
|
8
|
+
import { isCanonicalWireReplyTerminal } from '../framework-errors-internal';
|
|
9
|
+
import { routingIdsEqual } from '../routing-id';
|
|
10
|
+
import {
|
|
11
|
+
SERVICE_WIRE_MAGIC,
|
|
12
|
+
SERVICE_WIRE_MAJOR,
|
|
13
|
+
ServiceWireCommand,
|
|
14
|
+
ServiceWireFlag
|
|
15
|
+
} from './service-wire-constants.generated';
|
|
16
|
+
import {
|
|
17
|
+
decodeCanonicalServiceWireText,
|
|
18
|
+
decodeServiceWireRoutingId,
|
|
19
|
+
encodeCanonicalServiceWireText,
|
|
20
|
+
encodeServiceWireRoutingId
|
|
21
|
+
} from './service-wire-binary-primitives';
|
|
22
|
+
import {
|
|
23
|
+
decodeActorCreate49 as decodeGeneratedActorCreate49,
|
|
24
|
+
decodeActorJoin28,
|
|
25
|
+
decodeRelocationCutover34 as decodeGeneratedRelocationCutover34,
|
|
26
|
+
decodeRelocationData31 as decodeGeneratedRelocationData31,
|
|
27
|
+
decodeRelocationFailed53 as decodeGeneratedRelocationFailed53,
|
|
28
|
+
decodeRelocationPrepare40 as decodeGeneratedRelocationPrepare40,
|
|
29
|
+
decodeRelocationReady30 as decodeGeneratedRelocationReady30,
|
|
30
|
+
decodeRelocationState52 as decodeGeneratedRelocationState52,
|
|
31
|
+
decodeReplyRelay33 as decodeGeneratedReplyRelay33,
|
|
32
|
+
decodeReplyRelayAck46 as decodeGeneratedReplyRelayAck46,
|
|
33
|
+
decodeSessionRelocationRoute44 as decodeGeneratedSessionRelocationRoute44,
|
|
34
|
+
decodeSessionRelocationSeal42 as decodeGeneratedSessionRelocationSeal42,
|
|
35
|
+
decodeSessionRelocationSealed43 as decodeGeneratedSessionRelocationSealed43,
|
|
36
|
+
decodeUserSpotClose48 as decodeGeneratedUserSpotClose48,
|
|
37
|
+
decodeUserSpotCreate47 as decodeGeneratedUserSpotCreate47,
|
|
38
|
+
encodeActorCreate49 as encodeGeneratedActorCreate49,
|
|
39
|
+
encodeRelocationCutover34 as encodeGeneratedRelocationCutover34,
|
|
40
|
+
encodeRelocationData31 as encodeGeneratedRelocationData31,
|
|
41
|
+
encodeRelocationFailed53 as encodeGeneratedRelocationFailed53,
|
|
42
|
+
encodeRelocationPrepare40 as encodeGeneratedRelocationPrepare40,
|
|
43
|
+
encodeRelocationReady30 as encodeGeneratedRelocationReady30,
|
|
44
|
+
encodeRelocationState52 as encodeGeneratedRelocationState52,
|
|
45
|
+
encodeReplyRelay33 as encodeGeneratedReplyRelay33,
|
|
46
|
+
encodeReplyRelayAck46 as encodeGeneratedReplyRelayAck46,
|
|
47
|
+
encodeSessionRelocationRoute44 as encodeGeneratedSessionRelocationRoute44,
|
|
48
|
+
encodeSessionRelocationSeal42 as encodeGeneratedSessionRelocationSeal42,
|
|
49
|
+
encodeSessionRelocationSealed43 as encodeGeneratedSessionRelocationSealed43,
|
|
50
|
+
encodeUserSpotClose48 as encodeGeneratedUserSpotClose48,
|
|
51
|
+
encodeUserSpotCreate47 as encodeGeneratedUserSpotCreate47,
|
|
52
|
+
type ActorCreate49 as GeneratedActorCreate49,
|
|
53
|
+
type RelocationObjectIdentity as GeneratedRelocationObjectIdentity,
|
|
54
|
+
type ReplyRelay33 as GeneratedReplyRelay33,
|
|
55
|
+
type ServiceWireCoordinatorFence as GeneratedCoordinatorFence,
|
|
56
|
+
type ServiceWireRequestSourceFence as GeneratedRequestSourceFence,
|
|
57
|
+
type ServiceWireRouteFence as GeneratedRouteFence,
|
|
58
|
+
type ServiceWireTargetFence as GeneratedTargetFence,
|
|
59
|
+
type SessionRelocationRoute44 as GeneratedSessionRelocationRoute44,
|
|
60
|
+
type SessionRelocationSeal42 as GeneratedSessionRelocationSeal42,
|
|
61
|
+
type SessionRelocationSealed43 as GeneratedSessionRelocationSealed43,
|
|
62
|
+
type UserSpotClose48 as GeneratedUserSpotClose48,
|
|
63
|
+
type UserSpotCreate47 as GeneratedUserSpotCreate47
|
|
64
|
+
} from '../protocol/service_wire_pilot_codec.generated';
|
|
65
|
+
|
|
66
|
+
const PREFIX_SIZE = 5;
|
|
67
|
+
const MAGIC_0 = SERVICE_WIRE_MAGIC[0];
|
|
68
|
+
const MAGIC_1 = SERVICE_WIRE_MAGIC[1];
|
|
69
|
+
const MAJOR = SERVICE_WIRE_MAJOR;
|
|
70
|
+
|
|
71
|
+
export const M6bServiceWireCommand = ServiceWireCommand;
|
|
72
|
+
|
|
73
|
+
export interface ServiceWireOperationId {
|
|
74
|
+
readonly high: bigint;
|
|
75
|
+
readonly low: bigint;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export interface ServiceWireRelocationCoordinatorFence {
|
|
79
|
+
readonly ownerId: string;
|
|
80
|
+
readonly leaseGeneration: bigint;
|
|
81
|
+
readonly nodeRid: string;
|
|
82
|
+
readonly nodeGeneration: bigint;
|
|
83
|
+
readonly expectedAuthorityStoreVersion: string;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
export interface ServiceWireRequestSourceFence {
|
|
87
|
+
readonly ownerId: string;
|
|
88
|
+
readonly leaseGeneration: bigint;
|
|
89
|
+
readonly nodeRid: string;
|
|
90
|
+
readonly nodeGeneration: bigint;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
export interface ServiceMaintenanceReplyRelay {
|
|
94
|
+
readonly relocation: ServiceWireOperationId;
|
|
95
|
+
readonly targetAttemptGeneration: bigint;
|
|
96
|
+
readonly coordinator: ServiceWireRelocationCoordinatorFence;
|
|
97
|
+
readonly operation: ServiceWireOperationId;
|
|
98
|
+
readonly replyRouteId: bigint;
|
|
99
|
+
readonly participantId: bigint;
|
|
100
|
+
readonly sequence: bigint;
|
|
101
|
+
readonly terminalResult: number;
|
|
102
|
+
readonly failureCode: number;
|
|
103
|
+
readonly payload?: {
|
|
104
|
+
readonly packetName: string;
|
|
105
|
+
readonly contentType: string;
|
|
106
|
+
readonly bytes: Uint8Array;
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
export interface ServiceMaintenanceReplyRelayAck {
|
|
111
|
+
readonly relocation: ServiceWireOperationId;
|
|
112
|
+
readonly coordinator: ServiceWireRelocationCoordinatorFence;
|
|
113
|
+
readonly operation: ServiceWireOperationId;
|
|
114
|
+
readonly replyRouteId: bigint;
|
|
115
|
+
readonly requestSource: ServiceWireRequestSourceFence;
|
|
116
|
+
readonly status: 'terminalReceived' | 'alreadyTerminal';
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
export type ServiceWireRelocationRole = 'source' | 'target' | 'coordinator';
|
|
120
|
+
|
|
121
|
+
export interface ServiceWireRelocationTarget {
|
|
122
|
+
readonly nodeRid: string;
|
|
123
|
+
readonly nodeGeneration: bigint;
|
|
124
|
+
readonly ownerId: string;
|
|
125
|
+
readonly ownerLeaseGeneration: bigint;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
export type ServiceWireRelocationObject =
|
|
129
|
+
| {
|
|
130
|
+
readonly kind: 'actor';
|
|
131
|
+
readonly actorId: string;
|
|
132
|
+
readonly objectGeneration: bigint;
|
|
133
|
+
readonly expectedAuthorityOwnerGeneration: bigint;
|
|
134
|
+
}
|
|
135
|
+
| {
|
|
136
|
+
readonly kind: 'userSpot';
|
|
137
|
+
readonly spotId: string;
|
|
138
|
+
readonly objectGeneration: bigint;
|
|
139
|
+
readonly expectedAuthorityOwnerGeneration: bigint;
|
|
140
|
+
}
|
|
141
|
+
| {
|
|
142
|
+
readonly kind: 'instanceSpot';
|
|
143
|
+
readonly stableType: string;
|
|
144
|
+
readonly spotId: string;
|
|
145
|
+
readonly objectGeneration: bigint;
|
|
146
|
+
};
|
|
147
|
+
|
|
148
|
+
/** Shared CRC-32C wire bounds for the direct relocation payload transfer. */
|
|
149
|
+
export const RELOCATION_PAYLOAD_TOTAL_LENGTH_MAX = 274_877_906_944n;
|
|
150
|
+
export const RELOCATION_PAYLOAD_CHUNK_COUNT_MAX = 4096;
|
|
151
|
+
export const RELOCATION_STATE_CHUNK_DATA_MAX_BYTES = 67_108_864;
|
|
152
|
+
|
|
153
|
+
interface ServiceWireRelocationBase {
|
|
154
|
+
readonly relocation: ServiceWireOperationId;
|
|
155
|
+
readonly targetAttemptGeneration: bigint;
|
|
156
|
+
readonly coordinator: ServiceWireRelocationCoordinatorFence;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
export interface ServiceMaintenanceRelocationPrepare extends ServiceWireRelocationBase {
|
|
160
|
+
readonly kind: 'prepare';
|
|
161
|
+
readonly target: ServiceWireRelocationTarget;
|
|
162
|
+
readonly initiatorRole: ServiceWireRelocationRole;
|
|
163
|
+
readonly object: ServiceWireRelocationObject;
|
|
164
|
+
readonly sourceNodeRid: string;
|
|
165
|
+
readonly sourceNodeGeneration: bigint;
|
|
166
|
+
/** Total encoded byte length of the directly transferred relocation payload. */
|
|
167
|
+
readonly payloadTotalLength: bigint;
|
|
168
|
+
/** Number of relocationState chunks that carry the payload. */
|
|
169
|
+
readonly payloadChunkCount: number;
|
|
170
|
+
/** CRC-32C (Castagnoli) over the fully assembled payload bytes. */
|
|
171
|
+
readonly payloadChecksumCrc32c: number;
|
|
172
|
+
readonly applicationVersion: bigint;
|
|
173
|
+
/** NODE-INTERNAL; serialized as extra frames after canonical command 40. */
|
|
174
|
+
readonly nodeInternalBoundSessions?: readonly {
|
|
175
|
+
readonly participantKey: string;
|
|
176
|
+
readonly payload: Uint8Array;
|
|
177
|
+
}[];
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
export interface ServiceMaintenanceRelocationReady extends ServiceWireRelocationBase {
|
|
181
|
+
readonly kind: 'ready';
|
|
182
|
+
readonly target: ServiceWireRelocationTarget;
|
|
183
|
+
readonly object: ServiceWireRelocationObject;
|
|
184
|
+
readonly senderRole: ServiceWireRelocationRole;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
/** Explicit target-side pre-cutover relocation failure (command 53). */
|
|
188
|
+
export interface ServiceMaintenanceRelocationFailed extends ServiceWireRelocationBase {
|
|
189
|
+
readonly kind: 'failed';
|
|
190
|
+
readonly target: ServiceWireRelocationTarget;
|
|
191
|
+
readonly object: ServiceWireRelocationObject;
|
|
192
|
+
readonly senderRole: ServiceWireRelocationRole;
|
|
193
|
+
readonly failureCode: number;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
export interface ServiceWireFrozenRecord {
|
|
197
|
+
readonly recordKind: number;
|
|
198
|
+
readonly sourceKind: number;
|
|
199
|
+
readonly source: ServiceWireRequestSourceFence;
|
|
200
|
+
readonly sourceSpotId?: string;
|
|
201
|
+
readonly sourceActor?: { readonly actorId: string; readonly generation: bigint };
|
|
202
|
+
readonly sourceSessionRid?: string;
|
|
203
|
+
readonly sourceBindingGeneration?: bigint;
|
|
204
|
+
readonly sourceSessionSequence?: bigint;
|
|
205
|
+
readonly hasMetadata: boolean;
|
|
206
|
+
readonly operationId: ServiceWireOperationId;
|
|
207
|
+
readonly operationKind: number;
|
|
208
|
+
readonly replyRouteId?: bigint;
|
|
209
|
+
/** Decoded routing/application body used by the target temporary queue owner. */
|
|
210
|
+
readonly target?:
|
|
211
|
+
| {
|
|
212
|
+
readonly kind: 'spot';
|
|
213
|
+
readonly spotId: string;
|
|
214
|
+
readonly generation: bigint;
|
|
215
|
+
readonly targetNodeRid: string;
|
|
216
|
+
readonly targetNodeGeneration: bigint;
|
|
217
|
+
readonly authorityOwnerGeneration: bigint;
|
|
218
|
+
readonly ownerLeaseGeneration: bigint;
|
|
219
|
+
}
|
|
220
|
+
| {
|
|
221
|
+
readonly kind: 'actor';
|
|
222
|
+
readonly actorId: string;
|
|
223
|
+
readonly generation: bigint;
|
|
224
|
+
readonly targetNodeRid: string;
|
|
225
|
+
readonly targetNodeGeneration: bigint;
|
|
226
|
+
readonly authorityOwnerGeneration: bigint;
|
|
227
|
+
readonly ownerLeaseGeneration: bigint;
|
|
228
|
+
};
|
|
229
|
+
readonly applicationPayload?: NonNullable<ServiceMaintenanceReplyRelay['payload']>;
|
|
230
|
+
readonly canonicalBytes: Buffer;
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
export interface ServiceMaintenanceRelocationData extends ServiceWireRelocationBase {
|
|
234
|
+
readonly kind: 'data';
|
|
235
|
+
readonly senderRole: ServiceWireRelocationRole;
|
|
236
|
+
readonly object: ServiceWireRelocationObject;
|
|
237
|
+
readonly frozenRecord: ServiceWireFrozenRecord;
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
export interface ServiceMaintenanceRelocationCutover extends ServiceWireRelocationBase {
|
|
241
|
+
readonly kind: 'cutover';
|
|
242
|
+
readonly senderRole: ServiceWireRelocationRole;
|
|
243
|
+
readonly object: ServiceWireRelocationObject;
|
|
244
|
+
/** Number of boundary relay records sent before this cutover. */
|
|
245
|
+
readonly boundaryRecordCount: bigint;
|
|
246
|
+
/** CRC-32C over the concatenated canonical bytes of those relay records. */
|
|
247
|
+
readonly boundaryChecksumCrc32c: number;
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
/** One relocation payload chunk (command 52), sent one-way on the ordered connection. */
|
|
251
|
+
export interface ServiceMaintenanceRelocationState extends ServiceWireRelocationBase {
|
|
252
|
+
readonly kind: 'state';
|
|
253
|
+
readonly senderRole: ServiceWireRelocationRole;
|
|
254
|
+
readonly object: ServiceWireRelocationObject;
|
|
255
|
+
readonly chunkOrdinal: number;
|
|
256
|
+
readonly chunkData: Uint8Array;
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
export type ServiceMaintenanceRelocationControl =
|
|
260
|
+
| ServiceMaintenanceRelocationPrepare
|
|
261
|
+
| ServiceMaintenanceRelocationReady
|
|
262
|
+
| ServiceMaintenanceRelocationFailed
|
|
263
|
+
| ServiceMaintenanceRelocationData
|
|
264
|
+
| ServiceMaintenanceRelocationCutover
|
|
265
|
+
| ServiceMaintenanceRelocationState;
|
|
266
|
+
|
|
267
|
+
export const M6bServiceWireFlag = ServiceWireFlag;
|
|
268
|
+
|
|
269
|
+
export interface ServiceSpotRouteFence {
|
|
270
|
+
readonly spot: ServiceSpotRef;
|
|
271
|
+
readonly targetNodeRid: string;
|
|
272
|
+
readonly targetNodeGeneration: bigint;
|
|
273
|
+
readonly authorityOwnerGeneration: bigint;
|
|
274
|
+
/** Schema spot-route-fence expectedOwnerLeaseGeneration. */
|
|
275
|
+
readonly ownerLeaseGeneration: bigint;
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
export interface ServiceDirectSpotRouteFence extends ServiceSpotRouteFence {
|
|
279
|
+
readonly ownerLeaseGeneration: bigint;
|
|
280
|
+
readonly storeVersion: string;
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
export interface ServiceActorRouteFence {
|
|
284
|
+
readonly actor: ServiceActorRef;
|
|
285
|
+
readonly targetNodeGeneration: bigint;
|
|
286
|
+
readonly authorityOwnerGeneration: bigint;
|
|
287
|
+
readonly ownerLeaseGeneration: bigint;
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
/**
|
|
291
|
+
* The authority fence carried by a bound-session replacement notice. This
|
|
292
|
+
* command is deliberately separate from the legacy Actor message fence: the
|
|
293
|
+
* receiver validates the transport source against this authority target and
|
|
294
|
+
* must not resolve a local Actor object for the retired session.
|
|
295
|
+
*/
|
|
296
|
+
export interface ServiceBoundSessionActorAuthority {
|
|
297
|
+
readonly actor: ServiceActorRef;
|
|
298
|
+
readonly targetNodeGeneration: bigint;
|
|
299
|
+
readonly authorityOwnerGeneration: bigint;
|
|
300
|
+
readonly ownerLeaseGeneration: bigint;
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
export interface ServiceSessionRelocationOwnerFence {
|
|
304
|
+
readonly sessionOwnerNodeRid: string;
|
|
305
|
+
readonly sessionOwnerNodeGeneration: bigint;
|
|
306
|
+
readonly sessionOwnerId: string;
|
|
307
|
+
readonly sessionOwnerLeaseGeneration: bigint;
|
|
308
|
+
readonly sessionRid: string;
|
|
309
|
+
readonly bindingGeneration: bigint;
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
export interface ServiceSessionRelocationSeal {
|
|
313
|
+
readonly relocation: ServiceWireOperationId;
|
|
314
|
+
readonly coordinator: ServiceWireRelocationCoordinatorFence;
|
|
315
|
+
readonly senderRole: 'source' | 'coordinator';
|
|
316
|
+
readonly actor: ServiceBoundSessionActorAuthority;
|
|
317
|
+
readonly session: ServiceSessionRelocationOwnerFence;
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
export interface ServiceSessionRelocationSealed {
|
|
321
|
+
readonly relocation: ServiceWireOperationId;
|
|
322
|
+
readonly coordinator: ServiceWireRelocationCoordinatorFence;
|
|
323
|
+
readonly actor: ServiceBoundSessionActorAuthority;
|
|
324
|
+
readonly session: ServiceSessionRelocationOwnerFence;
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
export type ServiceSessionRelocationRoute =
|
|
328
|
+
| {
|
|
329
|
+
readonly relocation: ServiceWireOperationId;
|
|
330
|
+
readonly coordinator: ServiceWireRelocationCoordinatorFence;
|
|
331
|
+
readonly senderRole: 'target' | 'coordinator';
|
|
332
|
+
readonly actor: ServiceActorRef;
|
|
333
|
+
readonly session: ServiceSessionRelocationOwnerFence;
|
|
334
|
+
readonly route: {
|
|
335
|
+
readonly action: 'commit';
|
|
336
|
+
readonly previousAuthorityOwnerGeneration: bigint;
|
|
337
|
+
readonly targetAuthorityOwnerGeneration: bigint;
|
|
338
|
+
readonly targetNodeRid: string;
|
|
339
|
+
readonly targetNodeGeneration: bigint;
|
|
340
|
+
};
|
|
341
|
+
}
|
|
342
|
+
| {
|
|
343
|
+
readonly relocation: ServiceWireOperationId;
|
|
344
|
+
readonly coordinator: ServiceWireRelocationCoordinatorFence;
|
|
345
|
+
readonly senderRole: 'source' | 'coordinator';
|
|
346
|
+
readonly actor: ServiceActorRef;
|
|
347
|
+
readonly session: ServiceSessionRelocationOwnerFence;
|
|
348
|
+
readonly route: {
|
|
349
|
+
readonly action: 'abort';
|
|
350
|
+
readonly currentAuthorityOwnerGeneration: bigint;
|
|
351
|
+
};
|
|
352
|
+
};
|
|
353
|
+
|
|
354
|
+
export function serviceSessionRelocationIdentityKey(
|
|
355
|
+
value: ServiceSessionRelocationSeal | ServiceSessionRelocationSealed | ServiceSessionRelocationRoute
|
|
356
|
+
): string {
|
|
357
|
+
const actor = 'targetNodeGeneration' in value.actor
|
|
358
|
+
? value.actor.actor
|
|
359
|
+
: value.actor;
|
|
360
|
+
// Session owner가 seal을 대조할 때 쓰는 값만 넣는다 — Session과 Actor binding
|
|
361
|
+
// §8.1 "Session owner는 다음 값만 검증한다". coordinator identity는 transport가
|
|
362
|
+
// 검증하는 wire fence이므로 여기서 다시 대조하지 않는다.
|
|
363
|
+
return [
|
|
364
|
+
value.relocation.high.toString(),
|
|
365
|
+
value.relocation.low.toString(),
|
|
366
|
+
actor.actorId,
|
|
367
|
+
actor.generation.toString(),
|
|
368
|
+
value.session.sessionRid,
|
|
369
|
+
value.session.bindingGeneration.toString()
|
|
370
|
+
].join(':');
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
function toGeneratedRoutingId(value: string, field: string): Uint8Array {
|
|
374
|
+
return encodeServiceWireRoutingId(value as never, field, 0xff, fail);
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
function fromGeneratedRoutingId(value: Uint8Array, field: string): string {
|
|
378
|
+
return decodeServiceWireRoutingId(value, field, 0xff, fail) as string;
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
function toGeneratedReservation(
|
|
382
|
+
value: ServiceUserSpotReservationFence
|
|
383
|
+
): GeneratedUserSpotCreate47['reservation'] {
|
|
384
|
+
return {
|
|
385
|
+
...value,
|
|
386
|
+
targetNodeRid: toGeneratedRoutingId(value.targetNodeRid, 'targetNodeRid')
|
|
387
|
+
};
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
function fromGeneratedReservation(
|
|
391
|
+
value: GeneratedUserSpotCreate47['reservation']
|
|
392
|
+
): ServiceUserSpotReservationFence {
|
|
393
|
+
return {
|
|
394
|
+
...value,
|
|
395
|
+
targetNodeRid: fromGeneratedRoutingId(value.targetNodeRid, 'targetNodeRid')
|
|
396
|
+
};
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
function toGeneratedUserSpotCreate(
|
|
400
|
+
value: Omit<ServiceUserSpotCreateRecord, 'kind'>
|
|
401
|
+
): GeneratedUserSpotCreate47 {
|
|
402
|
+
return {
|
|
403
|
+
...value,
|
|
404
|
+
sourceNodeRid: toGeneratedRoutingId(value.sourceNodeRid, 'sourceNodeRid'),
|
|
405
|
+
reservation: toGeneratedReservation(value.reservation)
|
|
406
|
+
};
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
function fromGeneratedUserSpotCreate(
|
|
410
|
+
value: GeneratedUserSpotCreate47
|
|
411
|
+
): ServiceUserSpotCreateRecord {
|
|
412
|
+
return {
|
|
413
|
+
kind: 'userSpotCreate',
|
|
414
|
+
...value,
|
|
415
|
+
sourceNodeRid: fromGeneratedRoutingId(value.sourceNodeRid, 'sourceNodeRid'),
|
|
416
|
+
reservation: fromGeneratedReservation(value.reservation)
|
|
417
|
+
};
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
function toGeneratedUserSpotClose(
|
|
421
|
+
value: Omit<ServiceUserSpotCloseRecord, 'kind'>
|
|
422
|
+
): GeneratedUserSpotClose48 {
|
|
423
|
+
return {
|
|
424
|
+
...value,
|
|
425
|
+
sourceNodeRid: toGeneratedRoutingId(value.sourceNodeRid, 'sourceNodeRid'),
|
|
426
|
+
target: {
|
|
427
|
+
spotId: value.target.spotId,
|
|
428
|
+
objectGeneration: value.target.objectGeneration,
|
|
429
|
+
targetNodeRid: toGeneratedRoutingId(value.target.targetNodeRid, 'targetNodeRid'),
|
|
430
|
+
targetNodeGeneration: value.target.targetNodeGeneration,
|
|
431
|
+
expectedAuthorityOwnerGeneration: value.target.authorityOwnerGeneration,
|
|
432
|
+
expectedStoreVersion: value.target.expectedStoreVersion
|
|
433
|
+
}
|
|
434
|
+
};
|
|
435
|
+
}
|
|
436
|
+
|
|
437
|
+
function fromGeneratedUserSpotClose(
|
|
438
|
+
value: GeneratedUserSpotClose48
|
|
439
|
+
): ServiceUserSpotCloseRecord {
|
|
440
|
+
return {
|
|
441
|
+
kind: 'userSpotClose',
|
|
442
|
+
correlation: value.correlation,
|
|
443
|
+
operation: value.operation,
|
|
444
|
+
sourceNodeRid: fromGeneratedRoutingId(value.sourceNodeRid, 'sourceNodeRid'),
|
|
445
|
+
sourceNodeGeneration: value.sourceNodeGeneration,
|
|
446
|
+
target: {
|
|
447
|
+
spotId: value.target.spotId,
|
|
448
|
+
objectGeneration: value.target.objectGeneration,
|
|
449
|
+
targetNodeRid: fromGeneratedRoutingId(value.target.targetNodeRid, 'targetNodeRid'),
|
|
450
|
+
targetNodeGeneration: value.target.targetNodeGeneration,
|
|
451
|
+
authorityOwnerGeneration: value.target.expectedAuthorityOwnerGeneration,
|
|
452
|
+
expectedStoreVersion: value.target.expectedStoreVersion
|
|
453
|
+
},
|
|
454
|
+
deadlineUnixMs: value.deadlineUnixMs
|
|
455
|
+
};
|
|
456
|
+
}
|
|
457
|
+
|
|
458
|
+
function toGeneratedActorCreate(
|
|
459
|
+
value: Omit<ServiceActorCreateRecord, 'kind'>
|
|
460
|
+
): GeneratedActorCreate49 {
|
|
461
|
+
return {
|
|
462
|
+
...value,
|
|
463
|
+
sourceNodeRid: toGeneratedRoutingId(value.sourceNodeRid, 'sourceNodeRid'),
|
|
464
|
+
reservation: toGeneratedReservation(value.reservation)
|
|
465
|
+
};
|
|
466
|
+
}
|
|
467
|
+
|
|
468
|
+
function fromGeneratedActorCreate(value: GeneratedActorCreate49): ServiceActorCreateRecord {
|
|
469
|
+
return {
|
|
470
|
+
kind: 'actorCreate',
|
|
471
|
+
...value,
|
|
472
|
+
sourceNodeRid: fromGeneratedRoutingId(value.sourceNodeRid, 'sourceNodeRid'),
|
|
473
|
+
reservation: fromGeneratedReservation(value.reservation)
|
|
474
|
+
};
|
|
475
|
+
}
|
|
476
|
+
|
|
477
|
+
function toGeneratedCoordinatorFence(
|
|
478
|
+
value: ServiceWireRelocationCoordinatorFence
|
|
479
|
+
): GeneratedCoordinatorFence {
|
|
480
|
+
return {
|
|
481
|
+
coordinatorOwnerId: value.ownerId,
|
|
482
|
+
coordinatorLeaseGeneration: value.leaseGeneration,
|
|
483
|
+
coordinatorNodeRid: toGeneratedRoutingId(value.nodeRid, 'coordinatorNodeRid'),
|
|
484
|
+
coordinatorNodeGeneration: value.nodeGeneration,
|
|
485
|
+
expectedAuthorityStoreVersion: value.expectedAuthorityStoreVersion
|
|
486
|
+
};
|
|
487
|
+
}
|
|
488
|
+
|
|
489
|
+
function fromGeneratedCoordinatorFence(
|
|
490
|
+
value: GeneratedCoordinatorFence
|
|
491
|
+
): ServiceWireRelocationCoordinatorFence {
|
|
492
|
+
return {
|
|
493
|
+
ownerId: value.coordinatorOwnerId,
|
|
494
|
+
leaseGeneration: value.coordinatorLeaseGeneration,
|
|
495
|
+
nodeRid: fromGeneratedRoutingId(value.coordinatorNodeRid, 'coordinatorNodeRid'),
|
|
496
|
+
nodeGeneration: value.coordinatorNodeGeneration,
|
|
497
|
+
expectedAuthorityStoreVersion: value.expectedAuthorityStoreVersion
|
|
498
|
+
};
|
|
499
|
+
}
|
|
500
|
+
|
|
501
|
+
function toGeneratedTargetFence(value: ServiceWireRelocationTarget): GeneratedTargetFence {
|
|
502
|
+
return {
|
|
503
|
+
targetNodeRid: toGeneratedRoutingId(value.nodeRid, 'targetNodeRid'),
|
|
504
|
+
targetNodeGeneration: value.nodeGeneration,
|
|
505
|
+
targetOwnerId: value.ownerId,
|
|
506
|
+
targetOwnerLeaseGeneration: value.ownerLeaseGeneration
|
|
507
|
+
};
|
|
508
|
+
}
|
|
509
|
+
|
|
510
|
+
function fromGeneratedTargetFence(value: GeneratedTargetFence): ServiceWireRelocationTarget {
|
|
511
|
+
return {
|
|
512
|
+
nodeRid: fromGeneratedRoutingId(value.targetNodeRid, 'targetNodeRid'),
|
|
513
|
+
nodeGeneration: value.targetNodeGeneration,
|
|
514
|
+
ownerId: value.targetOwnerId,
|
|
515
|
+
ownerLeaseGeneration: value.targetOwnerLeaseGeneration
|
|
516
|
+
};
|
|
517
|
+
}
|
|
518
|
+
|
|
519
|
+
function toGeneratedRequestSourceFence(
|
|
520
|
+
value: ServiceWireRequestSourceFence
|
|
521
|
+
): GeneratedRequestSourceFence {
|
|
522
|
+
return {
|
|
523
|
+
sourceOwnerId: value.ownerId,
|
|
524
|
+
sourceOwnerLeaseGeneration: value.leaseGeneration,
|
|
525
|
+
sourceNodeRid: toGeneratedRoutingId(value.nodeRid, 'sourceNodeRid'),
|
|
526
|
+
sourceNodeGeneration: value.nodeGeneration
|
|
527
|
+
};
|
|
528
|
+
}
|
|
529
|
+
|
|
530
|
+
function fromGeneratedRequestSourceFence(
|
|
531
|
+
value: GeneratedRequestSourceFence
|
|
532
|
+
): ServiceWireRequestSourceFence {
|
|
533
|
+
return {
|
|
534
|
+
ownerId: value.sourceOwnerId,
|
|
535
|
+
leaseGeneration: value.sourceOwnerLeaseGeneration,
|
|
536
|
+
nodeRid: fromGeneratedRoutingId(value.sourceNodeRid, 'sourceNodeRid'),
|
|
537
|
+
nodeGeneration: value.sourceNodeGeneration
|
|
538
|
+
};
|
|
539
|
+
}
|
|
540
|
+
|
|
541
|
+
function toGeneratedRelocationObject(
|
|
542
|
+
value: ServiceWireRelocationObject
|
|
543
|
+
): GeneratedRelocationObjectIdentity {
|
|
544
|
+
switch (value.kind) {
|
|
545
|
+
case 'actor':
|
|
546
|
+
return {
|
|
547
|
+
objectKind: 'actor',
|
|
548
|
+
actorId: value.actorId,
|
|
549
|
+
objectGeneration: value.objectGeneration,
|
|
550
|
+
expectedAuthorityOwnerGeneration: value.expectedAuthorityOwnerGeneration
|
|
551
|
+
};
|
|
552
|
+
case 'userSpot':
|
|
553
|
+
return {
|
|
554
|
+
objectKind: 'userSpot',
|
|
555
|
+
spotId: value.spotId,
|
|
556
|
+
objectGeneration: value.objectGeneration,
|
|
557
|
+
expectedAuthorityOwnerGeneration: value.expectedAuthorityOwnerGeneration
|
|
558
|
+
};
|
|
559
|
+
case 'instanceSpot':
|
|
560
|
+
return {
|
|
561
|
+
objectKind: 'instanceSpot',
|
|
562
|
+
instanceType: value.stableType,
|
|
563
|
+
spotId: value.spotId,
|
|
564
|
+
objectGeneration: value.objectGeneration
|
|
565
|
+
};
|
|
566
|
+
}
|
|
567
|
+
}
|
|
568
|
+
|
|
569
|
+
function fromGeneratedRelocationObject(
|
|
570
|
+
value: GeneratedRelocationObjectIdentity
|
|
571
|
+
): ServiceWireRelocationObject {
|
|
572
|
+
switch (value.objectKind) {
|
|
573
|
+
case 'actor':
|
|
574
|
+
return {
|
|
575
|
+
kind: 'actor',
|
|
576
|
+
actorId: value.actorId,
|
|
577
|
+
objectGeneration: value.objectGeneration,
|
|
578
|
+
expectedAuthorityOwnerGeneration: value.expectedAuthorityOwnerGeneration
|
|
579
|
+
};
|
|
580
|
+
case 'userSpot':
|
|
581
|
+
return {
|
|
582
|
+
kind: 'userSpot',
|
|
583
|
+
spotId: value.spotId,
|
|
584
|
+
objectGeneration: value.objectGeneration,
|
|
585
|
+
expectedAuthorityOwnerGeneration: value.expectedAuthorityOwnerGeneration
|
|
586
|
+
};
|
|
587
|
+
case 'instanceSpot':
|
|
588
|
+
return {
|
|
589
|
+
kind: 'instanceSpot',
|
|
590
|
+
stableType: value.instanceType,
|
|
591
|
+
spotId: value.spotId,
|
|
592
|
+
objectGeneration: value.objectGeneration
|
|
593
|
+
};
|
|
594
|
+
}
|
|
595
|
+
}
|
|
596
|
+
|
|
597
|
+
function toGeneratedRouteFence(value: ServiceBoundSessionActorAuthority): GeneratedRouteFence {
|
|
598
|
+
return {
|
|
599
|
+
id: value.actor.actorId,
|
|
600
|
+
generation: value.actor.generation,
|
|
601
|
+
targetNodeRid: toGeneratedRoutingId(value.actor.nodeRid, 'targetNodeRid'),
|
|
602
|
+
targetNodeGeneration: value.targetNodeGeneration,
|
|
603
|
+
expectedAuthorityOwnerGeneration: value.authorityOwnerGeneration,
|
|
604
|
+
expectedOwnerLeaseGeneration: value.ownerLeaseGeneration
|
|
605
|
+
};
|
|
606
|
+
}
|
|
607
|
+
|
|
608
|
+
function fromGeneratedRouteFence(value: GeneratedRouteFence): ServiceBoundSessionActorAuthority {
|
|
609
|
+
return {
|
|
610
|
+
actor: {
|
|
611
|
+
actorId: value.id,
|
|
612
|
+
generation: value.generation,
|
|
613
|
+
nodeRid: fromGeneratedRoutingId(value.targetNodeRid, 'targetNodeRid')
|
|
614
|
+
},
|
|
615
|
+
targetNodeGeneration: value.targetNodeGeneration,
|
|
616
|
+
authorityOwnerGeneration: value.expectedAuthorityOwnerGeneration,
|
|
617
|
+
ownerLeaseGeneration: value.expectedOwnerLeaseGeneration
|
|
618
|
+
};
|
|
619
|
+
}
|
|
620
|
+
|
|
621
|
+
function toGeneratedSessionOwnerFence(value: ServiceSessionRelocationOwnerFence) {
|
|
622
|
+
return {
|
|
623
|
+
sessionOwnerNodeRid: toGeneratedRoutingId(value.sessionOwnerNodeRid, 'sessionOwnerNodeRid'),
|
|
624
|
+
sessionOwnerNodeGeneration: value.sessionOwnerNodeGeneration,
|
|
625
|
+
sessionOwnerId: value.sessionOwnerId,
|
|
626
|
+
sessionOwnerLeaseGeneration: value.sessionOwnerLeaseGeneration,
|
|
627
|
+
sessionRid: toGeneratedRoutingId(value.sessionRid, 'sessionRid'),
|
|
628
|
+
bindingGeneration: value.bindingGeneration
|
|
629
|
+
};
|
|
630
|
+
}
|
|
631
|
+
|
|
632
|
+
function fromGeneratedSessionOwnerFence(value: {
|
|
633
|
+
readonly sessionOwnerNodeRid: Uint8Array;
|
|
634
|
+
readonly sessionOwnerNodeGeneration: bigint;
|
|
635
|
+
readonly sessionOwnerId: string;
|
|
636
|
+
readonly sessionOwnerLeaseGeneration: bigint;
|
|
637
|
+
readonly sessionRid: Uint8Array;
|
|
638
|
+
readonly bindingGeneration: bigint;
|
|
639
|
+
}): ServiceSessionRelocationOwnerFence {
|
|
640
|
+
return {
|
|
641
|
+
sessionOwnerNodeRid: fromGeneratedRoutingId(value.sessionOwnerNodeRid, 'sessionOwnerNodeRid'),
|
|
642
|
+
sessionOwnerNodeGeneration: value.sessionOwnerNodeGeneration,
|
|
643
|
+
sessionOwnerId: value.sessionOwnerId,
|
|
644
|
+
sessionOwnerLeaseGeneration: value.sessionOwnerLeaseGeneration,
|
|
645
|
+
sessionRid: fromGeneratedRoutingId(value.sessionRid, 'sessionRid'),
|
|
646
|
+
bindingGeneration: value.bindingGeneration
|
|
647
|
+
};
|
|
648
|
+
}
|
|
649
|
+
|
|
650
|
+
function toGeneratedSessionRelocationSeal(
|
|
651
|
+
value: ServiceSessionRelocationSeal
|
|
652
|
+
): GeneratedSessionRelocationSeal42 {
|
|
653
|
+
return {
|
|
654
|
+
relocation: value.relocation,
|
|
655
|
+
coordinator: toGeneratedCoordinatorFence(value.coordinator),
|
|
656
|
+
senderRole: value.senderRole,
|
|
657
|
+
actor: toGeneratedRouteFence(value.actor),
|
|
658
|
+
...toGeneratedSessionOwnerFence(value.session)
|
|
659
|
+
};
|
|
660
|
+
}
|
|
661
|
+
|
|
662
|
+
function fromGeneratedSessionRelocationSeal(
|
|
663
|
+
value: GeneratedSessionRelocationSeal42
|
|
664
|
+
): ServiceSessionRelocationSeal {
|
|
665
|
+
return {
|
|
666
|
+
relocation: value.relocation,
|
|
667
|
+
coordinator: fromGeneratedCoordinatorFence(value.coordinator),
|
|
668
|
+
senderRole: value.senderRole as ServiceSessionRelocationSeal['senderRole'],
|
|
669
|
+
actor: fromGeneratedRouteFence(value.actor),
|
|
670
|
+
session: fromGeneratedSessionOwnerFence(value)
|
|
671
|
+
};
|
|
672
|
+
}
|
|
673
|
+
|
|
674
|
+
function toGeneratedSessionRelocationSealed(
|
|
675
|
+
value: ServiceSessionRelocationSealed
|
|
676
|
+
): GeneratedSessionRelocationSealed43 {
|
|
677
|
+
return {
|
|
678
|
+
relocation: value.relocation,
|
|
679
|
+
coordinator: toGeneratedCoordinatorFence(value.coordinator),
|
|
680
|
+
actor: toGeneratedRouteFence(value.actor),
|
|
681
|
+
...toGeneratedSessionOwnerFence(value.session)
|
|
682
|
+
};
|
|
683
|
+
}
|
|
684
|
+
|
|
685
|
+
function fromGeneratedSessionRelocationSealed(
|
|
686
|
+
value: GeneratedSessionRelocationSealed43
|
|
687
|
+
): ServiceSessionRelocationSealed {
|
|
688
|
+
return {
|
|
689
|
+
relocation: value.relocation,
|
|
690
|
+
coordinator: fromGeneratedCoordinatorFence(value.coordinator),
|
|
691
|
+
actor: fromGeneratedRouteFence(value.actor),
|
|
692
|
+
session: fromGeneratedSessionOwnerFence(value)
|
|
693
|
+
};
|
|
694
|
+
}
|
|
695
|
+
|
|
696
|
+
function toGeneratedSessionRelocationRoute(
|
|
697
|
+
value: ServiceSessionRelocationRoute
|
|
698
|
+
): GeneratedSessionRelocationRoute44 {
|
|
699
|
+
const route = value.route.action === 'commit'
|
|
700
|
+
? {
|
|
701
|
+
...value.route,
|
|
702
|
+
targetNodeRid: toGeneratedRoutingId(value.route.targetNodeRid, 'targetNodeRid')
|
|
703
|
+
}
|
|
704
|
+
: value.route;
|
|
705
|
+
return {
|
|
706
|
+
relocation: value.relocation,
|
|
707
|
+
coordinator: toGeneratedCoordinatorFence(value.coordinator),
|
|
708
|
+
senderRole: value.senderRole,
|
|
709
|
+
actor: {
|
|
710
|
+
actorId: value.actor.actorId,
|
|
711
|
+
objectGeneration: value.actor.generation
|
|
712
|
+
},
|
|
713
|
+
...toGeneratedSessionOwnerFence(value.session),
|
|
714
|
+
route
|
|
715
|
+
};
|
|
716
|
+
}
|
|
717
|
+
|
|
718
|
+
function fromGeneratedSessionRelocationRoute(
|
|
719
|
+
value: GeneratedSessionRelocationRoute44
|
|
720
|
+
): ServiceSessionRelocationRoute {
|
|
721
|
+
const common = {
|
|
722
|
+
relocation: value.relocation,
|
|
723
|
+
coordinator: fromGeneratedCoordinatorFence(value.coordinator),
|
|
724
|
+
actor: { actorId: value.actor.actorId, generation: value.actor.objectGeneration, nodeRid: '' },
|
|
725
|
+
session: fromGeneratedSessionOwnerFence(value)
|
|
726
|
+
};
|
|
727
|
+
return value.route.action === 'commit'
|
|
728
|
+
? {
|
|
729
|
+
...common,
|
|
730
|
+
senderRole: value.senderRole as 'target' | 'coordinator',
|
|
731
|
+
route: {
|
|
732
|
+
...value.route,
|
|
733
|
+
targetNodeRid: fromGeneratedRoutingId(value.route.targetNodeRid, 'targetNodeRid')
|
|
734
|
+
}
|
|
735
|
+
}
|
|
736
|
+
: {
|
|
737
|
+
...common,
|
|
738
|
+
senderRole: value.senderRole as 'source' | 'coordinator',
|
|
739
|
+
route: value.route
|
|
740
|
+
};
|
|
741
|
+
}
|
|
742
|
+
|
|
743
|
+
function toGeneratedRelocationBase(value: ServiceWireRelocationBase) {
|
|
744
|
+
return {
|
|
745
|
+
relocation: value.relocation,
|
|
746
|
+
targetAttemptGeneration: value.targetAttemptGeneration,
|
|
747
|
+
coordinator: toGeneratedCoordinatorFence(value.coordinator)
|
|
748
|
+
};
|
|
749
|
+
}
|
|
750
|
+
|
|
751
|
+
function fromGeneratedRelocationBase(value: {
|
|
752
|
+
readonly relocation: ServiceWireOperationId;
|
|
753
|
+
readonly targetAttemptGeneration: bigint;
|
|
754
|
+
readonly coordinator: GeneratedCoordinatorFence;
|
|
755
|
+
}) {
|
|
756
|
+
return {
|
|
757
|
+
relocation: value.relocation,
|
|
758
|
+
targetAttemptGeneration: value.targetAttemptGeneration,
|
|
759
|
+
coordinator: fromGeneratedCoordinatorFence(value.coordinator)
|
|
760
|
+
};
|
|
761
|
+
}
|
|
762
|
+
|
|
763
|
+
function fromGeneratedRelocationPrepare(
|
|
764
|
+
value: ReturnType<typeof decodeGeneratedRelocationPrepare40>
|
|
765
|
+
): ServiceMaintenanceRelocationPrepare {
|
|
766
|
+
return {
|
|
767
|
+
kind: 'prepare',
|
|
768
|
+
...fromGeneratedRelocationBase(value),
|
|
769
|
+
target: fromGeneratedTargetFence(value.target),
|
|
770
|
+
initiatorRole: value.initiatorRole,
|
|
771
|
+
object: fromGeneratedRelocationObject(value.object),
|
|
772
|
+
sourceNodeRid: fromGeneratedRoutingId(value.sourceNodeRid, 'sourceNodeRid'),
|
|
773
|
+
sourceNodeGeneration: value.sourceNodeGeneration,
|
|
774
|
+
payloadTotalLength: value.payloadTotalLength,
|
|
775
|
+
payloadChunkCount: value.payloadChunkCount,
|
|
776
|
+
payloadChecksumCrc32c: value.payloadChecksumCrc32c,
|
|
777
|
+
applicationVersion: value.applicationVersion
|
|
778
|
+
};
|
|
779
|
+
}
|
|
780
|
+
|
|
781
|
+
function fromGeneratedRelocationReady(
|
|
782
|
+
value: ReturnType<typeof decodeGeneratedRelocationReady30>
|
|
783
|
+
): ServiceMaintenanceRelocationReady {
|
|
784
|
+
return {
|
|
785
|
+
kind: 'ready',
|
|
786
|
+
...fromGeneratedRelocationBase(value),
|
|
787
|
+
target: fromGeneratedTargetFence(value.target),
|
|
788
|
+
object: fromGeneratedRelocationObject(value.object),
|
|
789
|
+
senderRole: value.senderRole
|
|
790
|
+
};
|
|
791
|
+
}
|
|
792
|
+
|
|
793
|
+
function fromGeneratedRelocationFailed(
|
|
794
|
+
value: ReturnType<typeof decodeGeneratedRelocationFailed53>
|
|
795
|
+
): ServiceMaintenanceRelocationFailed {
|
|
796
|
+
return {
|
|
797
|
+
kind: 'failed',
|
|
798
|
+
...fromGeneratedRelocationBase(value),
|
|
799
|
+
target: fromGeneratedTargetFence(value.target),
|
|
800
|
+
object: fromGeneratedRelocationObject(value.object),
|
|
801
|
+
senderRole: value.senderRole,
|
|
802
|
+
failureCode: value.failureCode
|
|
803
|
+
};
|
|
804
|
+
}
|
|
805
|
+
|
|
806
|
+
function fromGeneratedRelocationData(
|
|
807
|
+
value: ReturnType<typeof decodeGeneratedRelocationData31>
|
|
808
|
+
): ServiceMaintenanceRelocationData {
|
|
809
|
+
return {
|
|
810
|
+
kind: 'data',
|
|
811
|
+
...fromGeneratedRelocationBase(value),
|
|
812
|
+
senderRole: value.senderRole,
|
|
813
|
+
object: fromGeneratedRelocationObject(value.object),
|
|
814
|
+
frozenRecord: decodeServiceWireFrozenRecord(value.record)
|
|
815
|
+
};
|
|
816
|
+
}
|
|
817
|
+
|
|
818
|
+
function fromGeneratedRelocationCutover(
|
|
819
|
+
value: ReturnType<typeof decodeGeneratedRelocationCutover34>
|
|
820
|
+
): ServiceMaintenanceRelocationCutover {
|
|
821
|
+
return {
|
|
822
|
+
kind: 'cutover',
|
|
823
|
+
...fromGeneratedRelocationBase(value),
|
|
824
|
+
senderRole: value.senderRole,
|
|
825
|
+
object: fromGeneratedRelocationObject(value.object),
|
|
826
|
+
boundaryRecordCount: value.boundaryRecordCount,
|
|
827
|
+
boundaryChecksumCrc32c: value.boundaryChecksumCrc32c
|
|
828
|
+
};
|
|
829
|
+
}
|
|
830
|
+
|
|
831
|
+
function fromGeneratedRelocationState(
|
|
832
|
+
value: ReturnType<typeof decodeGeneratedRelocationState52>
|
|
833
|
+
): ServiceMaintenanceRelocationState {
|
|
834
|
+
return {
|
|
835
|
+
kind: 'state',
|
|
836
|
+
...fromGeneratedRelocationBase(value),
|
|
837
|
+
senderRole: value.senderRole,
|
|
838
|
+
object: fromGeneratedRelocationObject(value.object),
|
|
839
|
+
chunkOrdinal: value.chunkOrdinal,
|
|
840
|
+
chunkData: Buffer.from(value.chunkData)
|
|
841
|
+
};
|
|
842
|
+
}
|
|
843
|
+
|
|
844
|
+
function toGeneratedReplyRelay(value: ServiceMaintenanceReplyRelay): GeneratedReplyRelay33 {
|
|
845
|
+
return {
|
|
846
|
+
operation: value.operation,
|
|
847
|
+
replyRouteId: value.replyRouteId,
|
|
848
|
+
context: {
|
|
849
|
+
contextKind: 'maintenanceRelocation',
|
|
850
|
+
relocation: value.relocation,
|
|
851
|
+
targetAttemptGeneration: value.targetAttemptGeneration,
|
|
852
|
+
coordinator: toGeneratedCoordinatorFence(value.coordinator),
|
|
853
|
+
participantId: value.participantId,
|
|
854
|
+
sequence: value.sequence
|
|
855
|
+
},
|
|
856
|
+
terminalResult: value.terminalResult,
|
|
857
|
+
failureCode: value.failureCode,
|
|
858
|
+
...(value.payload === undefined ? {} : {
|
|
859
|
+
payload: {
|
|
860
|
+
packetName: value.payload.packetName,
|
|
861
|
+
contentType: value.payload.contentType,
|
|
862
|
+
payload: value.payload.bytes
|
|
863
|
+
}
|
|
864
|
+
})
|
|
865
|
+
};
|
|
866
|
+
}
|
|
867
|
+
|
|
868
|
+
function fromGeneratedReplyRelay(value: GeneratedReplyRelay33): ServiceMaintenanceReplyRelay {
|
|
869
|
+
if (value.context.contextKind !== 'maintenanceRelocation') {
|
|
870
|
+
fail('replyRelay context must be maintenanceRelocation.');
|
|
871
|
+
}
|
|
872
|
+
return {
|
|
873
|
+
relocation: value.context.relocation,
|
|
874
|
+
targetAttemptGeneration: value.context.targetAttemptGeneration,
|
|
875
|
+
coordinator: fromGeneratedCoordinatorFence(value.context.coordinator),
|
|
876
|
+
operation: value.operation,
|
|
877
|
+
replyRouteId: value.replyRouteId,
|
|
878
|
+
participantId: value.context.participantId,
|
|
879
|
+
sequence: value.context.sequence,
|
|
880
|
+
terminalResult: value.terminalResult,
|
|
881
|
+
failureCode: value.failureCode,
|
|
882
|
+
...(value.payload === undefined ? {} : {
|
|
883
|
+
payload: {
|
|
884
|
+
packetName: value.payload.packetName,
|
|
885
|
+
contentType: value.payload.contentType,
|
|
886
|
+
bytes: Buffer.from(value.payload.payload)
|
|
887
|
+
}
|
|
888
|
+
})
|
|
889
|
+
};
|
|
890
|
+
}
|
|
891
|
+
|
|
892
|
+
export interface ServiceRetiredBoundSessionRouteFence {
|
|
893
|
+
readonly sessionOwnerNodeRid: string;
|
|
894
|
+
readonly sessionOwnerNodeGeneration: bigint;
|
|
895
|
+
readonly sessionOwnerId: string;
|
|
896
|
+
readonly sessionOwnerLeaseGeneration: bigint;
|
|
897
|
+
readonly sessionRid: string;
|
|
898
|
+
readonly retiredBindingGeneration: bigint;
|
|
899
|
+
}
|
|
900
|
+
|
|
901
|
+
export interface ServiceBoundSessionSource {
|
|
902
|
+
readonly sessionRid: string;
|
|
903
|
+
readonly bindingGeneration: bigint;
|
|
904
|
+
readonly sequence: bigint;
|
|
905
|
+
}
|
|
906
|
+
|
|
907
|
+
export interface ServiceInstanceRouteFence {
|
|
908
|
+
readonly targetNodeRid: string;
|
|
909
|
+
readonly targetNodeGeneration: bigint;
|
|
910
|
+
readonly targetSpotId: string;
|
|
911
|
+
readonly objectGeneration: bigint;
|
|
912
|
+
readonly ownerId: string;
|
|
913
|
+
readonly authorityOwnerGeneration: bigint;
|
|
914
|
+
readonly leaseGeneration: bigint;
|
|
915
|
+
readonly storeVersion: string;
|
|
916
|
+
}
|
|
917
|
+
|
|
918
|
+
export interface ServiceInstanceActivationTarget {
|
|
919
|
+
readonly targetNodeRid: string;
|
|
920
|
+
readonly targetNodeGeneration: bigint;
|
|
921
|
+
readonly targetSpotId: string;
|
|
922
|
+
readonly stableType: string;
|
|
923
|
+
readonly descriptorVersion: string;
|
|
924
|
+
}
|
|
925
|
+
|
|
926
|
+
export interface ServiceUserSpotReservationFence {
|
|
927
|
+
readonly reservationId: string;
|
|
928
|
+
readonly expectedStoreVersion: string;
|
|
929
|
+
readonly objectGeneration: bigint;
|
|
930
|
+
readonly authorityOwnerGeneration: bigint;
|
|
931
|
+
readonly targetNodeRid: string;
|
|
932
|
+
readonly targetNodeGeneration: bigint;
|
|
933
|
+
readonly targetOwnerId: string;
|
|
934
|
+
readonly targetOwnerLeaseGeneration: bigint;
|
|
935
|
+
readonly pendingCapacityDelta: number;
|
|
936
|
+
}
|
|
937
|
+
|
|
938
|
+
export interface ServiceUserSpotCreateRecord {
|
|
939
|
+
readonly kind: 'userSpotCreate';
|
|
940
|
+
readonly correlation: bigint;
|
|
941
|
+
readonly operation: { readonly high: bigint; readonly low: bigint };
|
|
942
|
+
readonly sourceNodeRid: string;
|
|
943
|
+
readonly sourceNodeGeneration: bigint;
|
|
944
|
+
readonly spotId: string;
|
|
945
|
+
readonly stableType: string;
|
|
946
|
+
readonly reservation: ServiceUserSpotReservationFence;
|
|
947
|
+
readonly deadlineUnixMs: bigint;
|
|
948
|
+
}
|
|
949
|
+
|
|
950
|
+
export interface ServiceActorCreateRecord {
|
|
951
|
+
readonly kind: 'actorCreate';
|
|
952
|
+
readonly correlation: bigint;
|
|
953
|
+
readonly operation: { readonly high: bigint; readonly low: bigint };
|
|
954
|
+
readonly sourceNodeRid: string;
|
|
955
|
+
readonly sourceNodeGeneration: bigint;
|
|
956
|
+
readonly actorId: string;
|
|
957
|
+
readonly stableType: string;
|
|
958
|
+
readonly reservation: ServiceUserSpotReservationFence;
|
|
959
|
+
readonly deadlineUnixMs: bigint;
|
|
960
|
+
}
|
|
961
|
+
|
|
962
|
+
export interface ServiceUserSpotCloseRecord {
|
|
963
|
+
readonly kind: 'userSpotClose';
|
|
964
|
+
readonly correlation: bigint;
|
|
965
|
+
readonly operation: { readonly high: bigint; readonly low: bigint };
|
|
966
|
+
readonly sourceNodeRid: string;
|
|
967
|
+
readonly sourceNodeGeneration: bigint;
|
|
968
|
+
readonly target: {
|
|
969
|
+
readonly spotId: string;
|
|
970
|
+
readonly objectGeneration: bigint;
|
|
971
|
+
readonly targetNodeRid: string;
|
|
972
|
+
readonly targetNodeGeneration: bigint;
|
|
973
|
+
readonly authorityOwnerGeneration: bigint;
|
|
974
|
+
readonly expectedStoreVersion: string;
|
|
975
|
+
};
|
|
976
|
+
readonly deadlineUnixMs: bigint;
|
|
977
|
+
}
|
|
978
|
+
|
|
979
|
+
export type ServiceMessageFollowRoute =
|
|
980
|
+
| {
|
|
981
|
+
readonly kind: 'actor';
|
|
982
|
+
readonly actor: ServiceActorRef;
|
|
983
|
+
readonly targetNodeRid: string;
|
|
984
|
+
readonly targetNodeGeneration: bigint;
|
|
985
|
+
readonly authorityOwnerGeneration: bigint;
|
|
986
|
+
readonly ownerLeaseGeneration: bigint;
|
|
987
|
+
}
|
|
988
|
+
| {
|
|
989
|
+
readonly kind: 'spot';
|
|
990
|
+
readonly spot: ServiceSpotRef;
|
|
991
|
+
readonly targetNodeRid: string;
|
|
992
|
+
readonly targetNodeGeneration: bigint;
|
|
993
|
+
readonly authorityOwnerGeneration: bigint;
|
|
994
|
+
readonly ownerLeaseGeneration: bigint;
|
|
995
|
+
};
|
|
996
|
+
|
|
997
|
+
export interface ServiceMessageFollowRecord {
|
|
998
|
+
readonly kind: 'messageFollow';
|
|
999
|
+
readonly source: ServiceMessageFollowRoute;
|
|
1000
|
+
readonly target: ServiceMessageFollowRoute;
|
|
1001
|
+
readonly hopCount: number;
|
|
1002
|
+
readonly queuedMessages: number;
|
|
1003
|
+
readonly queuedBytes: number;
|
|
1004
|
+
readonly originalOperation: ServiceWireOperationId;
|
|
1005
|
+
readonly originalReplyRouteId: bigint;
|
|
1006
|
+
}
|
|
1007
|
+
|
|
1008
|
+
export type ServiceBoundSessionTransition =
|
|
1009
|
+
| { readonly state: 'active'; readonly generation: bigint }
|
|
1010
|
+
| { readonly state: 'tombstone'; readonly retiredGeneration: bigint };
|
|
1011
|
+
|
|
1012
|
+
export type ServiceStatefulWireRecord =
|
|
1013
|
+
| {
|
|
1014
|
+
readonly kind: 'spotSend' | 'spotRequest';
|
|
1015
|
+
readonly correlation?: bigint;
|
|
1016
|
+
readonly sourceSpotId: string;
|
|
1017
|
+
readonly target: ServiceDirectSpotRouteFence;
|
|
1018
|
+
}
|
|
1019
|
+
| {
|
|
1020
|
+
readonly kind: 'logicalMulticast';
|
|
1021
|
+
readonly channelName: string;
|
|
1022
|
+
readonly topic: string;
|
|
1023
|
+
readonly sourceSpotId: string;
|
|
1024
|
+
}
|
|
1025
|
+
| {
|
|
1026
|
+
readonly kind: 'actorSend' | 'actorRequest';
|
|
1027
|
+
readonly correlation?: bigint;
|
|
1028
|
+
readonly sourceActor?: ServiceActorRef;
|
|
1029
|
+
readonly target: ServiceActorRouteFence;
|
|
1030
|
+
readonly boundSession?: ServiceBoundSessionSource;
|
|
1031
|
+
}
|
|
1032
|
+
| {
|
|
1033
|
+
readonly kind: 'actorLookup';
|
|
1034
|
+
readonly correlation: bigint;
|
|
1035
|
+
readonly actorId: string;
|
|
1036
|
+
}
|
|
1037
|
+
| {
|
|
1038
|
+
readonly kind: 'actorDestroy';
|
|
1039
|
+
readonly correlation: bigint;
|
|
1040
|
+
readonly actor: ServiceActorRouteFence;
|
|
1041
|
+
}
|
|
1042
|
+
| {
|
|
1043
|
+
readonly kind: 'actorJoin';
|
|
1044
|
+
readonly correlation: bigint;
|
|
1045
|
+
readonly actor: ServiceActorRouteFence;
|
|
1046
|
+
readonly entry: boolean;
|
|
1047
|
+
readonly target: ServiceSpotRouteFence;
|
|
1048
|
+
}
|
|
1049
|
+
| {
|
|
1050
|
+
readonly kind: 'boundSessionSend';
|
|
1051
|
+
readonly actor: ServiceActorRouteFence;
|
|
1052
|
+
readonly expectedBindingGeneration: bigint;
|
|
1053
|
+
}
|
|
1054
|
+
| {
|
|
1055
|
+
readonly kind: 'boundSessionBind';
|
|
1056
|
+
readonly correlation: bigint;
|
|
1057
|
+
readonly actor: ServiceActorRouteFence;
|
|
1058
|
+
readonly sessionRid: string;
|
|
1059
|
+
readonly binding: ServiceBoundSessionTransition;
|
|
1060
|
+
}
|
|
1061
|
+
| {
|
|
1062
|
+
readonly kind: 'boundSessionReplaced';
|
|
1063
|
+
readonly actorAuthority: ServiceBoundSessionActorAuthority;
|
|
1064
|
+
readonly retiredSession: ServiceRetiredBoundSessionRouteFence;
|
|
1065
|
+
}
|
|
1066
|
+
| {
|
|
1067
|
+
readonly kind: 'instanceSpot';
|
|
1068
|
+
readonly activation: 'ready';
|
|
1069
|
+
readonly route: ServiceInstanceRouteFence;
|
|
1070
|
+
readonly sourceNodeGeneration: bigint;
|
|
1071
|
+
readonly sourceNodeRid: string;
|
|
1072
|
+
readonly sourceSpotId?: string;
|
|
1073
|
+
readonly operationKind: 'send' | 'request';
|
|
1074
|
+
readonly operation: { readonly high: bigint; readonly low: bigint };
|
|
1075
|
+
readonly replyRouteId?: bigint;
|
|
1076
|
+
}
|
|
1077
|
+
| {
|
|
1078
|
+
readonly kind: 'instanceSpot';
|
|
1079
|
+
readonly activation: 'missing';
|
|
1080
|
+
readonly target: ServiceInstanceActivationTarget;
|
|
1081
|
+
readonly sourceNodeGeneration: bigint;
|
|
1082
|
+
readonly sourceNodeRid: string;
|
|
1083
|
+
readonly sourceSpotId?: string;
|
|
1084
|
+
readonly operationKind: 'send' | 'request';
|
|
1085
|
+
readonly operation: { readonly high: bigint; readonly low: bigint };
|
|
1086
|
+
readonly deadlineUnixMs: bigint;
|
|
1087
|
+
readonly replyRouteId?: bigint;
|
|
1088
|
+
}
|
|
1089
|
+
| ServiceUserSpotCreateRecord
|
|
1090
|
+
| ServiceUserSpotCloseRecord
|
|
1091
|
+
| ServiceActorCreateRecord
|
|
1092
|
+
| ServiceMessageFollowRecord;
|
|
1093
|
+
|
|
1094
|
+
export type ServiceStatefulReplyTail =
|
|
1095
|
+
| {
|
|
1096
|
+
readonly kind: 'actorLookup';
|
|
1097
|
+
readonly actor: ServiceActorRef;
|
|
1098
|
+
readonly spot: ServiceSpotRef;
|
|
1099
|
+
readonly membershipEpoch: bigint;
|
|
1100
|
+
readonly authorityOwnerGeneration: bigint;
|
|
1101
|
+
}
|
|
1102
|
+
| {
|
|
1103
|
+
readonly kind: 'actorJoin';
|
|
1104
|
+
readonly joinResult: 0 | 1;
|
|
1105
|
+
readonly spot?: ServiceSpotRef;
|
|
1106
|
+
readonly membershipEpoch?: bigint;
|
|
1107
|
+
/** Target's advertised valid receive chunk cap. 0 = not advertised (accepted only). */
|
|
1108
|
+
readonly receiveChunkLimitBytes?: number;
|
|
1109
|
+
}
|
|
1110
|
+
| {
|
|
1111
|
+
readonly kind: 'streamBind';
|
|
1112
|
+
readonly bindingGeneration: bigint;
|
|
1113
|
+
readonly authorityOwnerGeneration: bigint;
|
|
1114
|
+
}
|
|
1115
|
+
| {
|
|
1116
|
+
readonly kind: 'userSpotCreate';
|
|
1117
|
+
readonly createResult: 'existing' | 'created' | 'rejected';
|
|
1118
|
+
readonly spotId: string;
|
|
1119
|
+
readonly objectGeneration: bigint;
|
|
1120
|
+
}
|
|
1121
|
+
| {
|
|
1122
|
+
readonly kind: 'userSpotClose';
|
|
1123
|
+
readonly closed: boolean;
|
|
1124
|
+
}
|
|
1125
|
+
| {
|
|
1126
|
+
readonly kind: 'actorCreate';
|
|
1127
|
+
readonly createResult: 'existing' | 'created' | 'rejected';
|
|
1128
|
+
readonly actor?: ServiceActorRef & { readonly nodeRid: string };
|
|
1129
|
+
};
|
|
1130
|
+
|
|
1131
|
+
export interface ServiceStatefulReply {
|
|
1132
|
+
readonly correlation: bigint;
|
|
1133
|
+
readonly terminalResult: number;
|
|
1134
|
+
readonly failureCode: number;
|
|
1135
|
+
readonly tail?: ServiceStatefulReplyTail;
|
|
1136
|
+
}
|
|
1137
|
+
|
|
1138
|
+
export function encodeSpotHeader(
|
|
1139
|
+
kind: 'spotSend' | 'spotRequest',
|
|
1140
|
+
sourceSpotId: string,
|
|
1141
|
+
target: ServiceDirectSpotRouteFence,
|
|
1142
|
+
correlation?: bigint
|
|
1143
|
+
): Buffer {
|
|
1144
|
+
return concat(
|
|
1145
|
+
prefix(kind === 'spotSend'
|
|
1146
|
+
? M6bServiceWireCommand.spotSend
|
|
1147
|
+
: M6bServiceWireCommand.spotRequest),
|
|
1148
|
+
...(kind === 'spotRequest' ? [u64(requirePositive(correlation, 'correlation'))] : []),
|
|
1149
|
+
rid(sourceSpotId, 'sourceSpotId'),
|
|
1150
|
+
directSpotFence(target)
|
|
1151
|
+
);
|
|
1152
|
+
}
|
|
1153
|
+
|
|
1154
|
+
export function encodeActorHeader(
|
|
1155
|
+
kind: 'actorSend' | 'actorRequest',
|
|
1156
|
+
target: ServiceActorRouteFence,
|
|
1157
|
+
correlation?: bigint,
|
|
1158
|
+
sourceActor?: ServiceActorRef,
|
|
1159
|
+
boundSession?: ServiceBoundSessionSource
|
|
1160
|
+
): Buffer {
|
|
1161
|
+
const flags = boundSession === undefined
|
|
1162
|
+
? 0
|
|
1163
|
+
: M6bServiceWireFlag.boundSession | M6bServiceWireFlag.sourceSpotId;
|
|
1164
|
+
return concat(
|
|
1165
|
+
prefix(
|
|
1166
|
+
kind === 'actorSend'
|
|
1167
|
+
? M6bServiceWireCommand.actorSend
|
|
1168
|
+
: M6bServiceWireCommand.actorRequest,
|
|
1169
|
+
flags
|
|
1170
|
+
),
|
|
1171
|
+
...(kind === 'actorRequest' ? [u64(requirePositive(correlation, 'correlation'))] : []),
|
|
1172
|
+
optionalActor(sourceActor),
|
|
1173
|
+
actorFence(target),
|
|
1174
|
+
...(boundSession === undefined
|
|
1175
|
+
? []
|
|
1176
|
+
: [
|
|
1177
|
+
rid(boundSession.sessionRid, 'sourceSessionRid'),
|
|
1178
|
+
u64(boundSession.bindingGeneration),
|
|
1179
|
+
u64(boundSession.sequence)
|
|
1180
|
+
])
|
|
1181
|
+
);
|
|
1182
|
+
}
|
|
1183
|
+
|
|
1184
|
+
export function encodeLogicalMulticastHeader(
|
|
1185
|
+
channelName: string,
|
|
1186
|
+
topic: string,
|
|
1187
|
+
sourceSpotId: string
|
|
1188
|
+
): Buffer {
|
|
1189
|
+
return concat(
|
|
1190
|
+
prefix(M6bServiceWireCommand.logicalMulticast),
|
|
1191
|
+
text8(channelName, 'channelName'),
|
|
1192
|
+
text8(topic, 'topic'),
|
|
1193
|
+
rid(sourceSpotId, 'sourceSpotId')
|
|
1194
|
+
);
|
|
1195
|
+
}
|
|
1196
|
+
|
|
1197
|
+
export function encodeActorLookupHeader(correlation: bigint, actorId: string): Buffer {
|
|
1198
|
+
return concat(
|
|
1199
|
+
prefix(M6bServiceWireCommand.actorLookup),
|
|
1200
|
+
u64(correlation),
|
|
1201
|
+
text8(actorId, 'actorId')
|
|
1202
|
+
);
|
|
1203
|
+
}
|
|
1204
|
+
|
|
1205
|
+
export function encodeActorDestroyHeader(
|
|
1206
|
+
correlation: bigint,
|
|
1207
|
+
actor: ServiceActorRouteFence
|
|
1208
|
+
): Buffer {
|
|
1209
|
+
return concat(prefix(M6bServiceWireCommand.actorDestroy), u64(correlation), actorFence(actor));
|
|
1210
|
+
}
|
|
1211
|
+
|
|
1212
|
+
export function encodeBoundSessionSendHeader(
|
|
1213
|
+
actor: ServiceActorRouteFence,
|
|
1214
|
+
expectedBindingGeneration: bigint
|
|
1215
|
+
): Buffer {
|
|
1216
|
+
return concat(
|
|
1217
|
+
prefix(M6bServiceWireCommand.boundSessionSend),
|
|
1218
|
+
actorFence(actor),
|
|
1219
|
+
u64(expectedBindingGeneration)
|
|
1220
|
+
);
|
|
1221
|
+
}
|
|
1222
|
+
|
|
1223
|
+
export function encodeBoundSessionBindHeader(
|
|
1224
|
+
correlation: bigint,
|
|
1225
|
+
actor: ServiceActorRouteFence,
|
|
1226
|
+
sessionRid: string,
|
|
1227
|
+
binding: ServiceBoundSessionTransition
|
|
1228
|
+
): Buffer {
|
|
1229
|
+
const body = binding.state === 'active'
|
|
1230
|
+
? u64(binding.generation)
|
|
1231
|
+
: u64(binding.retiredGeneration);
|
|
1232
|
+
return concat(
|
|
1233
|
+
prefix(M6bServiceWireCommand.boundSessionBind),
|
|
1234
|
+
u64(correlation),
|
|
1235
|
+
actorFence(actor),
|
|
1236
|
+
rid(sessionRid, 'sessionRid'),
|
|
1237
|
+
Buffer.of(binding.state === 'active' ? 1 : 2),
|
|
1238
|
+
u16(body.byteLength),
|
|
1239
|
+
body
|
|
1240
|
+
);
|
|
1241
|
+
}
|
|
1242
|
+
|
|
1243
|
+
export function encodeBoundSessionReplacedHeader(
|
|
1244
|
+
actorAuthority: ServiceBoundSessionActorAuthority,
|
|
1245
|
+
retiredSession: ServiceRetiredBoundSessionRouteFence
|
|
1246
|
+
): Buffer {
|
|
1247
|
+
return concat(
|
|
1248
|
+
prefix(M6bServiceWireCommand.boundSessionReplaced),
|
|
1249
|
+
actorAuthorityFence(actorAuthority),
|
|
1250
|
+
rid(retiredSession.sessionOwnerNodeRid, 'sessionOwnerNodeRid'),
|
|
1251
|
+
u64(retiredSession.sessionOwnerNodeGeneration),
|
|
1252
|
+
text8(retiredSession.sessionOwnerId, 'sessionOwnerId'),
|
|
1253
|
+
u64(retiredSession.sessionOwnerLeaseGeneration),
|
|
1254
|
+
rid(retiredSession.sessionRid, 'sessionRid'),
|
|
1255
|
+
u64(retiredSession.retiredBindingGeneration)
|
|
1256
|
+
);
|
|
1257
|
+
}
|
|
1258
|
+
|
|
1259
|
+
/** Encodes canonical service-wire command 42. */
|
|
1260
|
+
export function encodeSessionRelocationSeal(value: ServiceSessionRelocationSeal): Buffer {
|
|
1261
|
+
return Buffer.from(encodeGeneratedSessionRelocationSeal42(
|
|
1262
|
+
toGeneratedSessionRelocationSeal(value)
|
|
1263
|
+
));
|
|
1264
|
+
}
|
|
1265
|
+
|
|
1266
|
+
/** Decodes canonical service-wire command 42. */
|
|
1267
|
+
export function decodeSessionRelocationSeal(frame: Uint8Array): ServiceSessionRelocationSeal {
|
|
1268
|
+
return fromGeneratedSessionRelocationSeal(decodeGeneratedSessionRelocationSeal42(frame));
|
|
1269
|
+
}
|
|
1270
|
+
|
|
1271
|
+
/** Encodes canonical service-wire command 43. */
|
|
1272
|
+
export function encodeSessionRelocationSealed(value: ServiceSessionRelocationSealed): Buffer {
|
|
1273
|
+
return Buffer.from(encodeGeneratedSessionRelocationSealed43(
|
|
1274
|
+
toGeneratedSessionRelocationSealed(value)
|
|
1275
|
+
));
|
|
1276
|
+
}
|
|
1277
|
+
|
|
1278
|
+
/** Decodes canonical service-wire command 43. */
|
|
1279
|
+
export function decodeSessionRelocationSealed(frame: Uint8Array): ServiceSessionRelocationSealed {
|
|
1280
|
+
return fromGeneratedSessionRelocationSealed(decodeGeneratedSessionRelocationSealed43(frame));
|
|
1281
|
+
}
|
|
1282
|
+
|
|
1283
|
+
/** Encodes canonical service-wire command 44. */
|
|
1284
|
+
export function encodeSessionRelocationRoute(value: ServiceSessionRelocationRoute): Buffer {
|
|
1285
|
+
return Buffer.from(encodeGeneratedSessionRelocationRoute44(
|
|
1286
|
+
toGeneratedSessionRelocationRoute(value)
|
|
1287
|
+
));
|
|
1288
|
+
}
|
|
1289
|
+
|
|
1290
|
+
/** Decodes canonical service-wire command 44. */
|
|
1291
|
+
export function decodeSessionRelocationRoute(frame: Uint8Array): ServiceSessionRelocationRoute {
|
|
1292
|
+
return fromGeneratedSessionRelocationRoute(decodeGeneratedSessionRelocationRoute44(frame));
|
|
1293
|
+
}
|
|
1294
|
+
|
|
1295
|
+
export function encodeInstanceSpotHeader(
|
|
1296
|
+
route: ServiceInstanceRouteFence,
|
|
1297
|
+
sourceNodeGeneration: bigint,
|
|
1298
|
+
sourceNodeRid: string,
|
|
1299
|
+
sourceSpotId: string | undefined,
|
|
1300
|
+
operationKind: 'send' | 'request',
|
|
1301
|
+
operation: { readonly high: bigint; readonly low: bigint },
|
|
1302
|
+
replyRouteId?: bigint,
|
|
1303
|
+
hasMetadata = false
|
|
1304
|
+
): Buffer {
|
|
1305
|
+
const routeBody = concat(
|
|
1306
|
+
rid(route.targetNodeRid, 'targetNodeRid'),
|
|
1307
|
+
u64(route.targetNodeGeneration),
|
|
1308
|
+
rid(route.targetSpotId, 'targetSpotId'),
|
|
1309
|
+
u64(route.objectGeneration),
|
|
1310
|
+
text8(route.ownerId, 'ownerId'),
|
|
1311
|
+
u64(route.authorityOwnerGeneration),
|
|
1312
|
+
u64(route.leaseGeneration),
|
|
1313
|
+
text16(route.storeVersion, 'storeVersion')
|
|
1314
|
+
);
|
|
1315
|
+
if (
|
|
1316
|
+
operationKind === 'send'
|
|
1317
|
+
&& (operation.high !== 0n || operation.low !== 0n || replyRouteId !== undefined)
|
|
1318
|
+
) {
|
|
1319
|
+
throw new RangeError('Instance Spot send must not carry an operation or reply route.');
|
|
1320
|
+
}
|
|
1321
|
+
if (operationKind === 'request' && operation.high === 0n && operation.low === 0n) {
|
|
1322
|
+
throw new RangeError('Instance Spot request requires a non-zero operation.');
|
|
1323
|
+
}
|
|
1324
|
+
return concat(
|
|
1325
|
+
prefix(
|
|
1326
|
+
M6bServiceWireCommand.instanceSpot,
|
|
1327
|
+
hasMetadata ? M6bServiceWireFlag.metadata : 0
|
|
1328
|
+
),
|
|
1329
|
+
Buffer.of(1),
|
|
1330
|
+
u16(routeBody.byteLength),
|
|
1331
|
+
routeBody,
|
|
1332
|
+
u64Any(sourceNodeGeneration),
|
|
1333
|
+
rid(sourceNodeRid, 'sourceNodeRid'),
|
|
1334
|
+
optionalRid(sourceSpotId),
|
|
1335
|
+
Buffer.of(operationKind === 'send' ? 1 : 2),
|
|
1336
|
+
u64Any(operation.high),
|
|
1337
|
+
u64Any(operation.low),
|
|
1338
|
+
...(operationKind === 'request'
|
|
1339
|
+
? [u64(requirePositive(replyRouteId, 'replyRouteId'))]
|
|
1340
|
+
: [])
|
|
1341
|
+
);
|
|
1342
|
+
}
|
|
1343
|
+
|
|
1344
|
+
export function encodeInstanceSpotActivationHeader(
|
|
1345
|
+
target: ServiceInstanceActivationTarget,
|
|
1346
|
+
sourceNodeGeneration: bigint,
|
|
1347
|
+
sourceNodeRid: string,
|
|
1348
|
+
sourceSpotId: string | undefined,
|
|
1349
|
+
operationKind: 'send' | 'request',
|
|
1350
|
+
operation: { readonly high: bigint; readonly low: bigint },
|
|
1351
|
+
deadlineUnixMs: bigint,
|
|
1352
|
+
replyRouteId?: bigint,
|
|
1353
|
+
hasMetadata = false
|
|
1354
|
+
): Buffer {
|
|
1355
|
+
if (operation.high === 0n && operation.low === 0n) {
|
|
1356
|
+
throw new RangeError('Instance Spot activation requires a non-zero operation identity.');
|
|
1357
|
+
}
|
|
1358
|
+
if (deadlineUnixMs <= 0n) {
|
|
1359
|
+
throw new RangeError('Instance Spot activation requires a positive deadline.');
|
|
1360
|
+
}
|
|
1361
|
+
if (operationKind === 'send' && replyRouteId !== undefined) {
|
|
1362
|
+
throw new RangeError('Instance Spot send must not carry a reply route.');
|
|
1363
|
+
}
|
|
1364
|
+
const targetBody = concat(
|
|
1365
|
+
rid(target.targetNodeRid, 'targetNodeRid'),
|
|
1366
|
+
u64(target.targetNodeGeneration),
|
|
1367
|
+
rid(target.targetSpotId, 'targetSpotId'),
|
|
1368
|
+
text16(target.stableType, 'stableType'),
|
|
1369
|
+
text16(target.descriptorVersion, 'descriptorVersion')
|
|
1370
|
+
);
|
|
1371
|
+
return concat(
|
|
1372
|
+
prefix(
|
|
1373
|
+
M6bServiceWireCommand.instanceSpot,
|
|
1374
|
+
hasMetadata ? M6bServiceWireFlag.metadata : 0
|
|
1375
|
+
),
|
|
1376
|
+
Buffer.of(2),
|
|
1377
|
+
u16(targetBody.byteLength),
|
|
1378
|
+
targetBody,
|
|
1379
|
+
u64Any(sourceNodeGeneration),
|
|
1380
|
+
rid(sourceNodeRid, 'sourceNodeRid'),
|
|
1381
|
+
optionalRid(sourceSpotId),
|
|
1382
|
+
Buffer.of(operationKind === 'send' ? 1 : 2),
|
|
1383
|
+
u64Any(operation.high),
|
|
1384
|
+
u64Any(operation.low),
|
|
1385
|
+
u64(deadlineUnixMs),
|
|
1386
|
+
...(operationKind === 'request'
|
|
1387
|
+
? [u64(requirePositive(replyRouteId, 'replyRouteId'))]
|
|
1388
|
+
: [])
|
|
1389
|
+
);
|
|
1390
|
+
}
|
|
1391
|
+
|
|
1392
|
+
export function encodeUserSpotCreateHeader(record: Omit<ServiceUserSpotCreateRecord, 'kind'>): Buffer {
|
|
1393
|
+
return Buffer.from(encodeGeneratedUserSpotCreate47(toGeneratedUserSpotCreate(record)));
|
|
1394
|
+
}
|
|
1395
|
+
|
|
1396
|
+
export function encodeActorCreateHeader(record: Omit<ServiceActorCreateRecord, 'kind'>): Buffer {
|
|
1397
|
+
return Buffer.from(encodeGeneratedActorCreate49(toGeneratedActorCreate(record)));
|
|
1398
|
+
}
|
|
1399
|
+
|
|
1400
|
+
export function encodeUserSpotCloseHeader(record: Omit<ServiceUserSpotCloseRecord, 'kind'>): Buffer {
|
|
1401
|
+
return Buffer.from(encodeGeneratedUserSpotClose48(toGeneratedUserSpotClose(record)));
|
|
1402
|
+
}
|
|
1403
|
+
|
|
1404
|
+
export function encodeMessageFollowHeader(
|
|
1405
|
+
record: Omit<ServiceMessageFollowRecord, 'kind'>
|
|
1406
|
+
): Buffer {
|
|
1407
|
+
validateMessageFollowRecord(record);
|
|
1408
|
+
const body = concat(
|
|
1409
|
+
messageFollowRoute(record.source),
|
|
1410
|
+
messageFollowRoute(record.target),
|
|
1411
|
+
Buffer.of(record.hopCount),
|
|
1412
|
+
u32(record.queuedMessages, 'queuedMessages'),
|
|
1413
|
+
u32(record.queuedBytes, 'queuedBytes'),
|
|
1414
|
+
u64Any(record.originalOperation.high),
|
|
1415
|
+
u64Any(record.originalOperation.low),
|
|
1416
|
+
u64Any(record.originalReplyRouteId)
|
|
1417
|
+
);
|
|
1418
|
+
if (body.byteLength > 16 * 1024 * 1024) {
|
|
1419
|
+
throw new RangeError('Message Follow body exceeds 16 MiB.');
|
|
1420
|
+
}
|
|
1421
|
+
return concat(
|
|
1422
|
+
prefix(M6bServiceWireCommand.messageFollow),
|
|
1423
|
+
Buffer.of(1),
|
|
1424
|
+
u32(body.byteLength, 'messageFollow.length'),
|
|
1425
|
+
body
|
|
1426
|
+
);
|
|
1427
|
+
}
|
|
1428
|
+
|
|
1429
|
+
export function decodeStatefulHeader(frame: Uint8Array): ServiceStatefulWireRecord {
|
|
1430
|
+
switch (frame[3]) {
|
|
1431
|
+
case M6bServiceWireCommand.userSpotCreate:
|
|
1432
|
+
return fromGeneratedUserSpotCreate(decodeGeneratedUserSpotCreate47(frame));
|
|
1433
|
+
case M6bServiceWireCommand.userSpotClose:
|
|
1434
|
+
return fromGeneratedUserSpotClose(decodeGeneratedUserSpotClose48(frame));
|
|
1435
|
+
case M6bServiceWireCommand.actorCreate:
|
|
1436
|
+
return fromGeneratedActorCreate(decodeGeneratedActorCreate49(frame));
|
|
1437
|
+
}
|
|
1438
|
+
const reader = new Reader(frame);
|
|
1439
|
+
const command = reader.prefix();
|
|
1440
|
+
switch (command.command) {
|
|
1441
|
+
case M6bServiceWireCommand.spotSend:
|
|
1442
|
+
case M6bServiceWireCommand.spotRequest: {
|
|
1443
|
+
requireFlags(command.flags, 0);
|
|
1444
|
+
const request = command.command === M6bServiceWireCommand.spotRequest;
|
|
1445
|
+
const correlation = request ? reader.nonZeroU64('correlation') : undefined;
|
|
1446
|
+
const sourceSpotId = reader.rid('sourceSpotId');
|
|
1447
|
+
const target = reader.directSpotFence();
|
|
1448
|
+
reader.end();
|
|
1449
|
+
return {
|
|
1450
|
+
kind: request ? 'spotRequest' : 'spotSend',
|
|
1451
|
+
...(correlation === undefined ? {} : { correlation }),
|
|
1452
|
+
sourceSpotId,
|
|
1453
|
+
target
|
|
1454
|
+
};
|
|
1455
|
+
}
|
|
1456
|
+
case M6bServiceWireCommand.actorSend:
|
|
1457
|
+
case M6bServiceWireCommand.actorRequest: {
|
|
1458
|
+
const request = command.command === M6bServiceWireCommand.actorRequest;
|
|
1459
|
+
const hasBinding = command.flags !== 0;
|
|
1460
|
+
requireFlags(
|
|
1461
|
+
command.flags,
|
|
1462
|
+
hasBinding
|
|
1463
|
+
? M6bServiceWireFlag.boundSession | M6bServiceWireFlag.sourceSpotId
|
|
1464
|
+
: 0
|
|
1465
|
+
);
|
|
1466
|
+
const correlation = request ? reader.nonZeroU64('correlation') : undefined;
|
|
1467
|
+
const sourceActor = reader.optionalActor();
|
|
1468
|
+
const target = reader.actorFence();
|
|
1469
|
+
const boundSession = hasBinding
|
|
1470
|
+
? {
|
|
1471
|
+
sessionRid: reader.rid('sourceSessionRid'),
|
|
1472
|
+
bindingGeneration: reader.nonZeroU64('sourceBindingGeneration'),
|
|
1473
|
+
sequence: reader.nonZeroU64('sourceSessionSequence')
|
|
1474
|
+
}
|
|
1475
|
+
: undefined;
|
|
1476
|
+
reader.end();
|
|
1477
|
+
return {
|
|
1478
|
+
kind: request ? 'actorRequest' : 'actorSend',
|
|
1479
|
+
...(correlation === undefined ? {} : { correlation }),
|
|
1480
|
+
...(sourceActor === undefined ? {} : { sourceActor }),
|
|
1481
|
+
target,
|
|
1482
|
+
...(boundSession === undefined ? {} : { boundSession })
|
|
1483
|
+
};
|
|
1484
|
+
}
|
|
1485
|
+
case M6bServiceWireCommand.logicalMulticast: {
|
|
1486
|
+
requireFlags(command.flags, 0);
|
|
1487
|
+
const result = {
|
|
1488
|
+
kind: 'logicalMulticast' as const,
|
|
1489
|
+
channelName: reader.text8('channelName'),
|
|
1490
|
+
topic: reader.text8('topic'),
|
|
1491
|
+
sourceSpotId: reader.rid('sourceSpotId')
|
|
1492
|
+
};
|
|
1493
|
+
reader.end();
|
|
1494
|
+
return result;
|
|
1495
|
+
}
|
|
1496
|
+
case M6bServiceWireCommand.actorLookup: {
|
|
1497
|
+
requireFlags(command.flags, 0);
|
|
1498
|
+
const result = {
|
|
1499
|
+
kind: 'actorLookup' as const,
|
|
1500
|
+
correlation: reader.nonZeroU64('correlation'),
|
|
1501
|
+
actorId: reader.text8('actorId')
|
|
1502
|
+
};
|
|
1503
|
+
reader.end();
|
|
1504
|
+
return result;
|
|
1505
|
+
}
|
|
1506
|
+
case M6bServiceWireCommand.actorDestroy: {
|
|
1507
|
+
requireFlags(command.flags, 0);
|
|
1508
|
+
const result = {
|
|
1509
|
+
kind: 'actorDestroy' as const,
|
|
1510
|
+
correlation: reader.nonZeroU64('correlation'),
|
|
1511
|
+
actor: reader.actorFence()
|
|
1512
|
+
};
|
|
1513
|
+
reader.end();
|
|
1514
|
+
return result;
|
|
1515
|
+
}
|
|
1516
|
+
case M6bServiceWireCommand.actorJoin: {
|
|
1517
|
+
// Command 28 is canonical-only; the generated codec owns its validation.
|
|
1518
|
+
const decoded = decodeActorJoin28([frame]);
|
|
1519
|
+
return {
|
|
1520
|
+
kind: 'actorJoin',
|
|
1521
|
+
correlation: decoded.correlation,
|
|
1522
|
+
actor: {
|
|
1523
|
+
actor: {
|
|
1524
|
+
actorId: decoded.actor.id,
|
|
1525
|
+
generation: decoded.actor.generation,
|
|
1526
|
+
nodeRid: Buffer.from(decoded.actor.targetNodeRid).toString('utf8')
|
|
1527
|
+
},
|
|
1528
|
+
targetNodeGeneration: decoded.actor.targetNodeGeneration,
|
|
1529
|
+
authorityOwnerGeneration: decoded.actor.expectedAuthorityOwnerGeneration,
|
|
1530
|
+
ownerLeaseGeneration: decoded.actor.expectedOwnerLeaseGeneration
|
|
1531
|
+
},
|
|
1532
|
+
entry: decoded.entry,
|
|
1533
|
+
target: {
|
|
1534
|
+
spot: {
|
|
1535
|
+
spotId: decoded.targetSpot.id,
|
|
1536
|
+
generation: decoded.targetSpot.generation
|
|
1537
|
+
},
|
|
1538
|
+
targetNodeRid: Buffer.from(decoded.targetSpot.targetNodeRid).toString('utf8'),
|
|
1539
|
+
targetNodeGeneration: decoded.targetSpot.targetNodeGeneration,
|
|
1540
|
+
authorityOwnerGeneration: decoded.targetSpot.expectedAuthorityOwnerGeneration,
|
|
1541
|
+
ownerLeaseGeneration: decoded.targetSpot.expectedOwnerLeaseGeneration
|
|
1542
|
+
}
|
|
1543
|
+
};
|
|
1544
|
+
}
|
|
1545
|
+
case M6bServiceWireCommand.boundSessionSend: {
|
|
1546
|
+
requireFlags(command.flags, 0);
|
|
1547
|
+
const actor = reader.actorFence();
|
|
1548
|
+
const expectedBindingGeneration = reader.nonZeroU64('expectedBindingGeneration');
|
|
1549
|
+
reader.end();
|
|
1550
|
+
return { kind: 'boundSessionSend', actor, expectedBindingGeneration };
|
|
1551
|
+
}
|
|
1552
|
+
case M6bServiceWireCommand.boundSessionBind: {
|
|
1553
|
+
requireFlags(command.flags, 0);
|
|
1554
|
+
const correlation = reader.nonZeroU64('correlation');
|
|
1555
|
+
const actor = reader.actorFence();
|
|
1556
|
+
const sessionRid = reader.rid('sessionRid');
|
|
1557
|
+
const state = reader.u8('bindingState');
|
|
1558
|
+
const bodyLength = reader.u16('bindingBodyLength');
|
|
1559
|
+
if (bodyLength !== 8) fail('Binding transition body must contain one u64.');
|
|
1560
|
+
const generation = reader.nonZeroU64('bindingGeneration');
|
|
1561
|
+
reader.end();
|
|
1562
|
+
if (state !== 1 && state !== 2) fail('Unknown binding transition state.');
|
|
1563
|
+
return {
|
|
1564
|
+
kind: 'boundSessionBind',
|
|
1565
|
+
correlation,
|
|
1566
|
+
actor,
|
|
1567
|
+
sessionRid,
|
|
1568
|
+
binding: state === 1
|
|
1569
|
+
? { state: 'active', generation }
|
|
1570
|
+
: { state: 'tombstone', retiredGeneration: generation }
|
|
1571
|
+
};
|
|
1572
|
+
}
|
|
1573
|
+
case M6bServiceWireCommand.boundSessionReplaced: {
|
|
1574
|
+
requireFlags(command.flags, 0);
|
|
1575
|
+
const actor = reader.actorRef('actorAuthority.actor');
|
|
1576
|
+
const targetNodeRid = reader.rid('actorAuthority.targetNodeRid');
|
|
1577
|
+
const actorAuthority = {
|
|
1578
|
+
actor: { ...actor, nodeRid: targetNodeRid },
|
|
1579
|
+
targetNodeGeneration: reader.nonZeroU64('actorAuthority.targetNodeGeneration'),
|
|
1580
|
+
authorityOwnerGeneration: reader.nonZeroU64(
|
|
1581
|
+
'actorAuthority.expectedAuthorityOwnerGeneration'
|
|
1582
|
+
),
|
|
1583
|
+
ownerLeaseGeneration: reader.nonZeroU64(
|
|
1584
|
+
'actorAuthority.expectedOwnerLeaseGeneration'
|
|
1585
|
+
)
|
|
1586
|
+
};
|
|
1587
|
+
const retiredSession = {
|
|
1588
|
+
sessionOwnerNodeRid: reader.rid('sessionOwnerNodeRid'),
|
|
1589
|
+
sessionOwnerNodeGeneration: reader.nonZeroU64('sessionOwnerNodeGeneration'),
|
|
1590
|
+
sessionOwnerId: reader.text8('sessionOwnerId'),
|
|
1591
|
+
sessionOwnerLeaseGeneration: reader.nonZeroU64('sessionOwnerLeaseGeneration'),
|
|
1592
|
+
sessionRid: reader.rid('sessionRid'),
|
|
1593
|
+
retiredBindingGeneration: reader.nonZeroU64('retiredBindingGeneration')
|
|
1594
|
+
};
|
|
1595
|
+
reader.end();
|
|
1596
|
+
return { kind: 'boundSessionReplaced', actorAuthority, retiredSession };
|
|
1597
|
+
}
|
|
1598
|
+
case M6bServiceWireCommand.instanceSpot: {
|
|
1599
|
+
if ((command.flags & ~M6bServiceWireFlag.metadata) !== 0) {
|
|
1600
|
+
fail(`Invalid command flags '${command.flags}'.`);
|
|
1601
|
+
}
|
|
1602
|
+
const version = reader.u8('instanceRoute.version');
|
|
1603
|
+
if (version !== 1 && version !== 2) fail('Unsupported Instance route version.');
|
|
1604
|
+
const routeLength = reader.u16('instanceRoute.length');
|
|
1605
|
+
const routeEnd = reader.offset + routeLength;
|
|
1606
|
+
const commonTarget = {
|
|
1607
|
+
targetNodeRid: reader.rid('targetNodeRid'),
|
|
1608
|
+
targetNodeGeneration: reader.nonZeroU64('targetNodeGeneration'),
|
|
1609
|
+
targetSpotId: reader.rid('targetSpotId')
|
|
1610
|
+
};
|
|
1611
|
+
const route: ServiceInstanceRouteFence | undefined = version === 1
|
|
1612
|
+
? {
|
|
1613
|
+
...commonTarget,
|
|
1614
|
+
objectGeneration: reader.nonZeroU64('objectGeneration'),
|
|
1615
|
+
ownerId: reader.text8('ownerId'),
|
|
1616
|
+
authorityOwnerGeneration: reader.nonZeroU64('authorityOwnerGeneration'),
|
|
1617
|
+
leaseGeneration: reader.nonZeroU64('leaseGeneration'),
|
|
1618
|
+
storeVersion: reader.text16('storeVersion')
|
|
1619
|
+
}
|
|
1620
|
+
: undefined;
|
|
1621
|
+
const target: ServiceInstanceActivationTarget | undefined = version === 2
|
|
1622
|
+
? {
|
|
1623
|
+
...commonTarget,
|
|
1624
|
+
stableType: reader.text16('stableType'),
|
|
1625
|
+
descriptorVersion: reader.text16('descriptorVersion')
|
|
1626
|
+
}
|
|
1627
|
+
: undefined;
|
|
1628
|
+
if (reader.offset !== routeEnd) fail('Invalid Instance route body length.');
|
|
1629
|
+
const sourceNodeGeneration = reader.nonZeroU64('sourceNodeGeneration');
|
|
1630
|
+
const sourceNodeRid = reader.rid('sourceNodeRid');
|
|
1631
|
+
const sourceSpotId = reader.optionalRid('sourceSpotId');
|
|
1632
|
+
const operationValue = reader.u8('operationKind');
|
|
1633
|
+
if (operationValue !== 1 && operationValue !== 2) fail('Unknown Instance operation kind.');
|
|
1634
|
+
const operation = {
|
|
1635
|
+
high: reader.u64('operation.high'),
|
|
1636
|
+
low: reader.u64('operation.low')
|
|
1637
|
+
};
|
|
1638
|
+
const operationKind = operationValue === 1 ? 'send' as const : 'request' as const;
|
|
1639
|
+
if (version === 1 && (
|
|
1640
|
+
(operationKind === 'send' && (operation.high !== 0n || operation.low !== 0n))
|
|
1641
|
+
|| (operationKind === 'request' && operation.high === 0n && operation.low === 0n)
|
|
1642
|
+
)) {
|
|
1643
|
+
fail('Invalid Instance operation identity.');
|
|
1644
|
+
}
|
|
1645
|
+
if (version === 2 && operation.high === 0n && operation.low === 0n) {
|
|
1646
|
+
fail('Instance activation requires a non-zero operation identity.');
|
|
1647
|
+
}
|
|
1648
|
+
const deadlineUnixMs = version === 2
|
|
1649
|
+
? reader.nonZeroU64('deadlineUnixMs')
|
|
1650
|
+
: undefined;
|
|
1651
|
+
const replyRouteId = operationKind === 'request'
|
|
1652
|
+
? reader.nonZeroU64('replyRouteId')
|
|
1653
|
+
: undefined;
|
|
1654
|
+
reader.end();
|
|
1655
|
+
const common = {
|
|
1656
|
+
kind: 'instanceSpot' as const,
|
|
1657
|
+
sourceNodeGeneration,
|
|
1658
|
+
sourceNodeRid,
|
|
1659
|
+
...(sourceSpotId === undefined ? {} : { sourceSpotId }),
|
|
1660
|
+
operationKind,
|
|
1661
|
+
operation,
|
|
1662
|
+
...(replyRouteId === undefined ? {} : { replyRouteId })
|
|
1663
|
+
};
|
|
1664
|
+
return version === 1
|
|
1665
|
+
? { ...common, activation: 'ready', route: route! }
|
|
1666
|
+
: {
|
|
1667
|
+
...common,
|
|
1668
|
+
activation: 'missing',
|
|
1669
|
+
target: target!,
|
|
1670
|
+
deadlineUnixMs: deadlineUnixMs!
|
|
1671
|
+
};
|
|
1672
|
+
}
|
|
1673
|
+
case M6bServiceWireCommand.messageFollow: {
|
|
1674
|
+
requireFlags(command.flags, 0);
|
|
1675
|
+
if (reader.u8('messageFollow.version') !== 1) {
|
|
1676
|
+
fail('Unsupported Message Follow version.');
|
|
1677
|
+
}
|
|
1678
|
+
const length = reader.u32('messageFollow.length');
|
|
1679
|
+
const end = reader.offset + length;
|
|
1680
|
+
if (length > 16 * 1024 * 1024 || end > reader.bytes.byteLength) {
|
|
1681
|
+
fail('Invalid Message Follow body length.');
|
|
1682
|
+
}
|
|
1683
|
+
const record: ServiceMessageFollowRecord = {
|
|
1684
|
+
kind: 'messageFollow',
|
|
1685
|
+
source: reader.messageFollowRoute('source'),
|
|
1686
|
+
target: reader.messageFollowRoute('target'),
|
|
1687
|
+
hopCount: reader.u8('hopCount'),
|
|
1688
|
+
queuedMessages: reader.u32('queuedMessages'),
|
|
1689
|
+
queuedBytes: reader.u32('queuedBytes'),
|
|
1690
|
+
originalOperation: reader.operationId('originalOperation'),
|
|
1691
|
+
originalReplyRouteId: reader.u64('originalReplyRouteId')
|
|
1692
|
+
};
|
|
1693
|
+
if (reader.offset !== end) fail('Invalid Message Follow body length.');
|
|
1694
|
+
reader.end();
|
|
1695
|
+
validateMessageFollowRecord(record, fail);
|
|
1696
|
+
return record;
|
|
1697
|
+
}
|
|
1698
|
+
default:
|
|
1699
|
+
fail(`Command '${command.command}' is not owned by the M6B codec.`);
|
|
1700
|
+
}
|
|
1701
|
+
}
|
|
1702
|
+
|
|
1703
|
+
export function encodeStatefulReply(
|
|
1704
|
+
correlation: bigint,
|
|
1705
|
+
terminalResult: number,
|
|
1706
|
+
failureCode: number,
|
|
1707
|
+
tail?: ServiceStatefulReplyTail
|
|
1708
|
+
): Buffer {
|
|
1709
|
+
const tailBytes = tail === undefined ? Buffer.alloc(0) : encodeReplyTail(tail);
|
|
1710
|
+
return concat(
|
|
1711
|
+
prefix(20),
|
|
1712
|
+
u64(correlation),
|
|
1713
|
+
u32(terminalResult, 'terminalResult'),
|
|
1714
|
+
u32(failureCode, 'failureCode'),
|
|
1715
|
+
tailBytes
|
|
1716
|
+
);
|
|
1717
|
+
}
|
|
1718
|
+
|
|
1719
|
+
/** Encodes canonical maintenance relocation commands 30, 31, 34, 40, 52, and 53. */
|
|
1720
|
+
export function encodeMaintenanceRelocationControl(
|
|
1721
|
+
value: ServiceMaintenanceRelocationControl
|
|
1722
|
+
): Buffer {
|
|
1723
|
+
switch (value.kind) {
|
|
1724
|
+
case 'prepare':
|
|
1725
|
+
return Buffer.from(encodeGeneratedRelocationPrepare40({
|
|
1726
|
+
...toGeneratedRelocationBase(value),
|
|
1727
|
+
target: toGeneratedTargetFence(value.target),
|
|
1728
|
+
initiatorRole: value.initiatorRole,
|
|
1729
|
+
object: toGeneratedRelocationObject(value.object),
|
|
1730
|
+
sourceNodeRid: toGeneratedRoutingId(value.sourceNodeRid, 'sourceNodeRid'),
|
|
1731
|
+
sourceNodeGeneration: value.sourceNodeGeneration,
|
|
1732
|
+
payloadTotalLength: value.payloadTotalLength,
|
|
1733
|
+
payloadChunkCount: value.payloadChunkCount,
|
|
1734
|
+
payloadChecksumCrc32c: value.payloadChecksumCrc32c,
|
|
1735
|
+
applicationVersion: value.applicationVersion
|
|
1736
|
+
}));
|
|
1737
|
+
case 'ready':
|
|
1738
|
+
return Buffer.from(encodeGeneratedRelocationReady30({
|
|
1739
|
+
...toGeneratedRelocationBase(value),
|
|
1740
|
+
target: toGeneratedTargetFence(value.target),
|
|
1741
|
+
object: toGeneratedRelocationObject(value.object),
|
|
1742
|
+
senderRole: value.senderRole
|
|
1743
|
+
}));
|
|
1744
|
+
case 'failed':
|
|
1745
|
+
return Buffer.from(encodeGeneratedRelocationFailed53({
|
|
1746
|
+
...toGeneratedRelocationBase(value),
|
|
1747
|
+
target: toGeneratedTargetFence(value.target),
|
|
1748
|
+
object: toGeneratedRelocationObject(value.object),
|
|
1749
|
+
senderRole: value.senderRole,
|
|
1750
|
+
failureCode: value.failureCode
|
|
1751
|
+
}));
|
|
1752
|
+
case 'data':
|
|
1753
|
+
return Buffer.from(encodeGeneratedRelocationData31({
|
|
1754
|
+
...toGeneratedRelocationBase(value),
|
|
1755
|
+
senderRole: value.senderRole,
|
|
1756
|
+
object: toGeneratedRelocationObject(value.object),
|
|
1757
|
+
record: encodeServiceWireFrozenRecord(value.frozenRecord)
|
|
1758
|
+
}));
|
|
1759
|
+
case 'cutover':
|
|
1760
|
+
return Buffer.from(encodeGeneratedRelocationCutover34({
|
|
1761
|
+
...toGeneratedRelocationBase(value),
|
|
1762
|
+
senderRole: value.senderRole,
|
|
1763
|
+
object: toGeneratedRelocationObject(value.object),
|
|
1764
|
+
boundaryRecordCount: value.boundaryRecordCount,
|
|
1765
|
+
boundaryChecksumCrc32c: value.boundaryChecksumCrc32c
|
|
1766
|
+
}));
|
|
1767
|
+
case 'state':
|
|
1768
|
+
return Buffer.from(encodeGeneratedRelocationState52({
|
|
1769
|
+
...toGeneratedRelocationBase(value),
|
|
1770
|
+
senderRole: value.senderRole,
|
|
1771
|
+
object: toGeneratedRelocationObject(value.object),
|
|
1772
|
+
chunkOrdinal: value.chunkOrdinal,
|
|
1773
|
+
chunkData: value.chunkData
|
|
1774
|
+
}));
|
|
1775
|
+
}
|
|
1776
|
+
}
|
|
1777
|
+
|
|
1778
|
+
/** Decodes canonical maintenance relocation commands and rejects malformed vectors. */
|
|
1779
|
+
export function decodeMaintenanceRelocationControl(
|
|
1780
|
+
frame: Uint8Array
|
|
1781
|
+
): ServiceMaintenanceRelocationControl {
|
|
1782
|
+
switch (frame[3]) {
|
|
1783
|
+
case M6bServiceWireCommand.relocationPrepare:
|
|
1784
|
+
return fromGeneratedRelocationPrepare(decodeGeneratedRelocationPrepare40(frame));
|
|
1785
|
+
case M6bServiceWireCommand.relocationReady:
|
|
1786
|
+
return fromGeneratedRelocationReady(decodeGeneratedRelocationReady30(frame));
|
|
1787
|
+
case M6bServiceWireCommand.relocationFailed:
|
|
1788
|
+
return fromGeneratedRelocationFailed(decodeGeneratedRelocationFailed53(frame));
|
|
1789
|
+
case M6bServiceWireCommand.relocationData:
|
|
1790
|
+
return fromGeneratedRelocationData(decodeGeneratedRelocationData31(frame));
|
|
1791
|
+
case M6bServiceWireCommand.relocationCutover:
|
|
1792
|
+
return fromGeneratedRelocationCutover(decodeGeneratedRelocationCutover34(frame));
|
|
1793
|
+
case M6bServiceWireCommand.relocationState:
|
|
1794
|
+
return fromGeneratedRelocationState(decodeGeneratedRelocationState52(frame));
|
|
1795
|
+
default:
|
|
1796
|
+
fail(`Unsupported maintenance relocation command '${frame.length > 3 ? frame[3] : -1}'.`);
|
|
1797
|
+
}
|
|
1798
|
+
}
|
|
1799
|
+
|
|
1800
|
+
/** Encodes canonical service-wire command 33 for a maintenance terminal relay. */
|
|
1801
|
+
export function encodeMaintenanceReplyRelay(
|
|
1802
|
+
value: ServiceMaintenanceReplyRelay
|
|
1803
|
+
): readonly Buffer[] {
|
|
1804
|
+
return encodeGeneratedReplyRelay33(toGeneratedReplyRelay(value)).map(Buffer.from);
|
|
1805
|
+
}
|
|
1806
|
+
|
|
1807
|
+
/** Decodes canonical service-wire command 33 and rejects non-maintenance contexts. */
|
|
1808
|
+
export function decodeMaintenanceReplyRelay(
|
|
1809
|
+
frames: readonly Uint8Array[]
|
|
1810
|
+
): ServiceMaintenanceReplyRelay {
|
|
1811
|
+
return fromGeneratedReplyRelay(decodeGeneratedReplyRelay33(frames));
|
|
1812
|
+
}
|
|
1813
|
+
|
|
1814
|
+
/** Encodes canonical service-wire command 46. */
|
|
1815
|
+
export function encodeMaintenanceReplyRelayAck(value: ServiceMaintenanceReplyRelayAck): Buffer {
|
|
1816
|
+
return Buffer.from(encodeGeneratedReplyRelayAck46({
|
|
1817
|
+
relocation: value.relocation,
|
|
1818
|
+
coordinator: toGeneratedCoordinatorFence(value.coordinator),
|
|
1819
|
+
operation: value.operation,
|
|
1820
|
+
replyRouteId: value.replyRouteId,
|
|
1821
|
+
requestSource: toGeneratedRequestSourceFence(value.requestSource),
|
|
1822
|
+
status: value.status
|
|
1823
|
+
}));
|
|
1824
|
+
}
|
|
1825
|
+
|
|
1826
|
+
/** Decodes canonical service-wire command 46. */
|
|
1827
|
+
export function decodeMaintenanceReplyRelayAck(frame: Uint8Array): ServiceMaintenanceReplyRelayAck {
|
|
1828
|
+
const value = decodeGeneratedReplyRelayAck46(frame);
|
|
1829
|
+
return {
|
|
1830
|
+
relocation: value.relocation,
|
|
1831
|
+
coordinator: fromGeneratedCoordinatorFence(value.coordinator),
|
|
1832
|
+
operation: value.operation,
|
|
1833
|
+
replyRouteId: value.replyRouteId,
|
|
1834
|
+
requestSource: fromGeneratedRequestSourceFence(value.requestSource),
|
|
1835
|
+
status: value.status
|
|
1836
|
+
};
|
|
1837
|
+
}
|
|
1838
|
+
|
|
1839
|
+
export function decodeStatefulReply(
|
|
1840
|
+
frame: Uint8Array,
|
|
1841
|
+
expectedCorrelation: bigint,
|
|
1842
|
+
operationKind: 'spotRequest' | 'actorRequest' | 'actorLookup' | 'actorDestroy' | 'actorJoin' | 'streamBind'
|
|
1843
|
+
| 'streamUnbind'
|
|
1844
|
+
| 'instanceSpotRequest' | 'userSpotCreate' | 'userSpotClose' | 'actorCreate',
|
|
1845
|
+
hasPayload = false
|
|
1846
|
+
): ServiceStatefulReply {
|
|
1847
|
+
const reader = new Reader(frame);
|
|
1848
|
+
const command = reader.prefix();
|
|
1849
|
+
if (command.command !== 20 || command.flags !== 0) fail('Invalid stateful reply prefix.');
|
|
1850
|
+
const correlation = reader.nonZeroU64('correlation');
|
|
1851
|
+
if (correlation !== expectedCorrelation) fail('Stateful reply correlation mismatch.');
|
|
1852
|
+
const terminalResult = reader.u32('terminalResult');
|
|
1853
|
+
const failureCode = reader.u32('failureCode');
|
|
1854
|
+
validateReplyTerminal(terminalResult, failureCode, hasPayload);
|
|
1855
|
+
let tail: ServiceStatefulReplyTail | undefined;
|
|
1856
|
+
if (terminalResult === 0) {
|
|
1857
|
+
if (operationKind === 'actorLookup') {
|
|
1858
|
+
tail = {
|
|
1859
|
+
kind: 'actorLookup',
|
|
1860
|
+
actor: reader.actorRef('actor'),
|
|
1861
|
+
spot: {
|
|
1862
|
+
spotId: reader.rid('spotId'),
|
|
1863
|
+
generation: reader.nonZeroU64('spotGeneration')
|
|
1864
|
+
},
|
|
1865
|
+
membershipEpoch: reader.nonZeroU64('membershipEpoch'),
|
|
1866
|
+
authorityOwnerGeneration: reader.nonZeroU64('authorityOwnerGeneration')
|
|
1867
|
+
};
|
|
1868
|
+
} else if (operationKind === 'actorJoin') {
|
|
1869
|
+
const joinResult = reader.u32('joinResult');
|
|
1870
|
+
if (joinResult !== 0 && joinResult !== 1) fail('Invalid actor join result.');
|
|
1871
|
+
const bodyLength = reader.u16('joinBodyLength');
|
|
1872
|
+
const bodyEnd = reader.offset + bodyLength;
|
|
1873
|
+
let spot: ServiceSpotRef | undefined;
|
|
1874
|
+
if (joinResult === 0) {
|
|
1875
|
+
spot = reader.spotRef();
|
|
1876
|
+
const membershipEpoch = reader.nonZeroU64('membershipEpoch');
|
|
1877
|
+
// Tolerant of frames from an unpatched encoder that stops after
|
|
1878
|
+
// membershipEpoch: 0 means "not advertised".
|
|
1879
|
+
const receiveChunkLimitBytes = reader.offset === bodyEnd
|
|
1880
|
+
? 0
|
|
1881
|
+
: (() => {
|
|
1882
|
+
const value = reader.u32('receiveChunkLimitBytes');
|
|
1883
|
+
if (value > RELOCATION_STATE_CHUNK_DATA_MAX_BYTES) {
|
|
1884
|
+
fail('receiveChunkLimitBytes exceeds the relocation state chunk data bound.');
|
|
1885
|
+
}
|
|
1886
|
+
return value;
|
|
1887
|
+
})();
|
|
1888
|
+
if (reader.offset !== bodyEnd) fail('Invalid actor join body length.');
|
|
1889
|
+
tail = { kind: 'actorJoin', joinResult, spot, membershipEpoch, receiveChunkLimitBytes };
|
|
1890
|
+
} else {
|
|
1891
|
+
const hasSpot = reader.bool8('hasSpot');
|
|
1892
|
+
const optionalLength = reader.u16('optionalSpotLength');
|
|
1893
|
+
const optionalEnd = reader.offset + optionalLength;
|
|
1894
|
+
if (hasSpot) spot = reader.spotRef();
|
|
1895
|
+
if (reader.offset !== optionalEnd) fail('Invalid optional Spot body length.');
|
|
1896
|
+
if (reader.offset !== bodyEnd) fail('Invalid actor join body length.');
|
|
1897
|
+
tail = { kind: 'actorJoin', joinResult, ...(spot === undefined ? {} : { spot }) };
|
|
1898
|
+
}
|
|
1899
|
+
} else if (operationKind === 'streamBind') {
|
|
1900
|
+
tail = {
|
|
1901
|
+
kind: 'streamBind',
|
|
1902
|
+
bindingGeneration: reader.nonZeroU64('bindingGeneration'),
|
|
1903
|
+
authorityOwnerGeneration: reader.nonZeroU64('authorityOwnerGeneration')
|
|
1904
|
+
};
|
|
1905
|
+
} else if (operationKind === 'userSpotCreate') {
|
|
1906
|
+
const createResult = reader.u8('createResult');
|
|
1907
|
+
if (createResult < 1 || createResult > 3) fail('Invalid User Spot create result.');
|
|
1908
|
+
tail = {
|
|
1909
|
+
kind: 'userSpotCreate',
|
|
1910
|
+
createResult: (['existing', 'created', 'rejected'] as const)[createResult - 1]!,
|
|
1911
|
+
spotId: reader.rid('spotId'),
|
|
1912
|
+
objectGeneration: reader.nonZeroU64('objectGeneration')
|
|
1913
|
+
};
|
|
1914
|
+
} else if (operationKind === 'userSpotClose') {
|
|
1915
|
+
tail = {
|
|
1916
|
+
kind: 'userSpotClose',
|
|
1917
|
+
closed: reader.bool8('closed')
|
|
1918
|
+
};
|
|
1919
|
+
} else if (operationKind === 'actorCreate') {
|
|
1920
|
+
const createResult = reader.u8('createResult');
|
|
1921
|
+
if (createResult < 1 || createResult > 3) fail('Invalid Actor create result.');
|
|
1922
|
+
const length = reader.u16('creationLength');
|
|
1923
|
+
const end = reader.offset + length;
|
|
1924
|
+
if (end > reader.bytes.byteLength) fail('Truncated Actor create terminal.');
|
|
1925
|
+
const result = (['existing', 'created', 'rejected'] as const)[createResult - 1]!;
|
|
1926
|
+
const actor = result === 'rejected'
|
|
1927
|
+
? undefined
|
|
1928
|
+
: {
|
|
1929
|
+
nodeRid: reader.rid('actor.nodeRid'),
|
|
1930
|
+
actorId: reader.text8('actor.actorId'),
|
|
1931
|
+
generation: reader.nonZeroU64('actor.objectGeneration')
|
|
1932
|
+
};
|
|
1933
|
+
if (reader.offset !== end) fail('Invalid Actor create terminal length.');
|
|
1934
|
+
tail = {
|
|
1935
|
+
kind: 'actorCreate',
|
|
1936
|
+
createResult: result,
|
|
1937
|
+
...(actor === undefined ? {} : { actor })
|
|
1938
|
+
};
|
|
1939
|
+
}
|
|
1940
|
+
}
|
|
1941
|
+
reader.end();
|
|
1942
|
+
return {
|
|
1943
|
+
correlation,
|
|
1944
|
+
terminalResult,
|
|
1945
|
+
failureCode,
|
|
1946
|
+
...(tail === undefined ? {} : { tail })
|
|
1947
|
+
};
|
|
1948
|
+
}
|
|
1949
|
+
|
|
1950
|
+
export function sessionBindingFromWire(
|
|
1951
|
+
actor: ServiceActorRef,
|
|
1952
|
+
sessionRid: string,
|
|
1953
|
+
sessionOwnerNodeRid: string,
|
|
1954
|
+
generation: bigint,
|
|
1955
|
+
membershipEpoch: bigint,
|
|
1956
|
+
sessionOwnerNodeGeneration?: bigint,
|
|
1957
|
+
sessionOwnerId?: string,
|
|
1958
|
+
sessionOwnerLeaseGeneration?: bigint
|
|
1959
|
+
): ServiceSessionBinding {
|
|
1960
|
+
return {
|
|
1961
|
+
actor,
|
|
1962
|
+
sessionRid,
|
|
1963
|
+
sessionOwnerNodeRid,
|
|
1964
|
+
...(sessionOwnerNodeGeneration === undefined ? {} : { sessionOwnerNodeGeneration }),
|
|
1965
|
+
...(sessionOwnerId === undefined ? {} : { sessionOwnerId }),
|
|
1966
|
+
...(sessionOwnerLeaseGeneration === undefined ? {} : { sessionOwnerLeaseGeneration }),
|
|
1967
|
+
bindingGeneration: generation,
|
|
1968
|
+
membershipEpoch
|
|
1969
|
+
};
|
|
1970
|
+
}
|
|
1971
|
+
|
|
1972
|
+
function encodeReplyTail(tail: ServiceStatefulReplyTail): Buffer {
|
|
1973
|
+
switch (tail.kind) {
|
|
1974
|
+
case 'actorLookup':
|
|
1975
|
+
return concat(
|
|
1976
|
+
actorRef(tail.actor),
|
|
1977
|
+
rid(tail.spot.spotId, 'spotId'),
|
|
1978
|
+
u64(tail.spot.generation),
|
|
1979
|
+
u64(tail.membershipEpoch),
|
|
1980
|
+
u64(tail.authorityOwnerGeneration)
|
|
1981
|
+
);
|
|
1982
|
+
case 'actorJoin': {
|
|
1983
|
+
if (tail.joinResult === 0) {
|
|
1984
|
+
if (tail.spot === undefined) fail('Accepted actor join requires a SpotRef.');
|
|
1985
|
+
if (tail.membershipEpoch === undefined) {
|
|
1986
|
+
fail('Accepted actor join requires a membership epoch.');
|
|
1987
|
+
}
|
|
1988
|
+
const receiveChunkLimitBytes = tail.receiveChunkLimitBytes ?? 0;
|
|
1989
|
+
if (receiveChunkLimitBytes < 0
|
|
1990
|
+
|| receiveChunkLimitBytes > RELOCATION_STATE_CHUNK_DATA_MAX_BYTES) {
|
|
1991
|
+
fail('receiveChunkLimitBytes exceeds the relocation state chunk data bound.');
|
|
1992
|
+
}
|
|
1993
|
+
const body = concat(
|
|
1994
|
+
spotRef(tail.spot),
|
|
1995
|
+
u64(tail.membershipEpoch),
|
|
1996
|
+
u32(receiveChunkLimitBytes, 'receiveChunkLimitBytes')
|
|
1997
|
+
);
|
|
1998
|
+
return concat(u32(0, 'joinResult'), u16(body.byteLength), body);
|
|
1999
|
+
}
|
|
2000
|
+
const optional = tail.spot === undefined
|
|
2001
|
+
? concat(Buffer.of(0), u16(0))
|
|
2002
|
+
: (() => {
|
|
2003
|
+
const body = spotRef(tail.spot);
|
|
2004
|
+
return concat(Buffer.of(1), u16(body.byteLength), body);
|
|
2005
|
+
})();
|
|
2006
|
+
return concat(u32(1, 'joinResult'), u16(optional.byteLength), optional);
|
|
2007
|
+
}
|
|
2008
|
+
case 'streamBind':
|
|
2009
|
+
return concat(u64(tail.bindingGeneration), u64(tail.authorityOwnerGeneration));
|
|
2010
|
+
case 'userSpotCreate':
|
|
2011
|
+
return concat(
|
|
2012
|
+
Buffer.of((['existing', 'created', 'rejected'] as const).indexOf(tail.createResult) + 1),
|
|
2013
|
+
rid(tail.spotId, 'spotId'),
|
|
2014
|
+
u64(tail.objectGeneration)
|
|
2015
|
+
);
|
|
2016
|
+
case 'userSpotClose':
|
|
2017
|
+
return Buffer.of(tail.closed ? 1 : 0);
|
|
2018
|
+
case 'actorCreate': {
|
|
2019
|
+
const selected = tail.actor === undefined
|
|
2020
|
+
? Buffer.alloc(0)
|
|
2021
|
+
: concat(
|
|
2022
|
+
rid(tail.actor.nodeRid, 'actor.nodeRid'),
|
|
2023
|
+
text8(tail.actor.actorId, 'actor.actorId'),
|
|
2024
|
+
u64(tail.actor.generation)
|
|
2025
|
+
);
|
|
2026
|
+
return concat(
|
|
2027
|
+
Buffer.of((['existing', 'created', 'rejected'] as const).indexOf(tail.createResult) + 1),
|
|
2028
|
+
u16(selected.byteLength),
|
|
2029
|
+
selected
|
|
2030
|
+
);
|
|
2031
|
+
}
|
|
2032
|
+
}
|
|
2033
|
+
}
|
|
2034
|
+
|
|
2035
|
+
function wireId(value: ServiceWireOperationId, name: string): Buffer {
|
|
2036
|
+
if (value.high === 0n && value.low === 0n) {
|
|
2037
|
+
throw new RangeError(`${name} must not be zero.`);
|
|
2038
|
+
}
|
|
2039
|
+
return concat(u64Any(value.high), u64Any(value.low));
|
|
2040
|
+
}
|
|
2041
|
+
|
|
2042
|
+
function validateReplyTerminal(
|
|
2043
|
+
terminalResult: number,
|
|
2044
|
+
failureCode: number,
|
|
2045
|
+
hasPayload: boolean
|
|
2046
|
+
): void {
|
|
2047
|
+
if (hasPayload && terminalResult !== 0) {
|
|
2048
|
+
throw new RangeError('Failed stateful reply must not carry a payload.');
|
|
2049
|
+
}
|
|
2050
|
+
if (!isCanonicalWireReplyTerminal(terminalResult, failureCode)) {
|
|
2051
|
+
throw new RangeError('Stateful reply terminalResult does not match its framework failureCode.');
|
|
2052
|
+
}
|
|
2053
|
+
}
|
|
2054
|
+
|
|
2055
|
+
function validateRelocationPhase(value: number): void {
|
|
2056
|
+
const phases = ['none', 'preparing', 'captured', 'prepared', 'committed',
|
|
2057
|
+
'activating', 'activated', 'cleaning', 'completed', 'aborted'] as const;
|
|
2058
|
+
if (!Number.isInteger(value) || value < 0 || value >= phases.length) {
|
|
2059
|
+
fail('Invalid relocationData control phase.');
|
|
2060
|
+
}
|
|
2061
|
+
}
|
|
2062
|
+
|
|
2063
|
+
function applicationPayload(value: NonNullable<ServiceMaintenanceReplyRelay['payload']>): Buffer {
|
|
2064
|
+
const body = concat(
|
|
2065
|
+
text8(value.packetName, 'packetName'),
|
|
2066
|
+
text8(value.contentType, 'contentType'),
|
|
2067
|
+
u32(value.bytes.byteLength, 'payload.length'),
|
|
2068
|
+
value.bytes
|
|
2069
|
+
);
|
|
2070
|
+
return concat(Buffer.of(1), u32(body.byteLength, 'applicationPayload.length'), body);
|
|
2071
|
+
}
|
|
2072
|
+
|
|
2073
|
+
function prefix(command: number, flags = 0): Buffer {
|
|
2074
|
+
return Buffer.from([MAGIC_0, MAGIC_1, MAJOR, command, flags]);
|
|
2075
|
+
}
|
|
2076
|
+
|
|
2077
|
+
function actorFence(value: ServiceActorRouteFence): Buffer {
|
|
2078
|
+
return concat(
|
|
2079
|
+
actorRef(value.actor),
|
|
2080
|
+
rid(value.actor.nodeRid, 'targetNodeRid'),
|
|
2081
|
+
u64(value.targetNodeGeneration),
|
|
2082
|
+
u64(value.authorityOwnerGeneration),
|
|
2083
|
+
u64(value.ownerLeaseGeneration)
|
|
2084
|
+
);
|
|
2085
|
+
}
|
|
2086
|
+
|
|
2087
|
+
function actorAuthorityFence(value: ServiceBoundSessionActorAuthority): Buffer {
|
|
2088
|
+
return concat(
|
|
2089
|
+
actorRef(value.actor),
|
|
2090
|
+
rid(value.actor.nodeRid, 'targetNodeRid'),
|
|
2091
|
+
u64(value.targetNodeGeneration),
|
|
2092
|
+
u64(value.authorityOwnerGeneration),
|
|
2093
|
+
u64(value.ownerLeaseGeneration)
|
|
2094
|
+
);
|
|
2095
|
+
}
|
|
2096
|
+
|
|
2097
|
+
function spotFence(value: ServiceSpotRouteFence): Buffer {
|
|
2098
|
+
return concat(
|
|
2099
|
+
spotRef(value.spot),
|
|
2100
|
+
rid(value.targetNodeRid, 'targetNodeRid'),
|
|
2101
|
+
u64(value.targetNodeGeneration),
|
|
2102
|
+
u64(value.authorityOwnerGeneration),
|
|
2103
|
+
u64(value.ownerLeaseGeneration)
|
|
2104
|
+
);
|
|
2105
|
+
}
|
|
2106
|
+
|
|
2107
|
+
function directSpotFence(value: ServiceDirectSpotRouteFence): Buffer {
|
|
2108
|
+
return concat(
|
|
2109
|
+
spotFence(value),
|
|
2110
|
+
text16(value.storeVersion, 'storeVersion')
|
|
2111
|
+
);
|
|
2112
|
+
}
|
|
2113
|
+
|
|
2114
|
+
function messageFollowRoute(value: ServiceMessageFollowRoute): Buffer {
|
|
2115
|
+
const body = value.kind === 'actor'
|
|
2116
|
+
? concat(
|
|
2117
|
+
actorRef(value.actor),
|
|
2118
|
+
rid(value.targetNodeRid, 'targetNodeRid'),
|
|
2119
|
+
u64(value.targetNodeGeneration),
|
|
2120
|
+
u64(value.authorityOwnerGeneration),
|
|
2121
|
+
u64(value.ownerLeaseGeneration)
|
|
2122
|
+
)
|
|
2123
|
+
: concat(
|
|
2124
|
+
spotRef(value.spot),
|
|
2125
|
+
rid(value.targetNodeRid, 'targetNodeRid'),
|
|
2126
|
+
u64(value.targetNodeGeneration),
|
|
2127
|
+
u64(value.authorityOwnerGeneration),
|
|
2128
|
+
u64(value.ownerLeaseGeneration)
|
|
2129
|
+
);
|
|
2130
|
+
return concat(Buffer.of(value.kind === 'actor' ? 1 : 2), u16(body.byteLength), body);
|
|
2131
|
+
}
|
|
2132
|
+
|
|
2133
|
+
function validateMessageFollowRecord(
|
|
2134
|
+
value: Omit<ServiceMessageFollowRecord, 'kind'>,
|
|
2135
|
+
invalid: (message: string) => never = (message) => { throw new RangeError(message); }
|
|
2136
|
+
): void {
|
|
2137
|
+
if (value.source.kind !== value.target.kind) {
|
|
2138
|
+
invalid('Message Follow source and target object kinds differ.');
|
|
2139
|
+
}
|
|
2140
|
+
const sameObject = value.source.kind === 'actor' && value.target.kind === 'actor'
|
|
2141
|
+
? value.source.actor.actorId === value.target.actor.actorId
|
|
2142
|
+
&& value.source.actor.generation === value.target.actor.generation
|
|
2143
|
+
: value.source.kind === 'spot' && value.target.kind === 'spot'
|
|
2144
|
+
? value.source.spot.spotId === value.target.spot.spotId
|
|
2145
|
+
&& value.source.spot.generation === value.target.spot.generation
|
|
2146
|
+
: false;
|
|
2147
|
+
if (!sameObject) invalid('Message Follow source and target object identities differ.');
|
|
2148
|
+
if (!Number.isInteger(value.hopCount) || value.hopCount < 1 || value.hopCount > 8) {
|
|
2149
|
+
invalid('Message Follow hopCount must be in 1..8.');
|
|
2150
|
+
}
|
|
2151
|
+
if (!Number.isInteger(value.queuedMessages)
|
|
2152
|
+
|| value.queuedMessages < 0
|
|
2153
|
+
|| value.queuedMessages > 0xffff_ffff) {
|
|
2154
|
+
invalid('Message Follow queuedMessages must be a u32.');
|
|
2155
|
+
}
|
|
2156
|
+
if (!Number.isInteger(value.queuedBytes)
|
|
2157
|
+
|| value.queuedBytes < 0
|
|
2158
|
+
|| value.queuedBytes > 0xffff_ffff) {
|
|
2159
|
+
invalid('Message Follow queuedBytes must be a u32.');
|
|
2160
|
+
}
|
|
2161
|
+
if (value.originalOperation.high === 0n && value.originalOperation.low === 0n) {
|
|
2162
|
+
invalid('Message Follow originalOperation must not be zero.');
|
|
2163
|
+
}
|
|
2164
|
+
if (value.originalReplyRouteId < 0n
|
|
2165
|
+
|| value.originalReplyRouteId > 0xffff_ffff_ffff_ffffn) {
|
|
2166
|
+
invalid('Message Follow originalReplyRouteId must be a u64.');
|
|
2167
|
+
}
|
|
2168
|
+
}
|
|
2169
|
+
|
|
2170
|
+
function actorRef(value: ServiceActorRef): Buffer {
|
|
2171
|
+
return concat(text8(value.actorId, 'actorId'), u64(value.generation));
|
|
2172
|
+
}
|
|
2173
|
+
|
|
2174
|
+
function optionalActor(value: ServiceActorRef | undefined): Buffer {
|
|
2175
|
+
return value === undefined
|
|
2176
|
+
? Buffer.of(0)
|
|
2177
|
+
: concat(text8(value.actorId, 'sourceActorId'), u64(value.generation));
|
|
2178
|
+
}
|
|
2179
|
+
|
|
2180
|
+
function spotRef(value: ServiceSpotRef): Buffer {
|
|
2181
|
+
return concat(rid(value.spotId, 'spotId'), u64(value.generation));
|
|
2182
|
+
}
|
|
2183
|
+
|
|
2184
|
+
function rid(value: string, name: string): Buffer {
|
|
2185
|
+
const bytes = encodeServiceWireRoutingId(value, name, 0xff, outOfRange);
|
|
2186
|
+
return concat(Buffer.of(bytes.byteLength), bytes);
|
|
2187
|
+
}
|
|
2188
|
+
|
|
2189
|
+
function text8(value: string, name: string): Buffer {
|
|
2190
|
+
return sized8(value, name);
|
|
2191
|
+
}
|
|
2192
|
+
|
|
2193
|
+
function text16(value: string, name: string): Buffer {
|
|
2194
|
+
const bytes = encodeCanonicalServiceWireText(value, name, 0xffff, outOfRange);
|
|
2195
|
+
return concat(u16(bytes.byteLength), bytes);
|
|
2196
|
+
}
|
|
2197
|
+
|
|
2198
|
+
function optionalRid(value: string | undefined): Buffer {
|
|
2199
|
+
return value === undefined ? Buffer.of(0) : rid(value, 'sourceSpotId');
|
|
2200
|
+
}
|
|
2201
|
+
|
|
2202
|
+
function sized8(value: string, name: string): Buffer {
|
|
2203
|
+
const bytes = encodeCanonicalServiceWireText(value, name, 0xff, outOfRange);
|
|
2204
|
+
return concat(Buffer.of(bytes.byteLength), bytes);
|
|
2205
|
+
}
|
|
2206
|
+
|
|
2207
|
+
function u16(value: number): Buffer {
|
|
2208
|
+
if (!Number.isInteger(value) || value < 0 || value > 0xffff) fail('u16 value is out of range.');
|
|
2209
|
+
const result = Buffer.alloc(2);
|
|
2210
|
+
result.writeUInt16BE(value);
|
|
2211
|
+
return result;
|
|
2212
|
+
}
|
|
2213
|
+
|
|
2214
|
+
function u32(value: number, name: string): Buffer {
|
|
2215
|
+
if (!Number.isInteger(value) || value < 0 || value > 0xffff_ffff) {
|
|
2216
|
+
throw new RangeError(`${name} must be a u32.`);
|
|
2217
|
+
}
|
|
2218
|
+
const result = Buffer.alloc(4);
|
|
2219
|
+
result.writeUInt32BE(value);
|
|
2220
|
+
return result;
|
|
2221
|
+
}
|
|
2222
|
+
|
|
2223
|
+
function u64(value: bigint): Buffer {
|
|
2224
|
+
requirePositive(value, 'u64');
|
|
2225
|
+
const result = Buffer.alloc(8);
|
|
2226
|
+
result.writeBigUInt64BE(value);
|
|
2227
|
+
return result;
|
|
2228
|
+
}
|
|
2229
|
+
|
|
2230
|
+
function u64Any(value: bigint): Buffer {
|
|
2231
|
+
if (value < 0n || value > 0xffff_ffff_ffff_ffffn) {
|
|
2232
|
+
throw new RangeError('u64 value is out of range.');
|
|
2233
|
+
}
|
|
2234
|
+
const result = Buffer.alloc(8);
|
|
2235
|
+
result.writeBigUInt64BE(value);
|
|
2236
|
+
return result;
|
|
2237
|
+
}
|
|
2238
|
+
|
|
2239
|
+
function requirePositive(value: bigint | undefined, name: string): bigint {
|
|
2240
|
+
if (value === undefined || value < 1n || value > 0xffff_ffff_ffff_ffffn) {
|
|
2241
|
+
throw new RangeError(`${name} must be a non-zero u64.`);
|
|
2242
|
+
}
|
|
2243
|
+
return value;
|
|
2244
|
+
}
|
|
2245
|
+
|
|
2246
|
+
function requireFlags(actual: number, expected: number): void {
|
|
2247
|
+
if (actual !== expected) fail(`Invalid command flags '${actual}'.`);
|
|
2248
|
+
}
|
|
2249
|
+
|
|
2250
|
+
function concat(...parts: readonly Uint8Array[]): Buffer {
|
|
2251
|
+
return Buffer.concat(parts.map(part => Buffer.from(part)));
|
|
2252
|
+
}
|
|
2253
|
+
|
|
2254
|
+
function fail(message: string): never {
|
|
2255
|
+
throw new ServiceWireProtocolError(message);
|
|
2256
|
+
}
|
|
2257
|
+
|
|
2258
|
+
function outOfRange(message: string): never {
|
|
2259
|
+
throw new RangeError(message);
|
|
2260
|
+
}
|
|
2261
|
+
|
|
2262
|
+
class Reader {
|
|
2263
|
+
readonly bytes: Buffer;
|
|
2264
|
+
offset = 0;
|
|
2265
|
+
|
|
2266
|
+
constructor(value: Uint8Array) {
|
|
2267
|
+
this.bytes = Buffer.from(value);
|
|
2268
|
+
}
|
|
2269
|
+
|
|
2270
|
+
get remaining(): number {
|
|
2271
|
+
return this.bytes.byteLength - this.offset;
|
|
2272
|
+
}
|
|
2273
|
+
|
|
2274
|
+
takeRemaining(): Buffer {
|
|
2275
|
+
const value = Buffer.from(this.bytes.subarray(this.offset));
|
|
2276
|
+
this.offset = this.bytes.byteLength;
|
|
2277
|
+
return value;
|
|
2278
|
+
}
|
|
2279
|
+
|
|
2280
|
+
prefix(): { readonly command: number; readonly flags: number } {
|
|
2281
|
+
this.need(PREFIX_SIZE, 'prefix');
|
|
2282
|
+
if (
|
|
2283
|
+
this.bytes[this.offset] !== MAGIC_0
|
|
2284
|
+
|| this.bytes[this.offset + 1] !== MAGIC_1
|
|
2285
|
+
|| this.bytes[this.offset + 2] !== MAJOR
|
|
2286
|
+
) {
|
|
2287
|
+
fail('Invalid service wire prefix.');
|
|
2288
|
+
}
|
|
2289
|
+
const command = this.bytes[this.offset + 3]!;
|
|
2290
|
+
const flags = this.bytes[this.offset + 4]!;
|
|
2291
|
+
this.offset += PREFIX_SIZE;
|
|
2292
|
+
return { command, flags };
|
|
2293
|
+
}
|
|
2294
|
+
|
|
2295
|
+
u8(name: string): number {
|
|
2296
|
+
this.need(1, name);
|
|
2297
|
+
return this.bytes[this.offset++]!;
|
|
2298
|
+
}
|
|
2299
|
+
|
|
2300
|
+
bool8(name: string): boolean {
|
|
2301
|
+
const value = this.u8(name);
|
|
2302
|
+
if (value !== 0 && value !== 1) fail(`${name} must be bool8.`);
|
|
2303
|
+
return value === 1;
|
|
2304
|
+
}
|
|
2305
|
+
|
|
2306
|
+
u16(name: string): number {
|
|
2307
|
+
this.need(2, name);
|
|
2308
|
+
const value = this.bytes.readUInt16BE(this.offset);
|
|
2309
|
+
this.offset += 2;
|
|
2310
|
+
return value;
|
|
2311
|
+
}
|
|
2312
|
+
|
|
2313
|
+
u32(name: string): number {
|
|
2314
|
+
this.need(4, name);
|
|
2315
|
+
const value = this.bytes.readUInt32BE(this.offset);
|
|
2316
|
+
this.offset += 4;
|
|
2317
|
+
return value;
|
|
2318
|
+
}
|
|
2319
|
+
|
|
2320
|
+
nonZeroU64(name: string): bigint {
|
|
2321
|
+
this.need(8, name);
|
|
2322
|
+
const value = this.bytes.readBigUInt64BE(this.offset);
|
|
2323
|
+
this.offset += 8;
|
|
2324
|
+
if (value === 0n) fail(`${name} must be a non-zero u64.`);
|
|
2325
|
+
return value;
|
|
2326
|
+
}
|
|
2327
|
+
|
|
2328
|
+
u64(name: string): bigint {
|
|
2329
|
+
this.need(8, name);
|
|
2330
|
+
const value = this.bytes.readBigUInt64BE(this.offset);
|
|
2331
|
+
this.offset += 8;
|
|
2332
|
+
return value;
|
|
2333
|
+
}
|
|
2334
|
+
|
|
2335
|
+
operationId(name: string): ServiceWireOperationId {
|
|
2336
|
+
const value = {
|
|
2337
|
+
high: this.u64(`${name}.high`),
|
|
2338
|
+
low: this.u64(`${name}.low`)
|
|
2339
|
+
};
|
|
2340
|
+
if (value.high === 0n && value.low === 0n) fail(`${name} must not be zero.`);
|
|
2341
|
+
return value;
|
|
2342
|
+
}
|
|
2343
|
+
|
|
2344
|
+
rid(name: string): string {
|
|
2345
|
+
return this.opaque8(name);
|
|
2346
|
+
}
|
|
2347
|
+
|
|
2348
|
+
text8(name: string): string {
|
|
2349
|
+
return this.sized8(name);
|
|
2350
|
+
}
|
|
2351
|
+
|
|
2352
|
+
text16(name: string): string {
|
|
2353
|
+
const length = this.u16(`${name}.length`);
|
|
2354
|
+
if (length === 0) fail(`${name} must not be empty.`);
|
|
2355
|
+
this.need(length, name);
|
|
2356
|
+
const bytes = this.bytes.subarray(this.offset, this.offset + length);
|
|
2357
|
+
this.offset += length;
|
|
2358
|
+
return decodeCanonicalServiceWireText(bytes, name, fail);
|
|
2359
|
+
}
|
|
2360
|
+
|
|
2361
|
+
optionalRid(name: string): string | undefined {
|
|
2362
|
+
const length = this.u8(`${name}.length`);
|
|
2363
|
+
if (length === 0) return undefined;
|
|
2364
|
+
this.need(length, name);
|
|
2365
|
+
const bytes = this.bytes.subarray(this.offset, this.offset + length);
|
|
2366
|
+
this.offset += length;
|
|
2367
|
+
return decodeServiceWireRoutingId(bytes, name, 0xff, fail);
|
|
2368
|
+
}
|
|
2369
|
+
|
|
2370
|
+
actorRef(name: string): ServiceActorRef {
|
|
2371
|
+
return {
|
|
2372
|
+
nodeRid: '',
|
|
2373
|
+
actorId: this.text8(`${name}.actorId`),
|
|
2374
|
+
generation: this.nonZeroU64(`${name}.generation`)
|
|
2375
|
+
};
|
|
2376
|
+
}
|
|
2377
|
+
|
|
2378
|
+
optionalActor(): ServiceActorRef | undefined {
|
|
2379
|
+
const length = this.u8('sourceActorId.length');
|
|
2380
|
+
if (length === 0) return undefined;
|
|
2381
|
+
this.need(length, 'sourceActorId');
|
|
2382
|
+
const bytes = this.bytes.subarray(this.offset, this.offset + length);
|
|
2383
|
+
this.offset += length;
|
|
2384
|
+
const actorId = decodeCanonicalServiceWireText(bytes, 'sourceActorId', fail);
|
|
2385
|
+
return {
|
|
2386
|
+
nodeRid: '',
|
|
2387
|
+
actorId,
|
|
2388
|
+
generation: this.nonZeroU64('sourceActorGeneration')
|
|
2389
|
+
};
|
|
2390
|
+
}
|
|
2391
|
+
|
|
2392
|
+
spotRef(): ServiceSpotRef {
|
|
2393
|
+
return {
|
|
2394
|
+
spotId: this.rid('spotId'),
|
|
2395
|
+
generation: this.nonZeroU64('spotGeneration')
|
|
2396
|
+
};
|
|
2397
|
+
}
|
|
2398
|
+
|
|
2399
|
+
actorFence(): ServiceActorRouteFence {
|
|
2400
|
+
const actor = this.actorRef('actor');
|
|
2401
|
+
const targetNodeRid = this.rid('targetNodeRid');
|
|
2402
|
+
return {
|
|
2403
|
+
actor: { ...actor, nodeRid: targetNodeRid },
|
|
2404
|
+
targetNodeGeneration: this.nonZeroU64('targetNodeGeneration'),
|
|
2405
|
+
authorityOwnerGeneration: this.nonZeroU64('authorityOwnerGeneration'),
|
|
2406
|
+
ownerLeaseGeneration: this.nonZeroU64('ownerLeaseGeneration')
|
|
2407
|
+
};
|
|
2408
|
+
}
|
|
2409
|
+
|
|
2410
|
+
spotFence(): ServiceSpotRouteFence {
|
|
2411
|
+
const spot = this.spotRef();
|
|
2412
|
+
return {
|
|
2413
|
+
spot,
|
|
2414
|
+
targetNodeRid: this.rid('targetNodeRid'),
|
|
2415
|
+
targetNodeGeneration: this.nonZeroU64('targetNodeGeneration'),
|
|
2416
|
+
authorityOwnerGeneration: this.nonZeroU64('authorityOwnerGeneration'),
|
|
2417
|
+
ownerLeaseGeneration: this.nonZeroU64('ownerLeaseGeneration')
|
|
2418
|
+
};
|
|
2419
|
+
}
|
|
2420
|
+
|
|
2421
|
+
directSpotFence(): ServiceDirectSpotRouteFence {
|
|
2422
|
+
return {
|
|
2423
|
+
...this.spotFence(),
|
|
2424
|
+
storeVersion: this.text16('storeVersion')
|
|
2425
|
+
};
|
|
2426
|
+
}
|
|
2427
|
+
|
|
2428
|
+
messageFollowRoute(name: string): ServiceMessageFollowRoute {
|
|
2429
|
+
const kind = this.u8(`${name}.objectKind`);
|
|
2430
|
+
const length = this.u16(`${name}.length`);
|
|
2431
|
+
const end = this.offset + length;
|
|
2432
|
+
if (end > this.bytes.byteLength) fail(`Truncated Message Follow ${name} route.`);
|
|
2433
|
+
let value: ServiceMessageFollowRoute;
|
|
2434
|
+
if (kind === 1) {
|
|
2435
|
+
const actor = this.actorRef(`${name}.actor`);
|
|
2436
|
+
value = {
|
|
2437
|
+
kind: 'actor',
|
|
2438
|
+
actor,
|
|
2439
|
+
targetNodeRid: this.rid(`${name}.targetNodeRid`),
|
|
2440
|
+
targetNodeGeneration: this.nonZeroU64(`${name}.targetNodeGeneration`),
|
|
2441
|
+
authorityOwnerGeneration: this.nonZeroU64(`${name}.authorityOwnerGeneration`),
|
|
2442
|
+
ownerLeaseGeneration: this.nonZeroU64(`${name}.ownerLeaseGeneration`)
|
|
2443
|
+
};
|
|
2444
|
+
} else if (kind === 2) {
|
|
2445
|
+
value = {
|
|
2446
|
+
kind: 'spot',
|
|
2447
|
+
spot: this.spotRef(),
|
|
2448
|
+
targetNodeRid: this.rid(`${name}.targetNodeRid`),
|
|
2449
|
+
targetNodeGeneration: this.nonZeroU64(`${name}.targetNodeGeneration`),
|
|
2450
|
+
authorityOwnerGeneration: this.nonZeroU64(`${name}.authorityOwnerGeneration`),
|
|
2451
|
+
ownerLeaseGeneration: this.nonZeroU64(`${name}.ownerLeaseGeneration`)
|
|
2452
|
+
};
|
|
2453
|
+
} else {
|
|
2454
|
+
fail(`Unknown Message Follow ${name} object kind.`);
|
|
2455
|
+
}
|
|
2456
|
+
if (this.offset !== end) fail(`Invalid Message Follow ${name} route length.`);
|
|
2457
|
+
return value;
|
|
2458
|
+
}
|
|
2459
|
+
|
|
2460
|
+
end(): void {
|
|
2461
|
+
if (this.remaining !== 0) fail('Service wire record has trailing bytes.');
|
|
2462
|
+
}
|
|
2463
|
+
|
|
2464
|
+
private sized8(name: string): string {
|
|
2465
|
+
const length = this.u8(`${name}.length`);
|
|
2466
|
+
if (length === 0) fail(`${name} must not be empty.`);
|
|
2467
|
+
this.need(length, name);
|
|
2468
|
+
const bytes = this.bytes.subarray(this.offset, this.offset + length);
|
|
2469
|
+
this.offset += length;
|
|
2470
|
+
return decodeCanonicalServiceWireText(bytes, name, fail);
|
|
2471
|
+
}
|
|
2472
|
+
|
|
2473
|
+
private opaque8(name: string): string {
|
|
2474
|
+
const length = this.u8(`${name}.length`);
|
|
2475
|
+
if (length === 0) fail(`${name} must not be empty.`);
|
|
2476
|
+
this.need(length, name);
|
|
2477
|
+
const bytes = this.bytes.subarray(this.offset, this.offset + length);
|
|
2478
|
+
this.offset += length;
|
|
2479
|
+
return decodeServiceWireRoutingId(bytes, name, 0xff, fail);
|
|
2480
|
+
}
|
|
2481
|
+
|
|
2482
|
+
private need(count: number, name: string): void {
|
|
2483
|
+
if (count < 0 || count > this.remaining) fail(`Truncated ${name}.`);
|
|
2484
|
+
}
|
|
2485
|
+
}
|
|
2486
|
+
|
|
2487
|
+
export function decodeServiceWireFrozenRecord(bytes: Uint8Array): ServiceWireFrozenRecord {
|
|
2488
|
+
const reader = new FrozenReader(bytes);
|
|
2489
|
+
const record = decodeServiceWireFrozenRecordFrom(reader);
|
|
2490
|
+
reader.end('frozen record');
|
|
2491
|
+
return { ...record, canonicalBytes: Buffer.from(bytes) };
|
|
2492
|
+
}
|
|
2493
|
+
|
|
2494
|
+
/**
|
|
2495
|
+
* Consumes exactly one canonical frozen record at `offset`. Relocation
|
|
2496
|
+
* saved-work is a vector of back-to-back records, so its boundary is the
|
|
2497
|
+
* record grammar itself rather than an enclosing length field.
|
|
2498
|
+
*/
|
|
2499
|
+
export function decodeServiceWireFrozenRecordPrefix(
|
|
2500
|
+
bytes: Uint8Array,
|
|
2501
|
+
offset = 0
|
|
2502
|
+
): { readonly record: ServiceWireFrozenRecord; readonly length: number } {
|
|
2503
|
+
if (!Number.isSafeInteger(offset) || offset < 0 || offset >= bytes.byteLength) {
|
|
2504
|
+
fail('Frozen record offset is outside the encoded bytes.');
|
|
2505
|
+
}
|
|
2506
|
+
const reader = new FrozenReader(bytes.subarray(offset));
|
|
2507
|
+
const record = decodeServiceWireFrozenRecordFrom(reader);
|
|
2508
|
+
return {
|
|
2509
|
+
record: { ...record, canonicalBytes: Buffer.from(bytes.subarray(offset, offset + reader.position)) },
|
|
2510
|
+
length: reader.position
|
|
2511
|
+
};
|
|
2512
|
+
}
|
|
2513
|
+
|
|
2514
|
+
function decodeServiceWireFrozenRecordFrom(reader: FrozenReader): ServiceWireFrozenRecord {
|
|
2515
|
+
const recordKind = reader.u8('recordKind');
|
|
2516
|
+
if (recordKind < 1 || recordKind > 14) fail('Invalid frozen record kind.');
|
|
2517
|
+
const sourceKind = reader.u8('sourceKind');
|
|
2518
|
+
if (sourceKind < 1 || sourceKind > 4) fail('Invalid frozen source kind.');
|
|
2519
|
+
const sourceReader = reader.body16('frozen source');
|
|
2520
|
+
const source: ServiceWireRequestSourceFence = {
|
|
2521
|
+
nodeRid: sourceReader.rid8('sourceNodeRid'),
|
|
2522
|
+
nodeGeneration: sourceReader.nonZeroU64('sourceNodeGeneration'),
|
|
2523
|
+
ownerId: sourceReader.text8('sourceOwnerId'),
|
|
2524
|
+
leaseGeneration: sourceReader.nonZeroU64('sourceOwnerLeaseGeneration')
|
|
2525
|
+
};
|
|
2526
|
+
let sourceSpotId: string | undefined;
|
|
2527
|
+
let sourceActor: ServiceWireFrozenRecord['sourceActor'];
|
|
2528
|
+
let sourceSessionRid: string | undefined;
|
|
2529
|
+
let sourceBindingGeneration: bigint | undefined;
|
|
2530
|
+
let sourceSessionSequence: bigint | undefined;
|
|
2531
|
+
if (sourceKind === 2) {
|
|
2532
|
+
sourceSpotId = sourceReader.text8('sourceSpotId');
|
|
2533
|
+
} else if (sourceKind === 3 || sourceKind === 4) {
|
|
2534
|
+
sourceActor = {
|
|
2535
|
+
actorId: sourceReader.text8('sourceActorId'),
|
|
2536
|
+
generation: sourceReader.nonZeroU64('sourceActorGeneration')
|
|
2537
|
+
};
|
|
2538
|
+
if (sourceKind === 4) {
|
|
2539
|
+
sourceSessionRid = sourceReader.rid8('sourceSessionRid');
|
|
2540
|
+
sourceBindingGeneration = sourceReader.nonZeroU64('sourceBindingGeneration');
|
|
2541
|
+
sourceSessionSequence = sourceReader.nonZeroU64('sourceSessionSequence');
|
|
2542
|
+
}
|
|
2543
|
+
}
|
|
2544
|
+
sourceReader.end('frozen source');
|
|
2545
|
+
if ([8, 12, 13].includes(recordKind) && sourceKind !== 1) {
|
|
2546
|
+
fail('Infrastructure frozen record requires a node source.');
|
|
2547
|
+
}
|
|
2548
|
+
const hasMetadata = reader.bool8('hasMetadata');
|
|
2549
|
+
if (hasMetadata) {
|
|
2550
|
+
if (!((recordKind >= 1 && recordKind <= 7)
|
|
2551
|
+
|| recordKind === 9 || recordKind === 10 || recordKind === 14)) {
|
|
2552
|
+
fail('Metadata is forbidden for this frozen record kind.');
|
|
2553
|
+
}
|
|
2554
|
+
reader.metadata();
|
|
2555
|
+
}
|
|
2556
|
+
const operationId = {
|
|
2557
|
+
high: reader.u64('operationId.high'),
|
|
2558
|
+
low: reader.u64('operationId.low')
|
|
2559
|
+
};
|
|
2560
|
+
const operationKind = reader.u32('operationKind');
|
|
2561
|
+
if (operationKind > 15) fail('Invalid frozen operation kind.');
|
|
2562
|
+
const replyReader = reader.body16('frozen reply route');
|
|
2563
|
+
const requiresReply = operationRequiresReply(operationKind);
|
|
2564
|
+
const replyRouteId = requiresReply
|
|
2565
|
+
? replyReader.nonZeroU64('replyRouteId')
|
|
2566
|
+
: undefined;
|
|
2567
|
+
replyReader.end('frozen reply route');
|
|
2568
|
+
const body = reader.frozenBody(recordKind);
|
|
2569
|
+
validateFrozenOperationMatrix(recordKind, operationKind, operationId, replyRouteId,
|
|
2570
|
+
body.instanceOperationKind);
|
|
2571
|
+
return {
|
|
2572
|
+
recordKind,
|
|
2573
|
+
sourceKind,
|
|
2574
|
+
source,
|
|
2575
|
+
...(sourceSpotId === undefined ? {} : { sourceSpotId }),
|
|
2576
|
+
...(sourceActor === undefined ? {} : { sourceActor }),
|
|
2577
|
+
...(sourceSessionRid === undefined ? {} : { sourceSessionRid }),
|
|
2578
|
+
...(sourceBindingGeneration === undefined ? {} : { sourceBindingGeneration }),
|
|
2579
|
+
...(sourceSessionSequence === undefined ? {} : { sourceSessionSequence }),
|
|
2580
|
+
hasMetadata,
|
|
2581
|
+
operationId,
|
|
2582
|
+
operationKind,
|
|
2583
|
+
...(replyRouteId === undefined ? {} : { replyRouteId }),
|
|
2584
|
+
...(body.target === undefined ? {} : { target: body.target }),
|
|
2585
|
+
...(body.applicationPayload === undefined
|
|
2586
|
+
? {}
|
|
2587
|
+
: { applicationPayload: body.applicationPayload }),
|
|
2588
|
+
canonicalBytes: Buffer.alloc(0)
|
|
2589
|
+
};
|
|
2590
|
+
}
|
|
2591
|
+
|
|
2592
|
+
export function encodeServiceWireFrozenRecord(record: ServiceWireFrozenRecord): Buffer {
|
|
2593
|
+
if (record.canonicalBytes.byteLength === 0) {
|
|
2594
|
+
throw new RangeError('Canonical frozen record bytes must not be empty.');
|
|
2595
|
+
}
|
|
2596
|
+
const decoded = decodeServiceWireFrozenRecord(record.canonicalBytes);
|
|
2597
|
+
if (!sameFrozenRecordSummary(decoded, record)) {
|
|
2598
|
+
throw new RangeError('Frozen record summary does not match its canonical bytes.');
|
|
2599
|
+
}
|
|
2600
|
+
return Buffer.from(record.canonicalBytes);
|
|
2601
|
+
}
|
|
2602
|
+
|
|
2603
|
+
export function encodeServiceWireFrozenActorApplicationRecord(input: {
|
|
2604
|
+
readonly source: ServiceWireRequestSourceFence;
|
|
2605
|
+
readonly target: {
|
|
2606
|
+
readonly actorId: string;
|
|
2607
|
+
readonly objectGeneration: bigint;
|
|
2608
|
+
readonly nodeRid: string;
|
|
2609
|
+
readonly nodeGeneration: bigint;
|
|
2610
|
+
readonly authorityOwnerGeneration: bigint;
|
|
2611
|
+
readonly ownerLeaseGeneration: bigint;
|
|
2612
|
+
};
|
|
2613
|
+
readonly operationId: ServiceWireOperationId;
|
|
2614
|
+
readonly replyRouteId?: bigint;
|
|
2615
|
+
readonly payload: NonNullable<ServiceMaintenanceReplyRelay['payload']>;
|
|
2616
|
+
}): ServiceWireFrozenRecord {
|
|
2617
|
+
const request = input.replyRouteId !== undefined;
|
|
2618
|
+
const sourceBody = concat(
|
|
2619
|
+
rid(input.source.nodeRid, 'sourceNodeRid'),
|
|
2620
|
+
u64(input.source.nodeGeneration),
|
|
2621
|
+
text8(input.source.ownerId, 'sourceOwnerId'),
|
|
2622
|
+
u64(input.source.leaseGeneration)
|
|
2623
|
+
);
|
|
2624
|
+
const replyBody = request ? u64(input.replyRouteId!) : Buffer.alloc(0);
|
|
2625
|
+
const bytes = concat(
|
|
2626
|
+
Buffer.of(request ? 10 : 9),
|
|
2627
|
+
Buffer.of(1), u16(sourceBody.byteLength), sourceBody,
|
|
2628
|
+
Buffer.of(0),
|
|
2629
|
+
wireId(input.operationId, 'operationId'),
|
|
2630
|
+
u32(request ? 4 : 0, 'operationKind'),
|
|
2631
|
+
u16(replyBody.byteLength), replyBody,
|
|
2632
|
+
text8(input.target.actorId, 'targetActorId'),
|
|
2633
|
+
u64(input.target.objectGeneration),
|
|
2634
|
+
rid(input.target.nodeRid, 'targetNodeRid'),
|
|
2635
|
+
u64(input.target.nodeGeneration),
|
|
2636
|
+
u64(input.target.authorityOwnerGeneration),
|
|
2637
|
+
u64(input.target.ownerLeaseGeneration),
|
|
2638
|
+
applicationPayload(input.payload)
|
|
2639
|
+
);
|
|
2640
|
+
return decodeServiceWireFrozenRecord(bytes);
|
|
2641
|
+
}
|
|
2642
|
+
|
|
2643
|
+
function sameFrozenRecordSummary(left: ServiceWireFrozenRecord, right: ServiceWireFrozenRecord): boolean {
|
|
2644
|
+
return left.recordKind === right.recordKind
|
|
2645
|
+
&& left.sourceKind === right.sourceKind
|
|
2646
|
+
&& routingIdsEqual(left.source.nodeRid, right.source.nodeRid)
|
|
2647
|
+
&& left.source.nodeGeneration === right.source.nodeGeneration
|
|
2648
|
+
&& left.source.ownerId === right.source.ownerId
|
|
2649
|
+
&& left.source.leaseGeneration === right.source.leaseGeneration
|
|
2650
|
+
&& left.sourceSpotId === right.sourceSpotId
|
|
2651
|
+
&& left.sourceActor?.actorId === right.sourceActor?.actorId
|
|
2652
|
+
&& left.sourceActor?.generation === right.sourceActor?.generation
|
|
2653
|
+
&& left.sourceSessionRid === right.sourceSessionRid
|
|
2654
|
+
&& left.sourceBindingGeneration === right.sourceBindingGeneration
|
|
2655
|
+
&& left.sourceSessionSequence === right.sourceSessionSequence
|
|
2656
|
+
&& left.hasMetadata === right.hasMetadata
|
|
2657
|
+
&& left.operationId.high === right.operationId.high
|
|
2658
|
+
&& left.operationId.low === right.operationId.low
|
|
2659
|
+
&& left.operationKind === right.operationKind
|
|
2660
|
+
&& left.replyRouteId === right.replyRouteId
|
|
2661
|
+
&& left.canonicalBytes.equals(right.canonicalBytes);
|
|
2662
|
+
}
|
|
2663
|
+
|
|
2664
|
+
function validateFrozenOperationMatrix(
|
|
2665
|
+
recordKind: number,
|
|
2666
|
+
operationKind: number,
|
|
2667
|
+
operationId: ServiceWireOperationId,
|
|
2668
|
+
replyRouteId: bigint | undefined,
|
|
2669
|
+
instanceOperationKind: number | undefined
|
|
2670
|
+
): void {
|
|
2671
|
+
const zero = operationId.high === 0n && operationId.low === 0n;
|
|
2672
|
+
let valid = false;
|
|
2673
|
+
if ([1, 3, 7, 12, 13].includes(recordKind)) valid = operationKind === 0 && zero;
|
|
2674
|
+
else if (recordKind === 2) valid = operationKind === 1 && !zero;
|
|
2675
|
+
else if (recordKind === 4) valid = operationKind === 2 && !zero;
|
|
2676
|
+
else if (recordKind === 5 || recordKind === 9) valid = operationKind === 0 && !zero;
|
|
2677
|
+
else if (recordKind === 6) valid = operationKind === 3 && !zero;
|
|
2678
|
+
else if (recordKind === 10) valid = operationKind === 4 && !zero;
|
|
2679
|
+
else if (recordKind === 8) {
|
|
2680
|
+
valid = operationKind === 0 && zero
|
|
2681
|
+
|| [6, 7, 8].includes(operationKind) && !zero;
|
|
2682
|
+
} else if (recordKind === 11) valid = operationKind >= 1 && operationKind <= 15 && !zero;
|
|
2683
|
+
else if (recordKind === 14 && instanceOperationKind !== undefined) {
|
|
2684
|
+
valid = instanceOperationKind === 1
|
|
2685
|
+
? operationKind === 0 && zero
|
|
2686
|
+
: operationKind === 12 && !zero;
|
|
2687
|
+
}
|
|
2688
|
+
if (!valid) fail('Frozen record kind, operation kind, and operation ID do not match.');
|
|
2689
|
+
if (operationRequiresReply(operationKind) !== (replyRouteId !== undefined)) {
|
|
2690
|
+
fail('Frozen reply route does not match the operation kind.');
|
|
2691
|
+
}
|
|
2692
|
+
}
|
|
2693
|
+
|
|
2694
|
+
class FrozenReader {
|
|
2695
|
+
private offset = 0;
|
|
2696
|
+
private readonly bytes: Buffer;
|
|
2697
|
+
|
|
2698
|
+
constructor(bytes: Buffer | Uint8Array) {
|
|
2699
|
+
this.bytes = Buffer.isBuffer(bytes)
|
|
2700
|
+
? bytes
|
|
2701
|
+
: Buffer.from(bytes.buffer, bytes.byteOffset, bytes.byteLength);
|
|
2702
|
+
}
|
|
2703
|
+
|
|
2704
|
+
private get remaining(): number {
|
|
2705
|
+
return this.bytes.byteLength - this.offset;
|
|
2706
|
+
}
|
|
2707
|
+
|
|
2708
|
+
get position(): number {
|
|
2709
|
+
return this.offset;
|
|
2710
|
+
}
|
|
2711
|
+
|
|
2712
|
+
u8(name: string): number {
|
|
2713
|
+
this.need(1, name);
|
|
2714
|
+
return this.bytes[this.offset++]!;
|
|
2715
|
+
}
|
|
2716
|
+
|
|
2717
|
+
bool8(name: string): boolean {
|
|
2718
|
+
const value = this.u8(name);
|
|
2719
|
+
if (value !== 0 && value !== 1) fail(`${name} must be bool8.`);
|
|
2720
|
+
return value === 1;
|
|
2721
|
+
}
|
|
2722
|
+
|
|
2723
|
+
u16(name: string): number {
|
|
2724
|
+
this.need(2, name);
|
|
2725
|
+
const value = this.bytes.readUInt16BE(this.offset);
|
|
2726
|
+
this.offset += 2;
|
|
2727
|
+
return value;
|
|
2728
|
+
}
|
|
2729
|
+
|
|
2730
|
+
u32(name: string): number {
|
|
2731
|
+
this.need(4, name);
|
|
2732
|
+
const value = this.bytes.readUInt32BE(this.offset);
|
|
2733
|
+
this.offset += 4;
|
|
2734
|
+
return value;
|
|
2735
|
+
}
|
|
2736
|
+
|
|
2737
|
+
u64(name: string): bigint {
|
|
2738
|
+
this.need(8, name);
|
|
2739
|
+
const value = this.bytes.readBigUInt64BE(this.offset);
|
|
2740
|
+
this.offset += 8;
|
|
2741
|
+
return value;
|
|
2742
|
+
}
|
|
2743
|
+
|
|
2744
|
+
nonZeroU64(name: string): bigint {
|
|
2745
|
+
const value = this.u64(name);
|
|
2746
|
+
if (value === 0n) fail(`${name} must be a non-zero u64.`);
|
|
2747
|
+
return value;
|
|
2748
|
+
}
|
|
2749
|
+
|
|
2750
|
+
text8(name: string): string {
|
|
2751
|
+
const length = this.u8(`${name}.length`);
|
|
2752
|
+
if (length === 0) fail(`${name} must not be empty.`);
|
|
2753
|
+
return this.textBody(length, name);
|
|
2754
|
+
}
|
|
2755
|
+
|
|
2756
|
+
rid8(name: string): string {
|
|
2757
|
+
const length = this.u8(`${name}.length`);
|
|
2758
|
+
if (length === 0) fail(`${name} must not be empty.`);
|
|
2759
|
+
this.need(length, name);
|
|
2760
|
+
const bytes = this.bytes.subarray(this.offset, this.offset + length);
|
|
2761
|
+
this.offset += length;
|
|
2762
|
+
return decodeServiceWireRoutingId(bytes, name, 0xff, fail);
|
|
2763
|
+
}
|
|
2764
|
+
|
|
2765
|
+
text16(name: string, allowEmpty = false): string {
|
|
2766
|
+
const length = this.u16(`${name}.length`);
|
|
2767
|
+
if (!allowEmpty && length === 0) fail(`${name} must not be empty.`);
|
|
2768
|
+
return this.textBody(length, name);
|
|
2769
|
+
}
|
|
2770
|
+
|
|
2771
|
+
body16(name: string): FrozenReader {
|
|
2772
|
+
const length = this.u16(`${name}.length`);
|
|
2773
|
+
this.need(length, name);
|
|
2774
|
+
const body = this.bytes.subarray(this.offset, this.offset + length);
|
|
2775
|
+
this.offset += length;
|
|
2776
|
+
return new FrozenReader(body);
|
|
2777
|
+
}
|
|
2778
|
+
|
|
2779
|
+
applicationPayload(): NonNullable<ServiceMaintenanceReplyRelay['payload']> {
|
|
2780
|
+
if (this.u8('applicationPayload.version') !== 1) {
|
|
2781
|
+
fail('Application payload envelope version must be one.');
|
|
2782
|
+
}
|
|
2783
|
+
const body = this.body32('application payload');
|
|
2784
|
+
const packetName = body.text8('packetName');
|
|
2785
|
+
const contentType = body.text8('contentType');
|
|
2786
|
+
const payloadLength = body.u32('payloadLength');
|
|
2787
|
+
const bytes = body.take(payloadLength, 'payload');
|
|
2788
|
+
body.end('application payload');
|
|
2789
|
+
return { packetName, contentType, bytes };
|
|
2790
|
+
}
|
|
2791
|
+
|
|
2792
|
+
metadata(): void {
|
|
2793
|
+
const start = this.offset;
|
|
2794
|
+
if (this.u8('metadata.version') !== 1) fail('Metadata frame version must be one.');
|
|
2795
|
+
const count = this.u8('metadata.count');
|
|
2796
|
+
const keys = new Set<string>();
|
|
2797
|
+
for (let index = 0; index < count; index++) {
|
|
2798
|
+
const key = this.text8('metadata.key');
|
|
2799
|
+
if (keys.has(key)) fail('Metadata keys must be unique.');
|
|
2800
|
+
keys.add(key);
|
|
2801
|
+
this.text16('metadata.value', true);
|
|
2802
|
+
if (this.offset - start > 1024) fail('Metadata frame exceeds 1024 encoded bytes.');
|
|
2803
|
+
}
|
|
2804
|
+
}
|
|
2805
|
+
|
|
2806
|
+
frozenBody(recordKind: number): {
|
|
2807
|
+
readonly instanceOperationKind?: number;
|
|
2808
|
+
readonly target?: ServiceWireFrozenRecord['target'];
|
|
2809
|
+
readonly applicationPayload?: NonNullable<ServiceMaintenanceReplyRelay['payload']>;
|
|
2810
|
+
} {
|
|
2811
|
+
if (recordKind === 1 || recordKind === 2) {
|
|
2812
|
+
return { applicationPayload: this.applicationPayload() };
|
|
2813
|
+
}
|
|
2814
|
+
else if (recordKind === 3 || recordKind === 4) {
|
|
2815
|
+
this.text8('channelName');
|
|
2816
|
+
return { applicationPayload: this.applicationPayload() };
|
|
2817
|
+
} else if (recordKind === 5 || recordKind === 6) {
|
|
2818
|
+
return {
|
|
2819
|
+
target: this.spotRoute(),
|
|
2820
|
+
applicationPayload: this.applicationPayload()
|
|
2821
|
+
};
|
|
2822
|
+
} else if (recordKind === 7) {
|
|
2823
|
+
this.text8('channelName');
|
|
2824
|
+
this.text8('topic');
|
|
2825
|
+
return { applicationPayload: this.applicationPayload() };
|
|
2826
|
+
} else if (recordKind === 8) this.actorControl();
|
|
2827
|
+
else if (recordKind === 9 || recordKind === 10) {
|
|
2828
|
+
return {
|
|
2829
|
+
target: this.actorRoute(),
|
|
2830
|
+
applicationPayload: this.applicationPayload()
|
|
2831
|
+
};
|
|
2832
|
+
} else if (recordKind === 11) {
|
|
2833
|
+
const terminalResult = this.u32('terminalResult');
|
|
2834
|
+
const failureCode = this.u32('failureCode');
|
|
2835
|
+
const hasPayload = this.bool8('hasPayload');
|
|
2836
|
+
validateReplyTerminal(terminalResult, failureCode, hasPayload);
|
|
2837
|
+
return hasPayload
|
|
2838
|
+
? { applicationPayload: this.applicationPayload() }
|
|
2839
|
+
: {};
|
|
2840
|
+
} else if (recordKind === 12) this.sendReadyDestination();
|
|
2841
|
+
else if (recordKind === 13) {
|
|
2842
|
+
validateRelocationPhase(this.u8('phase'));
|
|
2843
|
+
const role = this.u8('role');
|
|
2844
|
+
if (role < 1 || role > 3) fail('Invalid relocation control role.');
|
|
2845
|
+
const relocation = { high: this.u64('relocation.high'), low: this.u64('relocation.low') };
|
|
2846
|
+
if (relocation.high === 0n && relocation.low === 0n) fail('Relocation ID must not be zero.');
|
|
2847
|
+
this.relocationObject();
|
|
2848
|
+
validateReplyTerminal(this.u32('terminalResult'), this.u32('failureCode'), false);
|
|
2849
|
+
} else if (recordKind === 14) {
|
|
2850
|
+
this.instanceRoute();
|
|
2851
|
+
this.nonZeroU64('instanceSourceNodeGeneration');
|
|
2852
|
+
const operationKind = this.u8('instanceOperationKind');
|
|
2853
|
+
if (operationKind < 1 || operationKind > 2) fail('Invalid Instance activation operation kind.');
|
|
2854
|
+
const applicationPayload = this.applicationPayload();
|
|
2855
|
+
return { instanceOperationKind: operationKind, applicationPayload };
|
|
2856
|
+
}
|
|
2857
|
+
return {};
|
|
2858
|
+
}
|
|
2859
|
+
|
|
2860
|
+
private spotRoute(): Extract<NonNullable<ServiceWireFrozenRecord['target']>, { kind: 'spot' }> {
|
|
2861
|
+
const spot = this.spotIdentity();
|
|
2862
|
+
return {
|
|
2863
|
+
kind: 'spot',
|
|
2864
|
+
...spot,
|
|
2865
|
+
targetNodeRid: this.rid8('targetNodeRid'),
|
|
2866
|
+
targetNodeGeneration: this.nonZeroU64('targetNodeGeneration'),
|
|
2867
|
+
authorityOwnerGeneration: this.nonZeroU64('expectedAuthorityOwnerGeneration'),
|
|
2868
|
+
ownerLeaseGeneration: this.nonZeroU64('expectedOwnerLeaseGeneration')
|
|
2869
|
+
};
|
|
2870
|
+
}
|
|
2871
|
+
|
|
2872
|
+
private actorRoute(): Extract<NonNullable<ServiceWireFrozenRecord['target']>, { kind: 'actor' }> {
|
|
2873
|
+
const actor = this.actorIdentity();
|
|
2874
|
+
return {
|
|
2875
|
+
kind: 'actor',
|
|
2876
|
+
...actor,
|
|
2877
|
+
targetNodeRid: this.rid8('targetNodeRid'),
|
|
2878
|
+
targetNodeGeneration: this.nonZeroU64('targetNodeGeneration'),
|
|
2879
|
+
authorityOwnerGeneration: this.nonZeroU64('expectedAuthorityOwnerGeneration'),
|
|
2880
|
+
ownerLeaseGeneration: this.nonZeroU64('expectedOwnerLeaseGeneration')
|
|
2881
|
+
};
|
|
2882
|
+
}
|
|
2883
|
+
|
|
2884
|
+
private actorIdentity(): { readonly actorId: string; readonly generation: bigint } {
|
|
2885
|
+
return {
|
|
2886
|
+
actorId: this.text8('actorId'),
|
|
2887
|
+
generation: this.nonZeroU64('actorGeneration')
|
|
2888
|
+
};
|
|
2889
|
+
}
|
|
2890
|
+
|
|
2891
|
+
private spotIdentity(): { readonly spotId: string; readonly generation: bigint } {
|
|
2892
|
+
return {
|
|
2893
|
+
spotId: this.text8('spotId'),
|
|
2894
|
+
generation: this.nonZeroU64('spotGeneration')
|
|
2895
|
+
};
|
|
2896
|
+
}
|
|
2897
|
+
|
|
2898
|
+
private membershipSnapshot(): void {
|
|
2899
|
+
this.actorIdentity();
|
|
2900
|
+
this.spotIdentity();
|
|
2901
|
+
}
|
|
2902
|
+
|
|
2903
|
+
private optionalMembershipSnapshot(): void {
|
|
2904
|
+
const present = this.bool8('hasMembership');
|
|
2905
|
+
const body = this.body16('optionalMembership');
|
|
2906
|
+
if (present) body.membershipSnapshot();
|
|
2907
|
+
body.end('optional membership');
|
|
2908
|
+
}
|
|
2909
|
+
|
|
2910
|
+
private actorControl(): void {
|
|
2911
|
+
const lifecycle = this.u8('actorLifecycleKind');
|
|
2912
|
+
if (lifecycle < 1 || lifecycle > 5) fail('Invalid Actor lifecycle kind.');
|
|
2913
|
+
const body = this.body16('actorControl');
|
|
2914
|
+
if (lifecycle === 1 || lifecycle === 4 || lifecycle === 5) body.membershipSnapshot();
|
|
2915
|
+
else if (lifecycle === 2) {
|
|
2916
|
+
body.optionalMembershipSnapshot();
|
|
2917
|
+
body.membershipSnapshot();
|
|
2918
|
+
} else {
|
|
2919
|
+
body.membershipSnapshot();
|
|
2920
|
+
body.membershipSnapshot();
|
|
2921
|
+
}
|
|
2922
|
+
body.end('Actor control');
|
|
2923
|
+
}
|
|
2924
|
+
|
|
2925
|
+
private sendReadyDestination(): void {
|
|
2926
|
+
const kind = this.u8('destinationKind');
|
|
2927
|
+
if (kind < 1 || kind > 5) fail('Invalid send-ready destination kind.');
|
|
2928
|
+
const body = this.body16('send-ready destination');
|
|
2929
|
+
if (kind === 1 || kind === 2) body.text8('destination');
|
|
2930
|
+
else if (kind === 3) body.spotRoute();
|
|
2931
|
+
else {
|
|
2932
|
+
body.actorRoute();
|
|
2933
|
+
if (kind === 5) body.nonZeroU64('bindingGeneration');
|
|
2934
|
+
}
|
|
2935
|
+
body.end('send-ready destination');
|
|
2936
|
+
}
|
|
2937
|
+
|
|
2938
|
+
private instanceRoute(): void {
|
|
2939
|
+
const kind = this.u8('instanceRouteKind');
|
|
2940
|
+
if (kind < 1 || kind > 2) fail('Invalid Instance route kind.');
|
|
2941
|
+
const body = this.body16('Instance route');
|
|
2942
|
+
body.rid8('targetNodeRid');
|
|
2943
|
+
body.nonZeroU64('targetNodeGeneration');
|
|
2944
|
+
body.text8('targetSpotId');
|
|
2945
|
+
if (kind === 1) {
|
|
2946
|
+
body.nonZeroU64('objectGeneration');
|
|
2947
|
+
body.text8('ownerId');
|
|
2948
|
+
body.nonZeroU64('authorityOwnerGeneration');
|
|
2949
|
+
body.nonZeroU64('leaseGeneration');
|
|
2950
|
+
body.text16('storeVersion');
|
|
2951
|
+
} else {
|
|
2952
|
+
body.text8('targetMeshName');
|
|
2953
|
+
body.text8('stableType');
|
|
2954
|
+
body.text8('targetDescriptorVersion');
|
|
2955
|
+
body.nonZeroU64('deadlineUnixMs');
|
|
2956
|
+
}
|
|
2957
|
+
body.end('Instance route');
|
|
2958
|
+
}
|
|
2959
|
+
|
|
2960
|
+
private relocationObject(): void {
|
|
2961
|
+
const kind = this.u8('relocationObjectKind');
|
|
2962
|
+
const body = this.body16('relocation object');
|
|
2963
|
+
if (kind === 1) {
|
|
2964
|
+
body.text8('actorId');
|
|
2965
|
+
body.nonZeroU64('actorGeneration');
|
|
2966
|
+
body.nonZeroU64('expectedAuthorityOwnerGeneration');
|
|
2967
|
+
} else if (kind === 2) {
|
|
2968
|
+
body.text8('spotId');
|
|
2969
|
+
body.nonZeroU64('spotGeneration');
|
|
2970
|
+
body.nonZeroU64('expectedAuthorityOwnerGeneration');
|
|
2971
|
+
} else if (kind === 3) {
|
|
2972
|
+
body.text8('stableType');
|
|
2973
|
+
body.text8('spotId');
|
|
2974
|
+
body.nonZeroU64('objectGeneration');
|
|
2975
|
+
} else fail('Invalid relocation object kind.');
|
|
2976
|
+
body.end('relocation object');
|
|
2977
|
+
}
|
|
2978
|
+
|
|
2979
|
+
private body32(name: string): FrozenReader {
|
|
2980
|
+
const length = this.u32(`${name}.length`);
|
|
2981
|
+
this.need(length, name);
|
|
2982
|
+
const body = this.bytes.subarray(this.offset, this.offset + length);
|
|
2983
|
+
this.offset += length;
|
|
2984
|
+
return new FrozenReader(body);
|
|
2985
|
+
}
|
|
2986
|
+
|
|
2987
|
+
private take(length: number, name: string): Buffer {
|
|
2988
|
+
this.need(length, name);
|
|
2989
|
+
const value = Buffer.from(this.bytes.subarray(this.offset, this.offset + length));
|
|
2990
|
+
this.offset += length;
|
|
2991
|
+
return value;
|
|
2992
|
+
}
|
|
2993
|
+
|
|
2994
|
+
private textBody(length: number, name: string): string {
|
|
2995
|
+
this.need(length, name);
|
|
2996
|
+
const bytes = this.bytes.subarray(this.offset, this.offset + length);
|
|
2997
|
+
this.offset += length;
|
|
2998
|
+
return decodeCanonicalServiceWireText(bytes, name, fail);
|
|
2999
|
+
}
|
|
3000
|
+
|
|
3001
|
+
private need(length: number, name: string): void {
|
|
3002
|
+
if (length < 0 || length > this.remaining) fail(`Truncated ${name}.`);
|
|
3003
|
+
}
|
|
3004
|
+
|
|
3005
|
+
end(name: string): void {
|
|
3006
|
+
if (this.remaining !== 0) fail(`${name} has trailing bytes.`);
|
|
3007
|
+
}
|
|
3008
|
+
}
|