@zlink-systems/framework 0.29.1 → 0.30.1
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/ZLinkMessageMetadata.js +11 -5
- package/dist/contracts/Configuration/Builders.d.ts +1 -2
- package/dist/contracts/Configuration/Configs.d.ts +0 -5
- package/dist/contracts/Configuration/RegistrationBuilders.js +6 -4
- package/dist/contracts/Configuration/RegistrationTypes.d.ts +1 -6
- package/dist/contracts/Configuration/RegistrationValidators.js +4 -4
- package/dist/contracts/Configuration/index.d.ts +1 -1
- 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/Spots/Contracts.d.ts +2 -1
- package/dist/internal.d.ts +1 -0
- package/dist/internal.js +3 -1
- package/dist/nest-integration.d.ts +1 -1
- package/dist/nest-integration.js +2 -1
- package/dist/runtime/actors/actor-client.d.ts +1 -1
- package/dist/runtime/actors/actor-client.js +14 -12
- package/dist/runtime/actors/actor-handoff.d.ts +3 -2
- package/dist/runtime/actors/actor-handoff.js +15 -7
- package/dist/runtime/actors/actor-join-relocation.d.ts +1 -0
- package/dist/runtime/actors/actor-local-native-join.js +9 -12
- package/dist/runtime/actors/actor-remote-wire.js +15 -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/index.d.ts +2 -1
- package/dist/runtime/actors/index.js +18 -6
- package/dist/runtime/actors/spot-actor-dispatch.js +2 -2
- package/dist/runtime/admission.d.ts +1 -1
- package/dist/runtime/admission.js +15 -5
- package/dist/runtime/application-jobs/application-ingress-record-owner.d.ts +9 -9
- package/dist/runtime/application-jobs/application-ingress-record-owner.js +45 -23
- package/dist/runtime/application-jobs/application-job-queue-scope.d.ts +5 -2
- package/dist/runtime/application-jobs/application-job-queue-scope.js +41 -21
- package/dist/runtime/application-jobs/contracts.d.ts +15 -2
- package/dist/runtime/backend/contracts/index.d.ts +27 -27
- package/dist/runtime/backend/mesh-completion-table.d.ts +15 -5
- package/dist/runtime/backend/mesh-completion-table.js +160 -50
- package/dist/runtime/backend/mesh-dispatch-pump.d.ts +3 -0
- package/dist/runtime/backend/mesh-dispatch-pump.js +53 -36
- package/dist/runtime/backend/node/node-backend-adapter-factory.js +6 -1
- package/dist/runtime/backend/node/node-backend-adapter-support.d.ts +3 -3
- package/dist/runtime/backend/node/node-backend-adapter-support.js +33 -31
- 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-mesh-backend-adapter.d.ts +1 -9
- package/dist/runtime/backend/node/node-mesh-backend-adapter.js +1 -1
- package/dist/runtime/backend/node/node-raw-binding-port.js +50 -25
- package/dist/runtime/backend/node/node-raw-mesh-backend.d.ts +22 -16
- package/dist/runtime/backend/node/node-raw-mesh-backend.js +133 -149
- package/dist/runtime/backend/node/node-socket-backend-adapter.js +15 -10
- package/dist/runtime/backend/raw-binding-port.d.ts +10 -3
- 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 +1 -0
- package/dist/runtime/channels/channel-clients.js +58 -21
- package/dist/runtime/channels/channel-dispatch-pipeline.d.ts +3 -2
- package/dist/runtime/channels/channel-dispatch-pipeline.js +20 -11
- 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 +1 -1
- package/dist/runtime/channels/channel-dispatchers.js +27 -26
- 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 +1 -0
- package/dist/runtime/channels/channel-envelope.js +83 -8
- 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-receive-loops.js +3 -3
- package/dist/runtime/channels/channel-runtime-lifecycle.js +2 -1
- package/dist/runtime/channels/channel-runtime-manager.d.ts +6 -6
- package/dist/runtime/channels/channel-runtime-manager.js +12 -12
- package/dist/runtime/channels/channel-socket-registry.d.ts +10 -3
- package/dist/runtime/channels/channel-socket-registry.js +59 -82
- package/dist/runtime/channels/channel-transports.d.ts +18 -15
- package/dist/runtime/channels/channel-transports.js +48 -31
- 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/message-flow.d.ts +1 -0
- package/dist/runtime/diagnostics/message-flow.js +3 -3
- package/dist/runtime/execution/serial-execution-queue.d.ts +1 -0
- package/dist/runtime/execution/serial-execution-queue.js +1 -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/raw-service-mesh-runtime.d.ts +37 -6
- package/dist/runtime/foundation/raw-service-mesh-runtime.js +473 -220
- package/dist/runtime/foundation/service-liveness-registry.d.ts +20 -8
- package/dist/runtime/foundation/service-liveness-registry.js +57 -44
- package/dist/runtime/foundation/service-mailbox.d.ts +3 -0
- package/dist/runtime/foundation/service-mailbox.js +2 -1
- package/dist/runtime/foundation/service-relocation-object-owner.d.ts +1 -0
- package/dist/runtime/foundation/service-relocation-object-owner.js +1 -0
- package/dist/runtime/foundation/service-relocation-runtime.d.ts +2 -0
- package/dist/runtime/foundation/service-relocation-runtime.js +13 -1
- package/dist/runtime/foundation/service-runtime-contracts.d.ts +2 -0
- package/dist/runtime/foundation/service-stateful-runtime.d.ts +10 -9
- package/dist/runtime/foundation/service-stateful-runtime.js +78 -126
- package/dist/runtime/foundation/service-stateful-wire-codec.d.ts +5 -7
- package/dist/runtime/foundation/service-stateful-wire-codec.js +43 -61
- package/dist/runtime/foundation/service-topology-registry.d.ts +16 -4
- package/dist/runtime/foundation/service-topology-registry.js +69 -30
- package/dist/runtime/foundation/service-wire-m6a-codec.d.ts +3 -3
- package/dist/runtime/foundation/service-wire-m6a-codec.js +36 -38
- 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.js +7 -7
- package/dist/runtime/host/actor-runtime-options-factory.js +2 -2
- package/dist/runtime/host/application-job-queue.d.ts +28 -9
- package/dist/runtime/host/application-job-queue.js +214 -50
- package/dist/runtime/host/entry-actor-runtime.d.ts +1 -0
- package/dist/runtime/host/entry-actor-runtime.js +4 -1
- package/dist/runtime/host/index.d.ts +7 -1
- package/dist/runtime/host/index.js +154 -126
- package/dist/runtime/host/instance-activation-authority.d.ts +2 -1
- package/dist/runtime/host/instance-activation-authority.js +89 -25
- package/dist/runtime/host/remote-bound-session-relay.js +2 -18
- package/dist/runtime/host/route-mesh-runtime.js +1 -1
- 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 +6 -8
- package/dist/runtime/host/service-relocation-host-runtime.js +215 -243
- package/dist/runtime/host/spot-address-transport.d.ts +1 -0
- package/dist/runtime/host/spot-address-transport.js +28 -14
- package/dist/runtime/host/spot-runtime-options-factory.js +3 -2
- package/dist/runtime/host/user-spot-creation-coordinator.d.ts +1 -0
- package/dist/runtime/host/user-spot-creation-coordinator.js +1 -0
- 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/domain-store-contract.d.ts +2 -2
- package/dist/runtime/locations/in-memory-authority-store.d.ts +4 -2
- package/dist/runtime/locations/in-memory-authority-store.js +80 -8
- package/dist/runtime/locations/in-memory-location-store.d.ts +2 -2
- package/dist/runtime/locations/in-memory-location-store.js +19 -3
- package/dist/runtime/locations/internal-location-contracts.d.ts +3 -0
- 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 +3 -2
- package/dist/runtime/locations/location-store-repository.js +165 -22
- package/dist/runtime/locations/resolvers.d.ts +2 -1
- package/dist/runtime/locations/resolvers.js +10 -1
- package/dist/runtime/locations/runtime.d.ts +1 -1
- package/dist/runtime/locations/runtime.js +24 -23
- 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/request-result.d.ts +2 -0
- package/dist/runtime/messaging/request-result.js +54 -0
- package/dist/runtime/messaging/submission-result.d.ts +2 -1
- package/dist/runtime/messaging/submission-result.js +7 -4
- package/dist/runtime/protocol/service_wire_codec.generated.d.ts +15 -0
- package/dist/runtime/protocol/service_wire_codec.generated.js +144 -0
- package/dist/runtime/protocol/service_wire_pilot_codec.generated.d.ts +9 -0
- package/dist/runtime/protocol/service_wire_pilot_codec.generated.js +14 -1
- package/dist/runtime/spots/formal-remote-actor-admission-registry.d.ts +9 -2
- package/dist/runtime/spots/formal-remote-actor-admission-registry.js +33 -19
- package/dist/runtime/spots/index.d.ts +7 -3
- package/dist/runtime/spots/index.js +23 -16
- package/dist/runtime/spots/spot-activation.d.ts +3 -1
- package/dist/runtime/spots/spot-activation.js +21 -12
- package/dist/runtime/spots/spot-actor-admission-coordinator.d.ts +2 -1
- package/dist/runtime/spots/spot-actor-admission-coordinator.js +11 -10
- package/dist/runtime/spots/spot-actor-packet-dispatch.d.ts +4 -1
- package/dist/runtime/spots/spot-actor-packet-dispatch.js +7 -5
- package/dist/runtime/spots/spot-actor-packet-drain.js +2 -0
- package/dist/runtime/spots/spot-actor-packet-relay-dispatch.js +1 -0
- package/dist/runtime/spots/spot-entry-activation.js +9 -3
- package/dist/runtime/spots/spot-handler-registry.d.ts +3 -1
- package/dist/runtime/spots/spot-handler-registry.js +18 -8
- package/dist/runtime/spots/spot-node-autoconnect.js +4 -3
- package/dist/runtime/spots/spot-node-runtime-manager.d.ts +2 -1
- package/dist/runtime/spots/spot-node-runtime-manager.js +4 -11
- package/dist/runtime/spots/spot-outbound.d.ts +3 -0
- package/dist/runtime/spots/spot-outbound.js +24 -15
- 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-routing-internal.d.ts +6 -0
- package/dist/runtime/spots/spot-runtime-ports.d.ts +3 -1
- package/dist/runtime/spots/spot-subscription-dispatch.js +0 -3
- package/dist/runtime/spots/spot-timer.js +1 -0
- package/dist/runtime/streams/stream-session-runtime.d.ts +1 -1
- package/dist/runtime/streams/stream-session-runtime.js +14 -28
- 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/ZLinkMessageMetadata.ts +13 -8
- package/src/contracts/Configuration/Builders.ts +1 -2
- package/src/contracts/Configuration/Configs.ts +0 -6
- package/src/contracts/Configuration/RegistrationBuilders.ts +8 -12
- package/src/contracts/Configuration/RegistrationTypes.ts +1 -6
- package/src/contracts/Configuration/RegistrationValidators.ts +9 -10
- package/src/contracts/Configuration/index.ts +1 -6
- package/src/contracts/Handlers/Attributes.ts +14 -21
- package/src/contracts/Handlers/JsonContract.ts +8 -216
- package/src/contracts/Spots/Contracts.ts +2 -1
- package/src/internal.ts +1 -0
- package/src/nest-integration.ts +1 -0
- package/src/runtime/actors/actor-client.ts +40 -16
- package/src/runtime/actors/actor-handoff.ts +22 -8
- package/src/runtime/actors/actor-join-relocation.ts +1 -0
- package/src/runtime/actors/actor-local-native-join.ts +17 -26
- package/src/runtime/actors/actor-remote-wire.ts +17 -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/index.ts +19 -5
- package/src/runtime/actors/spot-actor-dispatch.ts +4 -2
- package/src/runtime/admission.ts +18 -5
- package/src/runtime/application-jobs/application-ingress-record-owner.ts +53 -27
- package/src/runtime/application-jobs/application-job-queue-scope.ts +56 -22
- package/src/runtime/application-jobs/contracts.ts +28 -2
- package/src/runtime/backend/contracts/index.ts +63 -32
- package/src/runtime/backend/mesh-completion-table.ts +175 -59
- package/src/runtime/backend/mesh-dispatch-pump.ts +59 -32
- package/src/runtime/backend/node/node-backend-adapter-factory.ts +12 -5
- package/src/runtime/backend/node/node-backend-adapter-support.ts +42 -31
- package/src/runtime/backend/node/node-dealer-channel-client-transport.ts +12 -2
- package/src/runtime/backend/node/node-mesh-backend-adapter.ts +3 -10
- package/src/runtime/backend/node/node-raw-binding-port.ts +73 -37
- package/src/runtime/backend/node/node-raw-mesh-backend.ts +209 -176
- package/src/runtime/backend/node/node-socket-backend-adapter.ts +32 -13
- package/src/runtime/backend/raw-binding-port.ts +18 -3
- 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 +90 -41
- package/src/runtime/channels/channel-dispatch-pipeline.ts +69 -34
- package/src/runtime/channels/channel-dispatch-services.ts +69 -1
- package/src/runtime/channels/channel-dispatchers.ts +29 -27
- package/src/runtime/channels/channel-envelope-inspection.ts +2 -16
- package/src/runtime/channels/channel-envelope.ts +133 -8
- package/src/runtime/channels/channel-outbound-operations.ts +22 -8
- package/src/runtime/channels/channel-receive-loops.ts +3 -3
- package/src/runtime/channels/channel-runtime-lifecycle.ts +7 -1
- package/src/runtime/channels/channel-runtime-manager.ts +29 -12
- package/src/runtime/channels/channel-socket-registry.ts +84 -130
- package/src/runtime/channels/channel-transports.ts +128 -60
- 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/message-flow.ts +1 -1
- package/src/runtime/execution/serial-execution-queue.ts +2 -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/raw-service-mesh-runtime.ts +642 -253
- package/src/runtime/foundation/service-liveness-registry.ts +68 -59
- package/src/runtime/foundation/service-mailbox.ts +7 -1
- package/src/runtime/foundation/service-relocation-object-owner.ts +2 -0
- package/src/runtime/foundation/service-relocation-runtime.ts +18 -1
- package/src/runtime/foundation/service-runtime-contracts.ts +7 -1
- package/src/runtime/foundation/service-stateful-runtime.ts +128 -160
- package/src/runtime/foundation/service-stateful-wire-codec.ts +55 -84
- package/src/runtime/foundation/service-topology-registry.ts +103 -42
- package/src/runtime/foundation/service-wire-m6a-codec.ts +57 -38
- package/src/runtime/handlers/handler-instance-scope.ts +67 -16
- package/src/runtime/host/actor-packet-relay.ts +7 -0
- package/src/runtime/host/actor-runtime-options-factory.ts +14 -2
- package/src/runtime/host/application-job-queue.ts +249 -48
- package/src/runtime/host/entry-actor-runtime.ts +5 -0
- package/src/runtime/host/index.ts +224 -160
- package/src/runtime/host/instance-activation-authority.ts +132 -27
- package/src/runtime/host/remote-bound-session-relay.ts +2 -23
- package/src/runtime/host/route-mesh-runtime.ts +1 -1
- package/src/runtime/host/service-relocation-control.ts +11 -5
- package/src/runtime/host/service-relocation-host-runtime.ts +317 -291
- package/src/runtime/host/spot-address-transport.ts +49 -24
- package/src/runtime/host/spot-runtime-options-factory.ts +4 -0
- package/src/runtime/host/user-spot-creation-coordinator.ts +8 -0
- package/src/runtime/locations/actor-location-claims.ts +52 -30
- package/src/runtime/locations/domain-store-contract.ts +6 -2
- package/src/runtime/locations/in-memory-authority-store.ts +113 -9
- package/src/runtime/locations/in-memory-location-store.ts +25 -3
- package/src/runtime/locations/internal-location-contracts.ts +4 -0
- package/src/runtime/locations/lifecycle.ts +8 -26
- package/src/runtime/locations/location-store-repository.ts +220 -15
- package/src/runtime/locations/resolvers.ts +25 -2
- package/src/runtime/locations/runtime.ts +28 -24
- package/src/runtime/messaging/framework-json-v1.ts +5 -325
- package/src/runtime/messaging/packet-name.ts +5 -25
- package/src/runtime/messaging/request-result.ts +58 -0
- package/src/runtime/messaging/submission-result.ts +7 -3
- package/src/runtime/protocol/service_wire_codec.generated.ts +131 -1
- package/src/runtime/protocol/service_wire_pilot_codec.generated.ts +4 -4
- package/src/runtime/spots/formal-remote-actor-admission-registry.ts +45 -23
- package/src/runtime/spots/index.ts +30 -2
- package/src/runtime/spots/spot-activation.ts +33 -10
- package/src/runtime/spots/spot-actor-admission-coordinator.ts +13 -0
- package/src/runtime/spots/spot-actor-packet-dispatch.ts +10 -0
- package/src/runtime/spots/spot-actor-packet-drain.ts +2 -0
- package/src/runtime/spots/spot-actor-packet-relay-dispatch.ts +1 -0
- package/src/runtime/spots/spot-entry-activation.ts +12 -2
- package/src/runtime/spots/spot-handler-registry.ts +41 -8
- package/src/runtime/spots/spot-node-autoconnect.ts +6 -2
- package/src/runtime/spots/spot-node-runtime-manager.ts +7 -12
- package/src/runtime/spots/spot-outbound.ts +36 -16
- package/src/runtime/spots/spot-routed-spot-packet-dispatch.ts +2 -1
- package/src/runtime/spots/spot-routing-internal.ts +14 -0
- package/src/runtime/spots/spot-runtime-ports.ts +3 -0
- package/src/runtime/spots/spot-subscription-dispatch.ts +0 -3
- package/src/runtime/spots/spot-timer.ts +5 -1
- package/src/runtime/streams/stream-session-runtime.ts +13 -30
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.DefaultZLinkActorClient = void 0;
|
|
4
4
|
exports.forwardEncodedActorPacket = forwardEncodedActorPacket;
|
|
5
5
|
const stream_wire_1 = require("@zlink-systems/stream-wire");
|
|
6
|
+
const request_result_1 = require("../messaging/request-result");
|
|
6
7
|
const contracts_1 = require("../../contracts");
|
|
7
8
|
const CoreTypes_1 = require("../../contracts/Common/CoreTypes");
|
|
8
9
|
const abort_1 = require("../abort");
|
|
@@ -32,7 +33,7 @@ class DefaultZLinkActorClient {
|
|
|
32
33
|
}
|
|
33
34
|
requestToActor(actorId, request) {
|
|
34
35
|
requireActorId(actorId);
|
|
35
|
-
return new DefaultZLinkActorRequestCall((packetName, timeoutMs, metadata, signal) => this.request(actorId, packetName, request, timeoutMs, metadata, signal, 'async'), (packetName, timeoutMs, metadata, signal) => this.request(actorId, packetName, request, timeoutMs, metadata, signal, 'yield'), actorId, request, this.options.defaultRequestTimeoutMs);
|
|
36
|
+
return new DefaultZLinkActorRequestCall((packetName, timeoutMs, metadata, signal, onAdmitted) => this.request(actorId, packetName, request, timeoutMs, metadata, signal, 'async', onAdmitted), (packetName, timeoutMs, metadata, signal) => this.request(actorId, packetName, request, timeoutMs, metadata, signal, 'yield'), actorId, request, this.options.defaultRequestTimeoutMs);
|
|
36
37
|
}
|
|
37
38
|
async send(actorId, explicitPacketName, message, metadata) {
|
|
38
39
|
const route = await this.resolveActorRoute(actorId);
|
|
@@ -82,7 +83,7 @@ class DefaultZLinkActorClient {
|
|
|
82
83
|
closeMessages(parts);
|
|
83
84
|
}
|
|
84
85
|
}
|
|
85
|
-
async request(actorId, explicitPacketName, request, timeoutMs, metadata, signal, waitPolicy = 'async') {
|
|
86
|
+
async request(actorId, explicitPacketName, request, timeoutMs, metadata, signal, waitPolicy = 'async', onAdmitted) {
|
|
86
87
|
(0, abort_1.throwIfAborted)(signal);
|
|
87
88
|
const sourceSpotId = (0, actor_execution_context_1.currentZLinkActorExecution)()?.spotId ?? (0, execution_1.currentZLinkSpotSerialSourceId)();
|
|
88
89
|
const effectiveTimeoutMs = timeoutMs ?? this.options.defaultRequestTimeoutMs;
|
|
@@ -109,18 +110,18 @@ class DefaultZLinkActorClient {
|
|
|
109
110
|
const submissionCopies = delivery === undefined
|
|
110
111
|
? 1
|
|
111
112
|
: ((await (0, actor_request_deadline_1.waitActorReply)(delivery, actorId, deadlineMs, signal)) ?? 1);
|
|
112
|
-
const handoff = this.options.handoffCapture?.(meshName, actor.actorId, parts, true, routedActor, deadlineUnixMs);
|
|
113
|
+
const handoff = this.options.handoffCapture?.(meshName, actor.actorId, parts, true, routedActor, deadlineUnixMs, onAdmitted);
|
|
113
114
|
if (handoff !== undefined) {
|
|
114
115
|
const submissions = [handoff];
|
|
115
116
|
for (let copy = 1; copy < submissionCopies; copy++) {
|
|
116
|
-
const duplicate = this.options.handoffCapture?.(meshName, actor.actorId, parts, true, routedActor, deadlineUnixMs);
|
|
117
|
+
const duplicate = this.options.handoffCapture?.(meshName, actor.actorId, parts, true, routedActor, deadlineUnixMs, onAdmitted);
|
|
117
118
|
if (duplicate !== undefined)
|
|
118
119
|
submissions.push(duplicate);
|
|
119
120
|
}
|
|
120
121
|
const replies = await (0, actor_request_deadline_1.waitActorReply)(Promise.all(submissions), actorId, deadlineMs, signal);
|
|
121
122
|
return replies[0];
|
|
122
123
|
}
|
|
123
|
-
return await this.submitActorRequest(meshName, toBackendActorRef(actor), parts, (0, actor_request_deadline_1.remainingActorRequestTimeout)(actorId, deadlineMs), signal, route, messageFollow);
|
|
124
|
+
return await this.submitActorRequest(meshName, toBackendActorRef(actor), parts, (0, actor_request_deadline_1.remainingActorRequestTimeout)(actorId, deadlineMs), signal, route, messageFollow, onAdmitted);
|
|
124
125
|
}
|
|
125
126
|
catch (error) {
|
|
126
127
|
if (isStaleActorError(error)) {
|
|
@@ -204,7 +205,7 @@ class DefaultZLinkActorClient {
|
|
|
204
205
|
throw mapSubmitError(error, 'Actor send');
|
|
205
206
|
}
|
|
206
207
|
}
|
|
207
|
-
async submitActorRequest(meshName, actor, parts, timeoutMs, signal, route, messageFollowContext) {
|
|
208
|
+
async submitActorRequest(meshName, actor, parts, timeoutMs, signal, route, messageFollowContext, onAdmitted) {
|
|
208
209
|
const node = this.requireNode(meshName);
|
|
209
210
|
if (this.options.routeTransport !== undefined &&
|
|
210
211
|
String(node.status().routingId) !== String(actor.nodeRid) &&
|
|
@@ -228,7 +229,7 @@ class DefaultZLinkActorClient {
|
|
|
228
229
|
returnResponse: true,
|
|
229
230
|
messageFollowContext
|
|
230
231
|
});
|
|
231
|
-
const reply = await (0, actor_routed_json_request_1.requestRoutedJsonReply)(this.options.routeTransport, remoteActorRouteTarget(route), relay, { timeoutMs, signal }, `Remote Actor request is not available for '${actor.actorId}'.`, (replyParts) => JSON.parse(replyParts[0]?.getString('utf8') ?? '{}'));
|
|
232
|
+
const reply = await (0, actor_routed_json_request_1.requestRoutedJsonReply)(this.options.routeTransport, remoteActorRouteTarget(route), relay, { timeoutMs, signal, onAdmitted }, `Remote Actor request is not available for '${actor.actorId}'.`, (replyParts) => JSON.parse(replyParts[0]?.getString('utf8') ?? '{}'));
|
|
232
233
|
if (reply.ok !== true) {
|
|
233
234
|
throw (0, framework_errors_internal_1.createInternalFrameworkException)(remoteRelayErrorKind(reply.errorKind), typeof reply.error === 'string'
|
|
234
235
|
? reply.error
|
|
@@ -242,7 +243,8 @@ class DefaultZLinkActorClient {
|
|
|
242
243
|
}
|
|
243
244
|
const completion = await completions.submit(() => node.requestToActor(actor, toMessageLikeParts(parts), {
|
|
244
245
|
flags: runtime_values_1.ZLINK_BACKEND_SEND_NONE,
|
|
245
|
-
timeoutMs
|
|
246
|
+
timeoutMs,
|
|
247
|
+
onAdmitted
|
|
246
248
|
}), signal);
|
|
247
249
|
if (completion.terminalResult !== runtime_values_1.RequestResult.Ok) {
|
|
248
250
|
(0, backend_1.closeMeshCompletion)(completion);
|
|
@@ -405,7 +407,8 @@ class DefaultZLinkActorRequestCall {
|
|
|
405
407
|
return this;
|
|
406
408
|
}
|
|
407
409
|
submit(signal) {
|
|
408
|
-
|
|
410
|
+
this.rejectSelfActorRequest();
|
|
411
|
+
return (0, request_result_1.createZLinkRequest)((onAdmitted) => this.execute('async', signal, onAdmitted));
|
|
409
412
|
}
|
|
410
413
|
yield(signal) {
|
|
411
414
|
this.rejectSelfActorRequest();
|
|
@@ -413,13 +416,12 @@ class DefaultZLinkActorRequestCall {
|
|
|
413
416
|
const pending = this.execute('yield', signal);
|
|
414
417
|
return turn.yieldPromise(pending);
|
|
415
418
|
}
|
|
416
|
-
execute(waitPolicy, signal) {
|
|
419
|
+
execute(waitPolicy, signal, onAdmitted) {
|
|
417
420
|
ensureSingleSubmit(this.executed);
|
|
418
|
-
this.rejectSelfActorRequest();
|
|
419
421
|
this.executed = true;
|
|
420
422
|
(0, abort_1.throwIfAborted)(signal);
|
|
421
423
|
const submitter = waitPolicy === 'async' ? this.asyncSubmitter : this.yieldSubmitter;
|
|
422
|
-
return submitter(this.packet ?? (0, packet_name_1.resolveFrameworkPacketName)(this.request, undefined, 'Actor'), this.timeoutMs ?? this.defaultRequestTimeoutMs, this.selectedMetadata, signal);
|
|
424
|
+
return submitter(this.packet ?? (0, packet_name_1.resolveFrameworkPacketName)(this.request, undefined, 'Actor'), this.timeoutMs ?? this.defaultRequestTimeoutMs, this.selectedMetadata, signal, onAdmitted);
|
|
423
425
|
}
|
|
424
426
|
rejectSelfActorRequest() {
|
|
425
427
|
const current = (0, actor_execution_context_1.currentZLinkActorExecution)();
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { type ActorRef, type RoutingId } from '../../contracts';
|
|
2
2
|
import type { Message } from '../../contracts/Common/Message';
|
|
3
|
+
import type { ApplicationJobOrigin } from '../application-jobs/contracts';
|
|
3
4
|
import type { ZLinkMessageFollowOrigin } from '../foundation/service-runtime-contracts';
|
|
4
5
|
import { ZLinkFrameworkInternalErrorKind } from '../framework-errors-internal';
|
|
5
6
|
import type { ZLinkSpotRouteTarget } from '../spots/spot-routing-internal';
|
|
@@ -56,7 +57,7 @@ export interface ZLinkActorHandoffPreparedReplayAdmission {
|
|
|
56
57
|
run<T>(operation: () => Promise<T>): Promise<T>;
|
|
57
58
|
cancel(): void;
|
|
58
59
|
}
|
|
59
|
-
export type ZLinkActorHandoffReplayPreparation = (signal: AbortSignal) => Promise<ZLinkActorHandoffPreparedReplayAdmission>;
|
|
60
|
+
export type ZLinkActorHandoffReplayPreparation = (signal: AbortSignal, origin: ApplicationJobOrigin) => Promise<ZLinkActorHandoffPreparedReplayAdmission>;
|
|
60
61
|
export interface ZLinkActorHandoffPrefixAdmission {
|
|
61
62
|
/** Completes after every child callback reaches its real terminal. */
|
|
62
63
|
readonly terminal: Promise<void>;
|
|
@@ -141,7 +142,7 @@ export declare class ZLinkActorHandoffCoordinator {
|
|
|
141
142
|
*/
|
|
142
143
|
failPending(actorId: string, reason: unknown): void;
|
|
143
144
|
cancel(actorId: string): void;
|
|
144
|
-
capture(actorId: string, parts: readonly Message[], returnResponse?: boolean, remoteBoundSessionTarget?: ZLinkRemoteBoundSessionTarget, fallbackActorRef?: ActorRef, deadlineUnixMs?: number, messageFollowOrigin?: ZLinkMessageFollowOrigin, provisionalReplay?: ZLinkActorHandoffDispatch): Promise<unknown> | undefined;
|
|
145
|
+
capture(origin: ApplicationJobOrigin, actorId: string, parts: readonly Message[], returnResponse?: boolean, remoteBoundSessionTarget?: ZLinkRemoteBoundSessionTarget, fallbackActorRef?: ActorRef, deadlineUnixMs?: number, messageFollowOrigin?: ZLinkMessageFollowOrigin, provisionalReplay?: ZLinkActorHandoffDispatch, onAdmitted?: () => void): Promise<unknown> | undefined;
|
|
145
146
|
snapshot(actorId: string): readonly ZLinkActorHandoffPacket[];
|
|
146
147
|
snapshotCoreBacklog(actorId: string): readonly ZLinkActorHandoffPacket[];
|
|
147
148
|
/**
|
|
@@ -247,7 +247,7 @@ class ZLinkActorHandoffCoordinator {
|
|
|
247
247
|
try {
|
|
248
248
|
await waitForHandoffReplayStart(release.start, signal);
|
|
249
249
|
if (release.preparation !== undefined) {
|
|
250
|
-
const next = await release.preparation(signal);
|
|
250
|
+
const next = await release.preparation(signal, pending.origin);
|
|
251
251
|
if (signal.aborted) {
|
|
252
252
|
next.cancel();
|
|
253
253
|
throw signal.reason;
|
|
@@ -422,7 +422,7 @@ class ZLinkActorHandoffCoordinator {
|
|
|
422
422
|
pending.reject?.(error);
|
|
423
423
|
}
|
|
424
424
|
}
|
|
425
|
-
capture(actorId, parts, returnResponse = false, remoteBoundSessionTarget, fallbackActorRef, deadlineUnixMs, messageFollowOrigin, provisionalReplay) {
|
|
425
|
+
capture(origin, actorId, parts, returnResponse = false, remoteBoundSessionTarget, fallbackActorRef, deadlineUnixMs, messageFollowOrigin, provisionalReplay, onAdmitted) {
|
|
426
426
|
const incomingContext = (0, actor_message_follow_context_1.actorMessageFollowContext)(fallbackActorRef);
|
|
427
427
|
const originalDeadlineUnixMs = deadlineUnixMs ?? incomingContext?.deadlineUnixMs ?? packetDeadlineUnixMs(parts);
|
|
428
428
|
const handoff = this.active.get(actorId);
|
|
@@ -456,7 +456,7 @@ class ZLinkActorHandoffCoordinator {
|
|
|
456
456
|
this.reportRequestFrame(actorId, packet);
|
|
457
457
|
}
|
|
458
458
|
if (!returnResponse) {
|
|
459
|
-
handoff.pending.push({ packet });
|
|
459
|
+
handoff.pending.push({ packet, origin });
|
|
460
460
|
// The durable handoff now owns this record. Return the ingress permit
|
|
461
461
|
// before waiting for a later replay, which must acquire its own fresh
|
|
462
462
|
// application-job permit.
|
|
@@ -494,9 +494,15 @@ class ZLinkActorHandoffCoordinator {
|
|
|
494
494
|
}, RELOCATION_REPLY_RETENTION_MS);
|
|
495
495
|
route.deadline.unref();
|
|
496
496
|
this.replyRoutes.set(source.replyRouteId, route);
|
|
497
|
-
handoff.pending.push({
|
|
497
|
+
handoff.pending.push({
|
|
498
|
+
packet: requestPacket,
|
|
499
|
+
origin,
|
|
500
|
+
resolve,
|
|
501
|
+
reject
|
|
502
|
+
});
|
|
498
503
|
});
|
|
499
504
|
(0, application_job_queue_scope_1.releaseApplicationJobPermitForDurableHandoff)();
|
|
505
|
+
onAdmitted?.();
|
|
500
506
|
if (handoff.prefixRelease !== undefined) {
|
|
501
507
|
try {
|
|
502
508
|
this.admitPendingPrefix(actorId, handoff, handoff.prefixRelease);
|
|
@@ -530,7 +536,7 @@ class ZLinkActorHandoffCoordinator {
|
|
|
530
536
|
return Promise.reject(actorLocationStale(actorId));
|
|
531
537
|
}
|
|
532
538
|
const packet = encodePacket(0, parts, returnResponse, remoteBoundSessionTarget, fallbackActorRef, incomingContext, messageFollowOrigin);
|
|
533
|
-
return this.enqueueMessageFollow(followRoute, actorId, packet);
|
|
539
|
+
return this.enqueueMessageFollow(followRoute, actorId, packet, onAdmitted);
|
|
534
540
|
}
|
|
535
541
|
this.options.onMarker?.('message_follow_rejected', actorId);
|
|
536
542
|
return Promise.reject(actorLocationStale(actorId));
|
|
@@ -576,7 +582,7 @@ class ZLinkActorHandoffCoordinator {
|
|
|
576
582
|
return Promise.reject(error);
|
|
577
583
|
}
|
|
578
584
|
const packet = encodePacket(0, parts, returnResponse, remoteBoundSessionTarget, fallbackActorRef, context, messageFollowOrigin);
|
|
579
|
-
return this.enqueueMessageFollow(followRoute, actorId, packet);
|
|
585
|
+
return this.enqueueMessageFollow(followRoute, actorId, packet, onAdmitted);
|
|
580
586
|
}
|
|
581
587
|
snapshot(actorId) {
|
|
582
588
|
const handoff = this.requireActive(actorId);
|
|
@@ -927,7 +933,7 @@ class ZLinkActorHandoffCoordinator {
|
|
|
927
933
|
}
|
|
928
934
|
return undefined;
|
|
929
935
|
}
|
|
930
|
-
enqueueMessageFollow(entry, actorId, packet) {
|
|
936
|
+
enqueueMessageFollow(entry, actorId, packet, onAdmitted) {
|
|
931
937
|
const context = packet.messageFollowContext;
|
|
932
938
|
const duplicate = entry.operations.get(context.operationId);
|
|
933
939
|
if (duplicate !== undefined) {
|
|
@@ -937,6 +943,7 @@ class ZLinkActorHandoffCoordinator {
|
|
|
937
943
|
this.options.onMarker?.('message_follow_rejected', actorId);
|
|
938
944
|
return Promise.reject(actorLocationStale(actorId));
|
|
939
945
|
}
|
|
946
|
+
onAdmitted?.();
|
|
940
947
|
return duplicate.result;
|
|
941
948
|
}
|
|
942
949
|
const bytes = packetBytes(packet);
|
|
@@ -958,6 +965,7 @@ class ZLinkActorHandoffCoordinator {
|
|
|
958
965
|
replyRouteId: context.replyRouteId,
|
|
959
966
|
result
|
|
960
967
|
});
|
|
968
|
+
onAdmitted?.();
|
|
961
969
|
entry.tail = entry.tail.then(async () => {
|
|
962
970
|
try {
|
|
963
971
|
resolve(await this.relayMessageFollow(actorId, entry, packet));
|
|
@@ -29,6 +29,7 @@ export interface ZLinkActorJoinRelocation {
|
|
|
29
29
|
};
|
|
30
30
|
/** Target's advertised relocation state chunk cap from the accepted admission reply. */
|
|
31
31
|
readonly advertisedReceiveChunkLimitBytes?: number;
|
|
32
|
+
readonly deadlineAtMs?: number;
|
|
32
33
|
readonly signal?: AbortSignal;
|
|
33
34
|
}): Promise<{
|
|
34
35
|
readonly actorRef: ZLinkBackendActorRef;
|
|
@@ -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
|
}),
|
|
@@ -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());
|
|
@@ -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>;
|
|
@@ -51,7 +51,8 @@ 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
|
-
|
|
54
|
+
releaseSpotActorMembers(meshName: string, spotId?: RoutingId): Promise<void>;
|
|
55
|
+
private releaseLocalActor;
|
|
55
56
|
completeCoreRelocationSource(actorId: string): Promise<void>;
|
|
56
57
|
private finalizeActorState;
|
|
57
58
|
private finalizeDestroyedActor;
|
|
@@ -118,7 +118,7 @@ class DefaultZLinkActorManager {
|
|
|
118
118
|
const actorRef = this.actorRefForState(state);
|
|
119
119
|
return {
|
|
120
120
|
spotId: spotId,
|
|
121
|
-
objectGeneration: state.
|
|
121
|
+
objectGeneration: state.spotGeneration ?? 0n,
|
|
122
122
|
meshName: this.actorMeshNames.get(actorId) ?? '',
|
|
123
123
|
nodeRid: actorRef.nodeRid
|
|
124
124
|
};
|
|
@@ -302,7 +302,7 @@ class DefaultZLinkActorManager {
|
|
|
302
302
|
}
|
|
303
303
|
state.setLocationGeneration(authorityOwnerGeneration);
|
|
304
304
|
if (spotId !== undefined)
|
|
305
|
-
state.setJoinedSpot(spotId, undefined, membershipEpoch);
|
|
305
|
+
state.setJoinedSpot(spotId, undefined, membershipEpoch, spotGeneration);
|
|
306
306
|
return actor;
|
|
307
307
|
}
|
|
308
308
|
catch (error) {
|
|
@@ -321,12 +321,24 @@ class DefaultZLinkActorManager {
|
|
|
321
321
|
this.relocationStaged.delete(actorId);
|
|
322
322
|
}
|
|
323
323
|
async abortRelocationActor(actorId) {
|
|
324
|
-
await this.
|
|
324
|
+
await this.releaseLocalActor(actorId);
|
|
325
325
|
}
|
|
326
326
|
async completeRelocationSource(actorId, sourceActorRef) {
|
|
327
|
-
await this.
|
|
328
|
-
}
|
|
329
|
-
async
|
|
327
|
+
await this.releaseLocalActor(actorId, sourceActorRef);
|
|
328
|
+
}
|
|
329
|
+
async releaseSpotActorMembers(meshName, spotId) {
|
|
330
|
+
const results = await Promise.allSettled([...this.states.values()]
|
|
331
|
+
.filter((state) => state.meshName === meshName && state.spotId === spotId)
|
|
332
|
+
.map((state) => this.releaseLocalActor(state.actorId)));
|
|
333
|
+
const errors = results
|
|
334
|
+
.filter((result) => result.status === 'rejected')
|
|
335
|
+
.map((result) => result.reason);
|
|
336
|
+
if (errors.length === 1)
|
|
337
|
+
throw errors[0];
|
|
338
|
+
if (errors.length > 1)
|
|
339
|
+
throw new AggregateError(errors, 'Actor member cleanup failed.');
|
|
340
|
+
}
|
|
341
|
+
async releaseLocalActor(actorId, exactNativeActorRef) {
|
|
330
342
|
const state = this.states.get(actorId);
|
|
331
343
|
const node = this.options.nativeActorNodeProvider?.() ?? this.options.nativeActorNode;
|
|
332
344
|
const nativeActorRef = exactNativeActorRef ?? state?.nativeActorRef;
|
|
@@ -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') &&
|
|
@@ -16,7 +16,7 @@ export declare class ZLinkRuntimeAdmissionGate {
|
|
|
16
16
|
seal(meshName: string, reason?: ZLinkFrameworkInternalErrorKind): void;
|
|
17
17
|
close(): void;
|
|
18
18
|
claim(meshName: string, operation: string): ZLinkApplicationWorkClaim;
|
|
19
|
-
run<T>(meshName: string, operation: string, work: () => Promise<T>): Promise<T>;
|
|
19
|
+
run<T>(meshName: string, operation: string, work: () => T | Promise<T>): Promise<T>;
|
|
20
20
|
awaitZero(meshName: string, signal?: AbortSignal): Promise<void>;
|
|
21
21
|
requireRequest(operation: string, meshName?: string): void;
|
|
22
22
|
requireActorCreate(actorId: string, meshName?: string): void;
|
|
@@ -77,13 +77,23 @@ class ZLinkRuntimeAdmissionGate {
|
|
|
77
77
|
}
|
|
78
78
|
throw (0, framework_errors_internal_1.createInternalFrameworkException)(state.sealedReason, `${operation} was rejected because framework admission is closed.`);
|
|
79
79
|
}
|
|
80
|
-
|
|
81
|
-
|
|
80
|
+
run(meshName, operation, work) {
|
|
81
|
+
let claim;
|
|
82
82
|
try {
|
|
83
|
-
|
|
83
|
+
claim = this.claim(meshName, operation);
|
|
84
|
+
const result = work();
|
|
85
|
+
const close = claim.close;
|
|
86
|
+
return Promise.resolve(result).then((value) => {
|
|
87
|
+
close();
|
|
88
|
+
return value;
|
|
89
|
+
}, (error) => {
|
|
90
|
+
close();
|
|
91
|
+
throw error;
|
|
92
|
+
});
|
|
84
93
|
}
|
|
85
|
-
|
|
86
|
-
claim
|
|
94
|
+
catch (error) {
|
|
95
|
+
claim?.close();
|
|
96
|
+
return Promise.reject(error);
|
|
87
97
|
}
|
|
88
98
|
}
|
|
89
99
|
awaitZero(meshName, signal) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ApplicationJobPermitPort, ApplicationJobQueuePort } from './contracts';
|
|
1
|
+
import type { ApplicationJobOrigin, ApplicationJobPermitPort, ApplicationJobQueuePort } from './contracts';
|
|
2
2
|
export type ApplicationJobRecordDomain = 'application' | 'infrastructure';
|
|
3
3
|
export interface IngressRecordPort {
|
|
4
4
|
close(): void;
|
|
@@ -10,32 +10,31 @@ export interface IngressRecordPort {
|
|
|
10
10
|
*/
|
|
11
11
|
export declare class ApplicationIngressRecordOwner {
|
|
12
12
|
private readonly shared;
|
|
13
|
-
private
|
|
13
|
+
private stop?;
|
|
14
14
|
private closed;
|
|
15
15
|
private constructor();
|
|
16
16
|
static create(queue: ApplicationJobQueuePort, initialPermit: ApplicationJobPermitPort, record: IngressRecordPort): ApplicationIngressRecordOwner;
|
|
17
17
|
retain(): ApplicationIngressRecordOwner;
|
|
18
18
|
takeInitial(domain: ApplicationJobRecordDomain): ApplicationJobRecordLease;
|
|
19
|
-
acquire(domain: ApplicationJobRecordDomain, signal?: AbortSignal): Promise<ApplicationJobRecordLease>;
|
|
19
|
+
acquire(domain: ApplicationJobRecordDomain, signal?: AbortSignal): ApplicationJobRecordLease | Promise<ApplicationJobRecordLease>;
|
|
20
|
+
private acquireAdditional;
|
|
20
21
|
close(): void;
|
|
21
22
|
private requireOpen;
|
|
22
23
|
}
|
|
23
24
|
/** Queue-permit child of one shared raw ingress record. */
|
|
24
25
|
export declare class ApplicationJobRecordLease implements ApplicationJobPermitPort {
|
|
25
26
|
private readonly shared;
|
|
26
|
-
private
|
|
27
|
+
private permit;
|
|
27
28
|
private ingressClosed;
|
|
28
|
-
private permitReleased;
|
|
29
29
|
private processingTerminal;
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
30
|
+
detachedForHandlerTurn: boolean;
|
|
31
|
+
constructor(shared: SharedIngressRecordState, permit: ApplicationJobPermitPort | undefined);
|
|
32
|
+
get origin(): ApplicationJobOrigin;
|
|
33
33
|
markApplicationQueued(): void;
|
|
34
34
|
detachForHandlerTurn(): void;
|
|
35
35
|
releaseBeforeHandler(): void;
|
|
36
36
|
releaseAfterInternalProcessing(): void;
|
|
37
37
|
close(): void;
|
|
38
|
-
private releasePermit;
|
|
39
38
|
private releaseJobIfTerminal;
|
|
40
39
|
}
|
|
41
40
|
declare class SharedIngressRecordState {
|
|
@@ -45,6 +44,7 @@ declare class SharedIngressRecordState {
|
|
|
45
44
|
private jobCount;
|
|
46
45
|
private initialPermit?;
|
|
47
46
|
private recordClosed;
|
|
47
|
+
readonly origin: ApplicationJobOrigin;
|
|
48
48
|
constructor(queue: ApplicationJobQueuePort, initialPermit: ApplicationJobPermitPort, record: IngressRecordPort);
|
|
49
49
|
retainOwner(): void;
|
|
50
50
|
releaseOwner(): void;
|