@zlink-systems/framework 0.30.0 → 0.30.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +150 -68
- package/dist/.tsbuildinfo +1 -1
- package/dist/contracts/Actors/ZLinkActorClient.d.ts +2 -1
- package/dist/contracts/Channels/Calls.d.ts +2 -1
- package/dist/contracts/Common/ZLinkEncodedPayload.d.ts +6 -0
- package/dist/contracts/Common/ZLinkEncodedPayload.js +18 -3
- package/dist/contracts/Common/ZLinkMessageMetadata.js +11 -5
- package/dist/contracts/Common/encoded-payload-storage.d.ts +1 -1
- package/dist/contracts/Common/encoded-payload-storage.js +5 -2
- package/dist/contracts/Configuration/Builders.d.ts +1 -1
- package/dist/contracts/Configuration/RegistrationBuilderPolicy.d.ts +2 -1
- package/dist/contracts/Configuration/RegistrationBuilderPolicy.js +5 -1
- package/dist/contracts/Configuration/RegistrationBuilders.js +2 -2
- package/dist/contracts/Configuration/RegistrationTypes.d.ts +1 -0
- package/dist/contracts/Dispatch/ZLinkDispatchOptions.d.ts +2 -2
- package/dist/contracts/Handlers/Attributes.d.ts +5 -13
- package/dist/contracts/Handlers/Attributes.js +7 -11
- package/dist/contracts/Handlers/JsonContract.d.ts +2 -46
- package/dist/contracts/Handlers/JsonContract.js +4 -153
- package/dist/contracts/Locations/Rows.d.ts +2 -0
- package/dist/contracts/Spots/Contracts.d.ts +6 -1
- package/dist/contracts/Spots/ZLinkSpot.d.ts +3 -3
- package/dist/nest-integration.d.ts +1 -1
- package/dist/nest-integration.js +2 -1
- package/dist/runtime/abort.d.ts +5 -0
- package/dist/runtime/abort.js +10 -0
- package/dist/runtime/actors/actor-authority-publication.js +3 -2
- package/dist/runtime/actors/actor-client.d.ts +1 -2
- package/dist/runtime/actors/actor-client.js +52 -57
- package/dist/runtime/actors/actor-context.d.ts +2 -0
- package/dist/runtime/actors/actor-context.js +46 -9
- package/dist/runtime/actors/actor-handoff.d.ts +8 -4
- package/dist/runtime/actors/actor-handoff.js +219 -92
- package/dist/runtime/actors/actor-join-relocation.d.ts +3 -0
- package/dist/runtime/actors/actor-local-native-join.js +13 -12
- package/dist/runtime/actors/actor-mailbox.js +27 -1
- package/dist/runtime/actors/actor-remote-joiner.js +3 -1
- package/dist/runtime/actors/actor-remote-wire.js +15 -0
- package/dist/runtime/actors/actor-reply.d.ts +4 -0
- package/dist/runtime/actors/actor-reply.js +29 -0
- package/dist/runtime/actors/actor-routed-join-transport.d.ts +6 -2
- package/dist/runtime/actors/actor-routed-json-request.d.ts +2 -0
- package/dist/runtime/actors/actor-runtime-contracts.d.ts +2 -0
- package/dist/runtime/actors/actor-runtime-state.js +2 -20
- package/dist/runtime/actors/actor-source-transfer.d.ts +1 -17
- package/dist/runtime/actors/index.d.ts +8 -3
- package/dist/runtime/actors/index.js +55 -27
- package/dist/runtime/actors/session-disconnected-wire.d.ts +8 -0
- package/dist/runtime/actors/session-disconnected-wire.js +48 -0
- package/dist/runtime/actors/spot-actor-dispatch.js +2 -2
- package/dist/runtime/admission.d.ts +9 -1
- package/dist/runtime/admission.js +56 -23
- package/dist/runtime/application-jobs/application-ingress-record-owner.d.ts +6 -8
- package/dist/runtime/application-jobs/application-ingress-record-owner.js +39 -22
- package/dist/runtime/application-jobs/application-job-queue-scope.d.ts +15 -1
- package/dist/runtime/application-jobs/application-job-queue-scope.js +61 -20
- package/dist/runtime/application-jobs/contracts.d.ts +12 -1
- package/dist/runtime/backend/contracts/index.d.ts +37 -12
- package/dist/runtime/backend/mesh-actor-session-node-adapter.js +2 -2
- package/dist/runtime/backend/mesh-completion-table.d.ts +9 -1
- package/dist/runtime/backend/mesh-completion-table.js +154 -49
- package/dist/runtime/backend/mesh-dispatch-pump.d.ts +28 -1
- package/dist/runtime/backend/mesh-dispatch-pump.js +208 -101
- package/dist/runtime/backend/node/node-backend-adapter-support.d.ts +2 -2
- package/dist/runtime/backend/node/node-backend-adapter-support.js +16 -9
- package/dist/runtime/backend/node/node-dealer-channel-client-transport.d.ts +1 -1
- package/dist/runtime/backend/node/node-dealer-channel-client-transport.js +5 -2
- package/dist/runtime/backend/node/node-raw-binding-port.js +124 -72
- package/dist/runtime/backend/node/node-raw-mesh-backend.d.ts +46 -13
- package/dist/runtime/backend/node/node-raw-mesh-backend.js +181 -164
- package/dist/runtime/backend/node/node-socket-backend-adapter.d.ts +1 -1
- package/dist/runtime/backend/node/node-socket-backend-adapter.js +11 -11
- package/dist/runtime/backend/raw-binding-port.d.ts +2 -2
- package/dist/runtime/backend/runtime-message.d.ts +1 -0
- package/dist/runtime/backend/runtime-message.js +5 -0
- package/dist/runtime/backend/runtime-values.d.ts +1 -0
- package/dist/runtime/backend/runtime-values.js +2 -1
- package/dist/runtime/channels/channel-clients.d.ts +2 -0
- package/dist/runtime/channels/channel-clients.js +75 -23
- package/dist/runtime/channels/channel-dispatch-pipeline.d.ts +25 -5
- package/dist/runtime/channels/channel-dispatch-pipeline.js +111 -56
- package/dist/runtime/channels/channel-dispatch-services.d.ts +1 -0
- package/dist/runtime/channels/channel-dispatch-services.js +45 -0
- package/dist/runtime/channels/channel-dispatchers.d.ts +4 -3
- package/dist/runtime/channels/channel-dispatchers.js +62 -54
- package/dist/runtime/channels/channel-envelope-inspection.d.ts +1 -2
- package/dist/runtime/channels/channel-envelope-inspection.js +1 -16
- package/dist/runtime/channels/channel-envelope.d.ts +2 -0
- package/dist/runtime/channels/channel-envelope.js +146 -28
- package/dist/runtime/channels/channel-outbound-operations.d.ts +2 -2
- package/dist/runtime/channels/channel-outbound-operations.js +8 -8
- package/dist/runtime/channels/channel-runtime-lifecycle.d.ts +4 -3
- package/dist/runtime/channels/channel-runtime-lifecycle.js +19 -24
- package/dist/runtime/channels/channel-runtime-manager.d.ts +9 -8
- package/dist/runtime/channels/channel-runtime-manager.js +16 -16
- package/dist/runtime/channels/channel-transports.d.ts +18 -16
- package/dist/runtime/channels/channel-transports.js +77 -58
- package/dist/runtime/channels/client-server-location-runtime.js +5 -4
- package/dist/runtime/channels/dispatch-error-reporter.d.ts +2 -1
- package/dist/runtime/channels/dispatch-error-reporter.js +2 -1
- package/dist/runtime/channels/fanout-location-runtime.d.ts +1 -1
- package/dist/runtime/channels/fanout-location-runtime.js +3 -3
- package/dist/runtime/channels/local-spot-route-transport.d.ts +1 -1
- package/dist/runtime/channels/local-spot-route-transport.js +2 -1
- package/dist/runtime/channels/router-socket-spot-route-transport.d.ts +2 -2
- package/dist/runtime/channels/router-socket-spot-route-transport.js +4 -4
- package/dist/runtime/channels/source-spot-router.d.ts +2 -2
- package/dist/runtime/channels/source-spot-router.js +4 -4
- package/dist/runtime/channels/spot-node-route-transport.d.ts +2 -2
- package/dist/runtime/channels/spot-node-route-transport.js +4 -4
- package/dist/runtime/channels/spot-route-bridge-transport.d.ts +2 -2
- package/dist/runtime/channels/spot-route-bridge-transport.js +4 -4
- package/dist/runtime/channels/spot-route-dispatch-strategy.d.ts +5 -4
- package/dist/runtime/channels/spot-route-dispatch-strategy.js +18 -18
- package/dist/runtime/diagnostics/flow-context.js +19 -7
- package/dist/runtime/diagnostics/index.js +4 -9
- package/dist/runtime/diagnostics/message-flow.d.ts +8 -0
- package/dist/runtime/diagnostics/message-flow.js +35 -5
- package/dist/runtime/diagnostics/runtime-metrics.d.ts +2 -2
- package/dist/runtime/diagnostics/runtime-metrics.js +10 -8
- package/dist/runtime/execution/index.d.ts +4 -2
- package/dist/runtime/execution/index.js +33 -10
- package/dist/runtime/execution/serial-execution-queue.d.ts +5 -0
- package/dist/runtime/execution/serial-execution-queue.js +22 -2
- package/dist/runtime/execution/state-lane.d.ts +2 -0
- package/dist/runtime/execution/state-lane.js +5 -0
- package/dist/runtime/foundation/actor-join-recovery-codec.js +2 -2
- package/dist/runtime/foundation/durable-service-request.d.ts +14 -0
- package/dist/runtime/foundation/durable-service-request.js +98 -0
- package/dist/runtime/foundation/operation-identity.d.ts +1 -0
- package/dist/runtime/foundation/operation-identity.js +5 -1
- package/dist/runtime/foundation/operation-registry.d.ts +25 -1
- package/dist/runtime/foundation/operation-registry.js +86 -18
- package/dist/runtime/foundation/raw-service-mesh-runtime.d.ts +61 -8
- package/dist/runtime/foundation/raw-service-mesh-runtime.js +486 -266
- package/dist/runtime/foundation/service-liveness-registry.d.ts +12 -1
- package/dist/runtime/foundation/service-liveness-registry.js +38 -0
- package/dist/runtime/foundation/service-mailbox.d.ts +7 -0
- package/dist/runtime/foundation/service-maintenance-runtime.js +1 -6
- package/dist/runtime/foundation/service-relocation-object-owner.d.ts +3 -3
- package/dist/runtime/foundation/service-relocation-object-owner.js +48 -34
- package/dist/runtime/foundation/service-relocation-runtime.d.ts +2 -0
- package/dist/runtime/foundation/service-relocation-runtime.js +20 -4
- package/dist/runtime/foundation/service-runtime-contracts.d.ts +10 -1
- package/dist/runtime/foundation/service-session-binding-ingress-port.d.ts +2 -1
- package/dist/runtime/foundation/service-stateful-registry.d.ts +5 -4
- package/dist/runtime/foundation/service-stateful-registry.js +24 -26
- package/dist/runtime/foundation/service-stateful-runtime.d.ts +75 -9
- package/dist/runtime/foundation/service-stateful-runtime.js +486 -218
- package/dist/runtime/foundation/service-stateful-wire-codec.d.ts +14 -6
- package/dist/runtime/foundation/service-stateful-wire-codec.js +48 -27
- package/dist/runtime/foundation/service-topology-registry.d.ts +12 -2
- package/dist/runtime/foundation/service-topology-registry.js +61 -27
- package/dist/runtime/foundation/service-wire-binary-primitives.d.ts +6 -1
- package/dist/runtime/foundation/service-wire-binary-primitives.js +27 -11
- package/dist/runtime/foundation/service-wire-constants.generated.d.ts +1 -0
- package/dist/runtime/foundation/service-wire-constants.generated.js +1 -0
- package/dist/runtime/foundation/service-wire-m6a-codec.d.ts +13 -3
- package/dist/runtime/foundation/service-wire-m6a-codec.js +189 -78
- package/dist/runtime/handlers/handler-instance-scope.d.ts +8 -0
- package/dist/runtime/handlers/handler-instance-scope.js +54 -11
- package/dist/runtime/host/actor-packet-relay.d.ts +6 -4
- package/dist/runtime/host/actor-packet-relay.js +59 -72
- package/dist/runtime/host/actor-placement-coordinator.js +25 -8
- package/dist/runtime/host/actor-runtime-options-factory.js +2 -2
- package/dist/runtime/host/actor-transfer-runtime.d.ts +7 -31
- package/dist/runtime/host/actor-transfer-runtime.js +85 -331
- package/dist/runtime/host/application-job-queue.d.ts +40 -7
- package/dist/runtime/host/application-job-queue.js +137 -42
- package/dist/runtime/host/entry-actor-runtime.d.ts +1 -0
- package/dist/runtime/host/entry-actor-runtime.js +3 -0
- package/dist/runtime/host/index.d.ts +12 -2
- package/dist/runtime/host/index.js +300 -202
- package/dist/runtime/host/location-runtime-owner.js +2 -6
- package/dist/runtime/host/mesh-router-resolver.d.ts +4 -0
- package/dist/runtime/host/mesh-router-resolver.js +14 -6
- package/dist/runtime/host/remote-bound-session-relay.d.ts +2 -4
- package/dist/runtime/host/remote-bound-session-relay.js +73 -208
- package/dist/runtime/host/route-mesh-runtime.d.ts +2 -2
- package/dist/runtime/host/route-mesh-runtime.js +6 -4
- package/dist/runtime/host/runtime-shutdown.d.ts +1 -0
- package/dist/runtime/host/runtime-shutdown.js +3 -2
- package/dist/runtime/host/service-relocation-control.d.ts +1 -0
- package/dist/runtime/host/service-relocation-control.js +10 -4
- package/dist/runtime/host/service-relocation-host-runtime.d.ts +22 -14
- package/dist/runtime/host/service-relocation-host-runtime.js +754 -599
- package/dist/runtime/host/spot-address-transport.js +3 -2
- package/dist/runtime/host/spot-runtime-options-factory.js +16 -7
- package/dist/runtime/host/user-spot-creation-coordinator.js +33 -84
- package/dist/runtime/locations/actor-location-claims.d.ts +2 -2
- package/dist/runtime/locations/actor-location-claims.js +34 -19
- package/dist/runtime/locations/auto-connect-loop.d.ts +2 -0
- package/dist/runtime/locations/auto-connect-loop.js +22 -14
- package/dist/runtime/locations/auto-connect-reconciler.js +0 -6
- package/dist/runtime/locations/auto-connect-types.d.ts +0 -1
- package/dist/runtime/locations/descriptor-publication.d.ts +4 -0
- package/dist/runtime/locations/descriptor-publication.js +11 -0
- package/dist/runtime/locations/domain-store-contract.d.ts +1 -0
- package/dist/runtime/locations/in-memory-authority-store.d.ts +7 -1
- package/dist/runtime/locations/in-memory-authority-store.js +56 -19
- package/dist/runtime/locations/in-memory-location-store.js +1 -10
- package/dist/runtime/locations/index.d.ts +1 -0
- package/dist/runtime/locations/index.js +1 -0
- package/dist/runtime/locations/lease-tracker.js +1 -6
- package/dist/runtime/locations/lifecycle.d.ts +1 -2
- package/dist/runtime/locations/lifecycle.js +2 -5
- package/dist/runtime/locations/location-store-repository.d.ts +51 -1
- package/dist/runtime/locations/location-store-repository.js +363 -139
- package/dist/runtime/locations/relocation-blob.d.ts +18 -1
- package/dist/runtime/locations/relocation-blob.js +52 -1
- package/dist/runtime/locations/request-source-resolver.d.ts +37 -0
- package/dist/runtime/locations/request-source-resolver.js +80 -0
- package/dist/runtime/locations/resolvers.js +1 -1
- package/dist/runtime/locations/runtime.d.ts +7 -3
- package/dist/runtime/locations/runtime.js +61 -53
- package/dist/runtime/messaging/framework-json-v1.d.ts +4 -6
- package/dist/runtime/messaging/framework-json-v1.js +38 -294
- package/dist/runtime/messaging/packet-name.d.ts +1 -1
- package/dist/runtime/messaging/packet-name.js +8 -24
- package/dist/runtime/messaging/payload-codec.d.ts +7 -1
- package/dist/runtime/messaging/payload-codec.js +7 -6
- package/dist/runtime/messaging/request-result.d.ts +2 -0
- package/dist/runtime/messaging/request-result.js +57 -0
- package/dist/runtime/messaging/submission-result.d.ts +1 -0
- package/dist/runtime/messaging/submission-result.js +5 -2
- package/dist/runtime/protocol/service_wire_codec.generated.d.ts +34 -1
- package/dist/runtime/protocol/service_wire_codec.generated.js +229 -0
- package/dist/runtime/protocol/service_wire_pilot_codec.generated.d.ts +16 -1
- package/dist/runtime/protocol/service_wire_pilot_codec.generated.js +37 -8
- package/dist/runtime/spots/formal-remote-actor-admission-registry.d.ts +7 -2
- package/dist/runtime/spots/formal-remote-actor-admission-registry.js +36 -21
- package/dist/runtime/spots/index.d.ts +21 -11
- package/dist/runtime/spots/index.js +243 -178
- package/dist/runtime/spots/spot-activation-registry.d.ts +4 -2
- package/dist/runtime/spots/spot-activation-registry.js +21 -11
- package/dist/runtime/spots/spot-activation-state.d.ts +1 -1
- package/dist/runtime/spots/spot-activation-state.js +7 -7
- package/dist/runtime/spots/spot-activation.d.ts +7 -3
- package/dist/runtime/spots/spot-activation.js +140 -52
- package/dist/runtime/spots/spot-actor-admission-coordinator.d.ts +1 -0
- package/dist/runtime/spots/spot-actor-admission-coordinator.js +13 -22
- package/dist/runtime/spots/spot-actor-membership.d.ts +0 -1
- package/dist/runtime/spots/spot-actor-membership.js +0 -8
- package/dist/runtime/spots/spot-actor-packet-dispatch.js +33 -8
- package/dist/runtime/spots/spot-actor-packet-drain.js +5 -33
- package/dist/runtime/spots/spot-entry-activation.d.ts +2 -0
- package/dist/runtime/spots/spot-entry-activation.js +20 -11
- package/dist/runtime/spots/spot-handler-registry.d.ts +7 -4
- package/dist/runtime/spots/spot-handler-registry.js +24 -10
- package/dist/runtime/spots/spot-manager-internal-contracts.d.ts +2 -2
- package/dist/runtime/spots/spot-manager-public.js +2 -2
- package/dist/runtime/spots/spot-node-autoconnect.d.ts +2 -1
- package/dist/runtime/spots/spot-node-autoconnect.js +22 -42
- package/dist/runtime/spots/spot-node-runtime-manager.d.ts +19 -2
- package/dist/runtime/spots/spot-node-runtime-manager.js +115 -50
- package/dist/runtime/spots/spot-outbound.d.ts +3 -0
- package/dist/runtime/spots/spot-outbound.js +27 -18
- package/dist/runtime/spots/spot-remote-codec.js +5 -1
- package/dist/runtime/spots/spot-routed-spot-packet-dispatch.d.ts +1 -0
- package/dist/runtime/spots/spot-routed-spot-packet-dispatch.js +1 -1
- package/dist/runtime/spots/spot-runtime-ports.d.ts +1 -1
- package/dist/runtime/spots/spot-serial-executor.d.ts +10 -0
- package/dist/runtime/spots/spot-serial-executor.js +61 -8
- package/dist/runtime/spots/spot-serial-turn-executor.js +19 -2
- package/dist/runtime/spots/spot-subscription-dispatch.js +1 -4
- package/dist/runtime/spots/spot-timer.d.ts +57 -5
- package/dist/runtime/spots/spot-timer.js +288 -103
- package/dist/runtime/streams/actor-session-binding-registry.d.ts +42 -11
- package/dist/runtime/streams/actor-session-binding-registry.js +165 -48
- package/dist/runtime/streams/actor-session-binding-runtime-owner.d.ts +8 -4
- package/dist/runtime/streams/bound-actor-relay-sender.d.ts +2 -1
- package/dist/runtime/streams/bound-actor-relay-sender.js +15 -8
- package/dist/runtime/streams/bound-session-service.d.ts +1 -1
- package/dist/runtime/streams/bound-session-service.js +6 -11
- package/dist/runtime/streams/index.d.ts +3 -2
- package/dist/runtime/streams/index.js +6 -4
- package/dist/runtime/streams/managed-stream.js +3 -2
- package/dist/runtime/streams/native-fallback-bound-session.js +8 -73
- package/dist/runtime/streams/session-actor-coordinator.d.ts +2 -8
- package/dist/runtime/streams/session-actor-coordinator.js +15 -32
- package/dist/runtime/streams/stream-binding-runtime-ports.d.ts +3 -10
- package/dist/runtime/streams/stream-session-runtime.d.ts +1 -1
- package/dist/runtime/streams/stream-session-runtime.js +14 -31
- package/dist/runtime/workers/index.js +1 -1
- package/package.json +3 -3
- package/src/contracts/Actors/ZLinkActorClient.ts +2 -1
- package/src/contracts/Channels/Calls.ts +2 -1
- package/src/contracts/Common/ZLinkEncodedPayload.ts +24 -4
- package/src/contracts/Common/ZLinkMessageMetadata.ts +13 -8
- package/src/contracts/Common/encoded-payload-storage.ts +6 -3
- package/src/contracts/Configuration/Builders.ts +4 -1
- package/src/contracts/Configuration/RegistrationBuilderPolicy.ts +7 -2
- package/src/contracts/Configuration/RegistrationBuilders.ts +6 -2
- package/src/contracts/Configuration/RegistrationTypes.ts +1 -0
- package/src/contracts/Dispatch/ZLinkDispatchOptions.ts +2 -1
- package/src/contracts/Handlers/Attributes.ts +14 -21
- package/src/contracts/Handlers/JsonContract.ts +8 -216
- package/src/contracts/Locations/Rows.ts +2 -0
- package/src/contracts/Spots/Contracts.ts +10 -1
- package/src/contracts/Spots/ZLinkSpot.ts +3 -3
- package/src/nest-integration.ts +1 -0
- package/src/runtime/abort.ts +12 -0
- package/src/runtime/actors/actor-authority-publication.ts +3 -2
- package/src/runtime/actors/actor-client.ts +100 -85
- package/src/runtime/actors/actor-context.ts +49 -9
- package/src/runtime/actors/actor-handoff.ts +291 -110
- package/src/runtime/actors/actor-join-relocation.ts +3 -0
- package/src/runtime/actors/actor-local-native-join.ts +21 -26
- package/src/runtime/actors/actor-mailbox.ts +40 -2
- package/src/runtime/actors/actor-remote-joiner.ts +6 -1
- package/src/runtime/actors/actor-remote-wire.ts +17 -0
- package/src/runtime/actors/actor-reply.ts +42 -0
- package/src/runtime/actors/actor-routed-join-transport.ts +14 -4
- package/src/runtime/actors/actor-routed-json-request.ts +10 -2
- package/src/runtime/actors/actor-runtime-contracts.ts +2 -0
- package/src/runtime/actors/actor-runtime-state.ts +2 -20
- package/src/runtime/actors/actor-source-transfer.ts +1 -34
- package/src/runtime/actors/index.ts +60 -32
- package/src/runtime/actors/session-disconnected-wire.ts +66 -0
- package/src/runtime/actors/spot-actor-dispatch.ts +4 -2
- package/src/runtime/admission.ts +69 -21
- package/src/runtime/application-jobs/application-ingress-record-owner.ts +41 -25
- package/src/runtime/application-jobs/application-job-queue-scope.ts +83 -22
- package/src/runtime/application-jobs/contracts.ts +16 -1
- package/src/runtime/backend/contracts/index.ts +92 -18
- package/src/runtime/backend/mesh-actor-session-node-adapter.ts +5 -3
- package/src/runtime/backend/mesh-completion-table.ts +160 -57
- package/src/runtime/backend/mesh-dispatch-pump.ts +237 -108
- package/src/runtime/backend/node/node-backend-adapter-support.ts +17 -8
- package/src/runtime/backend/node/node-dealer-channel-client-transport.ts +12 -2
- package/src/runtime/backend/node/node-raw-binding-port.ts +148 -85
- package/src/runtime/backend/node/node-raw-mesh-backend.ts +315 -201
- package/src/runtime/backend/node/node-socket-backend-adapter.ts +26 -11
- package/src/runtime/backend/raw-binding-port.ts +7 -2
- package/src/runtime/backend/runtime-message.ts +6 -0
- package/src/runtime/backend/runtime-values.ts +1 -0
- package/src/runtime/channels/channel-clients.ts +132 -58
- package/src/runtime/channels/channel-dispatch-pipeline.ts +198 -114
- package/src/runtime/channels/channel-dispatch-services.ts +69 -1
- package/src/runtime/channels/channel-dispatchers.ts +136 -90
- package/src/runtime/channels/channel-envelope-inspection.ts +2 -16
- package/src/runtime/channels/channel-envelope.ts +225 -31
- package/src/runtime/channels/channel-outbound-operations.ts +22 -8
- package/src/runtime/channels/channel-runtime-lifecycle.ts +13 -13
- package/src/runtime/channels/channel-runtime-manager.ts +41 -17
- package/src/runtime/channels/channel-transports.ts +171 -112
- package/src/runtime/channels/client-server-location-runtime.ts +11 -10
- package/src/runtime/channels/dispatch-error-reporter.ts +4 -2
- package/src/runtime/channels/fanout-location-runtime.ts +17 -9
- package/src/runtime/channels/local-spot-route-transport.ts +3 -1
- package/src/runtime/channels/router-socket-spot-route-transport.ts +13 -4
- package/src/runtime/channels/source-spot-router.ts +8 -4
- package/src/runtime/channels/spot-node-route-transport.ts +8 -4
- package/src/runtime/channels/spot-route-bridge-transport.ts +6 -4
- package/src/runtime/channels/spot-route-dispatch-strategy.ts +47 -18
- package/src/runtime/diagnostics/flow-context.ts +20 -7
- package/src/runtime/diagnostics/index.ts +1 -7
- package/src/runtime/diagnostics/message-flow.ts +47 -9
- package/src/runtime/diagnostics/runtime-metrics.ts +12 -10
- package/src/runtime/execution/index.ts +40 -14
- package/src/runtime/execution/serial-execution-queue.ts +33 -4
- package/src/runtime/execution/state-lane.ts +7 -0
- package/src/runtime/foundation/actor-join-recovery-codec.ts +2 -2
- package/src/runtime/foundation/durable-service-request.ts +137 -0
- package/src/runtime/foundation/operation-identity.ts +5 -1
- package/src/runtime/foundation/operation-registry.ts +98 -20
- package/src/runtime/foundation/raw-service-mesh-runtime.ts +704 -336
- package/src/runtime/foundation/service-liveness-registry.ts +39 -0
- package/src/runtime/foundation/service-mailbox.ts +8 -0
- package/src/runtime/foundation/service-maintenance-runtime.ts +1 -8
- package/src/runtime/foundation/service-relocation-object-owner.ts +55 -36
- package/src/runtime/foundation/service-relocation-runtime.ts +25 -4
- package/src/runtime/foundation/service-runtime-contracts.ts +19 -2
- package/src/runtime/foundation/service-session-binding-ingress-port.ts +2 -1
- package/src/runtime/foundation/service-stateful-registry.ts +38 -35
- package/src/runtime/foundation/service-stateful-runtime.ts +732 -275
- package/src/runtime/foundation/service-stateful-wire-codec.ts +49 -16
- package/src/runtime/foundation/service-topology-registry.ts +91 -36
- package/src/runtime/foundation/service-wire-binary-primitives.ts +35 -12
- package/src/runtime/foundation/service-wire-constants.generated.ts +1 -0
- package/src/runtime/foundation/service-wire-m6a-codec.ts +231 -76
- package/src/runtime/handlers/handler-instance-scope.ts +67 -16
- package/src/runtime/host/actor-packet-relay.ts +113 -94
- package/src/runtime/host/actor-placement-coordinator.ts +31 -8
- package/src/runtime/host/actor-runtime-options-factory.ts +13 -2
- package/src/runtime/host/actor-transfer-runtime.ts +104 -430
- package/src/runtime/host/application-job-queue.ts +160 -41
- package/src/runtime/host/entry-actor-runtime.ts +4 -0
- package/src/runtime/host/index.ts +473 -271
- package/src/runtime/host/location-runtime-owner.ts +2 -6
- package/src/runtime/host/mesh-router-resolver.ts +13 -5
- package/src/runtime/host/remote-bound-session-relay.ts +88 -271
- package/src/runtime/host/route-mesh-runtime.ts +12 -6
- package/src/runtime/host/runtime-shutdown.ts +15 -4
- package/src/runtime/host/service-relocation-control.ts +11 -5
- package/src/runtime/host/service-relocation-host-runtime.ts +1092 -759
- package/src/runtime/host/spot-address-transport.ts +4 -2
- package/src/runtime/host/spot-runtime-options-factory.ts +20 -7
- package/src/runtime/host/user-spot-creation-coordinator.ts +41 -100
- package/src/runtime/locations/actor-location-claims.ts +52 -30
- package/src/runtime/locations/auto-connect-loop.ts +22 -14
- package/src/runtime/locations/auto-connect-reconciler.ts +0 -6
- package/src/runtime/locations/auto-connect-types.ts +0 -1
- package/src/runtime/locations/descriptor-publication.ts +7 -0
- package/src/runtime/locations/domain-store-contract.ts +5 -0
- package/src/runtime/locations/in-memory-authority-store.ts +85 -23
- package/src/runtime/locations/in-memory-location-store.ts +1 -12
- package/src/runtime/locations/index.ts +1 -0
- package/src/runtime/locations/lease-tracker.ts +2 -9
- package/src/runtime/locations/lifecycle.ts +8 -26
- package/src/runtime/locations/location-store-repository.ts +628 -152
- package/src/runtime/locations/relocation-blob.ts +75 -1
- package/src/runtime/locations/request-source-resolver.ts +138 -0
- package/src/runtime/locations/resolvers.ts +2 -2
- package/src/runtime/locations/runtime.ts +98 -64
- package/src/runtime/messaging/framework-json-v1.ts +5 -325
- package/src/runtime/messaging/packet-name.ts +5 -25
- package/src/runtime/messaging/payload-codec.ts +8 -11
- package/src/runtime/messaging/request-result.ts +62 -0
- package/src/runtime/messaging/submission-result.ts +5 -1
- package/src/runtime/protocol/service_wire_codec.generated.ts +218 -5
- package/src/runtime/protocol/service_wire_pilot_codec.generated.ts +16 -13
- package/src/runtime/spots/formal-remote-actor-admission-registry.ts +46 -25
- package/src/runtime/spots/index.ts +389 -283
- package/src/runtime/spots/spot-activation-registry.ts +25 -13
- package/src/runtime/spots/spot-activation-state.ts +12 -19
- package/src/runtime/spots/spot-activation.ts +198 -96
- package/src/runtime/spots/spot-actor-admission-coordinator.ts +25 -55
- package/src/runtime/spots/spot-actor-membership.ts +0 -15
- package/src/runtime/spots/spot-actor-packet-dispatch.ts +56 -11
- package/src/runtime/spots/spot-actor-packet-drain.ts +9 -52
- package/src/runtime/spots/spot-entry-activation.ts +33 -21
- package/src/runtime/spots/spot-handler-registry.ts +56 -12
- package/src/runtime/spots/spot-manager-internal-contracts.ts +2 -2
- package/src/runtime/spots/spot-manager-public.ts +2 -2
- package/src/runtime/spots/spot-node-autoconnect.ts +28 -47
- package/src/runtime/spots/spot-node-runtime-manager.ts +197 -67
- package/src/runtime/spots/spot-outbound.ts +39 -19
- package/src/runtime/spots/spot-remote-codec.ts +9 -2
- package/src/runtime/spots/spot-routed-spot-packet-dispatch.ts +2 -1
- package/src/runtime/spots/spot-runtime-ports.ts +1 -1
- package/src/runtime/spots/spot-serial-executor.ts +97 -25
- package/src/runtime/spots/spot-serial-turn-executor.ts +22 -3
- package/src/runtime/spots/spot-subscription-dispatch.ts +1 -4
- package/src/runtime/spots/spot-timer.ts +418 -158
- package/src/runtime/streams/actor-session-binding-registry.ts +236 -64
- package/src/runtime/streams/actor-session-binding-runtime-owner.ts +16 -8
- package/src/runtime/streams/bound-actor-relay-sender.ts +23 -9
- package/src/runtime/streams/bound-session-service.ts +7 -10
- package/src/runtime/streams/index.ts +12 -6
- package/src/runtime/streams/managed-stream.ts +4 -2
- package/src/runtime/streams/native-fallback-bound-session.ts +14 -103
- package/src/runtime/streams/session-actor-coordinator.ts +39 -88
- package/src/runtime/streams/stream-binding-runtime-ports.ts +3 -9
- package/src/runtime/streams/stream-session-runtime.ts +13 -34
- package/src/runtime/workers/index.ts +1 -1
|
@@ -68,15 +68,12 @@ class ZLinkLocalNativeActorJoin {
|
|
|
68
68
|
throw new Error('Local Actor Join requires a valid target generation and stateful membership runtime.');
|
|
69
69
|
}
|
|
70
70
|
const membershipEpoch = location.membershipEpoch + 1n;
|
|
71
|
+
const currentActor = (0, actor_runtime_state_1.toFrameworkActorRef)(actorRef, meshName);
|
|
72
|
+
const authorityOwnerGeneration = state.locationGeneration ?? actorRef.generation;
|
|
71
73
|
const commit = async (spot) => {
|
|
72
74
|
(0, abort_1.throwIfAborted)(signal);
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
}
|
|
76
|
-
else {
|
|
77
|
-
await this.options.locationLifecycle?.notifyActorJoinedSpot(actorType, actor.context.actorId, meshName, storeSpotId, spotGeneration, membershipEpoch, node.status().lifecycleGeneration);
|
|
78
|
-
}
|
|
79
|
-
const committedActor = node.restoreActorAuthority(actor.context.actorId, actorType, actorRef.generation, state.locationGeneration ?? actorRef.generation, target.spotKind === contracts_1.ZLinkSpotKind.Entry ? undefined : String(target.spotId), spotGeneration, membershipEpoch);
|
|
75
|
+
await this.options.locationLifecycle?.commitActorMembership(actorType, currentActor, authorityOwnerGeneration, storeSpotId, spotGeneration, target.spotKind === contracts_1.ZLinkSpotKind.Entry ? contracts_1.ZLinkSpotKind.Entry : contracts_1.ZLinkSpotKind.User, node.status().lifecycleGeneration);
|
|
76
|
+
const committedActor = node.restoreActorAuthority(actor.context.actorId, actorType, actorRef.generation, authorityOwnerGeneration, target.spotKind === contracts_1.ZLinkSpotKind.Entry ? undefined : String(target.spotId), spotGeneration, membershipEpoch);
|
|
80
77
|
state.setNativeActorRef(committedActor);
|
|
81
78
|
if (target.spotKind === contracts_1.ZLinkSpotKind.Entry)
|
|
82
79
|
state.clearJoinedSpot();
|
|
@@ -120,6 +117,7 @@ class ZLinkLocalNativeActorJoin {
|
|
|
120
117
|
return submitJoinWhenConnected(() => completions.submit(submit, signal), timeoutMs, signal);
|
|
121
118
|
}
|
|
122
119
|
async relocateRemoteActorJoin(node, actor, state, actorRef, target, request, timeoutMs, signal, completionOperationId, entrySpot) {
|
|
120
|
+
const deadlineAtMs = timeoutMs === undefined ? undefined : performance.now() + timeoutMs;
|
|
123
121
|
const actorType = state.actorType;
|
|
124
122
|
if (actorType === undefined) {
|
|
125
123
|
throw (0, framework_errors_internal_1.createInternalFrameworkException)(framework_errors_internal_1.ZLinkFrameworkInternalErrorKind.ActorRouteNotFound, `Actor '${actor.context.actorId}' canonical remote Join identity is not configured.`);
|
|
@@ -214,6 +212,7 @@ class ZLinkLocalNativeActorJoin {
|
|
|
214
212
|
target,
|
|
215
213
|
relocationId,
|
|
216
214
|
completionOperationId,
|
|
215
|
+
deadlineAtMs,
|
|
217
216
|
...(control.canonicalHandoffId === undefined || canonicalAdmission === undefined
|
|
218
217
|
? {}
|
|
219
218
|
: {
|
|
@@ -227,11 +226,9 @@ class ZLinkLocalNativeActorJoin {
|
|
|
227
226
|
},
|
|
228
227
|
requestContentType: canonicalAdmission.request.contentType,
|
|
229
228
|
request: Buffer.from(canonicalAdmission.request.payload),
|
|
230
|
-
...(completionOperationId === undefined
|
|
229
|
+
...(completionOperationId === undefined || control.replyContentType === undefined
|
|
231
230
|
? {}
|
|
232
|
-
: {
|
|
233
|
-
replyContentType: control.replyContentType ?? stream_wire_1.ZlinkStreamContentType.Raw
|
|
234
|
-
}),
|
|
231
|
+
: { replyContentType: control.replyContentType }),
|
|
235
232
|
reply: completionOperationId === undefined
|
|
236
233
|
? Buffer.alloc(0)
|
|
237
234
|
: Buffer.from(admission.parts[0]?.data() ?? []),
|
|
@@ -239,7 +236,7 @@ class ZLinkLocalNativeActorJoin {
|
|
|
239
236
|
expectedOwnerLeaseGeneration: actorAuthorityFence.ownerLeaseGeneration,
|
|
240
237
|
targetNodeGeneration: target.targetNodeGeneration,
|
|
241
238
|
targetSpotGeneration: control.location.spotGeneration,
|
|
242
|
-
targetAuthorityOwnerGeneration: actorAuthorityFence.authorityOwnerGeneration
|
|
239
|
+
targetAuthorityOwnerGeneration: actorAuthorityFence.authorityOwnerGeneration,
|
|
243
240
|
targetSpotAuthorityOwnerGeneration: target.authorityOwnerGeneration ?? 1n
|
|
244
241
|
}
|
|
245
242
|
}),
|
|
@@ -251,6 +248,10 @@ class ZLinkLocalNativeActorJoin {
|
|
|
251
248
|
admission.parts[0]?.close();
|
|
252
249
|
throw error;
|
|
253
250
|
}
|
|
251
|
+
if (relocated.sourceCleanup !== undefined) {
|
|
252
|
+
admission.parts[0]?.close();
|
|
253
|
+
return { accepted: false, sourceCleanup: relocated.sourceCleanup };
|
|
254
|
+
}
|
|
254
255
|
state.setNativeActorRef(relocated.actorRef);
|
|
255
256
|
if (entrySpot) {
|
|
256
257
|
state.clearJoinedSpot();
|
|
@@ -14,8 +14,34 @@ class ZLinkActorSerialExecutor {
|
|
|
14
14
|
this.scheduler = new serial_execution_queue_1.ZLinkSerialExecutionQueue((record) => this.runRecord(record), options, sharedOwner);
|
|
15
15
|
}
|
|
16
16
|
execute(operation, workOptions) {
|
|
17
|
+
const initial = (0, application_job_queue_scope_1.currentApplicationJobPermit)();
|
|
18
|
+
if (initial !== undefined &&
|
|
19
|
+
workOptions?.lane !== 'lifecycle' &&
|
|
20
|
+
this.scheduler.hasPendingDurableApplication) {
|
|
21
|
+
let prepared;
|
|
22
|
+
const cancel = () => {
|
|
23
|
+
prepared?.releaseAfterInternalProcessing();
|
|
24
|
+
prepared = undefined;
|
|
25
|
+
};
|
|
26
|
+
const terminal = this.scheduler.admitDurablePrefix(() => (0, application_job_queue_scope_1.runWithApplicationJobPermit)(prepared, () => (0, actor_execution_context_1.runZLinkActorExecution)(this.actorId, this.sourceSpotId, operation)), workOptions, undefined, {
|
|
27
|
+
prepare: async (signal) => {
|
|
28
|
+
if (initial.reacquire === undefined) {
|
|
29
|
+
throw new Error('Durable Actor ingress requires its host permit source.');
|
|
30
|
+
}
|
|
31
|
+
prepared = await initial.reacquire(signal);
|
|
32
|
+
if (signal.aborted) {
|
|
33
|
+
cancel();
|
|
34
|
+
throw signal.reason;
|
|
35
|
+
}
|
|
36
|
+
prepared.markApplicationQueued();
|
|
37
|
+
},
|
|
38
|
+
cancel
|
|
39
|
+
});
|
|
40
|
+
initial.releaseAfterInternalProcessing();
|
|
41
|
+
return terminal;
|
|
42
|
+
}
|
|
17
43
|
const boundOperation = (0, application_job_queue_scope_1.bindApplicationJobPermit)(() => (0, actor_execution_context_1.runZLinkActorExecution)(this.actorId, this.sourceSpotId, operation));
|
|
18
|
-
return
|
|
44
|
+
return initial !== undefined
|
|
19
45
|
? this.scheduler.submitPreAdmitted(boundOperation, workOptions)
|
|
20
46
|
: this.scheduler.submit(boundOperation, workOptions);
|
|
21
47
|
}
|
|
@@ -78,7 +78,9 @@ class ZLinkActorNativeJoinCoordinator {
|
|
|
78
78
|
return this.withDeferredJoinFinalizer(actor, state, target, result, completionOperationId);
|
|
79
79
|
}
|
|
80
80
|
withDeferredJoinFinalizer(actor, state, target, result, operationId) {
|
|
81
|
-
if (
|
|
81
|
+
if (result.sourceCleanup !== undefined ||
|
|
82
|
+
operationId === undefined ||
|
|
83
|
+
this.options.sourceTransfer === undefined)
|
|
82
84
|
return result;
|
|
83
85
|
return {
|
|
84
86
|
...result,
|
|
@@ -13,7 +13,22 @@ exports.REMOTE_ACTOR_JOIN_PACKET = exports.ZLINK_REMOTE_ACTOR_JOIN_PACKET;
|
|
|
13
13
|
exports.REMOTE_ACTOR_JOIN_ADMISSION = 'admission';
|
|
14
14
|
exports.REMOTE_ACTOR_JOIN_COMMIT = 'commit';
|
|
15
15
|
exports.REMOTE_ACTOR_JOIN_ABORT = 'abort';
|
|
16
|
+
const JSON_OBJECT_START = '{'.charCodeAt(0);
|
|
17
|
+
const JSON_SPACE = ' '.charCodeAt(0);
|
|
18
|
+
const JSON_TAB = '\t'.charCodeAt(0);
|
|
19
|
+
const JSON_LINE_FEED = '\n'.charCodeAt(0);
|
|
20
|
+
const JSON_CARRIAGE_RETURN = '\r'.charCodeAt(0);
|
|
16
21
|
function decodeRemoteActorSourceLeaveTerminal(payload) {
|
|
22
|
+
// A SourceLeave terminal is a JSON object. Binary channel frames and JSON
|
|
23
|
+
// primitives cannot be terminals, so do not materialize or parse them.
|
|
24
|
+
let offset = 0;
|
|
25
|
+
while (payload[offset] === JSON_SPACE ||
|
|
26
|
+
payload[offset] === JSON_TAB ||
|
|
27
|
+
payload[offset] === JSON_LINE_FEED ||
|
|
28
|
+
payload[offset] === JSON_CARRIAGE_RETURN)
|
|
29
|
+
offset++;
|
|
30
|
+
if (payload[offset] !== JSON_OBJECT_START)
|
|
31
|
+
return undefined;
|
|
17
32
|
let decoded;
|
|
18
33
|
try {
|
|
19
34
|
decoded = JSON.parse(payload.toString());
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { encodeFrameworkPayload } from '../messaging/payload-codec';
|
|
2
|
+
import { ZLinkStreamMessageKind } from '../streams/protocol';
|
|
3
|
+
/** Ordinary dispatch and relocation use the same typed Actor reply envelope. */
|
|
4
|
+
export declare function encodeActorReply(requestHeaderBytes: Uint8Array, kind: ZLinkStreamMessageKind.Response | ZLinkStreamMessageKind.Error, payload: unknown, serializers: Parameters<typeof encodeFrameworkPayload>[1], flowEnabled: boolean): readonly Buffer[];
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.encodeActorReply = encodeActorReply;
|
|
4
|
+
const payload_codec_1 = require("../messaging/payload-codec");
|
|
5
|
+
const protocol_1 = require("../streams/protocol");
|
|
6
|
+
/** Ordinary dispatch and relocation use the same typed Actor reply envelope. */
|
|
7
|
+
function encodeActorReply(requestHeaderBytes, kind, payload, serializers, flowEnabled) {
|
|
8
|
+
const requestHeader = (0, protocol_1.decodeStreamHeader)(requestHeaderBytes, flowEnabled);
|
|
9
|
+
const encoded = kind === protocol_1.ZLinkStreamMessageKind.Response
|
|
10
|
+
? (0, payload_codec_1.encodeFrameworkPayload)(payload, serializers, requestHeader.name, 'reply')
|
|
11
|
+
: (0, payload_codec_1.encodeFrameworkPayload)(payload);
|
|
12
|
+
try {
|
|
13
|
+
const frame = (0, protocol_1.encodeStreamFrame)({
|
|
14
|
+
kind,
|
|
15
|
+
codec: (0, protocol_1.streamCodecForContentType)(encoded.contentType),
|
|
16
|
+
flags: protocol_1.ZLinkStreamHeaderFlags.None,
|
|
17
|
+
requestSeq: requestHeader.requestSeq,
|
|
18
|
+
name: '',
|
|
19
|
+
metadata: new Map(),
|
|
20
|
+
correlationId: requestHeader.correlationId,
|
|
21
|
+
flowId: requestHeader.flowId,
|
|
22
|
+
flowOrigin: requestHeader.flowOrigin
|
|
23
|
+
}, encoded.message.data());
|
|
24
|
+
return [Buffer.from(frame.buffer, frame.byteOffset, frame.byteLength)];
|
|
25
|
+
}
|
|
26
|
+
finally {
|
|
27
|
+
encoded.message.close();
|
|
28
|
+
}
|
|
29
|
+
}
|
|
@@ -6,27 +6,31 @@ export interface ZLinkActorRoutedJoinTransport {
|
|
|
6
6
|
canRouteChannel?(routerChannelId: string): boolean;
|
|
7
7
|
canRoutePacketChannel?(routerChannelId: string): boolean;
|
|
8
8
|
request<TReply>(routerChannelId: string, targetNodeRid: string, packetName: string | undefined, request: unknown, timeoutMs: number | undefined, signal?: AbortSignal): Promise<TReply>;
|
|
9
|
-
submit?(routerChannelId: string, targetNodeRid: string, packetName: string | undefined, message: unknown): Promise<ZLinkSubmitResult>;
|
|
10
|
-
submitInfrastructure?(routerChannelId: string, targetNodeRid: string, packetName: string | undefined, message: unknown): Promise<ZLinkSubmitResult>;
|
|
9
|
+
submit?(routerChannelId: string, targetNodeRid: string, packetName: string | undefined, message: unknown): ZLinkSubmitResult | Promise<ZLinkSubmitResult>;
|
|
10
|
+
submitInfrastructure?(routerChannelId: string, targetNodeRid: string, packetName: string | undefined, message: unknown): ZLinkSubmitResult | Promise<ZLinkSubmitResult>;
|
|
11
11
|
sendToSpot(spotRouteTarget: ZLinkSpotRouteTarget, message: unknown, options: {
|
|
12
12
|
readonly packetName?: string;
|
|
13
13
|
}): Promise<ZLinkSubmitResult>;
|
|
14
14
|
requestRawToSpot?(spotRouteTarget: ZLinkSpotRouteTarget, request: Message, options: {
|
|
15
15
|
readonly timeoutMs?: number;
|
|
16
16
|
readonly signal?: AbortSignal;
|
|
17
|
+
readonly onAdmitted?: () => void;
|
|
17
18
|
}): Promise<readonly Message[]>;
|
|
18
19
|
requestToSpot<TReply = unknown>(spotRouteTarget: ZLinkSpotRouteTarget, request: unknown, options: {
|
|
19
20
|
readonly packetName?: string;
|
|
20
21
|
readonly timeoutMs?: number;
|
|
21
22
|
readonly signal?: AbortSignal;
|
|
23
|
+
readonly onAdmitted?: () => void;
|
|
22
24
|
}): Promise<TReply>;
|
|
23
25
|
requestFromSpotToSpot?<TReply = unknown>(sourceSpot: ZLinkBackendSpot, spotRouteTarget: ZLinkSpotRouteTarget, request: unknown, options: {
|
|
24
26
|
readonly packetName?: string;
|
|
25
27
|
readonly timeoutMs?: number;
|
|
26
28
|
readonly signal?: AbortSignal;
|
|
29
|
+
readonly onAdmitted?: () => void;
|
|
27
30
|
}): Promise<TReply>;
|
|
28
31
|
requestRawFromSpotToSpot?(sourceSpot: ZLinkBackendSpot, spotRouteTarget: ZLinkSpotRouteTarget, request: Message, options: {
|
|
29
32
|
readonly timeoutMs?: number;
|
|
30
33
|
readonly signal?: AbortSignal;
|
|
34
|
+
readonly onAdmitted?: () => void;
|
|
31
35
|
}): Promise<readonly Message[]>;
|
|
32
36
|
}
|
|
@@ -4,8 +4,10 @@ import type { ZLinkActorRoutedJoinTransport } from './actor-routed-join-transpor
|
|
|
4
4
|
export declare function tryRequestRoutedJson(transport: ZLinkActorRoutedJoinTransport, target: ZLinkSpotRouteTarget, payload: unknown, options: {
|
|
5
5
|
readonly timeoutMs?: number;
|
|
6
6
|
readonly signal?: AbortSignal;
|
|
7
|
+
readonly onAdmitted?: () => void;
|
|
7
8
|
}): Promise<boolean>;
|
|
8
9
|
export declare function requestRoutedJsonReply<T>(transport: ZLinkActorRoutedJoinTransport, target: ZLinkSpotRouteTarget, payload: unknown, options: {
|
|
9
10
|
readonly timeoutMs?: number;
|
|
10
11
|
readonly signal?: AbortSignal;
|
|
12
|
+
readonly onAdmitted?: () => void;
|
|
11
13
|
}, unavailableMessage: string, decode: (replyParts: readonly Message[]) => T): Promise<T>;
|
|
@@ -8,6 +8,8 @@ import type { ZLinkActorTransferRegistry } from './actor-transfer-registry';
|
|
|
8
8
|
import type { ZLinkRuntimeAdmissionGate } from '../admission';
|
|
9
9
|
import type { ZLinkActivationAdmission } from '../activation-admission';
|
|
10
10
|
export interface ZLinkActorJoinRuntimeResult<TReply> {
|
|
11
|
+
/** Relay-ready transferred completion; this continuation only releases source work. */
|
|
12
|
+
readonly sourceCleanup?: () => Promise<void>;
|
|
11
13
|
readonly accepted: boolean;
|
|
12
14
|
readonly actor?: import('../../contracts').ActorRef;
|
|
13
15
|
readonly reply?: TReply;
|
|
@@ -30,14 +30,8 @@ function sameRemoteSessionOwnerLifecycle(left, right) {
|
|
|
30
30
|
right.sessionNodeRid !== undefined &&
|
|
31
31
|
left.sessionOwnerNodeGeneration !== undefined &&
|
|
32
32
|
right.sessionOwnerNodeGeneration !== undefined &&
|
|
33
|
-
left.sessionOwnerId !== undefined &&
|
|
34
|
-
right.sessionOwnerId !== undefined &&
|
|
35
|
-
left.sessionOwnerLeaseGeneration !== undefined &&
|
|
36
|
-
right.sessionOwnerLeaseGeneration !== undefined &&
|
|
37
33
|
(0, routing_id_1.routingIdsEqual)(left.sessionNodeRid, right.sessionNodeRid) &&
|
|
38
|
-
left.sessionOwnerNodeGeneration === right.sessionOwnerNodeGeneration
|
|
39
|
-
left.sessionOwnerId === right.sessionOwnerId &&
|
|
40
|
-
left.sessionOwnerLeaseGeneration === right.sessionOwnerLeaseGeneration);
|
|
34
|
+
left.sessionOwnerNodeGeneration === right.sessionOwnerNodeGeneration);
|
|
41
35
|
}
|
|
42
36
|
function sameRemoteSessionOwner(left, right) {
|
|
43
37
|
return (left.sessionRid !== undefined &&
|
|
@@ -296,19 +290,7 @@ class ZLinkActorRuntimeState {
|
|
|
296
290
|
target.bindingGeneration === undefined) {
|
|
297
291
|
throw new TypeError('An installed bound Session target requires its binding identity.');
|
|
298
292
|
}
|
|
299
|
-
|
|
300
|
-
if (current !== undefined && sameRemoteSessionOwnerLifecycle(current, target)) {
|
|
301
|
-
// A duplicate or late older command for the exact physical Session
|
|
302
|
-
// leaves the current binding; a newer generation of the same Session
|
|
303
|
-
// replaces it. A different Session in the same owner lifecycle must
|
|
304
|
-
// advance that lifecycle's generation; a late equal/lower one is stale.
|
|
305
|
-
const advances = current.bindingGeneration === undefined ||
|
|
306
|
-
target.bindingGeneration > current.bindingGeneration;
|
|
307
|
-
if (!advances)
|
|
308
|
-
return sameRemoteSessionOwner(current, target);
|
|
309
|
-
}
|
|
310
|
-
// Binding generations are scoped to a Session-owner lifecycle. A restarted
|
|
311
|
-
// owner can legitimately reset its counter below the predecessor value.
|
|
293
|
+
// The service registry accepted this identity in the Actor owner turn.
|
|
312
294
|
this.boundSessionValue = boundSessionIdentity(target);
|
|
313
295
|
return true;
|
|
314
296
|
}
|
|
@@ -1,27 +1,11 @@
|
|
|
1
|
-
import type { ActorRef, ZLinkActor
|
|
1
|
+
import type { ActorRef, ZLinkActor } from '../../contracts';
|
|
2
2
|
import type { ZLinkSpotRouteTarget } from '../spots/spot-routing-internal';
|
|
3
3
|
import type { ZLinkActorRuntimeState } from './actor-runtime-state';
|
|
4
|
-
import type { ZLinkActorHandoffPacket, ZLinkActorHandoffResult } from './actor-handoff';
|
|
5
|
-
import type { ServiceWireOperationId } from '../foundation/service-stateful-wire-codec';
|
|
6
|
-
export interface ZLinkPreparedActorSource {
|
|
7
|
-
readonly adapterKey?: string;
|
|
8
|
-
readonly state: ZLinkMessage;
|
|
9
|
-
readonly handoffBacklog: readonly ZLinkActorHandoffPacket[];
|
|
10
|
-
readonly sourceLeaveCompletion?: Promise<void>;
|
|
11
|
-
readonly sourceLeaveSubmitted?: Promise<void>;
|
|
12
|
-
onSourceLeaveSubmitted(notify: () => Promise<void>): void;
|
|
13
|
-
observeTargetAuthority(target: ZLinkSpotRouteTarget, targetActorRef: ActorRef, signal?: AbortSignal): Promise<void>;
|
|
14
|
-
commit(target: ZLinkSpotRouteTarget, targetActorRef: ActorRef, results: readonly ZLinkActorHandoffResult[], releaseLocation?: boolean): void;
|
|
15
|
-
rollback(): Promise<void>;
|
|
16
|
-
}
|
|
17
4
|
export interface ZLinkActorSourceTransfer {
|
|
18
5
|
/** Starts the ingress handoff before target route lookup. */
|
|
19
6
|
beginDeferredActorHandoff?(actor: ZLinkActor, state: ZLinkActorRuntimeState): void;
|
|
20
|
-
/** Changes a provisional ingress fence into a relocation handoff. */
|
|
21
|
-
promoteDeferredActorHandoff?(actor: ZLinkActor, state: ZLinkActorRuntimeState): void;
|
|
22
7
|
/** Finishes a same-node deferred Join handoff after completion callback. */
|
|
23
8
|
completeDeferredActorHandoff?(actor: ZLinkActor, target: ZLinkSpotRouteTarget, targetActorRef: ActorRef): Promise<void>;
|
|
24
9
|
/** Releases an early handoff when Join cannot commit. */
|
|
25
10
|
cancelDeferredActorHandoff?(actor: ZLinkActor, state: ZLinkActorRuntimeState): Promise<void>;
|
|
26
|
-
prepareSource(actor: ZLinkActor, state: ZLinkActorRuntimeState, signal?: AbortSignal, lifecycleAuthority?: 'framework' | 'core', deferredJoin?: boolean, relocation?: ServiceWireOperationId): Promise<ZLinkPreparedActorSource>;
|
|
27
11
|
}
|
|
@@ -2,7 +2,7 @@ import { type ActorRef, type RoutingId, type SpotRef, type ZLinkActor, type ZLin
|
|
|
2
2
|
import type { ZLinkBackendActorRef, ZLinkBackendSpotNode } from '../backend/contracts';
|
|
3
3
|
import type { ZLinkActorManagerOptions } from './actor-runtime-contracts';
|
|
4
4
|
import { ZLinkActorRuntimeState } from './actor-runtime-state';
|
|
5
|
-
export { DefaultZLinkActorClient,
|
|
5
|
+
export { DefaultZLinkActorClient, type ZLinkActorClientOptions } from './actor-client';
|
|
6
6
|
export { DefaultZLinkActorContext, ZLINK_ACTOR_JOIN_ENTRY_SPOT_RUNTIME } from './actor-context';
|
|
7
7
|
export { ZLinkActorSerialExecutor } from './actor-mailbox';
|
|
8
8
|
export { DEFAULT_MESSAGE_FOLLOW_DURATION_MS, ZLinkActorHandoffCoordinator, decodeHandoffPacket, type ZLinkActorHandoffPacket, type ZLinkActorHandoffDispatch, type ZLinkActorHandoffPrefixAdmission, type ZLinkActorHandoffPrefixQueue, type ZLinkActorHandoffPrefixRecord, type ZLinkActorHandoffPreparedReplayAdmission, type ZLinkActorHandoffReplayAdmission, type ZLinkActorHandoffReplayPreparation, type ZLinkActorHandoffResult } from './actor-handoff';
|
|
@@ -51,9 +51,14 @@ export declare class DefaultZLinkActorManager implements ZLinkActorManager {
|
|
|
51
51
|
publishRelocationActor(actorId: string): void;
|
|
52
52
|
abortRelocationActor(actorId: string): Promise<void>;
|
|
53
53
|
completeRelocationSource(actorId: string, sourceActorRef?: ZLinkBackendActorRef): Promise<void>;
|
|
54
|
-
|
|
55
|
-
|
|
54
|
+
/** Commit removes current ownership; a Join profile may still own its leave callback. */
|
|
55
|
+
detachRelocationSource(state: ZLinkActorRuntimeState): void;
|
|
56
|
+
releaseSpotActorMembers(meshName: string, spotId?: RoutingId): Promise<void>;
|
|
57
|
+
private releaseLocalActor;
|
|
58
|
+
completeCoreRelocationSource(actorId: string, state?: ZLinkActorRuntimeState | undefined): Promise<void>;
|
|
59
|
+
private discardNativeRelocationSource;
|
|
56
60
|
private finalizeActorState;
|
|
61
|
+
private detachActorStateRegistration;
|
|
57
62
|
private finalizeDestroyedActor;
|
|
58
63
|
private terminateActor;
|
|
59
64
|
private awaitActorDestroy;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.DefaultZLinkActorManager = exports.ZLINK_ACTOR_LIFECYCLE_SNAPSHOT = exports.createActorMembership = exports.createActorJoinRequest = exports.actorJoinIdentity = exports.ZLinkRemoteBoundSessionFenceError = exports.isRemoteBoundSessionFenceError = exports.encodeRemoteBoundSessionNack = exports.ZLINK_REMOTE_BOUND_SESSION_SEND_PACKET = exports.ZLINK_REMOTE_BOUND_SESSION_RESPONSE_PACKET = exports.ZLINK_REMOTE_BOUND_SESSION_FENCE_NACK_CODE = exports.ZLINK_REMOTE_BOUND_SESSION_ERROR_PACKET = exports.ZLINK_REMOTE_ACTOR_SESSION_DISCONNECTED_PACKET = exports.ZLINK_REMOTE_ACTOR_PACKET_RELAY_PACKET = exports.decodeRemoteActorSourceLeaveTerminal = exports.ZLINK_REMOTE_ACTOR_SOURCE_LEAVE_TERMINAL = exports.ZLINK_REMOTE_ACTOR_JOIN_PACKET = exports.ZLinkActorTransferRegistry = exports.ZLinkActorNativeJoinCoordinator = exports.ZLinkSpotActorHandlerRegistryRuntime = exports.ZLinkSpotActorDispatcher = exports.ZLinkActorPacketKind = exports.publishInitialActorAuthority = exports.rewriteActorAuthorityOwner = exports.rewriteActorAuthorityRoute = exports.isActorAuthorityPayload = exports.encodeActorAuthorityIdentity = exports.decodeRelocatingActorAuthorityIdentity = exports.decodeActorAuthorityIdentity = exports.createDeferredJoinCompletion = exports.toFrameworkRoutingId = exports.toFrameworkActorRef = exports.ZLinkActorRuntimeState = exports.decodeActorMessageFollowContext = exports.attachActorMessageFollowContext = exports.actorMessageFollowContext = exports.decodeHandoffPacket = exports.ZLinkActorHandoffCoordinator = exports.DEFAULT_MESSAGE_FOLLOW_DURATION_MS = exports.ZLinkActorSerialExecutor = exports.ZLINK_ACTOR_JOIN_ENTRY_SPOT_RUNTIME = exports.DefaultZLinkActorContext = exports.
|
|
3
|
+
exports.DefaultZLinkActorManager = exports.ZLINK_ACTOR_LIFECYCLE_SNAPSHOT = exports.createActorMembership = exports.createActorJoinRequest = exports.actorJoinIdentity = exports.ZLinkRemoteBoundSessionFenceError = exports.isRemoteBoundSessionFenceError = exports.encodeRemoteBoundSessionNack = exports.ZLINK_REMOTE_BOUND_SESSION_SEND_PACKET = exports.ZLINK_REMOTE_BOUND_SESSION_RESPONSE_PACKET = exports.ZLINK_REMOTE_BOUND_SESSION_FENCE_NACK_CODE = exports.ZLINK_REMOTE_BOUND_SESSION_ERROR_PACKET = exports.ZLINK_REMOTE_ACTOR_SESSION_DISCONNECTED_PACKET = exports.ZLINK_REMOTE_ACTOR_PACKET_RELAY_PACKET = exports.decodeRemoteActorSourceLeaveTerminal = exports.ZLINK_REMOTE_ACTOR_SOURCE_LEAVE_TERMINAL = exports.ZLINK_REMOTE_ACTOR_JOIN_PACKET = exports.ZLinkActorTransferRegistry = exports.ZLinkActorNativeJoinCoordinator = exports.ZLinkSpotActorHandlerRegistryRuntime = exports.ZLinkSpotActorDispatcher = exports.ZLinkActorPacketKind = exports.publishInitialActorAuthority = exports.rewriteActorAuthorityOwner = exports.rewriteActorAuthorityRoute = exports.isActorAuthorityPayload = exports.encodeActorAuthorityIdentity = exports.decodeRelocatingActorAuthorityIdentity = exports.decodeActorAuthorityIdentity = exports.createDeferredJoinCompletion = exports.toFrameworkRoutingId = exports.toFrameworkActorRef = exports.ZLinkActorRuntimeState = exports.decodeActorMessageFollowContext = exports.attachActorMessageFollowContext = exports.actorMessageFollowContext = exports.decodeHandoffPacket = exports.ZLinkActorHandoffCoordinator = exports.DEFAULT_MESSAGE_FOLLOW_DURATION_MS = exports.ZLinkActorSerialExecutor = exports.ZLINK_ACTOR_JOIN_ENTRY_SPOT_RUNTIME = exports.DefaultZLinkActorContext = exports.DefaultZLinkActorClient = void 0;
|
|
4
4
|
const contracts_1 = require("../../contracts");
|
|
5
5
|
const Registration_1 = require("../../contracts/Configuration/Registration");
|
|
6
6
|
const abort_1 = require("../abort");
|
|
@@ -20,7 +20,6 @@ const ACTOR_CREATION_RETRY_INTERVAL_MS = 5;
|
|
|
20
20
|
const LOCAL_DIAGNOSTIC_NODE_RID = 'local';
|
|
21
21
|
var actor_client_1 = require("./actor-client");
|
|
22
22
|
Object.defineProperty(exports, "DefaultZLinkActorClient", { enumerable: true, get: function () { return actor_client_1.DefaultZLinkActorClient; } });
|
|
23
|
-
Object.defineProperty(exports, "forwardEncodedActorPacket", { enumerable: true, get: function () { return actor_client_1.forwardEncodedActorPacket; } });
|
|
24
23
|
var actor_context_1 = require("./actor-context");
|
|
25
24
|
Object.defineProperty(exports, "DefaultZLinkActorContext", { enumerable: true, get: function () { return actor_context_1.DefaultZLinkActorContext; } });
|
|
26
25
|
Object.defineProperty(exports, "ZLINK_ACTOR_JOIN_ENTRY_SPOT_RUNTIME", { enumerable: true, get: function () { return actor_context_1.ZLINK_ACTOR_JOIN_ENTRY_SPOT_RUNTIME; } });
|
|
@@ -118,7 +117,7 @@ class DefaultZLinkActorManager {
|
|
|
118
117
|
const actorRef = this.actorRefForState(state);
|
|
119
118
|
return {
|
|
120
119
|
spotId: spotId,
|
|
121
|
-
objectGeneration: state.
|
|
120
|
+
objectGeneration: state.spotGeneration ?? 0n,
|
|
122
121
|
meshName: this.actorMeshNames.get(actorId) ?? '',
|
|
123
122
|
nodeRid: actorRef.nodeRid
|
|
124
123
|
};
|
|
@@ -262,6 +261,10 @@ class DefaultZLinkActorManager {
|
|
|
262
261
|
}
|
|
263
262
|
async findActor(actorId, signal) {
|
|
264
263
|
(0, abort_1.throwIfAborted)(signal);
|
|
264
|
+
return this.resolveLocalActor(actorId);
|
|
265
|
+
}
|
|
266
|
+
/** @internal Uses the relocation owner's publication boundary for local dispatch. */
|
|
267
|
+
resolveLocalActor(actorId) {
|
|
265
268
|
if (this.relocationStaged.has(actorId))
|
|
266
269
|
return undefined;
|
|
267
270
|
return this.states.get(actorId)?.actor;
|
|
@@ -302,7 +305,7 @@ class DefaultZLinkActorManager {
|
|
|
302
305
|
}
|
|
303
306
|
state.setLocationGeneration(authorityOwnerGeneration);
|
|
304
307
|
if (spotId !== undefined)
|
|
305
|
-
state.setJoinedSpot(spotId, undefined, membershipEpoch);
|
|
308
|
+
state.setJoinedSpot(spotId, undefined, membershipEpoch, spotGeneration);
|
|
306
309
|
return actor;
|
|
307
310
|
}
|
|
308
311
|
catch (error) {
|
|
@@ -310,7 +313,7 @@ class DefaultZLinkActorManager {
|
|
|
310
313
|
node.discardRelocatedActor?.(nativeRef);
|
|
311
314
|
this.relocationStaged.delete(actorId);
|
|
312
315
|
const failedState = this.states.get(actorId);
|
|
313
|
-
await this.finalizeActorState(
|
|
316
|
+
await this.finalizeActorState(failedState);
|
|
314
317
|
throw error;
|
|
315
318
|
}
|
|
316
319
|
}
|
|
@@ -321,26 +324,42 @@ class DefaultZLinkActorManager {
|
|
|
321
324
|
this.relocationStaged.delete(actorId);
|
|
322
325
|
}
|
|
323
326
|
async abortRelocationActor(actorId) {
|
|
324
|
-
await this.
|
|
327
|
+
await this.releaseLocalActor(actorId);
|
|
325
328
|
}
|
|
326
329
|
async completeRelocationSource(actorId, sourceActorRef) {
|
|
327
|
-
await this.
|
|
328
|
-
}
|
|
329
|
-
|
|
330
|
+
await this.releaseLocalActor(actorId, sourceActorRef);
|
|
331
|
+
}
|
|
332
|
+
/** Commit removes current ownership; a Join profile may still own its leave callback. */
|
|
333
|
+
detachRelocationSource(state) {
|
|
334
|
+
if (this.detachActorStateRegistration(state)) {
|
|
335
|
+
this.discardNativeRelocationSource(state.nativeActorRef);
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
async releaseSpotActorMembers(meshName, spotId) {
|
|
339
|
+
const results = await Promise.allSettled([...this.states.values()]
|
|
340
|
+
.filter((state) => state.meshName === meshName && state.spotId === spotId)
|
|
341
|
+
.map((state) => this.releaseLocalActor(state.actorId)));
|
|
342
|
+
const errors = results
|
|
343
|
+
.filter((result) => result.status === 'rejected')
|
|
344
|
+
.map((result) => result.reason);
|
|
345
|
+
if (errors.length === 1)
|
|
346
|
+
throw errors[0];
|
|
347
|
+
if (errors.length > 1)
|
|
348
|
+
throw new AggregateError(errors, 'Actor member cleanup failed.');
|
|
349
|
+
}
|
|
350
|
+
async releaseLocalActor(actorId, exactNativeActorRef) {
|
|
330
351
|
const state = this.states.get(actorId);
|
|
331
|
-
|
|
332
|
-
|
|
352
|
+
if (state === undefined)
|
|
353
|
+
return;
|
|
333
354
|
const failures = [];
|
|
334
355
|
try {
|
|
335
|
-
|
|
336
|
-
node?.discardRelocatedActor?.(nativeActorRef);
|
|
337
|
-
}
|
|
356
|
+
this.discardNativeRelocationSource(exactNativeActorRef ?? state.nativeActorRef);
|
|
338
357
|
}
|
|
339
358
|
catch (error) {
|
|
340
359
|
failures.push(error);
|
|
341
360
|
}
|
|
342
361
|
try {
|
|
343
|
-
await this.completeCoreRelocationSource(actorId);
|
|
362
|
+
await this.completeCoreRelocationSource(actorId, state);
|
|
344
363
|
}
|
|
345
364
|
catch (error) {
|
|
346
365
|
failures.push(error);
|
|
@@ -351,12 +370,17 @@ class DefaultZLinkActorManager {
|
|
|
351
370
|
: new AggregateError(failures, 'Actor relocation cleanup failed.');
|
|
352
371
|
}
|
|
353
372
|
}
|
|
354
|
-
async completeCoreRelocationSource(actorId) {
|
|
355
|
-
|
|
356
|
-
await this.finalizeActorState(actorId, state);
|
|
373
|
+
async completeCoreRelocationSource(actorId, state = this.states.get(actorId)) {
|
|
374
|
+
await this.finalizeActorState(state);
|
|
357
375
|
}
|
|
358
|
-
|
|
359
|
-
if (
|
|
376
|
+
discardNativeRelocationSource(nativeActorRef) {
|
|
377
|
+
if (nativeActorRef === undefined)
|
|
378
|
+
return;
|
|
379
|
+
const node = this.options.nativeActorNodeProvider?.() ?? this.options.nativeActorNode;
|
|
380
|
+
node?.discardRelocatedActor?.(nativeActorRef);
|
|
381
|
+
}
|
|
382
|
+
async finalizeActorState(state) {
|
|
383
|
+
if (state === undefined)
|
|
360
384
|
return;
|
|
361
385
|
try {
|
|
362
386
|
if (state.actor !== undefined)
|
|
@@ -364,13 +388,17 @@ class DefaultZLinkActorManager {
|
|
|
364
388
|
}
|
|
365
389
|
finally {
|
|
366
390
|
state.clearAfterDestroy();
|
|
367
|
-
|
|
368
|
-
this.states.delete(actorId);
|
|
369
|
-
this.actorMeshNames.delete(actorId);
|
|
370
|
-
this.relocationStaged.delete(actorId);
|
|
371
|
-
}
|
|
391
|
+
this.detachActorStateRegistration(state);
|
|
372
392
|
}
|
|
373
393
|
}
|
|
394
|
+
detachActorStateRegistration(state) {
|
|
395
|
+
if (this.states.get(state.actorId) !== state)
|
|
396
|
+
return false;
|
|
397
|
+
this.states.delete(state.actorId);
|
|
398
|
+
this.actorMeshNames.delete(state.actorId);
|
|
399
|
+
this.relocationStaged.delete(state.actorId);
|
|
400
|
+
return true;
|
|
401
|
+
}
|
|
374
402
|
async finalizeDestroyedActor(actorId, state) {
|
|
375
403
|
if (this.states.get(actorId) !== state)
|
|
376
404
|
return;
|
|
@@ -378,7 +406,7 @@ class DefaultZLinkActorManager {
|
|
|
378
406
|
this.options.actorDestroyedCleanup?.(actorId);
|
|
379
407
|
}
|
|
380
408
|
finally {
|
|
381
|
-
await this.finalizeActorState(
|
|
409
|
+
await this.finalizeActorState(state);
|
|
382
410
|
this.options.metrics?.change(runtime_metrics_1.METRIC_NAMES.ActorCount, -1);
|
|
383
411
|
}
|
|
384
412
|
}
|
|
@@ -632,7 +660,7 @@ class ZLinkActorCreateCallRuntime {
|
|
|
632
660
|
yield(signal) {
|
|
633
661
|
const turn = (0, execution_1.requireZLinkYieldTurn)(this.turn);
|
|
634
662
|
const pending = this.executeOnce(signal);
|
|
635
|
-
return turn.
|
|
663
|
+
return turn.yieldFrameworkPromise(pending);
|
|
636
664
|
}
|
|
637
665
|
executeOnce(signal) {
|
|
638
666
|
this.requireMutable();
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { RoutingId } from '../../contracts';
|
|
2
|
+
export interface SessionDisconnectedIdentity {
|
|
3
|
+
readonly sessionOwnerNodeRid: RoutingId;
|
|
4
|
+
readonly sessionOwnerNodeGeneration: bigint;
|
|
5
|
+
readonly bindingGeneration: bigint;
|
|
6
|
+
}
|
|
7
|
+
export declare function encodeSessionDisconnected(sessionOwnerNodeRid: RoutingId | undefined, sessionOwnerNodeGeneration: bigint | undefined, bindingGeneration: bigint | undefined): Buffer;
|
|
8
|
+
export declare function decodeSessionDisconnected(bytes: Uint8Array): SessionDisconnectedIdentity | undefined;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.encodeSessionDisconnected = encodeSessionDisconnected;
|
|
4
|
+
exports.decodeSessionDisconnected = decodeSessionDisconnected;
|
|
5
|
+
const CoreTypes_1 = require("../../contracts/Common/CoreTypes");
|
|
6
|
+
const contracts_1 = require("../../contracts");
|
|
7
|
+
const routing_id_1 = require("../routing-id");
|
|
8
|
+
const RID_LENGTH_BYTES = 1;
|
|
9
|
+
const GENERATION_BYTES = 8;
|
|
10
|
+
const GENERATIONS_BYTES = GENERATION_BYTES * 2;
|
|
11
|
+
function encodeSessionDisconnected(sessionOwnerNodeRid, sessionOwnerNodeGeneration, bindingGeneration) {
|
|
12
|
+
if (sessionOwnerNodeRid === undefined ||
|
|
13
|
+
sessionOwnerNodeGeneration === undefined ||
|
|
14
|
+
sessionOwnerNodeGeneration === 0n ||
|
|
15
|
+
bindingGeneration === undefined ||
|
|
16
|
+
bindingGeneration === 0n) {
|
|
17
|
+
throw new contracts_1.ZLinkFrameworkException(contracts_1.ZLinkFrameworkErrorKind.ProtocolError, 'Session disconnect requires an exact binding identity.');
|
|
18
|
+
}
|
|
19
|
+
const rid = Buffer.from((0, routing_id_1.encodeRoutingIdStorageHex)(sessionOwnerNodeRid), 'hex');
|
|
20
|
+
if (rid.length === 0 || rid.length > CoreTypes_1.ZLINK_MAX_ROUTING_ID_BYTES) {
|
|
21
|
+
throw new contracts_1.ZLinkFrameworkException(contracts_1.ZLinkFrameworkErrorKind.ProtocolError, 'Invalid Session owner Node RID length.');
|
|
22
|
+
}
|
|
23
|
+
const payload = Buffer.allocUnsafe(RID_LENGTH_BYTES + rid.length + GENERATIONS_BYTES);
|
|
24
|
+
payload[0] = rid.length;
|
|
25
|
+
rid.copy(payload, RID_LENGTH_BYTES);
|
|
26
|
+
payload.writeBigUInt64BE(sessionOwnerNodeGeneration, RID_LENGTH_BYTES + rid.length);
|
|
27
|
+
payload.writeBigUInt64BE(bindingGeneration, RID_LENGTH_BYTES + rid.length + GENERATION_BYTES);
|
|
28
|
+
return payload;
|
|
29
|
+
}
|
|
30
|
+
function decodeSessionDisconnected(bytes) {
|
|
31
|
+
const payload = Buffer.from(bytes.buffer, bytes.byteOffset, bytes.byteLength);
|
|
32
|
+
if (payload.length < RID_LENGTH_BYTES + 1 + GENERATIONS_BYTES)
|
|
33
|
+
return undefined;
|
|
34
|
+
const ridLength = payload[0];
|
|
35
|
+
if (ridLength === 0 || payload.length !== RID_LENGTH_BYTES + ridLength + GENERATIONS_BYTES)
|
|
36
|
+
return undefined;
|
|
37
|
+
const offset = RID_LENGTH_BYTES + ridLength;
|
|
38
|
+
const sessionOwnerNodeGeneration = payload.readBigUInt64BE(offset);
|
|
39
|
+
const bindingGeneration = payload.readBigUInt64BE(offset + GENERATION_BYTES);
|
|
40
|
+
if (sessionOwnerNodeGeneration === 0n || bindingGeneration === 0n)
|
|
41
|
+
return undefined;
|
|
42
|
+
const hex = payload.subarray(RID_LENGTH_BYTES, offset).toString('hex');
|
|
43
|
+
return {
|
|
44
|
+
sessionOwnerNodeRid: (0, routing_id_1.decodeRoutingId)(hex, hex),
|
|
45
|
+
sessionOwnerNodeGeneration,
|
|
46
|
+
bindingGeneration
|
|
47
|
+
};
|
|
48
|
+
}
|
|
@@ -21,7 +21,7 @@ class ZLinkSpotActorHandlerRegistryRuntime {
|
|
|
21
21
|
const metadata = (0, Attributes_1.readZLinkDecoratorMetadata)(handlerType).find((entry) => entry.kind === 'spotActorSend' || entry.kind === 'spotActorRequest');
|
|
22
22
|
const resolvedPacketName = packetName ?? metadata?.packetName;
|
|
23
23
|
if (metadata === undefined || resolvedPacketName === undefined) {
|
|
24
|
-
throw
|
|
24
|
+
throw (0, framework_errors_internal_1.createInternalFrameworkException)(framework_errors_internal_1.ZLinkFrameworkInternalErrorKind.InvalidOperation, `Actor packet handler '${handlerType.name}' must declare a packet name.`);
|
|
25
25
|
}
|
|
26
26
|
return this.addPacket({
|
|
27
27
|
kind: metadata.kind === 'spotActorSend'
|
|
@@ -36,7 +36,7 @@ class ZLinkSpotActorHandlerRegistryRuntime {
|
|
|
36
36
|
addPacket(descriptor) {
|
|
37
37
|
const key = packetKey(descriptor.kind, descriptor.actorType, descriptor.packetName);
|
|
38
38
|
if (this.packets.has(key)) {
|
|
39
|
-
throw
|
|
39
|
+
throw (0, framework_errors_internal_1.createInternalFrameworkException)(framework_errors_internal_1.ZLinkFrameworkInternalErrorKind.InvalidOperation, `Actor packet '${descriptor.packetName}' for '${descriptor.actorType.name}' is already registered.`);
|
|
40
40
|
}
|
|
41
41
|
const metadata = (0, Attributes_1.readZLinkDecoratorMetadata)(descriptor.handlerType).find((entry) => entry.kind ===
|
|
42
42
|
(descriptor.kind === ZLinkActorPacketKind.Send ? 'spotActorSend' : 'spotActorRequest') &&
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { ZLinkFrameworkInternalErrorKind } from './framework-errors-internal';
|
|
2
|
+
/** Runs host admission inside the domain's request completion boundary. */
|
|
3
|
+
export type ZLinkMeshDispatchAdmission = (dispatch: () => void | Promise<void>, onRejected?: (error: unknown) => void | Promise<void>) => void | Promise<void>;
|
|
2
4
|
/** 소비한 배열 prefix가 정리 조건에 도달했는지 판정합니다. */
|
|
3
5
|
export declare function shouldCompactBackingArray(head: number, length: number): boolean;
|
|
4
6
|
export declare class ZLinkRuntimeAdmissionGate {
|
|
@@ -16,7 +18,13 @@ export declare class ZLinkRuntimeAdmissionGate {
|
|
|
16
18
|
seal(meshName: string, reason?: ZLinkFrameworkInternalErrorKind): void;
|
|
17
19
|
close(): void;
|
|
18
20
|
claim(meshName: string, operation: string): ZLinkApplicationWorkClaim;
|
|
19
|
-
|
|
21
|
+
/**
|
|
22
|
+
* Runs one admitted unit of work. Work that completes synchronously leaves
|
|
23
|
+
* admission in the same turn; asynchronous work leaves it from the single
|
|
24
|
+
* continuation on its result.
|
|
25
|
+
*/
|
|
26
|
+
run<T>(meshName: string, operation: string, work: () => T | Promise<T>, onRejected?: (error: unknown) => T | Promise<T>): T | Promise<T>;
|
|
27
|
+
private enter;
|
|
20
28
|
awaitZero(meshName: string, signal?: AbortSignal): Promise<void>;
|
|
21
29
|
requireRequest(operation: string, meshName?: string): void;
|
|
22
30
|
requireActorCreate(actorId: string, meshName?: string): void;
|