@zlink-systems/framework 0.30.3 → 0.32.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/.tsbuildinfo +1 -1
- package/dist/contracts/Actors/ZLinkActor.d.ts +2 -0
- package/dist/contracts/Actors/ZLinkSessionBindingIdentity.d.ts +6 -0
- package/dist/contracts/Actors/ZLinkSessionBindingIdentity.js +2 -0
- package/dist/contracts/Actors/index.d.ts +1 -0
- package/dist/contracts/Actors/index.js +1 -0
- package/dist/contracts/Common/CoreTypes.d.ts +1 -0
- package/dist/contracts/Common/HandlerMessageType.d.ts +8 -0
- package/dist/contracts/Common/HandlerMessageType.js +41 -0
- package/dist/contracts/Common/ZLinkEncodedPayload.d.ts +1 -1
- package/dist/contracts/Common/ZLinkEncodedPayload.js +12 -20
- package/dist/contracts/Common/ZLinkMessage.js +11 -7
- package/dist/contracts/Common/encoded-payload-storage.d.ts +0 -2
- package/dist/contracts/Common/encoded-payload-storage.js +4 -16
- package/dist/contracts/Common/index.d.ts +1 -1
- package/dist/contracts/Common/payload-slab.d.ts +4 -0
- package/dist/contracts/Common/payload-slab.js +30 -0
- package/dist/contracts/Configuration/RegistrationBuilders.js +15 -9
- package/dist/contracts/Configuration/RegistrationTypes.d.ts +19 -0
- package/dist/contracts/Handlers/Contexts.d.ts +1 -0
- package/dist/contracts/Locations/Authority.d.ts +2 -0
- package/dist/internal.d.ts +9 -0
- package/dist/internal.js +23 -1
- package/dist/nest-integration.d.ts +1 -0
- package/dist/nest-integration.js +3 -1
- package/dist/runtime/actors/actor-client.d.ts +6 -2
- package/dist/runtime/actors/actor-client.js +120 -82
- package/dist/runtime/actors/actor-context.js +16 -5
- package/dist/runtime/actors/actor-execution-context.js +2 -2
- package/dist/runtime/actors/actor-handoff.d.ts +12 -1
- package/dist/runtime/actors/actor-handoff.js +79 -34
- package/dist/runtime/actors/actor-join-deferred-scope.js +6 -6
- package/dist/runtime/actors/actor-local-native-join.d.ts +2 -2
- package/dist/runtime/actors/actor-local-native-join.js +19 -17
- package/dist/runtime/actors/actor-mailbox.d.ts +1 -1
- package/dist/runtime/actors/actor-remote-joiner.d.ts +2 -2
- package/dist/runtime/actors/actor-remote-joiner.js +4 -4
- package/dist/runtime/actors/actor-routed-join-transport.d.ts +9 -3
- package/dist/runtime/actors/actor-routed-json-request.d.ts +3 -0
- package/dist/runtime/actors/actor-runtime-contracts.d.ts +2 -2
- package/dist/runtime/actors/actor-runtime-state.d.ts +1 -1
- package/dist/runtime/actors/spot-actor-dispatch.d.ts +9 -5
- package/dist/runtime/actors/spot-actor-dispatch.js +60 -38
- package/dist/runtime/admission.d.ts +6 -4
- package/dist/runtime/admission.js +21 -10
- package/dist/runtime/application-jobs/application-ingress-record-owner.d.ts +1 -0
- package/dist/runtime/application-jobs/application-ingress-record-owner.js +3 -0
- package/dist/runtime/backend/contracts/index.d.ts +26 -10
- package/dist/runtime/backend/mesh-completion-table.d.ts +7 -1
- package/dist/runtime/backend/mesh-completion-table.js +84 -20
- package/dist/runtime/backend/mesh-dispatch-pump.d.ts +19 -6
- package/dist/runtime/backend/mesh-dispatch-pump.js +246 -147
- package/dist/runtime/backend/node/node-backend-adapter-support.d.ts +3 -2
- package/dist/runtime/backend/node/node-backend-adapter-support.js +27 -19
- package/dist/runtime/backend/node/node-dealer-channel-client-transport.d.ts +5 -2
- package/dist/runtime/backend/node/node-dealer-channel-client-transport.js +70 -13
- package/dist/runtime/backend/node/node-event-loop-poller.d.ts +2 -2
- package/dist/runtime/backend/node/node-event-loop-poller.js +4 -3
- package/dist/runtime/backend/node/node-mesh-backend-adapter.js +5 -1
- package/dist/runtime/backend/node/node-raw-binding-port.d.ts +7 -2
- package/dist/runtime/backend/node/node-raw-binding-port.js +99 -63
- package/dist/runtime/backend/node/node-raw-mesh-backend.d.ts +34 -16
- package/dist/runtime/backend/node/node-raw-mesh-backend.js +210 -106
- package/dist/runtime/backend/node/node-socket-backend-adapter.js +20 -6
- package/dist/runtime/backend/raw-binding-port.d.ts +6 -3
- package/dist/runtime/channels/channel-clients.js +3 -3
- package/dist/runtime/channels/channel-dispatch-pipeline.d.ts +11 -7
- package/dist/runtime/channels/channel-dispatch-pipeline.js +40 -22
- package/dist/runtime/channels/channel-dispatch-services.d.ts +3 -1
- package/dist/runtime/channels/channel-dispatch-services.js +7 -6
- package/dist/runtime/channels/channel-dispatchers.d.ts +13 -6
- package/dist/runtime/channels/channel-dispatchers.js +57 -36
- package/dist/runtime/channels/channel-envelope.d.ts +2 -2
- package/dist/runtime/channels/channel-envelope.js +609 -83
- package/dist/runtime/channels/channel-multipart.d.ts +1 -0
- package/dist/runtime/channels/channel-multipart.js +10 -6
- package/dist/runtime/channels/channel-outbound-operations.d.ts +6 -9
- package/dist/runtime/channels/channel-outbound-operations.js +107 -105
- package/dist/runtime/channels/channel-receive-loops.d.ts +9 -7
- package/dist/runtime/channels/channel-receive-loops.js +126 -90
- package/dist/runtime/channels/channel-runtime-lifecycle.d.ts +23 -6
- package/dist/runtime/channels/channel-runtime-lifecycle.js +47 -38
- package/dist/runtime/channels/channel-runtime-manager.d.ts +13 -6
- package/dist/runtime/channels/channel-runtime-manager.js +32 -14
- package/dist/runtime/channels/channel-socket-registry.d.ts +28 -4
- package/dist/runtime/channels/channel-socket-registry.js +9 -1
- package/dist/runtime/channels/channel-transports.d.ts +23 -16
- package/dist/runtime/channels/channel-transports.js +139 -119
- package/dist/runtime/channels/dispatch-error-reporter.d.ts +4 -4
- package/dist/runtime/channels/dispatch-error-reporter.js +5 -5
- package/dist/runtime/channels/fanout-location-runtime.d.ts +1 -1
- package/dist/runtime/channels/local-spot-route-transport.d.ts +5 -2
- package/dist/runtime/channels/local-spot-route-transport.js +15 -18
- package/dist/runtime/channels/router-socket-spot-route-transport.d.ts +6 -3
- package/dist/runtime/channels/router-socket-spot-route-transport.js +33 -19
- package/dist/runtime/channels/source-spot-router.d.ts +6 -3
- package/dist/runtime/channels/source-spot-router.js +34 -23
- package/dist/runtime/channels/spot-node-route-transport.d.ts +6 -3
- package/dist/runtime/channels/spot-node-route-transport.js +23 -17
- package/dist/runtime/channels/spot-route-bridge-transport.d.ts +6 -3
- package/dist/runtime/channels/spot-route-bridge-transport.js +38 -24
- package/dist/runtime/channels/spot-route-dispatch-strategy.d.ts +8 -4
- package/dist/runtime/channels/spot-route-dispatch-strategy.js +36 -23
- package/dist/runtime/diagnostics/dispatch-error-details.js +9 -3
- package/dist/runtime/diagnostics/message-flow-bootstrap.d.ts +1 -0
- package/dist/runtime/diagnostics/message-flow-bootstrap.js +8 -0
- package/dist/runtime/diagnostics/message-flow-delivery.d.ts +47 -0
- package/dist/runtime/diagnostics/message-flow-delivery.js +149 -0
- package/dist/runtime/diagnostics/message-flow-record.d.ts +50 -0
- package/dist/runtime/diagnostics/message-flow-record.js +228 -0
- package/dist/runtime/diagnostics/message-flow-worker.d.ts +1 -0
- package/dist/runtime/diagnostics/message-flow-worker.js +118 -0
- package/dist/runtime/diagnostics/message-flow.d.ts +7 -19
- package/dist/runtime/diagnostics/message-flow.js +42 -290
- package/dist/runtime/diagnostics/runtime-metrics.d.ts +4 -3
- package/dist/runtime/diagnostics/runtime-metrics.js +8 -4
- package/dist/runtime/execution/index.d.ts +1 -0
- package/dist/runtime/execution/index.js +6 -3
- package/dist/runtime/execution/serial-execution-queue.d.ts +26 -13
- package/dist/runtime/execution/serial-execution-queue.js +75 -71
- package/dist/runtime/foundation/durable-service-request.d.ts +12 -3
- package/dist/runtime/foundation/durable-service-request.js +158 -73
- package/dist/runtime/foundation/operation-registry.d.ts +33 -3
- package/dist/runtime/foundation/operation-registry.js +272 -33
- package/dist/runtime/foundation/raw-service-mesh-runtime.d.ts +62 -23
- package/dist/runtime/foundation/raw-service-mesh-runtime.js +373 -194
- package/dist/runtime/foundation/request-runtime.d.ts +17 -0
- package/dist/runtime/foundation/request-runtime.js +163 -0
- package/dist/runtime/foundation/service-discovery-registry.d.ts +4 -0
- package/dist/runtime/foundation/service-discovery-registry.js +6 -0
- package/dist/runtime/foundation/service-liveness-registry.d.ts +1 -1
- package/dist/runtime/foundation/service-mailbox.d.ts +4 -2
- package/dist/runtime/foundation/service-mailbox.js +4 -1
- package/dist/runtime/foundation/service-relocation-object-owner.d.ts +2 -2
- package/dist/runtime/foundation/service-relocation-object-owner.js +12 -5
- package/dist/runtime/foundation/service-runtime-contracts.d.ts +7 -2
- package/dist/runtime/foundation/service-stateful-registry.d.ts +6 -2
- package/dist/runtime/foundation/service-stateful-registry.js +38 -17
- package/dist/runtime/foundation/service-stateful-runtime.d.ts +91 -26
- package/dist/runtime/foundation/service-stateful-runtime.js +245 -120
- package/dist/runtime/foundation/service-stateful-wire-codec.d.ts +3 -0
- package/dist/runtime/foundation/service-stateful-wire-codec.js +15 -0
- package/dist/runtime/foundation/service-topology-registry.d.ts +2 -0
- package/dist/runtime/foundation/service-topology-registry.js +13 -3
- package/dist/runtime/foundation/service-wire-constants.generated.d.ts +1 -0
- package/dist/runtime/foundation/service-wire-constants.generated.js +12 -0
- package/dist/runtime/foundation/service-wire-m6a-codec.d.ts +5 -1
- package/dist/runtime/foundation/service-wire-m6a-codec.js +50 -15
- package/dist/runtime/host/actor-packet-relay.d.ts +5 -6
- package/dist/runtime/host/actor-packet-relay.js +58 -57
- package/dist/runtime/host/actor-placement-coordinator.d.ts +1 -1
- package/dist/runtime/host/actor-runtime-options-factory.d.ts +2 -0
- package/dist/runtime/host/actor-runtime-options-factory.js +3 -2
- package/dist/runtime/host/actor-transfer-runtime.d.ts +3 -3
- package/dist/runtime/host/application-job-queue.d.ts +7 -5
- package/dist/runtime/host/application-job-queue.js +33 -21
- package/dist/runtime/host/bound-session-relay.js +0 -1
- package/dist/runtime/host/channel-runtime-options-factory.d.ts +2 -0
- package/dist/runtime/host/channel-runtime-options-factory.js +1 -0
- package/dist/runtime/host/entry-actor-runtime.d.ts +5 -2
- package/dist/runtime/host/entry-actor-runtime.js +2 -2
- package/dist/runtime/host/index.d.ts +106 -37
- package/dist/runtime/host/index.js +303 -151
- package/dist/runtime/host/location-runtime-owner.d.ts +2 -2
- package/dist/runtime/host/location-runtime-owner.js +1 -1
- package/dist/runtime/host/service-relocation-host-runtime.d.ts +195 -45
- package/dist/runtime/host/service-relocation-host-runtime.js +257 -144
- package/dist/runtime/host/spot-address-transport.d.ts +3 -0
- package/dist/runtime/host/spot-address-transport.js +73 -76
- package/dist/runtime/host/spot-runtime-options-factory.js +2 -0
- package/dist/runtime/host/user-spot-creation-coordinator.d.ts +3 -1
- package/dist/runtime/host/user-spot-creation-coordinator.js +49 -21
- package/dist/runtime/internal-observation.d.ts +1 -0
- package/dist/runtime/internal-observation.js +5 -0
- package/dist/runtime/locations/actor-location-claims.d.ts +1 -1
- package/dist/runtime/locations/actor-location-claims.js +15 -6
- package/dist/runtime/locations/auto-connect-loop.d.ts +0 -1
- package/dist/runtime/locations/auto-connect-loop.js +25 -19
- package/dist/runtime/locations/auto-connect-planner.js +2 -5
- package/dist/runtime/locations/auto-connect-reconciler.d.ts +1 -0
- package/dist/runtime/locations/auto-connect-reconciler.js +35 -23
- package/dist/runtime/locations/in-memory-authority-store.d.ts +1 -0
- package/dist/runtime/locations/in-memory-authority-store.js +15 -5
- package/dist/runtime/locations/in-memory-location-store.d.ts +0 -2
- package/dist/runtime/locations/in-memory-location-store.js +1 -38
- package/dist/runtime/locations/lifecycle.d.ts +1 -1
- package/dist/runtime/locations/lifecycle.js +2 -2
- package/dist/runtime/locations/location-store-repository.d.ts +0 -1
- package/dist/runtime/locations/location-store-repository.js +163 -246
- package/dist/runtime/locations/resolvers.d.ts +8 -1
- package/dist/runtime/locations/resolvers.js +16 -2
- package/dist/runtime/locations/runtime.d.ts +3 -3
- package/dist/runtime/locations/runtime.js +12 -16
- package/dist/runtime/messaging/creation-payload-codec.js +8 -7
- package/dist/runtime/messaging/framework-json-v1.d.ts +1 -1
- package/dist/runtime/messaging/framework-json-v1.js +6 -2
- package/dist/runtime/messaging/payload-codec.js +21 -35
- package/dist/runtime/messaging/request-deadline.d.ts +4 -2
- package/dist/runtime/messaging/request-deadline.js +40 -25
- package/dist/runtime/messaging/request-result.d.ts +14 -1
- package/dist/runtime/messaging/request-result.js +74 -13
- package/dist/runtime/protocol/service_wire_codec.generated.d.ts +4 -0
- package/dist/runtime/protocol/service_wire_codec.generated.js +17 -7
- package/dist/runtime/spots/index.d.ts +28 -7
- package/dist/runtime/spots/index.js +31 -6
- package/dist/runtime/spots/spot-activation-registry.d.ts +3 -2
- package/dist/runtime/spots/spot-activation-registry.js +13 -8
- package/dist/runtime/spots/spot-activation-state.d.ts +2 -0
- package/dist/runtime/spots/spot-activation-state.js +1 -0
- package/dist/runtime/spots/spot-actor-admission-coordinator.d.ts +9 -4
- package/dist/runtime/spots/spot-actor-admission-coordinator.js +33 -12
- package/dist/runtime/spots/spot-actor-ingress-admission.d.ts +40 -0
- package/dist/runtime/spots/spot-actor-ingress-admission.js +78 -0
- package/dist/runtime/spots/spot-actor-membership.js +3 -3
- package/dist/runtime/spots/spot-actor-packet-dispatch.d.ts +16 -43
- package/dist/runtime/spots/spot-actor-packet-dispatch.js +56 -113
- package/dist/runtime/spots/spot-actor-packet-drain.d.ts +1 -0
- package/dist/runtime/spots/spot-actor-packet-drain.js +12 -5
- package/dist/runtime/spots/spot-entry-activation.d.ts +4 -3
- package/dist/runtime/spots/spot-entry-activation.js +7 -12
- package/dist/runtime/spots/spot-handler-registry.d.ts +5 -1
- package/dist/runtime/spots/spot-handler-registry.js +31 -15
- package/dist/runtime/spots/spot-manager-public.js +3 -2
- package/dist/runtime/spots/spot-node-runtime-manager.d.ts +11 -6
- package/dist/runtime/spots/spot-node-runtime-manager.js +6 -1
- package/dist/runtime/spots/spot-outbound.d.ts +8 -2
- package/dist/runtime/spots/spot-outbound.js +5 -5
- package/dist/runtime/spots/spot-route-packet-dispatch.js +13 -8
- package/dist/runtime/spots/spot-routed-spot-packet-dispatch.d.ts +3 -3
- package/dist/runtime/spots/spot-routed-spot-packet-dispatch.js +9 -5
- package/dist/runtime/spots/spot-runtime-ports.d.ts +2 -2
- package/dist/runtime/spots/spot-serial-executor.d.ts +2 -1
- package/dist/runtime/spots/spot-serial-turn-executor.js +20 -26
- package/dist/runtime/spots/spot-subscription-dispatch.js +5 -2
- package/dist/runtime/spots/spot-timer.d.ts +1 -1
- package/dist/runtime/streams/actor-session-binding-registry.d.ts +11 -3
- package/dist/runtime/streams/actor-session-binding-registry.js +28 -0
- package/dist/runtime/streams/bound-actor-relay-sender.d.ts +2 -2
- package/dist/runtime/streams/bound-actor-relay-sender.js +3 -4
- package/dist/runtime/streams/bound-session-service.js +6 -7
- package/dist/runtime/streams/index.d.ts +3 -3
- package/dist/runtime/streams/index.js +22 -2
- package/dist/runtime/streams/managed-stream.js +2 -1
- package/dist/runtime/streams/session-calls.d.ts +1 -1
- package/dist/runtime/streams/session-calls.js +3 -9
- package/dist/runtime/streams/session-context.d.ts +2 -2
- package/dist/runtime/streams/session-context.js +2 -2
- package/dist/runtime/streams/stream-session-runtime.d.ts +1 -0
- package/dist/runtime/streams/stream-session-runtime.js +64 -33
- package/package.json +3 -3
- package/src/contracts/Actors/ZLinkActor.ts +6 -0
- package/src/contracts/Actors/ZLinkSessionBindingIdentity.ts +7 -0
- package/src/contracts/Actors/index.ts +1 -0
- package/src/contracts/Common/CoreTypes.ts +1 -0
- package/src/contracts/Common/HandlerMessageType.ts +50 -0
- package/src/contracts/Common/ZLinkEncodedPayload.ts +13 -25
- package/src/contracts/Common/ZLinkMessage.ts +11 -7
- package/src/contracts/Common/encoded-payload-storage.ts +4 -16
- package/src/contracts/Common/index.ts +1 -1
- package/src/contracts/Common/payload-slab.ts +29 -0
- package/src/contracts/Configuration/RegistrationBuilders.ts +29 -15
- package/src/contracts/Configuration/RegistrationTypes.ts +19 -0
- package/src/contracts/Handlers/Contexts.ts +1 -0
- package/src/contracts/Locations/Authority.ts +7 -1
- package/src/internal.ts +17 -0
- package/src/nest-integration.ts +1 -0
- package/src/runtime/actors/actor-client.ts +257 -163
- package/src/runtime/actors/actor-context.ts +26 -14
- package/src/runtime/actors/actor-execution-context.ts +2 -2
- package/src/runtime/actors/actor-handoff.ts +86 -51
- package/src/runtime/actors/actor-join-deferred-scope.ts +6 -6
- package/src/runtime/actors/actor-local-native-join.ts +38 -17
- package/src/runtime/actors/actor-mailbox.ts +1 -1
- package/src/runtime/actors/actor-remote-joiner.ts +8 -4
- package/src/runtime/actors/actor-routed-join-transport.ts +13 -5
- package/src/runtime/actors/actor-routed-json-request.ts +3 -0
- package/src/runtime/actors/actor-runtime-contracts.ts +4 -2
- package/src/runtime/actors/actor-runtime-state.ts +1 -1
- package/src/runtime/actors/spot-actor-dispatch.ts +70 -68
- package/src/runtime/admission.ts +42 -15
- package/src/runtime/application-jobs/application-ingress-record-owner.ts +4 -0
- package/src/runtime/backend/contracts/index.ts +77 -10
- package/src/runtime/backend/mesh-completion-table.ts +106 -15
- package/src/runtime/backend/mesh-dispatch-pump.ts +294 -146
- package/src/runtime/backend/node/node-backend-adapter-support.ts +42 -32
- package/src/runtime/backend/node/node-dealer-channel-client-transport.ts +91 -34
- package/src/runtime/backend/node/node-event-loop-poller.ts +14 -5
- package/src/runtime/backend/node/node-mesh-backend-adapter.ts +5 -1
- package/src/runtime/backend/node/node-raw-binding-port.ts +180 -69
- package/src/runtime/backend/node/node-raw-mesh-backend.ts +386 -157
- package/src/runtime/backend/node/node-socket-backend-adapter.ts +56 -11
- package/src/runtime/backend/raw-binding-port.ts +13 -5
- package/src/runtime/channels/channel-clients.ts +26 -11
- package/src/runtime/channels/channel-dispatch-pipeline.ts +77 -65
- package/src/runtime/channels/channel-dispatch-services.ts +7 -12
- package/src/runtime/channels/channel-dispatchers.ts +93 -39
- package/src/runtime/channels/channel-envelope.ts +680 -144
- package/src/runtime/channels/channel-multipart.ts +17 -13
- package/src/runtime/channels/channel-outbound-operations.ts +204 -178
- package/src/runtime/channels/channel-receive-loops.ts +160 -107
- package/src/runtime/channels/channel-runtime-lifecycle.ts +64 -59
- package/src/runtime/channels/channel-runtime-manager.ts +74 -27
- package/src/runtime/channels/channel-socket-registry.ts +20 -5
- package/src/runtime/channels/channel-transports.ts +414 -287
- package/src/runtime/channels/dispatch-error-reporter.ts +4 -9
- package/src/runtime/channels/local-spot-route-transport.ts +27 -29
- package/src/runtime/channels/router-socket-spot-route-transport.ts +63 -32
- package/src/runtime/channels/source-spot-router.ts +75 -38
- package/src/runtime/channels/spot-node-route-transport.ts +67 -37
- package/src/runtime/channels/spot-route-bridge-transport.ts +62 -30
- package/src/runtime/channels/spot-route-dispatch-strategy.ts +105 -34
- package/src/runtime/diagnostics/dispatch-error-details.ts +10 -2
- package/src/runtime/diagnostics/message-flow-bootstrap.ts +6 -0
- package/src/runtime/diagnostics/message-flow-delivery.ts +171 -0
- package/src/runtime/diagnostics/message-flow-record.ts +295 -0
- package/src/runtime/diagnostics/message-flow-worker.ts +146 -0
- package/src/runtime/diagnostics/message-flow.ts +49 -362
- package/src/runtime/diagnostics/runtime-metrics.ts +10 -4
- package/src/runtime/execution/index.ts +6 -0
- package/src/runtime/execution/serial-execution-queue.ts +94 -96
- package/src/runtime/foundation/durable-service-request.ts +212 -89
- package/src/runtime/foundation/operation-registry.ts +287 -38
- package/src/runtime/foundation/raw-service-mesh-runtime.ts +617 -292
- package/src/runtime/foundation/request-runtime.ts +227 -0
- package/src/runtime/foundation/service-discovery-registry.ts +7 -0
- package/src/runtime/foundation/service-liveness-registry.ts +1 -1
- package/src/runtime/foundation/service-mailbox.ts +7 -2
- package/src/runtime/foundation/service-relocation-object-owner.ts +21 -6
- package/src/runtime/foundation/service-runtime-contracts.ts +12 -2
- package/src/runtime/foundation/service-stateful-registry.ts +52 -19
- package/src/runtime/foundation/service-stateful-runtime.ts +365 -198
- package/src/runtime/foundation/service-stateful-wire-codec.ts +18 -0
- package/src/runtime/foundation/service-topology-registry.ts +21 -3
- package/src/runtime/foundation/service-wire-constants.generated.ts +10 -0
- package/src/runtime/foundation/service-wire-m6a-codec.ts +69 -17
- package/src/runtime/host/actor-packet-relay.ts +160 -156
- package/src/runtime/host/actor-placement-coordinator.ts +1 -1
- package/src/runtime/host/actor-runtime-options-factory.ts +7 -2
- package/src/runtime/host/actor-transfer-runtime.ts +3 -3
- package/src/runtime/host/application-job-queue.ts +56 -27
- package/src/runtime/host/bound-session-relay.ts +0 -1
- package/src/runtime/host/channel-runtime-options-factory.ts +3 -0
- package/src/runtime/host/entry-actor-runtime.ts +14 -6
- package/src/runtime/host/index.ts +388 -113
- package/src/runtime/host/location-runtime-owner.ts +3 -3
- package/src/runtime/host/service-relocation-host-runtime.ts +380 -252
- package/src/runtime/host/spot-address-transport.ts +110 -95
- package/src/runtime/host/spot-runtime-options-factory.ts +3 -0
- package/src/runtime/host/user-spot-creation-coordinator.ts +69 -22
- package/src/runtime/internal-observation.ts +2 -0
- package/src/runtime/locations/actor-location-claims.ts +42 -16
- package/src/runtime/locations/auto-connect-loop.ts +24 -16
- package/src/runtime/locations/auto-connect-planner.ts +2 -5
- package/src/runtime/locations/auto-connect-reconciler.ts +37 -24
- package/src/runtime/locations/in-memory-authority-store.ts +27 -7
- package/src/runtime/locations/in-memory-location-store.ts +1 -74
- package/src/runtime/locations/lifecycle.ts +4 -2
- package/src/runtime/locations/location-store-repository.ts +228 -308
- package/src/runtime/locations/resolvers.ts +20 -8
- package/src/runtime/locations/runtime.ts +16 -28
- package/src/runtime/messaging/creation-payload-codec.ts +12 -10
- package/src/runtime/messaging/framework-json-v1.ts +10 -1
- package/src/runtime/messaging/payload-codec.ts +50 -75
- package/src/runtime/messaging/request-deadline.ts +47 -39
- package/src/runtime/messaging/request-result.ts +88 -17
- package/src/runtime/protocol/service_wire_codec.generated.ts +18 -8
- package/src/runtime/protocol/service_wire_pilot_codec.generated.ts +1 -1
- package/src/runtime/spots/index.ts +57 -10
- package/src/runtime/spots/spot-activation-registry.ts +12 -8
- package/src/runtime/spots/spot-activation-state.ts +2 -0
- package/src/runtime/spots/spot-actor-admission-coordinator.ts +62 -37
- package/src/runtime/spots/spot-actor-ingress-admission.ts +157 -0
- package/src/runtime/spots/spot-actor-membership.ts +8 -5
- package/src/runtime/spots/spot-actor-packet-dispatch.ts +122 -206
- package/src/runtime/spots/spot-actor-packet-drain.ts +21 -6
- package/src/runtime/spots/spot-entry-activation.ts +25 -35
- package/src/runtime/spots/spot-handler-registry.ts +72 -15
- package/src/runtime/spots/spot-manager-public.ts +4 -2
- package/src/runtime/spots/spot-node-runtime-manager.ts +16 -7
- package/src/runtime/spots/spot-outbound.ts +26 -10
- package/src/runtime/spots/spot-route-packet-dispatch.ts +18 -8
- package/src/runtime/spots/spot-routed-spot-packet-dispatch.ts +14 -8
- package/src/runtime/spots/spot-runtime-ports.ts +5 -2
- package/src/runtime/spots/spot-serial-executor.ts +1 -1
- package/src/runtime/spots/spot-serial-turn-executor.ts +25 -40
- package/src/runtime/spots/spot-subscription-dispatch.ts +9 -2
- package/src/runtime/spots/spot-timer.ts +1 -1
- package/src/runtime/streams/actor-session-binding-registry.ts +46 -3
- package/src/runtime/streams/bound-actor-relay-sender.ts +16 -5
- package/src/runtime/streams/bound-session-service.ts +10 -7
- package/src/runtime/streams/index.ts +30 -4
- package/src/runtime/streams/managed-stream.ts +2 -1
- package/src/runtime/streams/session-calls.ts +9 -14
- package/src/runtime/streams/session-context.ts +6 -11
- package/src/runtime/streams/stream-session-runtime.ts +79 -40
- package/dist/runtime/spots/spot-lifecycle-metrics.d.ts +0 -8
- package/dist/runtime/spots/spot-lifecycle-metrics.js +0 -17
- package/src/runtime/spots/spot-lifecycle-metrics.ts +0 -16
|
@@ -21,16 +21,16 @@ class ActorJoinRegistrationScope {
|
|
|
21
21
|
sealAfterHandlerTerminal() {
|
|
22
22
|
this.open = false;
|
|
23
23
|
}
|
|
24
|
-
|
|
25
|
-
|
|
24
|
+
prepareSealedJoins() {
|
|
25
|
+
return this.prepareSealedJoinsCore();
|
|
26
26
|
}
|
|
27
27
|
async prepareSealedJoinsCore() {
|
|
28
28
|
if (this.prepared) {
|
|
29
29
|
return;
|
|
30
30
|
}
|
|
31
31
|
this.prepared = true;
|
|
32
|
-
for (
|
|
33
|
-
await
|
|
32
|
+
for (let index = 0; index < this.intents.length; index++) {
|
|
33
|
+
await this.intents[index].prepare?.();
|
|
34
34
|
}
|
|
35
35
|
}
|
|
36
36
|
async activateSealedJoins() {
|
|
@@ -48,8 +48,8 @@ class ActorJoinRegistrationScope {
|
|
|
48
48
|
await Promise.allSettled(this.intents.map((intent) => intent.discard()));
|
|
49
49
|
}
|
|
50
50
|
async execute() {
|
|
51
|
-
for (
|
|
52
|
-
await
|
|
51
|
+
for (let index = 0; index < this.intents.length; index++) {
|
|
52
|
+
await this.intents[index].execute();
|
|
53
53
|
}
|
|
54
54
|
}
|
|
55
55
|
}
|
|
@@ -23,8 +23,8 @@ export interface ZLinkLocalNativeActorJoinOptions {
|
|
|
23
23
|
export declare class ZLinkLocalNativeActorJoin {
|
|
24
24
|
private readonly options;
|
|
25
25
|
constructor(options: ZLinkLocalNativeActorJoinOptions);
|
|
26
|
-
joinSpot(node: ZLinkBackendMeshNode, actor: ZLinkActor, state: ZLinkActorRuntimeState, actorRef: ZLinkBackendActorRef, spotId: RoutingId, spotRouteTarget: ZLinkSpotRouteTarget | undefined, request: Message, timeoutMs: number | undefined, signal: AbortSignal | undefined, completionOperationId?: ZLinkActorJoinOperationId): Promise<ZLinkActorJoinRuntimeResult<Message>>;
|
|
27
|
-
joinEntrySpot(node: ZLinkBackendMeshNode, actor: ZLinkActor, state: ZLinkActorRuntimeState, actorRef: ZLinkBackendActorRef, nodeRid: RoutingId, spotRouteTarget: ZLinkSpotRouteTarget | undefined, request: Message, timeoutMs: number | undefined, signal: AbortSignal | undefined, completionOperationId?: ZLinkActorJoinOperationId): Promise<ZLinkActorJoinRuntimeResult<Message>>;
|
|
26
|
+
joinSpot(node: ZLinkBackendMeshNode, actor: ZLinkActor, state: ZLinkActorRuntimeState, actorRef: ZLinkBackendActorRef, spotId: RoutingId, spotRouteTarget: ZLinkSpotRouteTarget | undefined, request: Message, timeoutMs: number | undefined, signal: AbortSignal | undefined, completionOperationId?: ZLinkActorJoinOperationId, deadlineAtMs?: number): Promise<ZLinkActorJoinRuntimeResult<Message>>;
|
|
27
|
+
joinEntrySpot(node: ZLinkBackendMeshNode, actor: ZLinkActor, state: ZLinkActorRuntimeState, actorRef: ZLinkBackendActorRef, nodeRid: RoutingId, spotRouteTarget: ZLinkSpotRouteTarget | undefined, request: Message, timeoutMs: number | undefined, signal: AbortSignal | undefined, completionOperationId?: ZLinkActorJoinOperationId, deadlineAtMs?: number): Promise<ZLinkActorJoinRuntimeResult<Message>>;
|
|
28
28
|
private joinLocal;
|
|
29
29
|
private waitForJoinCompletion;
|
|
30
30
|
private relocateRemoteActorJoin;
|
|
@@ -10,6 +10,7 @@ const runtime_values_1 = require("../backend/runtime-values");
|
|
|
10
10
|
const operation_identity_1 = require("../foundation/operation-identity");
|
|
11
11
|
const framework_errors_internal_1 = require("../framework-errors-internal");
|
|
12
12
|
const payload_codec_1 = require("../messaging/payload-codec");
|
|
13
|
+
const actor_request_deadline_1 = require("./actor-request-deadline");
|
|
13
14
|
const routing_id_1 = require("../routing-id");
|
|
14
15
|
const actor_remote_wire_1 = require("./actor-remote-wire");
|
|
15
16
|
const actor_runtime_state_1 = require("./actor-runtime-state");
|
|
@@ -22,17 +23,17 @@ class ZLinkLocalNativeActorJoin {
|
|
|
22
23
|
constructor(options) {
|
|
23
24
|
this.options = options;
|
|
24
25
|
}
|
|
25
|
-
async joinSpot(node, actor, state, actorRef, spotId, spotRouteTarget, request, timeoutMs, signal, completionOperationId) {
|
|
26
|
+
async joinSpot(node, actor, state, actorRef, spotId, spotRouteTarget, request, timeoutMs, signal, completionOperationId, deadlineAtMs) {
|
|
26
27
|
if (signal?.aborted === true)
|
|
27
28
|
throw (0, abort_1.createAbortError)();
|
|
28
29
|
const target = requireUserSpotRoute(spotRouteTarget, spotId);
|
|
29
30
|
const remote = !(0, routing_id_1.routingIdsEqual)((0, actor_runtime_state_1.toFrameworkRoutingId)(node.status().routingId), target.targetNodeRid);
|
|
30
31
|
if (remote) {
|
|
31
|
-
return await this.relocateRemoteActorJoin(node, actor, state, actorRef, target, request, timeoutMs, signal, completionOperationId, false);
|
|
32
|
+
return await this.relocateRemoteActorJoin(node, actor, state, actorRef, target, request, timeoutMs, signal, completionOperationId, false, deadlineAtMs);
|
|
32
33
|
}
|
|
33
34
|
return await this.joinLocal(node, actor, state, actorRef, target, target.spotId, request, signal);
|
|
34
35
|
}
|
|
35
|
-
async joinEntrySpot(node, actor, state, actorRef, nodeRid, spotRouteTarget, request, timeoutMs, signal, completionOperationId) {
|
|
36
|
+
async joinEntrySpot(node, actor, state, actorRef, nodeRid, spotRouteTarget, request, timeoutMs, signal, completionOperationId, deadlineAtMs) {
|
|
36
37
|
if (signal?.aborted === true)
|
|
37
38
|
throw (0, abort_1.createAbortError)();
|
|
38
39
|
const targetNodeRid = spotRouteTarget?.targetNodeRid ?? nodeRid;
|
|
@@ -40,7 +41,7 @@ class ZLinkLocalNativeActorJoin {
|
|
|
40
41
|
(!(0, routing_id_1.routingIdsEqual)((0, actor_runtime_state_1.toFrameworkRoutingId)(node.status().routingId), spotRouteTarget.targetNodeRid) ||
|
|
41
42
|
!(0, routing_id_1.routingIdsEqual)((0, actor_runtime_state_1.toFrameworkRoutingId)(actorRef.nodeRid), spotRouteTarget.targetNodeRid));
|
|
42
43
|
if (remote) {
|
|
43
|
-
return await this.relocateRemoteActorJoin(node, actor, state, actorRef, spotRouteTarget, request, timeoutMs, signal, completionOperationId, true);
|
|
44
|
+
return await this.relocateRemoteActorJoin(node, actor, state, actorRef, spotRouteTarget, request, timeoutMs, signal, completionOperationId, true, deadlineAtMs);
|
|
44
45
|
}
|
|
45
46
|
const target = {
|
|
46
47
|
routerChannelId: spotRouteTarget?.routerChannelId ?? runtimeActorMeshName(actor, state, ''),
|
|
@@ -72,7 +73,7 @@ class ZLinkLocalNativeActorJoin {
|
|
|
72
73
|
const authorityOwnerGeneration = state.locationGeneration ?? actorRef.generation;
|
|
73
74
|
const commit = async (spot) => {
|
|
74
75
|
(0, abort_1.throwIfAborted)(signal);
|
|
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
|
+
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, signal);
|
|
76
77
|
const committedActor = node.restoreActorAuthority(actor.context.actorId, actorType, actorRef.generation, authorityOwnerGeneration, target.spotKind === contracts_1.ZLinkSpotKind.Entry ? undefined : String(target.spotId), spotGeneration, membershipEpoch);
|
|
77
78
|
state.setNativeActorRef(committedActor);
|
|
78
79
|
if (target.spotKind === contracts_1.ZLinkSpotKind.Entry)
|
|
@@ -110,14 +111,14 @@ class ZLinkLocalNativeActorJoin {
|
|
|
110
111
|
reply: response.reply
|
|
111
112
|
};
|
|
112
113
|
}
|
|
113
|
-
async waitForJoinCompletion(submit, completions, timeoutMs, signal) {
|
|
114
|
+
async waitForJoinCompletion(submit, completions, timeoutMs, signal, deadlineAtMs) {
|
|
114
115
|
// The operation ID identifies one Core request. Once it is submitted, a
|
|
115
116
|
// NotConnected completion is terminal for that request; resubmitting it
|
|
116
117
|
// could execute the target lifecycle twice after a delayed reply.
|
|
117
|
-
return submitJoinWhenConnected(() => completions.submit(submit, signal), timeoutMs, signal);
|
|
118
|
+
return submitJoinWhenConnected(() => completions.submit(submit, signal), timeoutMs, signal, deadlineAtMs);
|
|
118
119
|
}
|
|
119
|
-
async relocateRemoteActorJoin(node, actor, state, actorRef, target, request, timeoutMs, signal, completionOperationId, entrySpot) {
|
|
120
|
-
|
|
120
|
+
async relocateRemoteActorJoin(node, actor, state, actorRef, target, request, timeoutMs, signal, completionOperationId, entrySpot, deadlineAtMs) {
|
|
121
|
+
deadlineAtMs ??= timeoutMs === undefined ? undefined : performance.now() + timeoutMs;
|
|
121
122
|
const actorType = state.actorType;
|
|
122
123
|
if (actorType === undefined) {
|
|
123
124
|
throw (0, framework_errors_internal_1.createInternalFrameworkException)(framework_errors_internal_1.ZLinkFrameworkInternalErrorKind.ActorRouteNotFound, `Actor '${actor.context.actorId}' canonical remote Join identity is not configured.`);
|
|
@@ -147,19 +148,20 @@ class ZLinkLocalNativeActorJoin {
|
|
|
147
148
|
};
|
|
148
149
|
let admissionOperationId;
|
|
149
150
|
const admission = await this.waitForJoinCompletion(() => {
|
|
151
|
+
const remainingTimeoutMs = (0, actor_request_deadline_1.remainingActorRequestTimeout)(actor.context.actorId, deadlineAtMs);
|
|
150
152
|
const legacyAdmission = canonicalAdmission === undefined
|
|
151
153
|
? legacyRemoteActorJoinPayload(actor, state, actorRef, target, request, relocationId)
|
|
152
154
|
: undefined;
|
|
153
155
|
const operationId = canonicalAdmission === undefined
|
|
154
156
|
? entrySpot
|
|
155
|
-
? node.joinActorEntrySpot(actorRef, (0, routing_id_1.toBackendRoutingId)(target.targetNodeRid), legacyAdmission,
|
|
156
|
-
: node.joinActorSpot(actorRef, (0, routing_id_1.toBackendRoutingId)(target.targetNodeRid), (0, routing_id_1.toBackendRoutingId)(target.spotId), target.targetSpotGeneration, legacyAdmission,
|
|
157
|
+
? node.joinActorEntrySpot(actorRef, (0, routing_id_1.toBackendRoutingId)(target.targetNodeRid), legacyAdmission, remainingTimeoutMs)
|
|
158
|
+
: node.joinActorSpot(actorRef, (0, routing_id_1.toBackendRoutingId)(target.targetNodeRid), (0, routing_id_1.toBackendRoutingId)(target.spotId), target.targetSpotGeneration, legacyAdmission, remainingTimeoutMs)
|
|
157
159
|
: entrySpot
|
|
158
|
-
? node.joinActorEntrySpotCanonical(actorRef, (0, routing_id_1.toBackendRoutingId)(target.targetNodeRid), canonicalAdmission.request, canonicalAdmission.actorFence, canonicalAdmission.local,
|
|
159
|
-
: node.joinActorSpotCanonical(actorRef, (0, routing_id_1.toBackendRoutingId)(target.targetNodeRid), (0, routing_id_1.toBackendRoutingId)(target.spotId), target.targetSpotGeneration, canonicalAdmission.request, canonicalAdmission.actorFence, canonicalAdmission.local,
|
|
160
|
+
? node.joinActorEntrySpotCanonical(actorRef, (0, routing_id_1.toBackendRoutingId)(target.targetNodeRid), canonicalAdmission.request, canonicalAdmission.actorFence, canonicalAdmission.local, remainingTimeoutMs)
|
|
161
|
+
: node.joinActorSpotCanonical(actorRef, (0, routing_id_1.toBackendRoutingId)(target.targetNodeRid), (0, routing_id_1.toBackendRoutingId)(target.spotId), target.targetSpotGeneration, canonicalAdmission.request, canonicalAdmission.actorFence, canonicalAdmission.local, remainingTimeoutMs);
|
|
160
162
|
admissionOperationId = operationId;
|
|
161
163
|
return operationId;
|
|
162
|
-
}, completions, timeoutMs, signal);
|
|
164
|
+
}, completions, timeoutMs, signal, deadlineAtMs);
|
|
163
165
|
const control = admission.kindData;
|
|
164
166
|
if (control?.kind !== 'actorJoinCompletion' || control.actor === null) {
|
|
165
167
|
(0, mesh_completion_table_1.closeMeshCompletion)(admission);
|
|
@@ -342,9 +344,9 @@ function runtimeActorMeshName(actor, state, fallback) {
|
|
|
342
344
|
const stateMeshName = state?.meshName;
|
|
343
345
|
return context?.meshName ?? stateMeshName ?? fallback;
|
|
344
346
|
}
|
|
345
|
-
async function submitJoinWhenConnected(submit, timeoutMs, signal) {
|
|
346
|
-
const deadline = performance.now() +
|
|
347
|
-
Math.min(timeoutMs ?? LOCAL_JOIN_RESOLUTION_TIMEOUT_MS, LOCAL_JOIN_RESOLUTION_TIMEOUT_MS);
|
|
347
|
+
async function submitJoinWhenConnected(submit, timeoutMs, signal, deadlineAtMs) {
|
|
348
|
+
const deadline = Math.min(deadlineAtMs ?? Infinity, performance.now() +
|
|
349
|
+
Math.min(timeoutMs ?? LOCAL_JOIN_RESOLUTION_TIMEOUT_MS, LOCAL_JOIN_RESOLUTION_TIMEOUT_MS));
|
|
348
350
|
for (;;) {
|
|
349
351
|
(0, abort_1.throwIfAborted)(signal);
|
|
350
352
|
try {
|
|
@@ -2,7 +2,7 @@ import { ZLinkSerialExecutionQueue, type ZLinkSerialSchedulerOptions, type ZLink
|
|
|
2
2
|
export declare class ZLinkActorSerialExecutor {
|
|
3
3
|
private readonly actorId;
|
|
4
4
|
private readonly sourceSpotId;
|
|
5
|
-
|
|
5
|
+
readonly scheduler: ZLinkSerialExecutionQueue;
|
|
6
6
|
constructor(actorId: string, sourceSpotId: unknown, options?: ZLinkSerialSchedulerOptions, sharedOwner?: ZLinkSerialExecutionQueue);
|
|
7
7
|
execute<T>(operation: () => Promise<T> | T, workOptions?: ZLinkSerialWorkOptions): Promise<T>;
|
|
8
8
|
close(): Promise<void>;
|
|
@@ -30,8 +30,8 @@ export declare class ZLinkActorNativeJoinCoordinator implements ZLinkActorJoinCo
|
|
|
30
30
|
constructor(options: ZLinkActorNativeJoinCoordinatorOptions);
|
|
31
31
|
beginDeferredJoin(actor: ZLinkActor, state: ZLinkActorRuntimeState): void;
|
|
32
32
|
abortDeferredJoin(actor: ZLinkActor, state: ZLinkActorRuntimeState): Promise<void>;
|
|
33
|
-
joinSpot(actor: ZLinkActor, state: ZLinkActorRuntimeState, spotId: RoutingId, request: Message, timeoutMs: number | undefined, signal: AbortSignal | undefined, completionOperationId?: import('../../contracts').ZLinkActorJoinOperationId): Promise<ZLinkActorJoinRuntimeResult<Message>>;
|
|
34
|
-
joinEntrySpot(actor: ZLinkActor, state: ZLinkActorRuntimeState, nodeRid: RoutingId | undefined, request: Message, timeoutMs: number | undefined, signal: AbortSignal | undefined, completionOperationId?: import('../../contracts').ZLinkActorJoinOperationId): Promise<ZLinkActorJoinRuntimeResult<Message>>;
|
|
33
|
+
joinSpot(actor: ZLinkActor, state: ZLinkActorRuntimeState, spotId: RoutingId, request: Message, timeoutMs: number | undefined, signal: AbortSignal | undefined, completionOperationId?: import('../../contracts').ZLinkActorJoinOperationId, deadlineAtMs?: number): Promise<ZLinkActorJoinRuntimeResult<Message>>;
|
|
34
|
+
joinEntrySpot(actor: ZLinkActor, state: ZLinkActorRuntimeState, nodeRid: RoutingId | undefined, request: Message, timeoutMs: number | undefined, signal: AbortSignal | undefined, completionOperationId?: import('../../contracts').ZLinkActorJoinOperationId, deadlineAtMs?: number): Promise<ZLinkActorJoinRuntimeResult<Message>>;
|
|
35
35
|
private withDeferredJoinFinalizer;
|
|
36
36
|
private node;
|
|
37
37
|
}
|
|
@@ -39,7 +39,7 @@ class ZLinkActorNativeJoinCoordinator {
|
|
|
39
39
|
async abortDeferredJoin(actor, state) {
|
|
40
40
|
await this.options.sourceTransfer?.cancelDeferredActorHandoff?.(actor, state);
|
|
41
41
|
}
|
|
42
|
-
async joinSpot(actor, state, spotId, request, timeoutMs, signal, completionOperationId) {
|
|
42
|
+
async joinSpot(actor, state, spotId, request, timeoutMs, signal, completionOperationId, deadlineAtMs) {
|
|
43
43
|
(0, abort_1.throwIfAborted)(signal);
|
|
44
44
|
const node = this.node();
|
|
45
45
|
const actorRef = state.nativeActorRef ??
|
|
@@ -49,10 +49,10 @@ class ZLinkActorNativeJoinCoordinator {
|
|
|
49
49
|
let target;
|
|
50
50
|
target = await this.options.spotRouteResolver?.resolve(spotId, signal);
|
|
51
51
|
installResolvedSpotRoute(node, target);
|
|
52
|
-
const result = await this.localJoin.joinSpot(node, actor, state, actorRef, spotId, target, request, timeoutMs ?? this.options.actorTransferTimeoutMs, signal, completionOperationId);
|
|
52
|
+
const result = await this.localJoin.joinSpot(node, actor, state, actorRef, spotId, target, request, timeoutMs ?? this.options.actorTransferTimeoutMs, signal, completionOperationId, deadlineAtMs);
|
|
53
53
|
return this.withDeferredJoinFinalizer(actor, state, target, result, completionOperationId);
|
|
54
54
|
}
|
|
55
|
-
async joinEntrySpot(actor, state, nodeRid, request, timeoutMs, signal, completionOperationId) {
|
|
55
|
+
async joinEntrySpot(actor, state, nodeRid, request, timeoutMs, signal, completionOperationId, deadlineAtMs) {
|
|
56
56
|
(0, abort_1.throwIfAborted)(signal);
|
|
57
57
|
const node = this.node();
|
|
58
58
|
const actorRef = state.nativeActorRef ??
|
|
@@ -74,7 +74,7 @@ class ZLinkActorNativeJoinCoordinator {
|
|
|
74
74
|
state.entryNodeRid ??
|
|
75
75
|
(0, actor_runtime_state_1.toFrameworkRoutingId)(node.status().routingId);
|
|
76
76
|
const target = resolvedTarget;
|
|
77
|
-
const result = await this.localJoin.joinEntrySpot(node, actor, state, actorRef, selectedNodeRid, target, request, timeoutMs ?? this.options.actorTransferTimeoutMs, signal, completionOperationId);
|
|
77
|
+
const result = await this.localJoin.joinEntrySpot(node, actor, state, actorRef, selectedNodeRid, target, request, timeoutMs ?? this.options.actorTransferTimeoutMs, signal, completionOperationId, deadlineAtMs);
|
|
78
78
|
return this.withDeferredJoinFinalizer(actor, state, target, result, completionOperationId);
|
|
79
79
|
}
|
|
80
80
|
withDeferredJoinFinalizer(actor, state, target, result, operationId) {
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import type { PendingOperation, OperationObserver } from '../foundation/operation-registry';
|
|
2
|
+
import type { ZLinkRequestResult } from '../messaging/request-result';
|
|
1
3
|
import type { Message } from '../../contracts/Common/Message';
|
|
2
4
|
import type { ZLinkBackendSpot } from '../backend/contracts';
|
|
3
5
|
import type { ZLinkSubmitResult } from '../messaging/submission-result';
|
|
@@ -5,7 +7,7 @@ import type { ZLinkSpotRouteTarget } from '../spots/spot-routing-internal';
|
|
|
5
7
|
export interface ZLinkActorRoutedJoinTransport {
|
|
6
8
|
canRouteChannel?(routerChannelId: string): boolean;
|
|
7
9
|
canRoutePacketChannel?(routerChannelId: string): boolean;
|
|
8
|
-
request<TReply>(routerChannelId: string, targetNodeRid: string, packetName: string | undefined, request: unknown, timeoutMs: number | undefined, signal?: AbortSignal):
|
|
10
|
+
request<TReply>(routerChannelId: string, targetNodeRid: string, packetName: string | undefined, request: unknown, timeoutMs: number | undefined, signal?: AbortSignal): ZLinkRequestResult<TReply>;
|
|
9
11
|
submit?(routerChannelId: string, targetNodeRid: string, packetName: string | undefined, message: unknown): ZLinkSubmitResult | Promise<ZLinkSubmitResult>;
|
|
10
12
|
submitInfrastructure?(routerChannelId: string, targetNodeRid: string, packetName: string | undefined, message: unknown): ZLinkSubmitResult | Promise<ZLinkSubmitResult>;
|
|
11
13
|
sendToSpot(spotRouteTarget: ZLinkSpotRouteTarget, message: unknown, options: {
|
|
@@ -13,23 +15,27 @@ export interface ZLinkActorRoutedJoinTransport {
|
|
|
13
15
|
}): Promise<ZLinkSubmitResult>;
|
|
14
16
|
requestRawToSpot?(spotRouteTarget: ZLinkSpotRouteTarget, request: Message, options: {
|
|
15
17
|
readonly timeoutMs?: number;
|
|
18
|
+
readonly requestOperation?: PendingOperation<unknown>;
|
|
16
19
|
readonly signal?: AbortSignal;
|
|
17
20
|
readonly onAdmitted?: () => void;
|
|
18
21
|
}): Promise<readonly Message[]>;
|
|
19
22
|
requestToSpot<TReply = unknown>(spotRouteTarget: ZLinkSpotRouteTarget, request: unknown, options: {
|
|
20
23
|
readonly packetName?: string;
|
|
21
24
|
readonly timeoutMs?: number;
|
|
25
|
+
readonly requestOperation?: PendingOperation<unknown>;
|
|
22
26
|
readonly signal?: AbortSignal;
|
|
23
27
|
readonly onAdmitted?: () => void;
|
|
24
|
-
}):
|
|
28
|
+
}, destination?: OperationObserver<unknown, unknown>): ZLinkRequestResult<TReply>;
|
|
25
29
|
requestFromSpotToSpot?<TReply = unknown>(sourceSpot: ZLinkBackendSpot, spotRouteTarget: ZLinkSpotRouteTarget, request: unknown, options: {
|
|
26
30
|
readonly packetName?: string;
|
|
27
31
|
readonly timeoutMs?: number;
|
|
32
|
+
readonly requestOperation?: PendingOperation<unknown>;
|
|
28
33
|
readonly signal?: AbortSignal;
|
|
29
34
|
readonly onAdmitted?: () => void;
|
|
30
|
-
}):
|
|
35
|
+
}, destination?: OperationObserver<unknown, unknown>): ZLinkRequestResult<TReply>;
|
|
31
36
|
requestRawFromSpotToSpot?(sourceSpot: ZLinkBackendSpot, spotRouteTarget: ZLinkSpotRouteTarget, request: Message, options: {
|
|
32
37
|
readonly timeoutMs?: number;
|
|
38
|
+
readonly requestOperation?: PendingOperation<unknown>;
|
|
33
39
|
readonly signal?: AbortSignal;
|
|
34
40
|
readonly onAdmitted?: () => void;
|
|
35
41
|
}): Promise<readonly Message[]>;
|
|
@@ -1,13 +1,16 @@
|
|
|
1
|
+
import type { PendingOperation } from '../foundation/operation-registry';
|
|
1
2
|
import type { Message } from '../../contracts/Common/Message';
|
|
2
3
|
import type { ZLinkSpotRouteTarget } from '../spots/spot-routing-internal';
|
|
3
4
|
import type { ZLinkActorRoutedJoinTransport } from './actor-routed-join-transport';
|
|
4
5
|
export declare function tryRequestRoutedJson(transport: ZLinkActorRoutedJoinTransport, target: ZLinkSpotRouteTarget, payload: unknown, options: {
|
|
5
6
|
readonly timeoutMs?: number;
|
|
7
|
+
readonly requestOperation?: PendingOperation<unknown>;
|
|
6
8
|
readonly signal?: AbortSignal;
|
|
7
9
|
readonly onAdmitted?: () => void;
|
|
8
10
|
}): Promise<boolean>;
|
|
9
11
|
export declare function requestRoutedJsonReply<T>(transport: ZLinkActorRoutedJoinTransport, target: ZLinkSpotRouteTarget, payload: unknown, options: {
|
|
10
12
|
readonly timeoutMs?: number;
|
|
13
|
+
readonly requestOperation?: PendingOperation<unknown>;
|
|
11
14
|
readonly signal?: AbortSignal;
|
|
12
15
|
readonly onAdmitted?: () => void;
|
|
13
16
|
}, unavailableMessage: string, decode: (replyParts: readonly Message[]) => T): Promise<T>;
|
|
@@ -63,6 +63,6 @@ export interface ZLinkActorJoinCoordinator {
|
|
|
63
63
|
*/
|
|
64
64
|
beginDeferredJoin?(actor: ZLinkActor, state: ZLinkActorRuntimeState): void;
|
|
65
65
|
abortDeferredJoin?(actor: ZLinkActor, state: ZLinkActorRuntimeState): Promise<void>;
|
|
66
|
-
joinSpot(actor: ZLinkActor, state: ZLinkActorRuntimeState, spotId: RoutingId, request: Message, timeoutMs: number | undefined, signal: AbortSignal | undefined, completionOperationId?: import('../../contracts').ZLinkActorJoinOperationId): Promise<ZLinkActorJoinRuntimeResult<Message>>;
|
|
67
|
-
joinEntrySpot(actor: ZLinkActor, state: ZLinkActorRuntimeState, nodeRid: RoutingId | undefined, request: Message, timeoutMs: number | undefined, signal: AbortSignal | undefined, completionOperationId?: import('../../contracts').ZLinkActorJoinOperationId): Promise<ZLinkActorJoinRuntimeResult<Message>>;
|
|
66
|
+
joinSpot(actor: ZLinkActor, state: ZLinkActorRuntimeState, spotId: RoutingId, request: Message, timeoutMs: number | undefined, signal: AbortSignal | undefined, completionOperationId?: import('../../contracts').ZLinkActorJoinOperationId, deadlineAtMs?: number): Promise<ZLinkActorJoinRuntimeResult<Message>>;
|
|
67
|
+
joinEntrySpot(actor: ZLinkActor, state: ZLinkActorRuntimeState, nodeRid: RoutingId | undefined, request: Message, timeoutMs: number | undefined, signal: AbortSignal | undefined, completionOperationId?: import('../../contracts').ZLinkActorJoinOperationId, deadlineAtMs?: number): Promise<ZLinkActorJoinRuntimeResult<Message>>;
|
|
68
68
|
}
|
|
@@ -77,7 +77,7 @@ export declare class ZLinkActorRuntimeState {
|
|
|
77
77
|
private spotMembershipEpochValue;
|
|
78
78
|
private nativeActorRefValue;
|
|
79
79
|
private entryNodeRidValue;
|
|
80
|
-
|
|
80
|
+
boundSessionValue: ZLinkRemoteBoundSessionTarget | undefined;
|
|
81
81
|
private remoteActorPacketTargetValue;
|
|
82
82
|
private createRequestPayloadValue;
|
|
83
83
|
private ownsLocationValue;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { ZLinkHandlerMessageType } from '../../contracts/Common/HandlerMessageType';
|
|
1
2
|
import { type Type, type ZLinkActor, type ZLinkActorHandlerRegistry, type ZLinkMessageContext, type ZLinkMessageSerializer, type ZLinkSpot, type ZLinkSpotActorJoinResult } from '../../contracts';
|
|
2
3
|
import type { Message } from '../../contracts/Common/Message';
|
|
3
4
|
import type { ZLinkProviderResolver } from '../../contracts/Common/ZLinkProviderResolver';
|
|
@@ -11,6 +12,7 @@ export interface ZLinkActorPacketDescriptor {
|
|
|
11
12
|
readonly packetName: string;
|
|
12
13
|
readonly actorType: Type<ZLinkActor>;
|
|
13
14
|
readonly handlerType: Type;
|
|
15
|
+
readonly messageType?: ZLinkHandlerMessageType;
|
|
14
16
|
readonly methodName?: string;
|
|
15
17
|
}
|
|
16
18
|
export declare class ZLinkSpotActorHandlerRegistryRuntime implements ZLinkActorHandlerRegistry {
|
|
@@ -39,11 +41,11 @@ export declare class ZLinkSpotActorDispatcher {
|
|
|
39
41
|
private readonly options;
|
|
40
42
|
constructor(options: ZLinkSpotActorDispatcherOptions);
|
|
41
43
|
dispatchSend<TMessage>(actor: ZLinkActor, packetName: string, message: TMessage, context?: Partial<ZLinkMessageContext>): Promise<void>;
|
|
42
|
-
dispatchSendDecoded<TMessage>(actor: ZLinkActor, packetName: string, decode: () => TMessage, context?: Partial<ZLinkMessageContext>): Promise<void>;
|
|
44
|
+
dispatchSendDecoded<TMessage>(actor: ZLinkActor, packetName: string, decode: (messageType?: Type) => TMessage, context?: Partial<ZLinkMessageContext>): Promise<void>;
|
|
43
45
|
dispatchRequest<TRequest, TReply>(actor: ZLinkActor, packetName: string, request: TRequest, context?: Partial<ZLinkMessageContext>): Promise<TReply>;
|
|
44
|
-
dispatchRequestDecoded<TRequest, TReply>(actor: ZLinkActor, packetName: string, decode: () => TRequest, context?: Partial<ZLinkMessageContext>): Promise<TReply>;
|
|
46
|
+
dispatchRequestDecoded<TRequest, TReply>(actor: ZLinkActor, packetName: string, decode: (messageType?: Type) => TRequest, context?: Partial<ZLinkMessageContext>): Promise<TReply>;
|
|
45
47
|
dispatchRequestThen<TRequest, TReply, TResult>(actor: ZLinkActor, packetName: string, request: TRequest, context: Partial<ZLinkMessageContext> | undefined, afterReply: (reply: TReply, options: ZLinkSpotActorReplyOptionsSnapshot) => Promise<TResult> | TResult, beforeReply?: (reply: TReply, options: ZLinkSpotActorReplyOptionsSnapshot) => Promise<void> | void): Promise<TResult>;
|
|
46
|
-
dispatchRequestThenDecoded<TRequest, TReply, TResult>(actor: ZLinkActor, packetName: string, decode: () => TRequest, context: Partial<ZLinkMessageContext> | undefined, afterReply: (reply: TReply, options: ZLinkSpotActorReplyOptionsSnapshot) => Promise<TResult> | TResult, beforeReply?: (reply: TReply, options: ZLinkSpotActorReplyOptionsSnapshot) => Promise<void> | void): Promise<TResult>;
|
|
48
|
+
dispatchRequestThenDecoded<TRequest, TReply, TResult>(actor: ZLinkActor, packetName: string, decode: (messageType?: Type) => TRequest, context: Partial<ZLinkMessageContext> | undefined, afterReply: (reply: TReply, options: ZLinkSpotActorReplyOptionsSnapshot) => Promise<TResult> | TResult, beforeReply?: (reply: TReply, options: ZLinkSpotActorReplyOptionsSnapshot) => Promise<void> | void): Promise<TResult>;
|
|
47
49
|
admitActorJoin(actor: ZLinkActor, request: Message, commit: () => Promise<void> | void): Promise<ZLinkSpotActorJoinResult>;
|
|
48
50
|
evaluateActorJoin(actor: ZLinkActor, request: Message, contentType?: string): Promise<ZLinkSpotActorJoinResult>;
|
|
49
51
|
commitActorJoin(actor: ZLinkActor, commit: () => Promise<void> | void): Promise<void>;
|
|
@@ -52,8 +54,10 @@ export declare class ZLinkSpotActorDispatcher {
|
|
|
52
54
|
notifyDisconnectActor(actor: ZLinkActor): Promise<void>;
|
|
53
55
|
private requirePacket;
|
|
54
56
|
private ensureActorType;
|
|
55
|
-
|
|
57
|
+
invokeHandler<THandler, TResult>(actor: ZLinkActor, descriptor: Pick<ZLinkActorPacketDescriptor, 'handlerType' | 'methodName'>, callback: (handler: THandler, method: THandler extends {
|
|
58
|
+
handle: infer TMethod;
|
|
59
|
+
} ? TMethod : never) => Promise<TResult>): Promise<TResult>;
|
|
56
60
|
private execute;
|
|
57
|
-
|
|
61
|
+
createContext(packetName: string, context: Partial<ZLinkMessageContext> | undefined): ZLinkMessageContext;
|
|
58
62
|
}
|
|
59
63
|
export {};
|
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.ZLinkSpotActorDispatcher = exports.ZLinkSpotActorHandlerRegistryRuntime = exports.ZLinkActorPacketKind = void 0;
|
|
4
4
|
const stream_wire_1 = require("@zlink-systems/stream-wire");
|
|
5
5
|
const contracts_1 = require("../../contracts");
|
|
6
|
+
const HandlerMessageType_1 = require("../../contracts/Common/HandlerMessageType");
|
|
6
7
|
const Attributes_1 = require("../../contracts/Handlers/Attributes");
|
|
7
8
|
const configuration_1 = require("../configuration");
|
|
8
9
|
const framework_errors_internal_1 = require("../framework-errors-internal");
|
|
@@ -23,6 +24,7 @@ class ZLinkSpotActorHandlerRegistryRuntime {
|
|
|
23
24
|
if (metadata === undefined || resolvedPacketName === undefined) {
|
|
24
25
|
throw (0, framework_errors_internal_1.createInternalFrameworkException)(framework_errors_internal_1.ZLinkFrameworkInternalErrorKind.InvalidOperation, `Actor packet handler '${handlerType.name}' must declare a packet name.`);
|
|
25
26
|
}
|
|
27
|
+
const messageType = (0, HandlerMessageType_1.resolveHandlerMessageType)(handlerType);
|
|
26
28
|
return this.addPacket({
|
|
27
29
|
kind: metadata.kind === 'spotActorSend'
|
|
28
30
|
? ZLinkActorPacketKind.Send
|
|
@@ -30,37 +32,49 @@ class ZLinkSpotActorHandlerRegistryRuntime {
|
|
|
30
32
|
packetName: resolvedPacketName,
|
|
31
33
|
actorType: Object,
|
|
32
34
|
handlerType,
|
|
35
|
+
...(messageType === undefined ? {} : { messageType }),
|
|
33
36
|
methodName: metadata.methodName
|
|
34
37
|
});
|
|
35
38
|
}
|
|
36
39
|
addPacket(descriptor) {
|
|
37
|
-
const
|
|
38
|
-
|
|
40
|
+
const actorTypeName = descriptor.actorType.name;
|
|
41
|
+
let packets = this.packets.get(descriptor.kind);
|
|
42
|
+
let actors = packets?.get(descriptor.packetName);
|
|
43
|
+
if (actors?.has(actorTypeName) === true) {
|
|
39
44
|
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
45
|
}
|
|
41
46
|
const metadata = (0, Attributes_1.readZLinkDecoratorMetadata)(descriptor.handlerType).find((entry) => entry.kind ===
|
|
42
47
|
(descriptor.kind === ZLinkActorPacketKind.Send ? 'spotActorSend' : 'spotActorRequest') &&
|
|
43
48
|
entry.packetName === descriptor.packetName);
|
|
44
|
-
|
|
49
|
+
if (packets === undefined) {
|
|
50
|
+
packets = new Map();
|
|
51
|
+
this.packets.set(descriptor.kind, packets);
|
|
52
|
+
}
|
|
53
|
+
if (actors === undefined) {
|
|
54
|
+
actors = new Map();
|
|
55
|
+
packets.set(descriptor.packetName, actors);
|
|
56
|
+
}
|
|
57
|
+
actors.set(actorTypeName, {
|
|
45
58
|
...descriptor,
|
|
46
59
|
methodName: descriptor.methodName ?? metadata?.methodName
|
|
47
60
|
});
|
|
48
61
|
return this;
|
|
49
62
|
}
|
|
50
63
|
resolvePacket(kind, actor, packetName) {
|
|
64
|
+
const actors = this.packets.get(kind)?.get(packetName);
|
|
65
|
+
if (actors === undefined)
|
|
66
|
+
return undefined;
|
|
51
67
|
const actorType = actor.constructor;
|
|
52
|
-
const exact =
|
|
68
|
+
const exact = actors.get(actorType.name);
|
|
53
69
|
if (exact !== undefined) {
|
|
54
70
|
return exact;
|
|
55
71
|
}
|
|
56
|
-
const wildcard =
|
|
72
|
+
const wildcard = actors.get(Object.name);
|
|
57
73
|
if (wildcard !== undefined) {
|
|
58
74
|
return wildcard;
|
|
59
75
|
}
|
|
60
|
-
for (const descriptor of
|
|
61
|
-
if (descriptor.
|
|
62
|
-
descriptor.packetName === packetName &&
|
|
63
|
-
actor instanceof descriptor.actorType) {
|
|
76
|
+
for (const descriptor of actors.values()) {
|
|
77
|
+
if (actor instanceof descriptor.actorType) {
|
|
64
78
|
return descriptor;
|
|
65
79
|
}
|
|
66
80
|
}
|
|
@@ -73,40 +87,50 @@ class ZLinkSpotActorDispatcher {
|
|
|
73
87
|
constructor(options) {
|
|
74
88
|
this.options = options;
|
|
75
89
|
}
|
|
76
|
-
dispatchSend(actor, packetName, message, context
|
|
90
|
+
dispatchSend(actor, packetName, message, context) {
|
|
77
91
|
return this.dispatchSendDecoded(actor, packetName, () => message, context);
|
|
78
92
|
}
|
|
79
|
-
dispatchSendDecoded(actor, packetName, decode, context
|
|
93
|
+
dispatchSendDecoded(actor, packetName, decode, context) {
|
|
80
94
|
return this.execute(async () => {
|
|
81
95
|
const descriptor = this.requirePacket(ZLinkActorPacketKind.Send, actor, packetName);
|
|
82
|
-
const message = decode();
|
|
83
|
-
this.
|
|
84
|
-
|
|
96
|
+
const message = decode((0, HandlerMessageType_1.resolveMessageTypeForDecode)(descriptor.messageType));
|
|
97
|
+
await this.invokeHandler(actor, descriptor, (handler, method) => {
|
|
98
|
+
const handlerContext = this.createContext(packetName, context);
|
|
99
|
+
return (0, actor_join_deferred_scope_1.runActorHandlerWithDeferredJoins)(() => {
|
|
100
|
+
this.options.onHandlerStart?.();
|
|
101
|
+
return method.call(handler, this.options.spot, actor, handlerContext, message);
|
|
102
|
+
});
|
|
103
|
+
});
|
|
85
104
|
});
|
|
86
105
|
}
|
|
87
|
-
dispatchRequest(actor, packetName, request, context
|
|
106
|
+
dispatchRequest(actor, packetName, request, context) {
|
|
88
107
|
return this.dispatchRequestThenDecoded(actor, packetName, () => request, context, (reply) => reply);
|
|
89
108
|
}
|
|
90
|
-
dispatchRequestDecoded(actor, packetName, decode, context
|
|
109
|
+
dispatchRequestDecoded(actor, packetName, decode, context) {
|
|
91
110
|
return this.dispatchRequestThenDecoded(actor, packetName, decode, context, (reply) => reply);
|
|
92
111
|
}
|
|
93
|
-
dispatchRequestThen(actor, packetName, request, context
|
|
112
|
+
dispatchRequestThen(actor, packetName, request, context, afterReply, beforeReply) {
|
|
94
113
|
return this.dispatchRequestThenDecoded(actor, packetName, () => request, context, afterReply, beforeReply);
|
|
95
114
|
}
|
|
96
|
-
dispatchRequestThenDecoded(actor, packetName, decode, context
|
|
115
|
+
dispatchRequestThenDecoded(actor, packetName, decode, context, afterReply, beforeReply) {
|
|
97
116
|
return this.execute(async () => {
|
|
98
117
|
const descriptor = this.requirePacket(ZLinkActorPacketKind.Request, actor, packetName);
|
|
99
|
-
const request = decode();
|
|
100
|
-
this.
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
metadata: new Map(),
|
|
118
|
+
const request = decode((0, HandlerMessageType_1.resolveMessageTypeForDecode)(descriptor.messageType));
|
|
119
|
+
return await this.invokeHandler(actor, descriptor, (handler, method) => {
|
|
120
|
+
const handlerContext = this.createContext(packetName, context);
|
|
121
|
+
return (0, actor_join_deferred_scope_1.runActorHandlerWithDeferredJoins)(() => {
|
|
122
|
+
this.options.onHandlerStart?.();
|
|
123
|
+
return method.call(handler, this.options.spot, actor, handlerContext, request);
|
|
124
|
+
}, (reply) => afterReply(reply, {
|
|
125
|
+
metadata: contracts_1.ZLinkMessageMetadataEmpty.values,
|
|
108
126
|
compressPayload: false
|
|
109
|
-
})
|
|
127
|
+
}), beforeReply === undefined
|
|
128
|
+
? undefined
|
|
129
|
+
: (reply) => beforeReply(reply, {
|
|
130
|
+
metadata: contracts_1.ZLinkMessageMetadataEmpty.values,
|
|
131
|
+
compressPayload: false
|
|
132
|
+
}));
|
|
133
|
+
});
|
|
110
134
|
});
|
|
111
135
|
}
|
|
112
136
|
admitActorJoin(actor, request, commit) {
|
|
@@ -158,8 +182,8 @@ class ZLinkSpotActorDispatcher {
|
|
|
158
182
|
}
|
|
159
183
|
throw actorDispatchHandlerNotFound(`Actor handler '${descriptor.handlerType.name}' expects actor '${descriptor.actorType.name}'.`);
|
|
160
184
|
}
|
|
161
|
-
|
|
162
|
-
return
|
|
185
|
+
invokeHandler(actor, descriptor, callback) {
|
|
186
|
+
return (0, handler_instance_scope_1.runWithLifecycleHandler)(actor, descriptor.handlerType, this.options.providerResolver, (resolved) => {
|
|
163
187
|
const methodName = descriptor.methodName ?? 'handle';
|
|
164
188
|
const method = resolved[methodName];
|
|
165
189
|
if (typeof method !== 'function') {
|
|
@@ -176,19 +200,17 @@ class ZLinkSpotActorDispatcher {
|
|
|
176
200
|
}
|
|
177
201
|
createContext(packetName, context) {
|
|
178
202
|
return {
|
|
179
|
-
meshName: context
|
|
180
|
-
channelName: context
|
|
203
|
+
meshName: context?.meshName,
|
|
204
|
+
channelName: context?.channelName,
|
|
181
205
|
packetName,
|
|
182
|
-
contentType: context
|
|
183
|
-
metadata: context
|
|
184
|
-
correlationId: context
|
|
206
|
+
contentType: context?.contentType,
|
|
207
|
+
metadata: context?.metadata ?? contracts_1.ZLinkMessageMetadataEmpty,
|
|
208
|
+
correlationId: context?.correlationId,
|
|
209
|
+
receivedAt: context?.receivedAt ?? new Date()
|
|
185
210
|
};
|
|
186
211
|
}
|
|
187
212
|
}
|
|
188
213
|
exports.ZLinkSpotActorDispatcher = ZLinkSpotActorDispatcher;
|
|
189
|
-
function packetKey(kind, actorType, packetName) {
|
|
190
|
-
return `${kind}:${actorType.name}:${packetName}`;
|
|
191
|
-
}
|
|
192
214
|
function actorDispatchHandlerNotFound(message) {
|
|
193
215
|
return (0, framework_errors_internal_1.createInternalFrameworkException)(framework_errors_internal_1.ZLinkFrameworkInternalErrorKind.ActorDispatchHandlerNotFound, message);
|
|
194
216
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { ZLinkFrameworkInternalErrorKind } from './framework-errors-internal';
|
|
2
|
+
import { type ReceiveRecord } from './foundation/service-runtime-contracts';
|
|
2
3
|
/** Runs host admission inside the domain's request completion boundary. */
|
|
3
|
-
export type ZLinkMeshDispatchAdmission = (dispatch: () => void | Promise<void>, onRejected?: (error: unknown) => void | Promise<void
|
|
4
|
+
export type ZLinkMeshDispatchAdmission = <TReceiver = void, TContext = void>(dispatch: (this: TReceiver, context: TContext) => void | Promise<void>, onRejected?: (this: TReceiver, error: unknown, context: TContext) => void | Promise<void>, receiver?: TReceiver, context?: TContext) => void | Promise<void>;
|
|
4
5
|
/** 소비한 배열 prefix가 정리 조건에 도달했는지 판정합니다. */
|
|
5
6
|
export declare function shouldCompactBackingArray(head: number, length: number): boolean;
|
|
6
7
|
export declare class ZLinkRuntimeAdmissionGate {
|
|
@@ -13,17 +14,18 @@ export declare class ZLinkRuntimeAdmissionGate {
|
|
|
13
14
|
constructor(ownerAdmissionOpen?: () => boolean);
|
|
14
15
|
get acceptsNewWork(): boolean;
|
|
15
16
|
register(meshName: string): void;
|
|
16
|
-
accepts(meshName: string): boolean;
|
|
17
|
+
accepts(meshName: string, kind?: ReceiveRecord['kind']): boolean;
|
|
17
18
|
pending(meshName: string): number;
|
|
18
19
|
seal(meshName: string, reason?: ZLinkFrameworkInternalErrorKind): void;
|
|
19
20
|
close(): void;
|
|
20
|
-
claim(meshName: string, operation: string): ZLinkApplicationWorkClaim;
|
|
21
|
+
claim(meshName: string, operation: string, kind?: ReceiveRecord['kind']): ZLinkApplicationWorkClaim;
|
|
21
22
|
/**
|
|
22
23
|
* Runs one admitted unit of work. Work that completes synchronously leaves
|
|
23
24
|
* admission in the same turn; asynchronous work leaves it from the single
|
|
24
25
|
* continuation on its result.
|
|
25
26
|
*/
|
|
26
|
-
run<T>(meshName: string, operation: string, work: () => T | Promise<T>, onRejected?: (error: unknown) => T | Promise<T
|
|
27
|
+
run<T, TReceiver = void, TContext = void>(meshName: string, operation: string, work: (this: TReceiver, context: TContext) => T | Promise<T>, kind?: ReceiveRecord['kind'], onRejected?: (this: TReceiver, error: unknown, context: TContext) => T | Promise<T>, receiver?: TReceiver, context?: TContext): T | Promise<T>;
|
|
28
|
+
private isOpen;
|
|
27
29
|
private enter;
|
|
28
30
|
awaitZero(meshName: string, signal?: AbortSignal): Promise<void>;
|
|
29
31
|
requireRequest(operation: string, meshName?: string): void;
|
|
@@ -4,6 +4,7 @@ exports.ZLinkRuntimeAdmissionGate = void 0;
|
|
|
4
4
|
exports.shouldCompactBackingArray = shouldCompactBackingArray;
|
|
5
5
|
const framework_errors_internal_1 = require("./framework-errors-internal");
|
|
6
6
|
const abort_1 = require("./abort");
|
|
7
|
+
const service_runtime_contracts_1 = require("./foundation/service-runtime-contracts");
|
|
7
8
|
const BACKING_ARRAY_COMPACTION_MIN_HEAD = 1024;
|
|
8
9
|
/** 소비한 배열 prefix가 정리 조건에 도달했는지 판정합니다. */
|
|
9
10
|
function shouldCompactBackingArray(head, length) {
|
|
@@ -40,8 +41,8 @@ class ZLinkRuntimeAdmissionGate {
|
|
|
40
41
|
});
|
|
41
42
|
}
|
|
42
43
|
}
|
|
43
|
-
accepts(meshName) {
|
|
44
|
-
return this.
|
|
44
|
+
accepts(meshName, kind) {
|
|
45
|
+
return this.isOpen(this.requireState(meshName), kind);
|
|
45
46
|
}
|
|
46
47
|
pending(meshName) {
|
|
47
48
|
return this.requireState(meshName).active;
|
|
@@ -57,8 +58,8 @@ class ZLinkRuntimeAdmissionGate {
|
|
|
57
58
|
state.sealedReason = framework_errors_internal_1.ZLinkFrameworkInternalErrorKind.RuntimeShutdown;
|
|
58
59
|
}
|
|
59
60
|
}
|
|
60
|
-
claim(meshName, operation) {
|
|
61
|
-
const state = this.enter(meshName, operation);
|
|
61
|
+
claim(meshName, operation, kind) {
|
|
62
|
+
const state = this.enter(meshName, operation, kind);
|
|
62
63
|
let closed = false;
|
|
63
64
|
return {
|
|
64
65
|
close: () => {
|
|
@@ -74,18 +75,20 @@ class ZLinkRuntimeAdmissionGate {
|
|
|
74
75
|
* admission in the same turn; asynchronous work leaves it from the single
|
|
75
76
|
* continuation on its result.
|
|
76
77
|
*/
|
|
77
|
-
run(meshName, operation, work, onRejected) {
|
|
78
|
+
run(meshName, operation, work, kind, onRejected, receiver, context) {
|
|
78
79
|
let state;
|
|
79
80
|
let result;
|
|
80
81
|
try {
|
|
81
|
-
state = this.enter(meshName, operation);
|
|
82
|
+
state = this.enter(meshName, operation, kind);
|
|
82
83
|
}
|
|
83
84
|
catch (error) {
|
|
84
85
|
// The domain owns admission rejection completion, just as it owns handler failure.
|
|
85
|
-
return onRejected === undefined
|
|
86
|
+
return onRejected === undefined
|
|
87
|
+
? Promise.reject(error)
|
|
88
|
+
: onRejected.call(receiver, error, context);
|
|
86
89
|
}
|
|
87
90
|
try {
|
|
88
|
-
result = work();
|
|
91
|
+
result = work.call(receiver, context);
|
|
89
92
|
}
|
|
90
93
|
catch (error) {
|
|
91
94
|
exitAdmission(state);
|
|
@@ -103,9 +106,17 @@ class ZLinkRuntimeAdmissionGate {
|
|
|
103
106
|
throw error;
|
|
104
107
|
});
|
|
105
108
|
}
|
|
106
|
-
|
|
109
|
+
isOpen(state, kind) {
|
|
110
|
+
return (!state.sealed &&
|
|
111
|
+
(kind === service_runtime_contracts_1.ReceiveKind.NodeSend ||
|
|
112
|
+
kind === service_runtime_contracts_1.ReceiveKind.NodeRequest ||
|
|
113
|
+
kind === service_runtime_contracts_1.ReceiveKind.ChannelSend ||
|
|
114
|
+
kind === service_runtime_contracts_1.ReceiveKind.ChannelRequest ||
|
|
115
|
+
this.ownerAdmissionOpen()));
|
|
116
|
+
}
|
|
117
|
+
enter(meshName, operation, kind) {
|
|
107
118
|
const state = this.requireState(meshName);
|
|
108
|
-
if (this.
|
|
119
|
+
if (this.isOpen(state, kind)) {
|
|
109
120
|
state.active += 1;
|
|
110
121
|
return state;
|
|
111
122
|
}
|