@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
|
@@ -8,7 +8,7 @@ exports.ApplicationJobRecordLease = exports.ApplicationIngressRecordOwner = void
|
|
|
8
8
|
*/
|
|
9
9
|
class ApplicationIngressRecordOwner {
|
|
10
10
|
shared;
|
|
11
|
-
stop
|
|
11
|
+
stop;
|
|
12
12
|
closed = false;
|
|
13
13
|
constructor(shared) {
|
|
14
14
|
this.shared = shared;
|
|
@@ -29,13 +29,30 @@ class ApplicationIngressRecordOwner {
|
|
|
29
29
|
}
|
|
30
30
|
return job;
|
|
31
31
|
}
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
32
|
+
acquire(domain, signal) {
|
|
33
|
+
try {
|
|
34
|
+
this.requireOpen();
|
|
35
|
+
const initial = this.shared.takeInitialPermit(domain);
|
|
36
|
+
if (initial !== undefined)
|
|
37
|
+
return initial;
|
|
38
|
+
}
|
|
39
|
+
catch (error) {
|
|
40
|
+
return Promise.reject(error);
|
|
41
|
+
}
|
|
42
|
+
return this.acquireAdditional(domain, signal);
|
|
43
|
+
}
|
|
44
|
+
async acquireAdditional(domain, signal) {
|
|
45
|
+
const stop = (this.stop ??= new AbortController());
|
|
46
|
+
const waitSignal = signal === undefined ? stop.signal : AbortSignal.any([stop.signal, signal]);
|
|
47
|
+
let permit;
|
|
48
|
+
try {
|
|
49
|
+
permit = await this.shared.acquirePermit(waitSignal);
|
|
50
|
+
}
|
|
51
|
+
catch (error) {
|
|
52
|
+
if (error === ownerClosedError)
|
|
53
|
+
throw ownerClosedError();
|
|
54
|
+
throw error;
|
|
55
|
+
}
|
|
39
56
|
if (this.closed) {
|
|
40
57
|
permit.releaseAfterInternalProcessing();
|
|
41
58
|
throw ownerClosedError();
|
|
@@ -46,7 +63,8 @@ class ApplicationIngressRecordOwner {
|
|
|
46
63
|
if (this.closed)
|
|
47
64
|
return;
|
|
48
65
|
this.closed = true;
|
|
49
|
-
this.
|
|
66
|
+
// The queue forwards this reason; only a rejected acquisition constructs the error.
|
|
67
|
+
this.stop?.abort(ownerClosedError);
|
|
50
68
|
this.shared.releaseOwner();
|
|
51
69
|
}
|
|
52
70
|
requireOpen() {
|
|
@@ -60,14 +78,15 @@ class ApplicationJobRecordLease {
|
|
|
60
78
|
shared;
|
|
61
79
|
permit;
|
|
62
80
|
ingressClosed = false;
|
|
63
|
-
permitReleased = false;
|
|
64
81
|
processingTerminal = false;
|
|
65
82
|
detachedForHandlerTurn = false;
|
|
66
|
-
jobReleased = false;
|
|
67
83
|
constructor(shared, permit) {
|
|
68
84
|
this.shared = shared;
|
|
69
85
|
this.permit = permit;
|
|
70
86
|
}
|
|
87
|
+
get origin() {
|
|
88
|
+
return this.shared.origin;
|
|
89
|
+
}
|
|
71
90
|
markApplicationQueued() {
|
|
72
91
|
// The owner classifies and marks the child atomically when it is created;
|
|
73
92
|
// downstream dispatch must not mutate queue accounting a second time.
|
|
@@ -76,11 +95,11 @@ class ApplicationJobRecordLease {
|
|
|
76
95
|
this.detachedForHandlerTurn = true;
|
|
77
96
|
}
|
|
78
97
|
releaseBeforeHandler() {
|
|
79
|
-
this.
|
|
98
|
+
this.permit?.releaseBeforeHandler();
|
|
80
99
|
}
|
|
81
100
|
releaseAfterInternalProcessing() {
|
|
82
101
|
this.processingTerminal = true;
|
|
83
|
-
this.
|
|
102
|
+
this.permit?.releaseAfterInternalProcessing();
|
|
84
103
|
this.releaseJobIfTerminal();
|
|
85
104
|
}
|
|
86
105
|
close() {
|
|
@@ -93,17 +112,17 @@ class ApplicationJobRecordLease {
|
|
|
93
112
|
}
|
|
94
113
|
this.releaseJobIfTerminal();
|
|
95
114
|
}
|
|
96
|
-
releasePermit(release) {
|
|
97
|
-
if (this.permitReleased)
|
|
98
|
-
return;
|
|
99
|
-
this.permitReleased = true;
|
|
100
|
-
release();
|
|
101
|
-
}
|
|
102
115
|
releaseJobIfTerminal() {
|
|
103
|
-
|
|
116
|
+
const permit = this.permit;
|
|
117
|
+
if (permit === undefined || !this.ingressClosed || !this.processingTerminal)
|
|
104
118
|
return;
|
|
105
|
-
this.
|
|
106
|
-
|
|
119
|
+
this.permit = undefined;
|
|
120
|
+
try {
|
|
121
|
+
this.shared.releaseJob();
|
|
122
|
+
}
|
|
123
|
+
finally {
|
|
124
|
+
permit.releaseStorage?.();
|
|
125
|
+
}
|
|
107
126
|
}
|
|
108
127
|
}
|
|
109
128
|
exports.ApplicationJobRecordLease = ApplicationJobRecordLease;
|
|
@@ -114,9 +133,11 @@ class SharedIngressRecordState {
|
|
|
114
133
|
jobCount = 0;
|
|
115
134
|
initialPermit;
|
|
116
135
|
recordClosed = false;
|
|
136
|
+
origin;
|
|
117
137
|
constructor(queue, initialPermit, record) {
|
|
118
138
|
this.queue = queue;
|
|
119
139
|
this.record = record;
|
|
140
|
+
this.origin = initialPermit.origin;
|
|
120
141
|
this.initialPermit = initialPermit;
|
|
121
142
|
}
|
|
122
143
|
retainOwner() {
|
|
@@ -138,7 +159,7 @@ class SharedIngressRecordState {
|
|
|
138
159
|
return this.createJob(permit, domain);
|
|
139
160
|
}
|
|
140
161
|
acquirePermit(signal) {
|
|
141
|
-
return this.queue.acquire(signal);
|
|
162
|
+
return this.queue.acquire(signal, this.origin);
|
|
142
163
|
}
|
|
143
164
|
createJob(permit, domain) {
|
|
144
165
|
this.jobCount += 1;
|
|
@@ -169,6 +190,7 @@ class SharedIngressRecordState {
|
|
|
169
190
|
this.initialPermit?.releaseAfterInternalProcessing();
|
|
170
191
|
}
|
|
171
192
|
finally {
|
|
193
|
+
this.initialPermit?.releaseStorage?.();
|
|
172
194
|
this.initialPermit = undefined;
|
|
173
195
|
this.record.close();
|
|
174
196
|
}
|
|
@@ -1,13 +1,16 @@
|
|
|
1
|
-
import type { ApplicationJobPermitPort } from './contracts';
|
|
1
|
+
import type { ApplicationJobOrigin, ApplicationJobPermitPort } from './contracts';
|
|
2
2
|
/**
|
|
3
3
|
* Carries the host-owned queue permit through internal async dispatch without
|
|
4
4
|
* leaking capacity ownership into public handler contracts.
|
|
5
5
|
*/
|
|
6
|
-
export declare function runWithApplicationJobPermit<TResult>(permit: ApplicationJobPermitPort, callback: () => Promise<TResult>
|
|
6
|
+
export declare function runWithApplicationJobPermit<TResult>(permit: ApplicationJobPermitPort, callback: () => Promise<TResult>): Promise<TResult>;
|
|
7
|
+
export declare function runWithApplicationJobPermit<TResult, TFirst = undefined, TSecond = undefined>(permit: ApplicationJobPermitPort, callback: (first: TFirst, second: TSecond) => Promise<TResult> | TResult, first?: TFirst, second?: TSecond): TResult | Promise<TResult>;
|
|
7
8
|
/** Releases the current job permit immediately before the first user callback. */
|
|
8
9
|
export declare function releaseApplicationJobPermitBeforeHandler(): void;
|
|
9
10
|
/** True while dispatch already owns the host-wide application job permit. */
|
|
10
11
|
export declare function hasApplicationJobPermit(): boolean;
|
|
12
|
+
/** Keeps the ingress origin when a durable record later reacquires its permit. */
|
|
13
|
+
export declare function currentApplicationJobOrigin(): ApplicationJobOrigin;
|
|
11
14
|
/** Re-enters the captured permit scope when a serial executor runs later. */
|
|
12
15
|
export declare function bindApplicationJobPermit<TResult, TArgument>(callback: (argument?: TArgument) => Promise<TResult> | TResult): (argument?: TArgument) => Promise<TResult> | TResult;
|
|
13
16
|
/**
|
|
@@ -4,38 +4,59 @@ exports.runWithApplicationJobPermit = runWithApplicationJobPermit;
|
|
|
4
4
|
exports.releaseApplicationJobPermitBeforeHandler = releaseApplicationJobPermitBeforeHandler;
|
|
5
5
|
exports.releaseApplicationJobPermitForDurableHandoff = releaseApplicationJobPermitForDurableHandoff;
|
|
6
6
|
exports.hasApplicationJobPermit = hasApplicationJobPermit;
|
|
7
|
+
exports.currentApplicationJobOrigin = currentApplicationJobOrigin;
|
|
7
8
|
exports.bindApplicationJobPermit = bindApplicationJobPermit;
|
|
8
9
|
exports.detachApplicationJobPermit = detachApplicationJobPermit;
|
|
9
10
|
const node_async_hooks_1 = require("node:async_hooks");
|
|
10
11
|
const applicationJobPermitScope = new node_async_hooks_1.AsyncLocalStorage();
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
12
|
+
function releasePermitTurn() {
|
|
13
|
+
const permit = applicationJobPermitScope.getStore();
|
|
14
|
+
if (permit !== undefined && !permit.detachedForHandlerTurn)
|
|
15
|
+
permit.releaseAfterInternalProcessing();
|
|
16
|
+
}
|
|
17
|
+
function releasePermitSuccess(value) {
|
|
18
|
+
releasePermitTurn();
|
|
19
|
+
return value;
|
|
20
|
+
}
|
|
21
|
+
function releasePermitFailure(error) {
|
|
22
|
+
releasePermitTurn();
|
|
23
|
+
throw error;
|
|
24
|
+
}
|
|
25
|
+
function runWithApplicationJobPermit(permit, callback, first, second) {
|
|
26
|
+
const previous = applicationJobPermitScope.getStore();
|
|
27
|
+
applicationJobPermitScope.enterWith(permit);
|
|
28
|
+
try {
|
|
29
|
+
const result = callback(first, second);
|
|
30
|
+
if (result !== null && (typeof result === 'object' || typeof result === 'function')) {
|
|
31
|
+
return Promise.resolve(result).then(releasePermitSuccess, releasePermitFailure);
|
|
24
32
|
}
|
|
25
|
-
|
|
33
|
+
releasePermitTurn();
|
|
34
|
+
return result;
|
|
35
|
+
}
|
|
36
|
+
catch (error) {
|
|
37
|
+
releasePermitTurn();
|
|
38
|
+
return Promise.reject(error);
|
|
39
|
+
}
|
|
40
|
+
finally {
|
|
41
|
+
applicationJobPermitScope.enterWith(previous);
|
|
42
|
+
}
|
|
26
43
|
}
|
|
27
44
|
/** Releases the current job permit immediately before the first user callback. */
|
|
28
45
|
function releaseApplicationJobPermitBeforeHandler() {
|
|
29
|
-
applicationJobPermitScope.getStore()?.
|
|
46
|
+
applicationJobPermitScope.getStore()?.releaseBeforeHandler();
|
|
30
47
|
}
|
|
31
48
|
/** @internal Returns an ingress permit after a durable queue takes record ownership. */
|
|
32
49
|
function releaseApplicationJobPermitForDurableHandoff() {
|
|
33
|
-
applicationJobPermitScope.getStore()?.
|
|
50
|
+
applicationJobPermitScope.getStore()?.releaseAfterInternalProcessing();
|
|
34
51
|
}
|
|
35
52
|
/** True while dispatch already owns the host-wide application job permit. */
|
|
36
53
|
function hasApplicationJobPermit() {
|
|
37
54
|
return applicationJobPermitScope.getStore() !== undefined;
|
|
38
55
|
}
|
|
56
|
+
/** Keeps the ingress origin when a durable record later reacquires its permit. */
|
|
57
|
+
function currentApplicationJobOrigin() {
|
|
58
|
+
return applicationJobPermitScope.getStore().origin;
|
|
59
|
+
}
|
|
39
60
|
/** Re-enters the captured permit scope when a serial executor runs later. */
|
|
40
61
|
function bindApplicationJobPermit(callback) {
|
|
41
62
|
const scope = applicationJobPermitScope.getStore();
|
|
@@ -48,10 +69,9 @@ function bindApplicationJobPermit(callback) {
|
|
|
48
69
|
* detached owner must release it at handler entry or at a pre-start terminal.
|
|
49
70
|
*/
|
|
50
71
|
function detachApplicationJobPermit() {
|
|
51
|
-
const
|
|
52
|
-
if (
|
|
72
|
+
const permit = applicationJobPermitScope.getStore();
|
|
73
|
+
if (permit === undefined)
|
|
53
74
|
return undefined;
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
return scope.permit;
|
|
75
|
+
permit.detachForHandlerTurn();
|
|
76
|
+
return permit;
|
|
57
77
|
}
|
|
@@ -1,12 +1,25 @@
|
|
|
1
|
+
export type ApplicationJobOrigin = 'local' | 'remote';
|
|
1
2
|
export interface ApplicationJobPermitPort {
|
|
3
|
+
readonly origin: ApplicationJobOrigin;
|
|
4
|
+
readonly detachedForHandlerTurn: boolean;
|
|
2
5
|
markApplicationQueued(): void;
|
|
3
6
|
/** Transfers ingress-record cleanup to a detached exact-target handler turn. */
|
|
4
|
-
detachForHandlerTurn
|
|
7
|
+
detachForHandlerTurn(): void;
|
|
5
8
|
releaseBeforeHandler(): void;
|
|
6
9
|
releaseAfterInternalProcessing(): void;
|
|
10
|
+
/** Returns reusable reservation storage only after its ingress lifetime ends. */
|
|
11
|
+
releaseStorage?(): void;
|
|
12
|
+
}
|
|
13
|
+
export interface ApplicationJobReceiveRotationPort {
|
|
14
|
+
reserve(): void;
|
|
15
|
+
take(): ApplicationJobPermitPort | undefined;
|
|
16
|
+
releaseUnused(): void;
|
|
7
17
|
}
|
|
8
18
|
export interface ApplicationJobQueuePort {
|
|
9
|
-
|
|
19
|
+
createReceiveRotation(capacity: number, origin: ApplicationJobOrigin): ApplicationJobReceiveRotationPort;
|
|
20
|
+
acquire(signal: AbortSignal | undefined, origin: ApplicationJobOrigin): Promise<ApplicationJobPermitPort>;
|
|
21
|
+
/** Returns a grant now, or registers one FIFO waiter that later calls resume. */
|
|
22
|
+
acquireOrResume(resume: (permit: ApplicationJobPermitPort) => void, reject: (reason: unknown) => void, signal: AbortSignal | undefined, origin: ApplicationJobOrigin): ApplicationJobPermitPort | undefined;
|
|
10
23
|
registerReceiveFlowTarget?(identity: object, applyState: (state: 'running' | 'paused') => void, failureSink?: (error: unknown) => void): boolean;
|
|
11
24
|
unregisterReceiveFlowTarget?(identity: object): void;
|
|
12
25
|
pressureState?(): 'running' | 'paused';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { RequestResult, SubmitResult, ZLinkBackendMessageLike, ZLinkBackendMonitorEventType, ZLinkBackendReceived, ZLinkBackendTopicMessage } from '../runtime-values';
|
|
2
|
-
import type { CoreHwmBudgetSnapshot } from '@zlink-systems/zlink';
|
|
2
|
+
import type { CoreHwmBudgetSnapshot, ReceiveFlowState } from '@zlink-systems/zlink';
|
|
3
3
|
import { type ZLinkBackendRecvFlags, type ZLinkBackendSendFlags } from '../runtime-values';
|
|
4
4
|
export * from '../runtime-values';
|
|
5
5
|
type MessageLike = ZLinkBackendMessageLike;
|
|
@@ -10,10 +10,11 @@ import type { MeshNodeStatus, MeshOperationId, MeshPeerEntry, MeshPublisher, Rea
|
|
|
10
10
|
import type { RoutingId } from '../../../contracts';
|
|
11
11
|
import type { ZLinkCoreHwmOptions } from '../../../contracts/Configuration';
|
|
12
12
|
import type { ZLinkSubmitResult } from '../../messaging/submission-result';
|
|
13
|
+
import type { ZLinkMeshCompletionHandler } from '../mesh-completion-table';
|
|
13
14
|
import type { Message } from '../../../contracts/Common/Message';
|
|
14
15
|
import type { ServiceSpotMessageFollowSeal, ServiceUserSpotOperationHandler, ServiceUserSpotOperationResult } from '../../foundation/service-stateful-runtime';
|
|
15
16
|
import type { ServiceApplicationPayload } from '../../foundation/service-wire-m6a-codec';
|
|
16
|
-
import type { ServiceActorCreateRecord, ServiceDirectSpotRouteFence, ServiceInstanceRouteFence, ServiceUserSpotCloseRecord, ServiceUserSpotCreateRecord } from '../../foundation/service-stateful-wire-codec';
|
|
17
|
+
import type { ServiceActorCreateRecord, ServiceDirectSpotRouteFence, ServiceInstanceRouteFence, ServiceInstanceColdActivationTarget, ServiceUserSpotCloseRecord, ServiceUserSpotCreateRecord } from '../../foundation/service-stateful-wire-codec';
|
|
17
18
|
export declare const ZLINK_BACKEND_SPOT_ROUTE_BRIDGE_ROUTE_WITH_CHANNEL_INBOUND = 3;
|
|
18
19
|
export type ZLinkBackendMeshNodeStatus = MeshNodeStatus;
|
|
19
20
|
export type ZLinkBackendMeshPeerEntry = MeshPeerEntry;
|
|
@@ -32,6 +33,7 @@ export type ZLinkBackendObjectPlacement = {
|
|
|
32
33
|
readonly kind: 'unavailable';
|
|
33
34
|
};
|
|
34
35
|
export interface ZLinkBackendMeshNode {
|
|
36
|
+
readonly routingId?: RoutingId;
|
|
35
37
|
completeClosedInstance?(spotId: string, objectGeneration: bigint): void;
|
|
36
38
|
setDispatchErrorReporter?(reporter: import('../../channels/dispatch-error-reporter').ZLinkDispatchErrorReporter, meshName: string): void;
|
|
37
39
|
setRoutingId(routingId: unknown): void;
|
|
@@ -66,22 +68,10 @@ export interface ZLinkBackendMeshNode {
|
|
|
66
68
|
}): void;
|
|
67
69
|
selectObjectPlacement(stableType: string): ZLinkBackendObjectPlacement;
|
|
68
70
|
instanceSpotPlacementTypes?(): readonly string[];
|
|
69
|
-
sendToMissingInstanceSpot(target:
|
|
70
|
-
|
|
71
|
-
readonly targetNodeGeneration: bigint;
|
|
72
|
-
readonly targetSpotId: string;
|
|
73
|
-
readonly stableType: string;
|
|
74
|
-
readonly descriptorVersion: string;
|
|
75
|
-
}, parts: ZLinkBackendMessageLike | readonly ZLinkBackendMessageLike[], deadlineUnixMs: bigint, sourceSpotId?: string, metadata?: ReadonlyMap<string, string>): Promise<SubmitResult>;
|
|
76
|
-
requestToMissingInstanceSpot(target: {
|
|
77
|
-
readonly targetNodeRid: string;
|
|
78
|
-
readonly targetNodeGeneration: bigint;
|
|
79
|
-
readonly targetSpotId: string;
|
|
80
|
-
readonly stableType: string;
|
|
81
|
-
readonly descriptorVersion: string;
|
|
82
|
-
}, parts: ZLinkBackendMessageLike | readonly ZLinkBackendMessageLike[], deadlineUnixMs: bigint, sourceSpotId?: string, metadata?: ReadonlyMap<string, string>): MeshOperationId;
|
|
71
|
+
sendToMissingInstanceSpot(target: ServiceInstanceColdActivationTarget, parts: ZLinkBackendMessageLike | readonly ZLinkBackendMessageLike[], deadlineUnixMs: bigint, sourceSpotId?: string, metadata?: ReadonlyMap<string, string>): Promise<SubmitResult>;
|
|
72
|
+
requestToMissingInstanceSpot(target: ServiceInstanceColdActivationTarget, parts: ZLinkBackendMessageLike | readonly ZLinkBackendMessageLike[], deadlineUnixMs: bigint, sourceSpotId?: string, metadata?: ReadonlyMap<string, string>, onAdmitted?: () => void): MeshOperationId;
|
|
83
73
|
sendToInstanceSpot(route: ServiceInstanceRouteFence, parts: MessageLike | readonly MessageLike[], sourceSpotId?: string, metadata?: ReadonlyMap<string, string>, instanceIntent?: boolean): Promise<SubmitResult>;
|
|
84
|
-
requestInstanceSpot(route: ServiceInstanceRouteFence, parts: MessageLike | readonly MessageLike[], timeoutMs?: number, sourceSpotId?: string, metadata?: ReadonlyMap<string, string>, instanceIntent?: boolean): MeshOperationId;
|
|
74
|
+
requestInstanceSpot(route: ServiceInstanceRouteFence, parts: MessageLike | readonly MessageLike[], timeoutMs?: number, sourceSpotId?: string, metadata?: ReadonlyMap<string, string>, instanceIntent?: boolean, onAdmitted?: () => void): MeshOperationId;
|
|
85
75
|
registerUserSpotOperationHandler(handler: ServiceUserSpotOperationHandler): void;
|
|
86
76
|
requestUserSpotCreate(targetNodeRid: string, request: Omit<ServiceUserSpotCreateRecord, 'kind' | 'correlation' | 'operation'>, timeoutMs: number): Promise<ServiceUserSpotOperationResult>;
|
|
87
77
|
requestUserSpotClose(targetNodeRid: string, request: Omit<ServiceUserSpotCloseRecord, 'kind' | 'correlation' | 'operation'>, timeoutMs: number): Promise<ServiceUserSpotOperationResult>;
|
|
@@ -108,10 +98,12 @@ export interface ZLinkBackendMeshNode {
|
|
|
108
98
|
readonly lifecycleGeneration: bigint;
|
|
109
99
|
}): void;
|
|
110
100
|
isObjectClientNodeDirectTarget?(targetRid: unknown): boolean;
|
|
101
|
+
observePeerRoute?(targetRid: unknown): import('../../foundation/durable-service-request').PeerRouteObservation;
|
|
102
|
+
hasPeerRouteOrConnectionIntent?(targetRid: unknown, endpoint: string): boolean;
|
|
111
103
|
isPeerRouteReady?(targetRid: unknown, lifecycleGeneration?: bigint): boolean;
|
|
112
104
|
sendToNode(targetRid: unknown, parts: MessageLike | readonly MessageLike[], options?: {
|
|
113
105
|
flags?: number;
|
|
114
|
-
}): Promise<SubmitResult>;
|
|
106
|
+
}): SubmitResult | Promise<SubmitResult>;
|
|
115
107
|
/**
|
|
116
108
|
* Sends service-wire infrastructure frames directly to a peer. Relocation
|
|
117
109
|
* Prepare may add NODE-INTERNAL sideband frames after its canonical frame.
|
|
@@ -125,11 +117,14 @@ export interface ZLinkBackendMeshNode {
|
|
|
125
117
|
*/
|
|
126
118
|
requestInfrastructureControlFrames?(targetRid: unknown, frames: readonly Uint8Array[], options?: {
|
|
127
119
|
readonly timeoutMs?: number;
|
|
120
|
+
readonly signal?: AbortSignal;
|
|
121
|
+
readonly onSubmitted?: (signal: AbortSignal) => Promise<void>;
|
|
128
122
|
}): Promise<readonly Uint8Array[]>;
|
|
129
123
|
requestToNode(targetRid: unknown, parts: MessageLike | readonly MessageLike[], options?: {
|
|
130
124
|
flags?: number;
|
|
131
125
|
timeoutMs?: number;
|
|
132
126
|
applicationMetadata?: Buffer;
|
|
127
|
+
onAdmitted?: () => void;
|
|
133
128
|
}): MeshOperationId;
|
|
134
129
|
sendToChannel(channelName: string, parts: MessageLike | readonly MessageLike[], options?: {
|
|
135
130
|
flags?: number;
|
|
@@ -138,6 +133,7 @@ export interface ZLinkBackendMeshNode {
|
|
|
138
133
|
flags?: number;
|
|
139
134
|
timeoutMs?: number;
|
|
140
135
|
applicationMetadata?: Buffer;
|
|
136
|
+
onAdmitted?: () => void;
|
|
141
137
|
}): MeshOperationId;
|
|
142
138
|
status(): MeshNodeStatus;
|
|
143
139
|
peers(): MeshPeerEntry[];
|
|
@@ -202,6 +198,7 @@ export interface ZLinkBackendMeshNode {
|
|
|
202
198
|
flags?: number;
|
|
203
199
|
timeoutMs?: number;
|
|
204
200
|
applicationMetadata?: Buffer;
|
|
201
|
+
onAdmitted?: () => void;
|
|
205
202
|
}): MeshOperationId;
|
|
206
203
|
actorSendToActor(source: ZLinkBackendActorRef, target: ZLinkBackendActorRef, parts: MessageLike | readonly MessageLike[], options?: {
|
|
207
204
|
flags?: number;
|
|
@@ -210,11 +207,13 @@ export interface ZLinkBackendMeshNode {
|
|
|
210
207
|
flags?: number;
|
|
211
208
|
timeoutMs?: number;
|
|
212
209
|
applicationMetadata?: Buffer;
|
|
210
|
+
onAdmitted?: () => void;
|
|
213
211
|
}): MeshOperationId;
|
|
214
212
|
sendActorBoundSession(actor: ZLinkBackendActorRef, expectedBindingGeneration: bigint, parts: MessageLike | readonly MessageLike[], flags?: number): Promise<SubmitResult>;
|
|
215
213
|
closeActorBoundSession(actor: ZLinkBackendActorRef, expectedBindingGeneration: bigint, timeoutMs?: number): MeshOperationId;
|
|
216
214
|
leaveActor(actor: ZLinkBackendActorRef, expectedMembershipEpoch: bigint, timeoutMs?: number): MeshOperationId;
|
|
217
215
|
setReadyHandler(handler: (readyDomains: number) => number): void;
|
|
216
|
+
setCompletionHandler(handler: ZLinkMeshCompletionHandler): void;
|
|
218
217
|
createReadyBatch(capacity: number): ReadyBatch;
|
|
219
218
|
createReceiveBatch(messageCapacity: number, partCapacity: number): ReceiveBatch;
|
|
220
219
|
drainReady(domains: number, batch: ReadyBatch, flags?: number): {
|
|
@@ -278,7 +277,6 @@ export interface ZLinkBackendSocket extends ZLinkBackendObject {
|
|
|
278
277
|
readonly lastEndpoint?: string;
|
|
279
278
|
bind(endpoint: string): void;
|
|
280
279
|
setChannelName(channelName: string): void;
|
|
281
|
-
setReceiveFlowState?(state: 0 | 1): void;
|
|
282
280
|
dispose(): Promise<void>;
|
|
283
281
|
}
|
|
284
282
|
export interface ZLinkBackendConnectableSocket extends ZLinkBackendSocket {
|
|
@@ -286,7 +284,7 @@ export interface ZLinkBackendConnectableSocket extends ZLinkBackendSocket {
|
|
|
286
284
|
disconnect(endpoint: string): void;
|
|
287
285
|
}
|
|
288
286
|
export interface ZLinkBackendDealerSocket extends ZLinkBackendConnectableSocket {
|
|
289
|
-
|
|
287
|
+
receiveAdmission?: import('../../foundation/service-liveness-registry').ServiceLivenessConnection;
|
|
290
288
|
setRoutingId(routingId: RoutingId): void;
|
|
291
289
|
peerWeight: number;
|
|
292
290
|
sendHighWaterMark: number;
|
|
@@ -294,7 +292,7 @@ export interface ZLinkBackendDealerSocket extends ZLinkBackendConnectableSocket
|
|
|
294
292
|
receiveTimeoutMs: number;
|
|
295
293
|
maxMessageSize: number;
|
|
296
294
|
send(message: Message | readonly Message[]): Promise<void>;
|
|
297
|
-
request(message: Message | readonly Message[], timeoutMs?: number): Promise<readonly Message[]>;
|
|
295
|
+
request(message: Message | readonly Message[], timeoutMs?: number, onAdmitted?: () => void): Promise<readonly Message[]>;
|
|
298
296
|
recv(flags?: ZLinkBackendRecvFlags): Received | undefined;
|
|
299
297
|
}
|
|
300
298
|
export interface ZLinkBackendReplyOperation {
|
|
@@ -308,10 +306,10 @@ export interface ZLinkBackendSendOperation {
|
|
|
308
306
|
export interface ZLinkBackendRequestOperation {
|
|
309
307
|
message(message: MessageLike): ZLinkBackendRequestOperation;
|
|
310
308
|
timeout(timeoutMs: number): ZLinkBackendRequestOperation;
|
|
311
|
-
submit(): Promise<readonly Message[]>;
|
|
309
|
+
submit(onAdmitted?: () => void): Promise<readonly Message[]>;
|
|
312
310
|
}
|
|
313
311
|
export interface ZLinkBackendRouterSocket extends ZLinkBackendConnectableSocket {
|
|
314
|
-
setReceiveFlowState(state:
|
|
312
|
+
setReceiveFlowState(state: ReceiveFlowState): void;
|
|
315
313
|
/** Enables the native probe handshake for manually configured routes. */
|
|
316
314
|
setProbe(enabled: boolean): void;
|
|
317
315
|
peerWeight: number;
|
|
@@ -322,14 +320,15 @@ export interface ZLinkBackendRouterSocket extends ZLinkBackendConnectableSocket
|
|
|
322
320
|
setRoutingId(routingId: RoutingId): void;
|
|
323
321
|
recv(flags?: ZLinkBackendRecvFlags): Received | undefined;
|
|
324
322
|
send(routingId: RoutingId, message: Message | readonly Message[]): Promise<void>;
|
|
325
|
-
request(routingId: RoutingId, message: Message | readonly Message[], timeoutMs?: number): Promise<readonly Message[]>;
|
|
323
|
+
request(routingId: RoutingId, message: Message | readonly Message[], timeoutMs?: number, onAdmitted?: () => void): Promise<readonly Message[]>;
|
|
326
324
|
sendToSpot(targetNodeRid: RoutingId, targetSpotId: RoutingId, parts: readonly Message[], flags?: ZLinkBackendSendFlags): Promise<void>;
|
|
327
|
-
requestToSpot(targetNodeRid: RoutingId, targetSpotId: RoutingId, parts: readonly Message[], timeoutMs?: number): Promise<readonly Message[]>;
|
|
325
|
+
requestToSpot(targetNodeRid: RoutingId, targetSpotId: RoutingId, parts: readonly Message[], timeoutMs?: number, onAdmitted?: () => void): Promise<readonly Message[]>;
|
|
328
326
|
disconnectPeer(routingId: RoutingId): void;
|
|
329
327
|
reply(routingId: RoutingId, replyToken: unknown): ZLinkBackendReplyOperation;
|
|
330
328
|
reply(routingId: RoutingId, replyToken: unknown, message: Message | readonly Message[]): void;
|
|
331
329
|
}
|
|
332
330
|
export interface ZLinkBackendPublisherSocket extends ZLinkBackendSocket {
|
|
331
|
+
lingerMs: number;
|
|
333
332
|
sendTimeoutMs: number;
|
|
334
333
|
sendHighWaterMark: number;
|
|
335
334
|
noDrop: boolean;
|
|
@@ -423,11 +422,11 @@ export interface ZLinkBackendSpot extends ZLinkBackendObject {
|
|
|
423
422
|
drainReply(): number;
|
|
424
423
|
drainChannelReply(subjectHandle: bigint): number;
|
|
425
424
|
setDispatchHandler(handler: (info: ZLinkBackendSpotDispatchInfo) => void): void;
|
|
426
|
-
requestToChannel(channelName: string, payload: Message | readonly Message[], timeoutMs?: number): Promise<readonly Message[]>;
|
|
425
|
+
requestToChannel(channelName: string, payload: Message | readonly Message[], timeoutMs?: number, onAdmitted?: () => void): Promise<readonly Message[]>;
|
|
427
426
|
sendToChannel(channelName: string, payload: Message | readonly Message[]): Promise<void>;
|
|
428
427
|
publish(topic: string, payload: Message | readonly Message[], flags: ZLinkBackendSendFlags): boolean;
|
|
429
428
|
sendToSpot(targetRid: RoutingId, spotId: RoutingId, payload: Message | readonly Message[]): Promise<void>;
|
|
430
|
-
requestToSpot(targetRid: RoutingId, spotId: RoutingId, payload: Message | readonly Message[], timeoutMs?: number): Promise<readonly Message[]>;
|
|
429
|
+
requestToSpot(targetRid: RoutingId, spotId: RoutingId, payload: Message | readonly Message[], timeoutMs?: number, onAdmitted?: () => void): Promise<readonly Message[]>;
|
|
431
430
|
dispose(): Promise<void>;
|
|
432
431
|
}
|
|
433
432
|
export interface ZLinkChannelBackendAdapter {
|
|
@@ -447,6 +446,7 @@ export interface ZLinkMeshBackendAdapter {
|
|
|
447
446
|
readonly trustProfile?: string;
|
|
448
447
|
readonly applicationJobQueue: import('../../application-jobs/contracts').ApplicationJobQueuePort;
|
|
449
448
|
readonly applicationJobReceiveFlowFailureSink?: (error: unknown) => void;
|
|
449
|
+
readonly infrastructureTaskRunner?: import('../../spots/spot-actor-join-dispatch').ZLinkDetachedTaskRunner;
|
|
450
450
|
readonly peerAdmissionSealed?: () => boolean;
|
|
451
451
|
}): ZLinkBackendMeshNode;
|
|
452
452
|
}
|
|
@@ -12,20 +12,30 @@ export interface ZLinkMeshCompletion {
|
|
|
12
12
|
readonly kindData: ReceiveKindData | null;
|
|
13
13
|
readonly parts: Message[];
|
|
14
14
|
}
|
|
15
|
+
export type ZLinkMeshCompletionTerminal = Pick<ReceiveRecord, 'operationId' | 'terminalResult'>;
|
|
16
|
+
export type ZLinkMeshCompletionHandler = (terminal: ZLinkMeshCompletionTerminal, materialize: () => ReceiveRecord) => void;
|
|
15
17
|
export declare class ZLinkMeshCompletionTable {
|
|
16
18
|
private readonly onDiagnostic?;
|
|
17
|
-
private
|
|
19
|
+
private buckets;
|
|
20
|
+
private readonly slots;
|
|
21
|
+
private free;
|
|
22
|
+
private activeCount;
|
|
18
23
|
private disposed;
|
|
19
24
|
constructor(onDiagnostic?: ((diagnostic: ZLinkMeshCompletionDiagnostic) => void) | undefined);
|
|
25
|
+
private prepareSlots;
|
|
26
|
+
private bucket;
|
|
27
|
+
private indexSlot;
|
|
28
|
+
private findSlot;
|
|
29
|
+
private releaseSlot;
|
|
20
30
|
/**
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
* arrived before their waiter.
|
|
31
|
+
* Reserves the dispatcher slot before transport submission. The backend
|
|
32
|
+
* observes native terminals through Promises, so identity binding finishes
|
|
33
|
+
* before the terminal callback can run, without an infrastructure pump.
|
|
25
34
|
*/
|
|
26
35
|
submit(operation: () => MeshOperationId, signal?: AbortSignal): Promise<ZLinkMeshCompletion>;
|
|
27
36
|
private isDisposed;
|
|
28
37
|
complete(record: ReceiveRecord): void;
|
|
38
|
+
complete(record: ZLinkMeshCompletionTerminal, materialize: () => ReceiveRecord): void;
|
|
29
39
|
dispose(reason?: unknown): void;
|
|
30
40
|
get pendingCount(): number;
|
|
31
41
|
}
|