@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
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ZLinkNodeRawMeshBackend = void 0;
|
|
4
4
|
exports.requestFailureResult = requestFailureResult;
|
|
5
|
+
const durable_service_request_1 = require("../../foundation/durable-service-request");
|
|
5
6
|
const stream_wire_1 = require("@zlink-systems/stream-wire");
|
|
6
7
|
const zlink_1 = require("@zlink-systems/zlink");
|
|
7
8
|
const node_crypto_1 = require("node:crypto");
|
|
@@ -12,7 +13,6 @@ const EndpointNotation_1 = require("../../../contracts/Configuration/EndpointNot
|
|
|
12
13
|
const InternalDefaults_1 = require("../../../contracts/Configuration/InternalDefaults");
|
|
13
14
|
const Registration_1 = require("../../../contracts/Configuration/Registration");
|
|
14
15
|
const RegistrationBuilderPolicy_1 = require("../../../contracts/Configuration/RegistrationBuilderPolicy");
|
|
15
|
-
const admission_1 = require("../../admission");
|
|
16
16
|
const operation_identity_1 = require("../../foundation/operation-identity");
|
|
17
17
|
const operation_registry_1 = require("../../foundation/operation-registry");
|
|
18
18
|
const raw_service_mesh_runtime_1 = require("../../foundation/raw-service-mesh-runtime");
|
|
@@ -58,12 +58,11 @@ class ZLinkNodeRawMeshBackend {
|
|
|
58
58
|
applicationJobQueue;
|
|
59
59
|
applicationJobReceiveFlowFailureSink;
|
|
60
60
|
peerAdmissionSealed;
|
|
61
|
+
infrastructureTaskRunner;
|
|
61
62
|
nativeInstance = this;
|
|
62
63
|
channels = new Map();
|
|
63
64
|
peerIntents = new Map();
|
|
64
|
-
|
|
65
|
-
completionHead = 0;
|
|
66
|
-
completionCount = 0;
|
|
65
|
+
completionHandler;
|
|
67
66
|
routingId;
|
|
68
67
|
lifecycleGeneration;
|
|
69
68
|
bindEndpoint;
|
|
@@ -107,12 +106,13 @@ class ZLinkNodeRawMeshBackend {
|
|
|
107
106
|
messageFollowHandler;
|
|
108
107
|
dispatchErrors;
|
|
109
108
|
peerDisconnectedHandlers = new Set();
|
|
110
|
-
constructor(meshName, routingId, bindingPort, applicationJobQueue, applicationJobReceiveFlowFailureSink, peerAdmissionSealed) {
|
|
109
|
+
constructor(meshName, routingId, bindingPort, applicationJobQueue, applicationJobReceiveFlowFailureSink, peerAdmissionSealed, infrastructureTaskRunner) {
|
|
111
110
|
this.meshName = meshName;
|
|
112
111
|
this.bindingPort = bindingPort;
|
|
113
112
|
this.applicationJobQueue = applicationJobQueue;
|
|
114
113
|
this.applicationJobReceiveFlowFailureSink = applicationJobReceiveFlowFailureSink;
|
|
115
114
|
this.peerAdmissionSealed = peerAdmissionSealed;
|
|
115
|
+
this.infrastructureTaskRunner = infrastructureTaskRunner;
|
|
116
116
|
if (meshName.length === 0)
|
|
117
117
|
throw new TypeError('MeshName must be non-empty.');
|
|
118
118
|
if (routingId === undefined || routingId.length === 0) {
|
|
@@ -169,8 +169,8 @@ class ZLinkNodeRawMeshBackend {
|
|
|
169
169
|
const result = await this.requireStateful().sendToMissingInstanceSpotFrame(target, encodeMultipartApplicationFrame(parts), deadlineUnixMs, sourceSpotId, metadata === undefined ? undefined : (0, service_metadata_codec_1.encodeServiceMetadataFrame)(metadata));
|
|
170
170
|
return result;
|
|
171
171
|
}
|
|
172
|
-
requestToMissingInstanceSpot(target, parts, deadlineUnixMs, sourceSpotId, metadata) {
|
|
173
|
-
return this.observeStateful(service_runtime_contracts_1.OperationKind.InstanceSpotRequest, this.requireStateful().requestToMissingInstanceSpotFrame(target, encodeMultipartApplicationFrame(parts), deadlineUnixMs, sourceSpotId, metadata === undefined ? undefined : (0, service_metadata_codec_1.encodeServiceMetadataFrame)(metadata)));
|
|
172
|
+
requestToMissingInstanceSpot(target, parts, deadlineUnixMs, sourceSpotId, metadata, onAdmitted) {
|
|
173
|
+
return this.observeStateful(service_runtime_contracts_1.OperationKind.InstanceSpotRequest, this.requireStateful().requestToMissingInstanceSpotFrame(target, encodeMultipartApplicationFrame(parts), deadlineUnixMs, sourceSpotId, metadata === undefined ? undefined : (0, service_metadata_codec_1.encodeServiceMetadataFrame)(metadata), onAdmitted));
|
|
174
174
|
}
|
|
175
175
|
setRoutingId(routingId) {
|
|
176
176
|
if (String(routingId) !== this.routingId) {
|
|
@@ -203,6 +203,8 @@ class ZLinkNodeRawMeshBackend {
|
|
|
203
203
|
resolveAdvertisedEndpoint: (boundEndpoint) => this.resolveAdvertisedEndpoint(boundEndpoint),
|
|
204
204
|
bindingPort: this.bindingPort,
|
|
205
205
|
applicationJobQueue: this.requireApplicationJobQueue(),
|
|
206
|
+
onReceiveReady: () => this.onReadable(true, false),
|
|
207
|
+
infrastructureTaskRunner: this.infrastructureTaskRunner,
|
|
206
208
|
peerAdmissionSealed: this.peerAdmissionSealed,
|
|
207
209
|
onReceiveFlowConfigFailure: this.applicationJobReceiveFlowFailureSink,
|
|
208
210
|
onMailboxReady: (domain) => this.readyHandler?.(domain === 'application' ? service_runtime_contracts_1.ReadyDomain.Application : service_runtime_contracts_1.ReadyDomain.Infrastructure),
|
|
@@ -220,13 +222,7 @@ class ZLinkNodeRawMeshBackend {
|
|
|
220
222
|
}
|
|
221
223
|
}
|
|
222
224
|
},
|
|
223
|
-
onPeerDisconnected: (
|
|
224
|
-
for (const [intentId, peer] of this.peerIntents) {
|
|
225
|
-
if (peer.endpoint === endpoint &&
|
|
226
|
-
(peer.nodeRoutingId === undefined || peer.nodeRoutingId === nodeRoutingId)) {
|
|
227
|
-
this.peerIntents.delete(intentId);
|
|
228
|
-
}
|
|
229
|
-
}
|
|
225
|
+
onPeerDisconnected: (_nodeRoutingId, endpoint) => {
|
|
230
226
|
for (const handler of this.peerDisconnectedHandlers)
|
|
231
227
|
handler(endpoint);
|
|
232
228
|
}
|
|
@@ -275,7 +271,6 @@ class ZLinkNodeRawMeshBackend {
|
|
|
275
271
|
this.stateful = undefined;
|
|
276
272
|
this.runtime?.close();
|
|
277
273
|
this.runtime = undefined;
|
|
278
|
-
this.clearCompletions();
|
|
279
274
|
this.closed = true;
|
|
280
275
|
}
|
|
281
276
|
addChannelName(name) {
|
|
@@ -379,13 +374,28 @@ class ZLinkNodeRawMeshBackend {
|
|
|
379
374
|
isObjectClientNodeDirectTarget(targetRid) {
|
|
380
375
|
return this.requireRuntime().isObjectClientNodeDirectTarget(String(targetRid));
|
|
381
376
|
}
|
|
377
|
+
observePeerRoute(targetRid) {
|
|
378
|
+
return this.requireRuntime().observePeerRoute(String(targetRid));
|
|
379
|
+
}
|
|
380
|
+
hasPeerRouteOrConnectionIntent(targetRid, endpoint) {
|
|
381
|
+
const rid = String(targetRid);
|
|
382
|
+
if (this.requireRuntime().hasSelectedPeerRoute(rid))
|
|
383
|
+
return true;
|
|
384
|
+
for (const intent of this.peerIntents.values()) {
|
|
385
|
+
if (intent.nodeRoutingId === rid ||
|
|
386
|
+
(intent.nodeRoutingId === undefined && intent.endpoint === endpoint))
|
|
387
|
+
return true;
|
|
388
|
+
}
|
|
389
|
+
return false;
|
|
390
|
+
}
|
|
382
391
|
isPeerRouteReady(targetRid, lifecycleGeneration) {
|
|
383
392
|
return this.requireRuntime().isPeerRouteReady(String(targetRid), lifecycleGeneration);
|
|
384
393
|
}
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
394
|
+
sendToNode(targetRid, parts) {
|
|
395
|
+
const submitted = this.requireRuntime().sendToNode(String(targetRid), encodeMultipartApplicationFrame(parts));
|
|
396
|
+
return submitted instanceof Promise
|
|
397
|
+
? submitted.then(nodeSendResult)
|
|
398
|
+
: nodeSendResult(submitted);
|
|
389
399
|
}
|
|
390
400
|
async sendInfrastructureControl(targetRid, record) {
|
|
391
401
|
return (await this.requireRuntime().sendService(String(targetRid), (Array.isArray(record) ? record : [record]).map((value) => Buffer.from(value))))
|
|
@@ -398,17 +408,17 @@ class ZLinkNodeRawMeshBackend {
|
|
|
398
408
|
: zlink_1.SubmitResult.NotConnected;
|
|
399
409
|
}
|
|
400
410
|
async requestInfrastructureControlFrames(targetRid, frames, options) {
|
|
401
|
-
return
|
|
411
|
+
return (0, durable_service_request_1.requestDurableService)(this.requireRuntime(), String(targetRid), frames, performance.now() + (options?.timeoutMs ?? Registration_1.DEFAULT_REQUEST_TIMEOUT_MS), 'relocation control', options?.signal, options?.onSubmitted);
|
|
402
412
|
}
|
|
403
413
|
requestToNode(targetRid, parts, options) {
|
|
404
|
-
const pending = this.requireRuntime().requestToNode(String(targetRid), encodeMultipartApplicationFrame(parts), options?.timeoutMs ?? Registration_1.DEFAULT_REQUEST_TIMEOUT_MS);
|
|
414
|
+
const pending = this.requireRuntime().requestToNode(String(targetRid), encodeMultipartApplicationFrame(parts), options?.timeoutMs ?? Registration_1.DEFAULT_REQUEST_TIMEOUT_MS, options?.onAdmitted);
|
|
405
415
|
return this.observeCompletion(pending.id, service_runtime_contracts_1.OperationKind.NodeRequest, pending.promise);
|
|
406
416
|
}
|
|
407
417
|
async sendToChannel(channelName, parts) {
|
|
408
418
|
return this.requireRuntime().sendToChannel(channelName, encodeMultipartApplicationFrame(parts));
|
|
409
419
|
}
|
|
410
420
|
requestToChannel(channelName, parts, options) {
|
|
411
|
-
const pending = this.requireRuntime().requestToChannel(channelName, encodeMultipartApplicationFrame(parts), options?.timeoutMs ?? Registration_1.DEFAULT_REQUEST_TIMEOUT_MS);
|
|
421
|
+
const pending = this.requireRuntime().requestToChannel(channelName, encodeMultipartApplicationFrame(parts), options?.timeoutMs ?? Registration_1.DEFAULT_REQUEST_TIMEOUT_MS, options?.onAdmitted);
|
|
412
422
|
return this.observeCompletion(pending.id, service_runtime_contracts_1.OperationKind.ChannelRequest, pending.promise);
|
|
413
423
|
}
|
|
414
424
|
status() {
|
|
@@ -426,7 +436,7 @@ class ZLinkNodeRawMeshBackend {
|
|
|
426
436
|
admittedPeerCount: peers.length,
|
|
427
437
|
drainingPeerCount: peers.filter((peer) => peer.descriptor.state === 'draining').length,
|
|
428
438
|
pendingApplicationMessages: BigInt(this.runtime?.mailbox.pendingMessages('application') ?? 0),
|
|
429
|
-
pendingInfrastructureMessages: BigInt(
|
|
439
|
+
pendingInfrastructureMessages: BigInt(this.runtime?.mailbox.pendingMessages('infrastructure') ?? 0),
|
|
430
440
|
pendingBytes: BigInt((this.runtime?.mailbox.pendingBytes('application') ?? 0) +
|
|
431
441
|
(this.runtime?.mailbox.pendingBytes('infrastructure') ?? 0)),
|
|
432
442
|
lastError: 0,
|
|
@@ -519,6 +529,9 @@ class ZLinkNodeRawMeshBackend {
|
|
|
519
529
|
}
|
|
520
530
|
};
|
|
521
531
|
}
|
|
532
|
+
setCompletionHandler(handler) {
|
|
533
|
+
this.completionHandler = handler;
|
|
534
|
+
}
|
|
522
535
|
setReadyHandler(handler) {
|
|
523
536
|
this.readyHandler = handler;
|
|
524
537
|
this.notifyReady();
|
|
@@ -532,7 +545,6 @@ class ZLinkNodeRawMeshBackend {
|
|
|
532
545
|
drainReady(domains, batch) {
|
|
533
546
|
const target = requireRawReadyBatch(batch);
|
|
534
547
|
if ((domains & service_runtime_contracts_1.ReadyDomain.Infrastructure) !== 0) {
|
|
535
|
-
this.drainCompletions(target);
|
|
536
548
|
this.drainMailbox('infrastructure', target);
|
|
537
549
|
}
|
|
538
550
|
if ((domains & service_runtime_contracts_1.ReadyDomain.Application) !== 0) {
|
|
@@ -540,7 +552,7 @@ class ZLinkNodeRawMeshBackend {
|
|
|
540
552
|
}
|
|
541
553
|
const runtime = this.runtime;
|
|
542
554
|
const infrastructureResidue = (domains & service_runtime_contracts_1.ReadyDomain.Infrastructure) !== 0 &&
|
|
543
|
-
(
|
|
555
|
+
(runtime?.mailbox.pendingMessages('infrastructure') ?? 0) > 0;
|
|
544
556
|
const applicationResidue = (domains & service_runtime_contracts_1.ReadyDomain.Application) !== 0 &&
|
|
545
557
|
(runtime?.mailbox.pendingMessages('application') ?? 0) > 0;
|
|
546
558
|
return {
|
|
@@ -664,8 +676,8 @@ class ZLinkNodeRawMeshBackend {
|
|
|
664
676
|
const result = await this.requireStateful().sendToInstanceSpot(route, encodeMultipart(parts), sourceSpotId, metadata === undefined ? undefined : (0, service_metadata_codec_1.encodeServiceMetadataFrame)(metadata), instanceIntent);
|
|
665
677
|
return result;
|
|
666
678
|
}
|
|
667
|
-
requestInstanceSpot(route, parts, timeoutMs = Registration_1.DEFAULT_REQUEST_TIMEOUT_MS, sourceSpotId, metadata, instanceIntent = false) {
|
|
668
|
-
return this.observeStateful(service_runtime_contracts_1.OperationKind.InstanceSpotRequest, this.requireStateful().requestToInstanceSpot(route, encodeMultipart(parts), timeoutMs, sourceSpotId, metadata === undefined ? undefined : (0, service_metadata_codec_1.encodeServiceMetadataFrame)(metadata), instanceIntent));
|
|
679
|
+
requestInstanceSpot(route, parts, timeoutMs = Registration_1.DEFAULT_REQUEST_TIMEOUT_MS, sourceSpotId, metadata, instanceIntent = false, onAdmitted) {
|
|
680
|
+
return this.observeStateful(service_runtime_contracts_1.OperationKind.InstanceSpotRequest, this.requireStateful().requestToInstanceSpot(route, encodeMultipart(parts), timeoutMs, sourceSpotId, metadata === undefined ? undefined : (0, service_metadata_codec_1.encodeServiceMetadataFrame)(metadata), instanceIntent, onAdmitted));
|
|
669
681
|
}
|
|
670
682
|
actorLookup(actorId) {
|
|
671
683
|
const actor = this.requireStateful().actor(actorId);
|
|
@@ -705,13 +717,13 @@ class ZLinkNodeRawMeshBackend {
|
|
|
705
717
|
return this.requireStateful().sendToActor(actor, this.peerGeneration(String(actor.nodeRid)), actor.generation, encodeMultipart(parts));
|
|
706
718
|
}
|
|
707
719
|
requestToActor(actor, parts, options) {
|
|
708
|
-
return this.observeStateful(service_runtime_contracts_1.OperationKind.ActorRequest, this.requireStateful().requestToActor(actor, this.peerGeneration(String(actor.nodeRid)), actor.generation, encodeMultipart(parts), options?.timeoutMs ?? Registration_1.DEFAULT_REQUEST_TIMEOUT_MS));
|
|
720
|
+
return this.observeStateful(service_runtime_contracts_1.OperationKind.ActorRequest, this.requireStateful().requestToActor(actor, this.peerGeneration(String(actor.nodeRid)), actor.generation, encodeMultipart(parts), options?.timeoutMs ?? Registration_1.DEFAULT_REQUEST_TIMEOUT_MS, undefined, undefined, options?.onAdmitted));
|
|
709
721
|
}
|
|
710
722
|
async actorSendToActor(source, target, parts) {
|
|
711
723
|
return (await this.requireStateful().sendToActor(target, this.peerGeneration(String(target.nodeRid)), target.generation, encodeMultipart(parts), source));
|
|
712
724
|
}
|
|
713
725
|
actorRequestToActor(source, target, parts, options) {
|
|
714
|
-
return this.observeStateful(service_runtime_contracts_1.OperationKind.ActorRequest, this.requireStateful().requestToActor(target, this.peerGeneration(String(target.nodeRid)), target.generation, encodeMultipart(parts), options?.timeoutMs ?? Registration_1.DEFAULT_REQUEST_TIMEOUT_MS, source));
|
|
726
|
+
return this.observeStateful(service_runtime_contracts_1.OperationKind.ActorRequest, this.requireStateful().requestToActor(target, this.peerGeneration(String(target.nodeRid)), target.generation, encodeMultipart(parts), options?.timeoutMs ?? Registration_1.DEFAULT_REQUEST_TIMEOUT_MS, source, undefined, options?.onAdmitted));
|
|
715
727
|
}
|
|
716
728
|
async sendActorBoundSession(actor, expectedBindingGeneration, parts, _flags) {
|
|
717
729
|
return (await this.requireStateful().sendBoundSession(actor, expectedBindingGeneration, encodeMultipart(parts)));
|
|
@@ -719,7 +731,7 @@ class ZLinkNodeRawMeshBackend {
|
|
|
719
731
|
closeActorBoundSession(actor, expectedBindingGeneration, timeoutMs = Registration_1.DEFAULT_REQUEST_TIMEOUT_MS) {
|
|
720
732
|
const binding = this.requireStateful().registry.binding(actor);
|
|
721
733
|
if (binding === undefined) {
|
|
722
|
-
return this.
|
|
734
|
+
return this.observeImmediateFailure(service_runtime_contracts_1.OperationKind.StreamUnbind, zlink_1.RequestResult.NotFound);
|
|
723
735
|
}
|
|
724
736
|
return this.observeStateful(service_runtime_contracts_1.OperationKind.StreamUnbind, this.requireStateful().unbindSession(binding.sessionRid, actor, expectedBindingGeneration, timeoutMs));
|
|
725
737
|
}
|
|
@@ -732,8 +744,8 @@ class ZLinkNodeRawMeshBackend {
|
|
|
732
744
|
async sendFromSpot(source, target, parts) {
|
|
733
745
|
return (await this.requireStateful().sendToSpot(source.ref.spotId, target, encodeMultipart(parts)));
|
|
734
746
|
}
|
|
735
|
-
requestFromSpot(source, target, parts, timeoutMs) {
|
|
736
|
-
return this.observeStateful(service_runtime_contracts_1.OperationKind.SpotRequest, this.requireStateful().requestToSpot(source.ref.spotId, target, encodeMultipart(parts), timeoutMs));
|
|
747
|
+
requestFromSpot(source, target, parts, timeoutMs, onAdmitted) {
|
|
748
|
+
return this.observeStateful(service_runtime_contracts_1.OperationKind.SpotRequest, this.requireStateful().requestToSpot(source.ref.spotId, target, encodeMultipart(parts), timeoutMs, onAdmitted));
|
|
737
749
|
}
|
|
738
750
|
closeSpot(state) {
|
|
739
751
|
return this.requireStateful().registry.closeSpot(state.ref);
|
|
@@ -742,6 +754,8 @@ class ZLinkNodeRawMeshBackend {
|
|
|
742
754
|
await this.requireStateful().publishLogicalMulticast(channelName, topic, encodeMultipart(parts), state.ref.spotId);
|
|
743
755
|
}
|
|
744
756
|
setSpotSubscription(state, channelName, topicFilter) {
|
|
757
|
+
if (!this.channels.has(channelName))
|
|
758
|
+
throw new contracts_1.ZLinkFrameworkException(contracts_1.ZLinkFrameworkErrorKind.InvalidOperation, `Spot does not participate in subscription channel '${channelName}'.`);
|
|
745
759
|
this.requireStateful().setSubscription(state, channelName, topicFilter);
|
|
746
760
|
}
|
|
747
761
|
unsetSpotSubscription(state, channelName, topicFilter) {
|
|
@@ -824,7 +838,7 @@ class ZLinkNodeRawMeshBackend {
|
|
|
824
838
|
notifyReady() {
|
|
825
839
|
const runtime = this.runtime;
|
|
826
840
|
let domains = service_runtime_contracts_1.ReadyDomain.None;
|
|
827
|
-
if (
|
|
841
|
+
if ((runtime?.mailbox.pendingMessages('infrastructure') ?? 0) > 0) {
|
|
828
842
|
domains |= service_runtime_contracts_1.ReadyDomain.Infrastructure;
|
|
829
843
|
}
|
|
830
844
|
if ((runtime?.mailbox.pendingMessages('application') ?? 0) > 0) {
|
|
@@ -835,61 +849,31 @@ class ZLinkNodeRawMeshBackend {
|
|
|
835
849
|
}
|
|
836
850
|
observeCompletion(low, operationKind, promise) {
|
|
837
851
|
const id = { high: 1n, low };
|
|
838
|
-
void promise.then((result) => this.
|
|
852
|
+
void promise.then((result) => this.deliverCompletion(id, operationKind, result), (error) => this.deliverCompletion(id, operationKind, requestFailureResult(error)));
|
|
839
853
|
return id;
|
|
840
854
|
}
|
|
841
855
|
observeStateful(operationKind, pending) {
|
|
842
856
|
const id = { high: operation_identity_1.ZLINK_NATIVE_CORRELATION_OPERATION_NAMESPACE, low: pending.id };
|
|
843
|
-
void pending.promise.then((result) => this.
|
|
857
|
+
void pending.promise.then((result) => this.deliverCompletion(id, operationKind, result), (error) => this.deliverCompletion(id, operationKind, requestFailureResult(error)));
|
|
844
858
|
return id;
|
|
845
859
|
}
|
|
846
|
-
|
|
860
|
+
observeImmediateFailure(operationKind, terminalResult) {
|
|
847
861
|
const low = this.nextPeerIntent++;
|
|
848
|
-
|
|
849
|
-
this.enqueueCompletion(id, operationKind, { terminalResult, failureCode: 0 });
|
|
850
|
-
return id;
|
|
862
|
+
return this.observeCompletion(low, operationKind, Promise.resolve({ terminalResult, failureCode: 0 }));
|
|
851
863
|
}
|
|
852
|
-
|
|
853
|
-
if (this.
|
|
864
|
+
deliverCompletion(operationId, operationKind, result) {
|
|
865
|
+
if (this.completionHandler !== undefined) {
|
|
866
|
+
this.completionHandler({ operationId, terminalResult: result.terminalResult }, () => completionRecord(operationId, operationKind, result));
|
|
854
867
|
return;
|
|
855
|
-
this.completions.push({ operationId, operationKind, result });
|
|
856
|
-
this.completionCount += 1;
|
|
857
|
-
this.readyHandler?.(service_runtime_contracts_1.ReadyDomain.Infrastructure);
|
|
858
|
-
}
|
|
859
|
-
drainCompletions(batch) {
|
|
860
|
-
while (!batch.full && this.completionCount > 0) {
|
|
861
|
-
const completion = this.takeCompletion();
|
|
862
|
-
if (completion === undefined)
|
|
863
|
-
continue;
|
|
864
|
-
batch.push({
|
|
865
|
-
ownerKind: service_runtime_contracts_1.ReadyOwnerKind.Node,
|
|
866
|
-
domain: service_runtime_contracts_1.ReadyDomain.Infrastructure,
|
|
867
|
-
spotId: null,
|
|
868
|
-
actor: null,
|
|
869
|
-
terminalCompletion: true
|
|
870
|
-
}, new CompletionClaim(completion));
|
|
871
|
-
}
|
|
872
|
-
}
|
|
873
|
-
takeCompletion() {
|
|
874
|
-
const completion = this.completions[this.completionHead];
|
|
875
|
-
if (completion === undefined)
|
|
876
|
-
return undefined;
|
|
877
|
-
this.completions[this.completionHead] = undefined;
|
|
878
|
-
this.completionHead += 1;
|
|
879
|
-
this.completionCount -= 1;
|
|
880
|
-
if (this.completionCount === 0) {
|
|
881
|
-
this.clearCompletions();
|
|
882
|
-
}
|
|
883
|
-
else if ((0, admission_1.shouldCompactBackingArray)(this.completionHead, this.completions.length)) {
|
|
884
|
-
this.completions.splice(0, this.completionHead);
|
|
885
|
-
this.completionHead = 0;
|
|
886
868
|
}
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
869
|
+
// The raw pull contract uses the existing infrastructure mailbox. A
|
|
870
|
+
// registered Framework owner receives the terminal directly above.
|
|
871
|
+
this.runtime?.mailbox.tryEnqueue({
|
|
872
|
+
owner: this.routingId,
|
|
873
|
+
domain: 'infrastructure',
|
|
874
|
+
parts: [],
|
|
875
|
+
completion: completionRecord(operationId, operationKind, result)
|
|
876
|
+
});
|
|
893
877
|
}
|
|
894
878
|
drainMailbox(domain, batch) {
|
|
895
879
|
const runtime = this.runtime;
|
|
@@ -899,7 +883,15 @@ class ZLinkNodeRawMeshBackend {
|
|
|
899
883
|
const claim = runtime.mailbox.tryClaim(domain, MAX_DRAIN_RECORDS, Number.MAX_SAFE_INTEGER);
|
|
900
884
|
if (claim === undefined)
|
|
901
885
|
break;
|
|
902
|
-
const owner =
|
|
886
|
+
const owner = claim.records[0]?.completion === undefined
|
|
887
|
+
? readyOwner(claim.owner, this.routingId, this.stateful, domain)
|
|
888
|
+
: {
|
|
889
|
+
ownerKind: service_runtime_contracts_1.ReadyOwnerKind.Node,
|
|
890
|
+
domain: service_runtime_contracts_1.ReadyDomain.Infrastructure,
|
|
891
|
+
spotId: null,
|
|
892
|
+
actor: null,
|
|
893
|
+
terminalCompletion: true
|
|
894
|
+
};
|
|
903
895
|
batch.push(owner, new MailboxClaim(runtime, claim));
|
|
904
896
|
}
|
|
905
897
|
}
|
|
@@ -973,7 +965,7 @@ class RawServiceSpot {
|
|
|
973
965
|
const routeFence = requireDirectSpotRouteFence(options?.routeFence, String(targetNodeRid), String(targetSpotId), targetSpotGeneration, options?.entrySpot === true
|
|
974
966
|
? this.backend.entrySpotRouteFence(String(targetNodeRid), String(targetSpotId))
|
|
975
967
|
: undefined);
|
|
976
|
-
return this.backend.requestFromSpot(this.state, routeFence, parts, options?.timeoutMs ?? Registration_1.DEFAULT_REQUEST_TIMEOUT_MS);
|
|
968
|
+
return this.backend.requestFromSpot(this.state, routeFence, parts, options?.timeoutMs ?? Registration_1.DEFAULT_REQUEST_TIMEOUT_MS, options?.onAdmitted);
|
|
977
969
|
}
|
|
978
970
|
async publish(channelName, topic, parts, options) {
|
|
979
971
|
this.requireOpen();
|
|
@@ -1012,6 +1004,9 @@ class RawServiceSpot {
|
|
|
1012
1004
|
throw new Error(`Spot '${this.routingId}' is closed.`);
|
|
1013
1005
|
}
|
|
1014
1006
|
}
|
|
1007
|
+
function nodeSendResult(submitted) {
|
|
1008
|
+
return submitted ? zlink_1.SubmitResult.Ok : zlink_1.SubmitResult.NotConnected;
|
|
1009
|
+
}
|
|
1015
1010
|
function requireDirectSpotRouteFence(route, targetNodeRid, targetSpotId, targetSpotGeneration, entryRoute) {
|
|
1016
1011
|
if (route === undefined && entryRoute !== undefined) {
|
|
1017
1012
|
return entryRoute;
|
|
@@ -1093,7 +1088,7 @@ class RawStreamSessionService {
|
|
|
1093
1088
|
if (target === undefined)
|
|
1094
1089
|
return false;
|
|
1095
1090
|
const operation = this.stream.send(target);
|
|
1096
|
-
const parts =
|
|
1091
|
+
const parts = decodeMultipartParts((0, service_wire_m6a_codec_1.decodeApplicationPayloadView)(payload).payload, borrowMultipartPart);
|
|
1097
1092
|
if (parts.length === 0)
|
|
1098
1093
|
return false;
|
|
1099
1094
|
const actorSlot = await (0, service_session_binding_ingress_port_1.serviceSessionBindingIngressPortIfRegistered)(this)?.actorSlot(actorId, sessionRid);
|
|
@@ -1259,49 +1254,35 @@ class MailboxClaim {
|
|
|
1259
1254
|
this.runtime.mailbox.release(this.claim, this.remaining);
|
|
1260
1255
|
}
|
|
1261
1256
|
}
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
applicationMetadata: null,
|
|
1288
|
-
kindData: 'kindData' in this.completion.result ? (this.completion.result.kindData ?? null) : null,
|
|
1289
|
-
terminalResult: this.completion.result.terminalResult,
|
|
1290
|
-
failureErrno: this.completion.result.failureCode,
|
|
1291
|
-
parts: payload === undefined
|
|
1292
|
-
? []
|
|
1293
|
-
: payload.contentType === MULTIPART_CONTENT_TYPE
|
|
1294
|
-
? decodeMultipart(payload.payload)
|
|
1295
|
-
: [zlink_1.Message.from(payload.payload)],
|
|
1296
|
-
reply: () => zlink_1.SubmitResult.InvalidState,
|
|
1297
|
-
replyActorJoin: () => zlink_1.SubmitResult.NotSupported
|
|
1298
|
-
}
|
|
1299
|
-
]
|
|
1300
|
-
};
|
|
1301
|
-
}
|
|
1302
|
-
release() { }
|
|
1257
|
+
function completionRecord(operationId, operationKind, result) {
|
|
1258
|
+
const payload = result.payload;
|
|
1259
|
+
return {
|
|
1260
|
+
kind: service_runtime_contracts_1.ReceiveKind.Completion,
|
|
1261
|
+
domain: service_runtime_contracts_1.ReadyDomain.Infrastructure,
|
|
1262
|
+
sourceNodeRid: null,
|
|
1263
|
+
sourceSpotId: null,
|
|
1264
|
+
sourceBindingGeneration: 0n,
|
|
1265
|
+
sourceActor: null,
|
|
1266
|
+
operationId,
|
|
1267
|
+
operationKind,
|
|
1268
|
+
channelName: null,
|
|
1269
|
+
topic: null,
|
|
1270
|
+
applicationMetadata: null,
|
|
1271
|
+
kindData: 'kindData' in result ? (result.kindData ?? null) : null,
|
|
1272
|
+
terminalResult: result.terminalResult,
|
|
1273
|
+
failureErrno: result.failureCode,
|
|
1274
|
+
parts: payload === undefined
|
|
1275
|
+
? []
|
|
1276
|
+
: payload.contentType === MULTIPART_CONTENT_TYPE
|
|
1277
|
+
? decodeMultipart(payload.payload)
|
|
1278
|
+
: [runtime_message_1.ZLinkBufferMessage.from(payload.payload)],
|
|
1279
|
+
reply: () => zlink_1.SubmitResult.InvalidState,
|
|
1280
|
+
replyActorJoin: () => zlink_1.SubmitResult.NotSupported
|
|
1281
|
+
};
|
|
1303
1282
|
}
|
|
1304
1283
|
function decodeMultipartRecord(runtime, record) {
|
|
1284
|
+
if (record.completion !== undefined)
|
|
1285
|
+
return record.completion;
|
|
1305
1286
|
const stateful = (0, service_stateful_runtime_1.statefulMailboxData)(record);
|
|
1306
1287
|
if (stateful !== undefined) {
|
|
1307
1288
|
return decodeStatefulRecord(record, stateful);
|
|
@@ -1671,22 +1652,15 @@ function decodeApplicationEnvelope(frame) {
|
|
|
1671
1652
|
return { packetName, contentType, payload: bytes.subarray(offset) };
|
|
1672
1653
|
}
|
|
1673
1654
|
function decodeMultipart(payload) {
|
|
1674
|
-
|
|
1675
|
-
const parts = new Array(buffers.length);
|
|
1676
|
-
let materialized = 0;
|
|
1677
|
-
try {
|
|
1678
|
-
for (; materialized < buffers.length; materialized += 1) {
|
|
1679
|
-
parts[materialized] = runtime_message_1.ZLinkBufferMessage.fromOwned(buffers[materialized]);
|
|
1680
|
-
}
|
|
1681
|
-
return parts;
|
|
1682
|
-
}
|
|
1683
|
-
catch (error) {
|
|
1684
|
-
for (let index = 0; index < materialized; index += 1)
|
|
1685
|
-
parts[index].close();
|
|
1686
|
-
throw error;
|
|
1687
|
-
}
|
|
1655
|
+
return decodeMultipartParts(payload, runtime_message_1.ZLinkBufferMessage.fromOwned, closeMultipartMessage);
|
|
1688
1656
|
}
|
|
1689
|
-
function
|
|
1657
|
+
function closeMultipartMessage(part) {
|
|
1658
|
+
part.close();
|
|
1659
|
+
}
|
|
1660
|
+
function borrowMultipartPart(part) {
|
|
1661
|
+
return part;
|
|
1662
|
+
}
|
|
1663
|
+
function decodeMultipartParts(payload, materialize, release) {
|
|
1690
1664
|
const bytes = Buffer.from(payload.buffer, payload.byteOffset, payload.byteLength);
|
|
1691
1665
|
if (bytes.length < 4)
|
|
1692
1666
|
throw new service_wire_m6a_codec_1.ServiceWireProtocolError('Truncated multipart payload.');
|
|
@@ -1696,22 +1670,32 @@ function decodeMultipartBuffers(payload) {
|
|
|
1696
1670
|
}
|
|
1697
1671
|
const result = new Array(count);
|
|
1698
1672
|
let offset = 4;
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
|
|
1673
|
+
let index = 0;
|
|
1674
|
+
try {
|
|
1675
|
+
for (; index < count; index++) {
|
|
1676
|
+
if (bytes.length - offset < 4) {
|
|
1677
|
+
throw new service_wire_m6a_codec_1.ServiceWireProtocolError('Truncated multipart part length.');
|
|
1678
|
+
}
|
|
1679
|
+
const length = bytes.readUInt32BE(offset);
|
|
1680
|
+
offset += 4;
|
|
1681
|
+
if (bytes.length - offset < length) {
|
|
1682
|
+
throw new service_wire_m6a_codec_1.ServiceWireProtocolError('Truncated multipart part.');
|
|
1683
|
+
}
|
|
1684
|
+
result[index] = materialize(bytes.subarray(offset, offset + length));
|
|
1685
|
+
offset += length;
|
|
1702
1686
|
}
|
|
1703
|
-
|
|
1704
|
-
|
|
1705
|
-
if (bytes.length - offset < length) {
|
|
1706
|
-
throw new service_wire_m6a_codec_1.ServiceWireProtocolError('Truncated multipart part.');
|
|
1687
|
+
if (offset !== bytes.length) {
|
|
1688
|
+
throw new service_wire_m6a_codec_1.ServiceWireProtocolError('Multipart payload has trailing bytes.');
|
|
1707
1689
|
}
|
|
1708
|
-
result
|
|
1709
|
-
offset += length;
|
|
1690
|
+
return result;
|
|
1710
1691
|
}
|
|
1711
|
-
|
|
1712
|
-
|
|
1692
|
+
catch (error) {
|
|
1693
|
+
if (release !== undefined) {
|
|
1694
|
+
for (let retained = 0; retained < index; retained++)
|
|
1695
|
+
release(result[retained]);
|
|
1696
|
+
}
|
|
1697
|
+
throw error;
|
|
1713
1698
|
}
|
|
1714
|
-
return result;
|
|
1715
1699
|
}
|
|
1716
1700
|
function messageBytesView(value) {
|
|
1717
1701
|
if (typeof value === 'object' && 'data' in value) {
|
|
@@ -10,6 +10,8 @@ const node_event_loop_poller_1 = require("./node-event-loop-poller");
|
|
|
10
10
|
const eventLoopPollers = new WeakMap();
|
|
11
11
|
function wrapSocket(nativeInstance, pollCompletion) {
|
|
12
12
|
const socket = nativeInstance;
|
|
13
|
+
if (socket.options !== undefined)
|
|
14
|
+
socket.options.linger = 0;
|
|
13
15
|
const hasRequest = typeof nativeInstance.request === 'function';
|
|
14
16
|
const hasRoutedPeer = hasRequest && typeof nativeInstance.reply === 'function';
|
|
15
17
|
const hasStream = typeof nativeInstance.recvPacket === 'function';
|
|
@@ -18,9 +20,9 @@ function wrapSocket(nativeInstance, pollCompletion) {
|
|
|
18
20
|
: new node_event_loop_poller_1.ZLinkNodeEventLoopPoller(nativeInstance, pollCompletion, () => { });
|
|
19
21
|
const adapter = {
|
|
20
22
|
nativeInstance,
|
|
23
|
+
receiveAdmission: undefined,
|
|
21
24
|
async dispose() {
|
|
22
25
|
eventLoopPoller?.dispose();
|
|
23
|
-
(0, node_backend_adapter_support_1.disableSocketLinger)(nativeInstance);
|
|
24
26
|
(0, node_backend_adapter_support_1.closeBindingHandle)(nativeInstance);
|
|
25
27
|
},
|
|
26
28
|
close() {
|
|
@@ -44,9 +46,6 @@ function wrapSocket(nativeInstance, pollCompletion) {
|
|
|
44
46
|
.setChannelName;
|
|
45
47
|
setChannelName?.call(nativeInstance, channelName);
|
|
46
48
|
},
|
|
47
|
-
setReceiveFlowState(state) {
|
|
48
|
-
nativeInstance.setReceiveFlowState(state);
|
|
49
|
-
},
|
|
50
49
|
setProbe(enabled) {
|
|
51
50
|
requireSocketOptions(socket).probe = enabled;
|
|
52
51
|
},
|
|
@@ -68,6 +67,12 @@ function wrapSocket(nativeInstance, pollCompletion) {
|
|
|
68
67
|
setRoutingId(routingId) {
|
|
69
68
|
nativeInstance.setRoutingId((0, node_backend_adapter_support_1.toNativeRoutingId)(routingId));
|
|
70
69
|
},
|
|
70
|
+
get lingerMs() {
|
|
71
|
+
return requireSocketOptions(socket).linger;
|
|
72
|
+
},
|
|
73
|
+
set lingerMs(value) {
|
|
74
|
+
requireSocketOptions(socket).linger = value;
|
|
75
|
+
},
|
|
71
76
|
get peerWeight() {
|
|
72
77
|
return socket.options?.peerWeight ?? RegistrationBuilderPolicy_1.ZLINK_DEFAULT_PUBLIC_WEIGHT;
|
|
73
78
|
},
|
|
@@ -139,12 +144,12 @@ function wrapSocket(nativeInstance, pollCompletion) {
|
|
|
139
144
|
},
|
|
140
145
|
request(...args) {
|
|
141
146
|
if (hasRoutedPeer) {
|
|
142
|
-
const [routingId, payload, timeoutMs] = args;
|
|
143
|
-
return (0, node_backend_adapter_support_1.submitBindingRequest)(nativeInstance.request((0, node_backend_adapter_support_1.toNativeRoutingId)(routingId)), payload, timeoutMs);
|
|
147
|
+
const [routingId, payload, timeoutMs, onAdmitted] = args;
|
|
148
|
+
return (0, node_backend_adapter_support_1.submitBindingRequest)(nativeInstance.request((0, node_backend_adapter_support_1.toNativeRoutingId)(routingId)), payload, timeoutMs, undefined, onAdmitted);
|
|
144
149
|
}
|
|
145
150
|
if (hasRequest) {
|
|
146
|
-
const [payload, timeoutMs] = args;
|
|
147
|
-
return (0, node_backend_adapter_support_1.submitBindingRequest)(nativeInstance.request(), payload, timeoutMs);
|
|
151
|
+
const [payload, timeoutMs, onAdmitted] = args;
|
|
152
|
+
return (0, node_backend_adapter_support_1.submitBindingRequest)(nativeInstance.request(), payload, timeoutMs, adapter.receiveAdmission?.recordReceived, onAdmitted);
|
|
148
153
|
}
|
|
149
154
|
throw new TypeError('Backend request requires a DEALER or ROUTER socket.');
|
|
150
155
|
},
|
|
@@ -196,8 +201,8 @@ function wrapSocket(nativeInstance, pollCompletion) {
|
|
|
196
201
|
const operation = nativeInstance.sendToSpot((0, node_backend_adapter_support_1.toNativeRoutingId)(targetRid), (0, node_backend_adapter_support_1.toNativeRoutingId)(targetSpot));
|
|
197
202
|
await (0, node_backend_adapter_support_1.submitBindingAsyncSend)(operation, payload);
|
|
198
203
|
},
|
|
199
|
-
requestToSpot(targetRid, targetSpot, payload, timeoutMs) {
|
|
200
|
-
return (0, node_backend_adapter_support_1.submitBindingRequest)(nativeInstance.requestToSpot((0, node_backend_adapter_support_1.toNativeRoutingId)(targetRid), (0, node_backend_adapter_support_1.toNativeRoutingId)(targetSpot)), payload, timeoutMs);
|
|
204
|
+
requestToSpot(targetRid, targetSpot, payload, timeoutMs, onAdmitted) {
|
|
205
|
+
return (0, node_backend_adapter_support_1.submitBindingRequest)(nativeInstance.requestToSpot((0, node_backend_adapter_support_1.toNativeRoutingId)(targetRid), (0, node_backend_adapter_support_1.toNativeRoutingId)(targetSpot)), payload, timeoutMs, undefined, onAdmitted);
|
|
201
206
|
},
|
|
202
207
|
disconnectPeer(routingId) {
|
|
203
208
|
disconnectStreamPeer(nativeInstance, routingId);
|
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
import type { SubmitResult } from './runtime-values';
|
|
2
|
+
export interface ZLinkRawSendSubmission {
|
|
3
|
+
readonly result: typeof SubmitResult.Ok | typeof SubmitResult.Backpressured;
|
|
4
|
+
readonly admitted: Promise<void>;
|
|
5
|
+
}
|
|
1
6
|
export interface ZLinkRawReceivedRecord {
|
|
2
7
|
readonly sourceRid: string;
|
|
3
8
|
readonly sourceRoute: Uint8Array;
|
|
@@ -29,7 +34,6 @@ export interface ZLinkRawSocketPort {
|
|
|
29
34
|
unbind(endpoint: string): void;
|
|
30
35
|
connect(endpoint: string): void;
|
|
31
36
|
disconnect(endpoint: string): void;
|
|
32
|
-
setReceiveFlowState(state: 'running' | 'paused'): void;
|
|
33
37
|
monitor(): ZLinkRawMonitorPort;
|
|
34
38
|
close(): void;
|
|
35
39
|
}
|
|
@@ -44,12 +48,15 @@ export interface ZLinkRawRouterRoute {
|
|
|
44
48
|
readonly routeGeneration: bigint;
|
|
45
49
|
}
|
|
46
50
|
export interface ZLinkRawRouterPort extends ZLinkRawSocketPort {
|
|
51
|
+
setReceiveFlowState(state: 'running' | 'paused'): void;
|
|
52
|
+
/** Reports Core submit synchronously; admitted observes only pending admission. */
|
|
53
|
+
submitSend(targetRid: string, parts: readonly Uint8Array[]): ZLinkRawSendSubmission;
|
|
47
54
|
disconnectRid?(routingId: string): void;
|
|
48
55
|
localEndpoint(): string;
|
|
49
56
|
setRoutingId(routingId: string): void;
|
|
50
57
|
connectToRoutingId(routingId: string, endpoint: string): void;
|
|
51
58
|
send(targetRid: string, parts: readonly Uint8Array[]): Promise<void>;
|
|
52
|
-
request(targetRid: string, parts: readonly Uint8Array[], timeoutMs: number): Promise<readonly Buffer[]>;
|
|
59
|
+
request(targetRid: string, parts: readonly Uint8Array[], timeoutMs: number, recordReceived?: () => void, onAdmitted?: () => void): Promise<readonly Buffer[]>;
|
|
53
60
|
receive(dontWait?: boolean): ZLinkRawReceivedRecord | undefined;
|
|
54
61
|
/** The selected route of every RID. The socket's one route observer calls it. */
|
|
55
62
|
routesSnapshot(): readonly ZLinkRawRouterRoute[];
|
|
@@ -57,7 +64,7 @@ export interface ZLinkRawRouterPort extends ZLinkRawSocketPort {
|
|
|
57
64
|
export interface ZLinkRawDealerPort extends ZLinkRawSocketPort {
|
|
58
65
|
setRoutingId(routingId: string): void;
|
|
59
66
|
send(parts: readonly Uint8Array[]): Promise<void>;
|
|
60
|
-
request(parts: readonly Uint8Array[], timeoutMs: number): Promise<readonly Buffer[]>;
|
|
67
|
+
request(parts: readonly Uint8Array[], timeoutMs: number, onAdmitted?: () => void): Promise<readonly Buffer[]>;
|
|
61
68
|
receive(dontWait?: boolean): ZLinkRawReceivedRecord | undefined;
|
|
62
69
|
}
|
|
63
70
|
export interface ZLinkRawHostPort {
|
|
@@ -4,6 +4,7 @@ export declare class ZLinkBufferMessage implements Message {
|
|
|
4
4
|
private constructor();
|
|
5
5
|
static from(value: Message | Buffer | Uint8Array | string): ZLinkBufferMessage;
|
|
6
6
|
static fromOwned(bytes: Buffer): ZLinkBufferMessage;
|
|
7
|
+
static retainPayload(message: Message): Buffer;
|
|
7
8
|
data(): Buffer;
|
|
8
9
|
toBytes(): Uint8Array;
|
|
9
10
|
copy(): Message;
|
|
@@ -16,6 +16,11 @@ class ZLinkBufferMessage {
|
|
|
16
16
|
static fromOwned(bytes) {
|
|
17
17
|
return new ZLinkBufferMessage(bytes);
|
|
18
18
|
}
|
|
19
|
+
static retainPayload(message) {
|
|
20
|
+
// Binding data() Buffers retain their storage after the message handle closes.
|
|
21
|
+
// Preserve that ownership at runtime boundaries without copying the payload.
|
|
22
|
+
return message.data();
|
|
23
|
+
}
|
|
19
24
|
data() {
|
|
20
25
|
return this.bytes;
|
|
21
26
|
}
|