@zlink-systems/framework 0.30.0 → 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/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/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 +1 -1
- package/dist/runtime/actors/actor-handoff.js +7 -4
- 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 +6 -8
- package/dist/runtime/application-jobs/application-ingress-record-owner.js +39 -22
- package/dist/runtime/application-jobs/application-job-queue-scope.d.ts +2 -1
- package/dist/runtime/application-jobs/application-job-queue-scope.js +37 -22
- package/dist/runtime/application-jobs/contracts.d.ts +10 -1
- package/dist/runtime/backend/contracts/index.d.ts +18 -9
- package/dist/runtime/backend/mesh-completion-table.d.ts +9 -1
- package/dist/runtime/backend/mesh-completion-table.js +149 -49
- package/dist/runtime/backend/mesh-dispatch-pump.d.ts +3 -0
- package/dist/runtime/backend/mesh-dispatch-pump.js +32 -11
- package/dist/runtime/backend/node/node-backend-adapter-support.d.ts +2 -2
- package/dist/runtime/backend/node/node-backend-adapter-support.js +16 -9
- package/dist/runtime/backend/node/node-dealer-channel-client-transport.d.ts +1 -1
- package/dist/runtime/backend/node/node-dealer-channel-client-transport.js +5 -2
- package/dist/runtime/backend/node/node-raw-binding-port.js +42 -22
- package/dist/runtime/backend/node/node-raw-mesh-backend.d.ts +13 -5
- package/dist/runtime/backend/node/node-raw-mesh-backend.js +69 -51
- package/dist/runtime/backend/node/node-socket-backend-adapter.js +6 -6
- package/dist/runtime/backend/raw-binding-port.d.ts +2 -2
- package/dist/runtime/backend/runtime-message.d.ts +1 -0
- package/dist/runtime/backend/runtime-message.js +5 -0
- package/dist/runtime/backend/runtime-values.d.ts +1 -0
- package/dist/runtime/backend/runtime-values.js +2 -1
- package/dist/runtime/channels/channel-clients.d.ts +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-runtime-manager.d.ts +6 -6
- package/dist/runtime/channels/channel-runtime-manager.js +12 -12
- 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/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 +22 -5
- package/dist/runtime/foundation/raw-service-mesh-runtime.js +356 -232
- 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 +4 -4
- package/dist/runtime/foundation/service-stateful-runtime.js +44 -103
- package/dist/runtime/foundation/service-stateful-wire-codec.d.ts +0 -5
- package/dist/runtime/foundation/service-topology-registry.d.ts +12 -2
- package/dist/runtime/foundation/service-topology-registry.js +61 -27
- package/dist/runtime/foundation/service-wire-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-runtime-options-factory.js +2 -2
- package/dist/runtime/host/application-job-queue.d.ts +19 -7
- package/dist/runtime/host/application-job-queue.js +150 -42
- package/dist/runtime/host/entry-actor-runtime.d.ts +1 -0
- package/dist/runtime/host/entry-actor-runtime.js +3 -0
- package/dist/runtime/host/index.d.ts +7 -1
- package/dist/runtime/host/index.js +142 -118
- 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 +213 -241
- package/dist/runtime/host/spot-address-transport.js +3 -2
- package/dist/runtime/host/spot-runtime-options-factory.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/lifecycle.d.ts +1 -2
- package/dist/runtime/locations/lifecycle.js +2 -5
- 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 +1 -0
- package/dist/runtime/messaging/submission-result.js +5 -2
- 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 +7 -2
- package/dist/runtime/spots/formal-remote-actor-admission-registry.js +33 -19
- package/dist/runtime/spots/index.d.ts +3 -0
- package/dist/runtime/spots/index.js +9 -2
- package/dist/runtime/spots/spot-activation.d.ts +1 -0
- package/dist/runtime/spots/spot-activation.js +17 -8
- package/dist/runtime/spots/spot-entry-activation.js +6 -2
- 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-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-runtime-ports.d.ts +1 -0
- 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 +13 -27
- package/package.json +2 -2
- 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/Handlers/Attributes.ts +14 -21
- package/src/contracts/Handlers/JsonContract.ts +8 -216
- package/src/contracts/Spots/Contracts.ts +2 -1
- package/src/nest-integration.ts +1 -0
- package/src/runtime/actors/actor-client.ts +40 -16
- package/src/runtime/actors/actor-handoff.ts +9 -4
- 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 +41 -25
- package/src/runtime/application-jobs/application-job-queue-scope.ts +51 -22
- package/src/runtime/application-jobs/contracts.ts +14 -1
- package/src/runtime/backend/contracts/index.ts +53 -14
- package/src/runtime/backend/mesh-completion-table.ts +156 -57
- package/src/runtime/backend/mesh-dispatch-pump.ts +40 -10
- package/src/runtime/backend/node/node-backend-adapter-support.ts +17 -8
- package/src/runtime/backend/node/node-dealer-channel-client-transport.ts +12 -2
- package/src/runtime/backend/node/node-raw-binding-port.ts +57 -30
- package/src/runtime/backend/node/node-raw-mesh-backend.ts +128 -65
- package/src/runtime/backend/node/node-socket-backend-adapter.ts +21 -6
- package/src/runtime/backend/raw-binding-port.ts +7 -2
- package/src/runtime/backend/runtime-message.ts +6 -0
- package/src/runtime/backend/runtime-values.ts +1 -0
- package/src/runtime/channels/channel-clients.ts +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-runtime-manager.ts +29 -12
- 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/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 +484 -293
- 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 +67 -125
- package/src/runtime/foundation/service-stateful-wire-codec.ts +0 -5
- package/src/runtime/foundation/service-topology-registry.ts +91 -36
- 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-runtime-options-factory.ts +13 -2
- package/src/runtime/host/application-job-queue.ts +175 -41
- package/src/runtime/host/entry-actor-runtime.ts +4 -0
- package/src/runtime/host/index.ts +201 -156
- 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 +315 -291
- package/src/runtime/host/spot-address-transport.ts +4 -2
- package/src/runtime/host/spot-runtime-options-factory.ts +2 -0
- package/src/runtime/locations/actor-location-claims.ts +52 -30
- package/src/runtime/locations/lifecycle.ts +8 -26
- 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 +5 -1
- 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 +43 -23
- package/src/runtime/spots/index.ts +14 -2
- package/src/runtime/spots/spot-activation.ts +28 -10
- package/src/runtime/spots/spot-entry-activation.ts +9 -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-outbound.ts +36 -16
- package/src/runtime/spots/spot-routed-spot-packet-dispatch.ts +2 -1
- package/src/runtime/spots/spot-runtime-ports.ts +1 -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 +12 -29
|
@@ -36,7 +36,7 @@ class ZLinkSpotActivationLifecycle {
|
|
|
36
36
|
const serial = new spot_serial_turn_executor_1.ZLinkSpotSerialTurnExecutor(executionMode === contracts_1.ZLinkUserSpotExecutionMode.SpotWide, spotId);
|
|
37
37
|
const serialExecutor = new spot_serial_executor_1.ZLinkSpotSerialExecutor(serial, executionMode, spotId);
|
|
38
38
|
const actorHandlers = new actors_1.ZLinkSpotActorHandlerRegistryRuntime();
|
|
39
|
-
const handlers = new spot_handler_registry_1.DefaultZLinkSpotHandlerRegistry(actorHandlers);
|
|
39
|
+
const handlers = new spot_handler_registry_1.DefaultZLinkSpotHandlerRegistry(actorHandlers, this.options.providerResolver);
|
|
40
40
|
(0, spot_handler_registry_1.applySpotHandlerRegistrations)(handlers, implementation, objectKind === 'user_spot'
|
|
41
41
|
? {
|
|
42
42
|
actorSendHandlers: this.options.spotActorSendHandlers,
|
|
@@ -154,7 +154,7 @@ class ZLinkSpotActivationLifecycle {
|
|
|
154
154
|
const serial = serialOwner?.serial ?? new spot_serial_turn_executor_1.ZLinkSpotSerialTurnExecutor(true, spotId);
|
|
155
155
|
const serialExecutor = new spot_serial_executor_1.ZLinkSpotSerialExecutor(serial, contracts_1.ZLinkUserSpotExecutionMode.SpotWide, spotId);
|
|
156
156
|
const actorHandlers = new actors_1.ZLinkSpotActorHandlerRegistryRuntime();
|
|
157
|
-
const handlers = new spot_handler_registry_1.DefaultZLinkSpotHandlerRegistry(actorHandlers);
|
|
157
|
+
const handlers = new spot_handler_registry_1.DefaultZLinkSpotHandlerRegistry(actorHandlers, this.options.providerResolver);
|
|
158
158
|
const instanceHandlers = new spot_handler_registry_1.DefaultZLinkInstanceSpotHandlerRegistry(handlers);
|
|
159
159
|
(0, spot_handler_registry_1.applySpotHandlerRegistrations)(handlers, implementation, {
|
|
160
160
|
packetHandlers: this.options.spotPacketHandlers
|
|
@@ -268,7 +268,7 @@ class ZLinkSpotActivationLifecycle {
|
|
|
268
268
|
const serial = new spot_serial_turn_executor_1.ZLinkSpotSerialTurnExecutor(executionMode === contracts_1.ZLinkUserSpotExecutionMode.SpotWide, spotId);
|
|
269
269
|
const serialExecutor = new spot_serial_executor_1.ZLinkSpotSerialExecutor(serial, executionMode, spotId);
|
|
270
270
|
const actorHandlers = new actors_1.ZLinkSpotActorHandlerRegistryRuntime();
|
|
271
|
-
const handlers = new spot_handler_registry_1.DefaultZLinkSpotHandlerRegistry(actorHandlers);
|
|
271
|
+
const handlers = new spot_handler_registry_1.DefaultZLinkSpotHandlerRegistry(actorHandlers, this.options.providerResolver);
|
|
272
272
|
(0, spot_handler_registry_1.applySpotHandlerRegistrations)(handlers, spotType, {
|
|
273
273
|
actorSendHandlers: this.options.spotActorSendHandlers,
|
|
274
274
|
actorRequestHandlers: this.options.spotActorRequestHandlers,
|
|
@@ -571,7 +571,9 @@ class ZLinkSpotActivationLifecycle {
|
|
|
571
571
|
catch (error) {
|
|
572
572
|
// An OnClosing failure is diagnostic and cleanup continues. It is
|
|
573
573
|
// returned so host shutdown can classify its teardown outcome.
|
|
574
|
-
|
|
574
|
+
if (reason !== contracts_1.ZLinkSpotCloseReason.HostShutdown) {
|
|
575
|
+
this.options.closeErrorSink?.reportRuntimeTaskException(`spot ${String(activation.spotId)} onClosing`, error);
|
|
576
|
+
}
|
|
575
577
|
closingFailure = error;
|
|
576
578
|
}
|
|
577
579
|
}
|
|
@@ -598,7 +600,12 @@ class ZLinkSpotActivationLifecycle {
|
|
|
598
600
|
});
|
|
599
601
|
}
|
|
600
602
|
if (!state.nativeDisposed) {
|
|
601
|
-
await cleanup(
|
|
603
|
+
await cleanup(async () => {
|
|
604
|
+
if (reason === contracts_1.ZLinkSpotCloseReason.HostShutdown) {
|
|
605
|
+
await this.options.releaseActorMembers?.(locationMeshName, activation.spotId);
|
|
606
|
+
}
|
|
607
|
+
await activation.nativeSpot?.dispose();
|
|
608
|
+
}, () => {
|
|
602
609
|
state.nativeDisposed = true;
|
|
603
610
|
});
|
|
604
611
|
}
|
|
@@ -617,9 +624,11 @@ class ZLinkSpotActivationLifecycle {
|
|
|
617
624
|
state.locationReleased = true;
|
|
618
625
|
});
|
|
619
626
|
}
|
|
620
|
-
if (errors.length
|
|
621
|
-
|
|
622
|
-
|
|
627
|
+
if (errors.length > 0) {
|
|
628
|
+
if (closingFailure !== undefined)
|
|
629
|
+
errors.unshift(closingFailure);
|
|
630
|
+
if (errors.length === 1)
|
|
631
|
+
throw errors[0];
|
|
623
632
|
throw new AggregateError(errors, `Spot '${activation.spotId}' cleanup failed.`);
|
|
624
633
|
}
|
|
625
634
|
return closingFailure;
|
|
@@ -27,7 +27,7 @@ class ZLinkEntrySpotActivation {
|
|
|
27
27
|
spotSerialExecutor;
|
|
28
28
|
timers;
|
|
29
29
|
actorHandlers = new actors_1.ZLinkSpotActorHandlerRegistryRuntime();
|
|
30
|
-
handlers
|
|
30
|
+
handlers;
|
|
31
31
|
outbound;
|
|
32
32
|
workerRuntime;
|
|
33
33
|
lifecycleMetrics;
|
|
@@ -43,6 +43,7 @@ class ZLinkEntrySpotActivation {
|
|
|
43
43
|
if (options.detachedTaskRunner === undefined) {
|
|
44
44
|
throw new configuration_1.ZLinkConfigurationException('Entry Spot activation requires a detached task runner.');
|
|
45
45
|
}
|
|
46
|
+
this.handlers = new spot_handler_registry_1.DefaultZLinkSpotHandlerRegistry(this.actorHandlers, options.providerResolver);
|
|
46
47
|
this.serial = new spot_serial_turn_executor_1.ZLinkSpotSerialTurnExecutor(false, options.nativeSpot.routingId);
|
|
47
48
|
this.spotSerialExecutor = new spot_serial_executor_1.ZLinkSpotSerialExecutor(this.serial, contracts_1.ZLinkUserSpotExecutionMode.PerActor, options.nativeSpot.routingId);
|
|
48
49
|
// Entry Spot lifecycle, timers and detached continuations use this serial
|
|
@@ -182,7 +183,10 @@ class ZLinkEntrySpotActivation {
|
|
|
182
183
|
await cleanup(() => this.timers.dispose());
|
|
183
184
|
await cleanup(() => this.spotSerialExecutor.close());
|
|
184
185
|
await cleanup(() => (0, handler_instance_scope_1.disposeLifecycleHandlers)(this.entrySpot, this.options.detachedTaskRunner));
|
|
185
|
-
await cleanup(() =>
|
|
186
|
+
await cleanup(async () => {
|
|
187
|
+
await this.options.entryActorRuntime?.releaseMembers?.(this.options.spotNodeName);
|
|
188
|
+
await this.options.nativeSpot.dispose();
|
|
189
|
+
});
|
|
186
190
|
if (this.initialized) {
|
|
187
191
|
this.lifecycleMetrics.closed('entry');
|
|
188
192
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { Type, ZLinkActor, ZLinkEntrySpot, ZLinkInstanceSpotHandlerRegistry, ZLinkSpot, ZLinkSpotHandlerRegistry } from '../../contracts';
|
|
2
2
|
import type { ZLinkEntrySpotActorRequestHandlerRegistration, ZLinkEntrySpotActorSendHandlerRegistration, ZLinkEntrySpotPacketHandlerRegistration, ZLinkEntrySpotSubscriptionHandlerRegistration, ZLinkSpotActorRequestHandlerRegistration, ZLinkSpotActorSendHandlerRegistration, ZLinkSpotPacketHandlerRegistration, ZLinkSpotSubscriptionHandlerRegistration } from '../../contracts/Configuration/RegistrationTypes';
|
|
3
|
+
import type { ZLinkProviderResolver } from '../../contracts/Common/ZLinkProviderResolver';
|
|
3
4
|
import { ZLinkActorPacketKind, ZLinkSpotActorHandlerRegistryRuntime } from '../actors';
|
|
4
5
|
export interface ZLinkSpotHandlerRegistration {
|
|
5
6
|
readonly kind: 'packet' | 'subscribe' | 'actorSend' | 'actorRequest' | 'spotHandler';
|
|
@@ -11,8 +12,9 @@ export interface ZLinkSpotHandlerRegistration {
|
|
|
11
12
|
}
|
|
12
13
|
export declare class DefaultZLinkSpotHandlerRegistry<TActor extends ZLinkActor = ZLinkActor> implements ZLinkSpotHandlerRegistry {
|
|
13
14
|
private readonly actorHandlers?;
|
|
15
|
+
private readonly providerResolver?;
|
|
14
16
|
private readonly entries;
|
|
15
|
-
constructor(actorHandlers?: ZLinkSpotActorHandlerRegistryRuntime | undefined);
|
|
17
|
+
constructor(actorHandlers?: ZLinkSpotActorHandlerRegistryRuntime | undefined, providerResolver?: ZLinkProviderResolver | undefined);
|
|
16
18
|
addHandler<THandler>(handlerType: Type<THandler>, packetName?: string): this;
|
|
17
19
|
addActorPacket<THandler, TRegisteredActor extends ZLinkActor>(handlerType: Type<THandler>, actorType: Type<TRegisteredActor>): this;
|
|
18
20
|
addPacket(handlerType: Type, packetName?: string): this;
|
|
@@ -3,36 +3,43 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.DefaultZLinkInstanceSpotHandlerRegistry = exports.DefaultZLinkSpotHandlerRegistry = void 0;
|
|
4
4
|
exports.applyEntrySpotHandlerRegistrations = applyEntrySpotHandlerRegistrations;
|
|
5
5
|
exports.applySpotHandlerRegistrations = applySpotHandlerRegistrations;
|
|
6
|
-
const
|
|
6
|
+
const handler_instance_scope_1 = require("../handlers/handler-instance-scope");
|
|
7
|
+
const framework_errors_internal_1 = require("../framework-errors-internal");
|
|
7
8
|
const actors_1 = require("../actors");
|
|
8
9
|
const Attributes_1 = require("../../contracts/Handlers/Attributes");
|
|
9
10
|
class DefaultZLinkSpotHandlerRegistry {
|
|
10
11
|
actorHandlers;
|
|
12
|
+
providerResolver;
|
|
11
13
|
entries = [];
|
|
12
|
-
constructor(actorHandlers) {
|
|
14
|
+
constructor(actorHandlers, providerResolver) {
|
|
13
15
|
this.actorHandlers = actorHandlers;
|
|
16
|
+
this.providerResolver = providerResolver;
|
|
14
17
|
}
|
|
15
18
|
addHandler(handlerType, packetName) {
|
|
16
19
|
const metadata = (0, Attributes_1.readZLinkDecoratorMetadata)(handlerType).find((entry) => entry.kind === 'spotActorSend' || entry.kind === 'spotActorRequest');
|
|
17
20
|
const resolvedPacketName = packetName ?? metadata?.packetName;
|
|
18
21
|
if (metadata === undefined || resolvedPacketName === undefined) {
|
|
19
|
-
throw
|
|
22
|
+
throw (0, framework_errors_internal_1.createInternalFrameworkException)(framework_errors_internal_1.ZLinkFrameworkInternalErrorKind.InvalidOperation, `Actor packet handler '${handlerType.name}' must declare a packet name.`);
|
|
20
23
|
}
|
|
21
24
|
return this.addActorPacketRegistration(metadata.kind === 'spotActorSend' ? actors_1.ZLinkActorPacketKind.Send : actors_1.ZLinkActorPacketKind.Request, handlerType, Object, resolvedPacketName);
|
|
22
25
|
}
|
|
23
26
|
addActorPacket(handlerType, actorType) {
|
|
24
27
|
const metadata = (0, Attributes_1.readZLinkDecoratorMetadata)(handlerType).find((entry) => entry.kind === 'spotActorSend' || entry.kind === 'spotActorRequest');
|
|
25
28
|
if (metadata?.packetName === undefined) {
|
|
26
|
-
throw
|
|
29
|
+
throw (0, framework_errors_internal_1.createInternalFrameworkException)(framework_errors_internal_1.ZLinkFrameworkInternalErrorKind.InvalidOperation, `Actor packet handler '${handlerType.name}' must declare a packet name.`);
|
|
27
30
|
}
|
|
28
31
|
return this.addActorPacketRegistration(metadata.kind === 'spotActorSend' ? actors_1.ZLinkActorPacketKind.Send : actors_1.ZLinkActorPacketKind.Request, handlerType, actorType, metadata.packetName);
|
|
29
32
|
}
|
|
30
33
|
addPacket(handlerType, packetName) {
|
|
31
34
|
const declared = (0, Attributes_1.readZLinkDecoratorMetadata)(handlerType).find((entry) => entry.kind === 'packet')?.packetName;
|
|
35
|
+
(0, handler_instance_scope_1.prepareHandlerInstance)(this.providerResolver, handlerType);
|
|
36
|
+
const resolvedPacketName = packetName ?? declared ?? handlerType.name;
|
|
37
|
+
if (this.entries.some((entry) => entry.kind === 'packet' && entry.packetName === resolvedPacketName))
|
|
38
|
+
throw (0, framework_errors_internal_1.createInternalFrameworkException)(framework_errors_internal_1.ZLinkFrameworkInternalErrorKind.InvalidOperation, `SPOT packet '${resolvedPacketName}' is already registered.`);
|
|
32
39
|
this.entries.push({
|
|
33
40
|
kind: 'packet',
|
|
34
41
|
handlerType,
|
|
35
|
-
packetName:
|
|
42
|
+
packetName: resolvedPacketName
|
|
36
43
|
});
|
|
37
44
|
return this;
|
|
38
45
|
}
|
|
@@ -40,6 +47,7 @@ class DefaultZLinkSpotHandlerRegistry {
|
|
|
40
47
|
return this.addPacket(handlerType, packetName);
|
|
41
48
|
}
|
|
42
49
|
addActorPacketRegistration(kind, handlerType, actorType, packetName) {
|
|
50
|
+
(0, handler_instance_scope_1.prepareHandlerInstance)(this.providerResolver, handlerType);
|
|
43
51
|
this.entries.push({
|
|
44
52
|
kind: kind === actors_1.ZLinkActorPacketKind.Send ? 'actorSend' : 'actorRequest',
|
|
45
53
|
handlerType,
|
|
@@ -62,17 +70,18 @@ class DefaultZLinkSpotHandlerRegistry {
|
|
|
62
70
|
}
|
|
63
71
|
addSubscribe(handlerType, channelName, topic) {
|
|
64
72
|
if (channelName.trim().length === 0) {
|
|
65
|
-
throw
|
|
73
|
+
throw (0, framework_errors_internal_1.createInternalFrameworkException)(framework_errors_internal_1.ZLinkFrameworkInternalErrorKind.InvalidOperation, 'SPOT subscribe channel name must not be empty.');
|
|
66
74
|
}
|
|
67
75
|
if (topic.trim().length === 0) {
|
|
68
|
-
throw
|
|
76
|
+
throw (0, framework_errors_internal_1.createInternalFrameworkException)(framework_errors_internal_1.ZLinkFrameworkInternalErrorKind.InvalidOperation, 'SPOT subscribe topic must not be empty.');
|
|
69
77
|
}
|
|
70
78
|
if (this.entries.some((entry) => entry.kind === 'subscribe' &&
|
|
71
79
|
entry.handlerType === handlerType &&
|
|
72
80
|
entry.channelName === channelName &&
|
|
73
81
|
entry.topic === topic)) {
|
|
74
|
-
|
|
82
|
+
throw (0, framework_errors_internal_1.createInternalFrameworkException)(framework_errors_internal_1.ZLinkFrameworkInternalErrorKind.InvalidOperation, `SPOT subscription '${channelName}/${topic}' is already registered.`);
|
|
75
83
|
}
|
|
84
|
+
(0, handler_instance_scope_1.prepareHandlerInstance)(this.providerResolver, handlerType);
|
|
76
85
|
this.entries.push({ kind: 'subscribe', handlerType, channelName, topic });
|
|
77
86
|
return this;
|
|
78
87
|
}
|
|
@@ -80,6 +89,7 @@ class DefaultZLinkSpotHandlerRegistry {
|
|
|
80
89
|
return this.addSubscribe(handlerType, channelName, topic);
|
|
81
90
|
}
|
|
82
91
|
addSpotHandler(handlerType) {
|
|
92
|
+
(0, handler_instance_scope_1.prepareHandlerInstance)(this.providerResolver, handlerType);
|
|
83
93
|
this.entries.push({ kind: 'spotHandler', handlerType });
|
|
84
94
|
return this;
|
|
85
95
|
}
|
|
@@ -105,16 +105,17 @@ class ZLinkSpotNodeAutoConnectExecutor {
|
|
|
105
105
|
this.node.onPeerDisconnected?.(handler);
|
|
106
106
|
}
|
|
107
107
|
async connect(target) {
|
|
108
|
-
if (this.manualConnections)
|
|
109
|
-
return false;
|
|
110
108
|
const key = connectionKey(target);
|
|
109
|
+
if (!this.connectionIntents.has(key) &&
|
|
110
|
+
this.node.hasPeerRouteOrConnectionIntent?.(target.nodeRid, target.endpoint) === true)
|
|
111
|
+
return false;
|
|
111
112
|
const intent = await this.lane.run(() => this.prepareConnectCore(key));
|
|
112
113
|
if (intent === undefined)
|
|
113
114
|
return true;
|
|
114
115
|
return await runDetachedSpotNodeAutoConnect(() => this.connectPeer(target, key, intent));
|
|
115
116
|
}
|
|
116
117
|
disconnect(target) {
|
|
117
|
-
if (this.
|
|
118
|
+
if (!this.connectionIntents.has(connectionKey(target)))
|
|
118
119
|
return;
|
|
119
120
|
this.disconnectPeer(target);
|
|
120
121
|
}
|
|
@@ -35,6 +35,7 @@ export declare class DefaultZLinkSpotOutbound implements ZLinkSpotOutbound {
|
|
|
35
35
|
private requireAddressTransport;
|
|
36
36
|
}
|
|
37
37
|
export interface ZLinkSpotAddressCallOptions {
|
|
38
|
+
readonly onAdmitted?: () => void;
|
|
38
39
|
readonly metadata?: ReadonlyMap<string, string>;
|
|
39
40
|
readonly instanceSpot: boolean;
|
|
40
41
|
readonly instanceSpotType?: string;
|
|
@@ -63,10 +64,12 @@ export interface ZLinkSpotRoutedSendOptions {
|
|
|
63
64
|
readonly metadata?: ReadonlyMap<string, string>;
|
|
64
65
|
}
|
|
65
66
|
export interface ZLinkSpotRoutedRequestOptions extends ZLinkSpotRoutedSendOptions {
|
|
67
|
+
readonly onAdmitted?: () => void;
|
|
66
68
|
readonly timeoutMs?: number;
|
|
67
69
|
readonly signal?: AbortSignal;
|
|
68
70
|
}
|
|
69
71
|
export interface ZLinkSpotHandleCallOptions {
|
|
72
|
+
readonly onAdmitted?: () => void;
|
|
70
73
|
readonly metadata?: ReadonlyMap<string, string>;
|
|
71
74
|
readonly timeoutMs?: number;
|
|
72
75
|
readonly signal?: AbortSignal;
|
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.DefaultZLinkSpotOutbound = void 0;
|
|
4
4
|
exports.sendToSpotHandle = sendToSpotHandle;
|
|
5
5
|
exports.requestToSpotHandle = requestToSpotHandle;
|
|
6
|
+
const request_result_1 = require("../messaging/request-result");
|
|
6
7
|
const contracts_1 = require("../../contracts");
|
|
7
8
|
const CoreTypes_1 = require("../../contracts/Common/CoreTypes");
|
|
8
9
|
const configuration_1 = require("../configuration");
|
|
@@ -115,14 +116,13 @@ function createAddressedSpotSendCall(serial, transport, spotId, message, sourceS
|
|
|
115
116
|
}
|
|
116
117
|
function createAddressedSpotRequestCall(serial, transport, spotId, request, sourceSpotProvider) {
|
|
117
118
|
const options = newAddressCallOptions();
|
|
118
|
-
const begin = (
|
|
119
|
-
markSubmitted(options);
|
|
120
|
-
rejectSameSpotAsyncRequest(serial, spotId, waitPolicy);
|
|
119
|
+
const begin = (signal, onAdmitted) => {
|
|
121
120
|
return startRequestOnSerial(serial, () => ({
|
|
122
121
|
pending: transport.requestToSpotAddress(spotId, request, {
|
|
123
122
|
...freezeAddressCallOptions(options, sourceSpotProvider?.()),
|
|
124
123
|
timeoutMs: options.timeoutMs,
|
|
125
|
-
signal
|
|
124
|
+
signal,
|
|
125
|
+
onAdmitted
|
|
126
126
|
})
|
|
127
127
|
}));
|
|
128
128
|
};
|
|
@@ -153,12 +153,15 @@ function createAddressedSpotRequestCall(serial, transport, spotId, request, sour
|
|
|
153
153
|
return this;
|
|
154
154
|
},
|
|
155
155
|
submit(signal) {
|
|
156
|
-
|
|
157
|
-
|
|
156
|
+
markSubmitted(options);
|
|
157
|
+
rejectSameSpotAsyncRequest(serial, spotId, 'async');
|
|
158
|
+
return (0, request_result_1.createZLinkRequest)((onAdmitted) => begin(signal, onAdmitted), (pending) => (serial.isCurrentTurn ? pending : (0, workers_1.deliverOnSerial)(serial, pending)));
|
|
158
159
|
},
|
|
159
160
|
yield(signal) {
|
|
160
161
|
const turn = (0, execution_1.requireZLinkYieldTurn)();
|
|
161
|
-
|
|
162
|
+
markSubmitted(options);
|
|
163
|
+
rejectSameSpotAsyncRequest(serial, spotId, 'yield');
|
|
164
|
+
const pending = begin(signal);
|
|
162
165
|
return turn.yieldPromise(pending);
|
|
163
166
|
}
|
|
164
167
|
};
|
|
@@ -250,7 +253,12 @@ function wrapPublishCall(serial, inner) {
|
|
|
250
253
|
};
|
|
251
254
|
}
|
|
252
255
|
function wrapRequestCall(serial, inner) {
|
|
253
|
-
const begin = (signal) => startRequestOnSerial(serial, () =>
|
|
256
|
+
const begin = (signal, onAdmitted) => startRequestOnSerial(serial, () => {
|
|
257
|
+
const pending = inner.submit(signal);
|
|
258
|
+
if (onAdmitted !== undefined)
|
|
259
|
+
void pending.admitted.then(onAdmitted, () => undefined);
|
|
260
|
+
return { pending };
|
|
261
|
+
});
|
|
254
262
|
return {
|
|
255
263
|
metadata(key, value) {
|
|
256
264
|
if (typeof key === 'string')
|
|
@@ -264,8 +272,7 @@ function wrapRequestCall(serial, inner) {
|
|
|
264
272
|
return this;
|
|
265
273
|
},
|
|
266
274
|
submit(signal) {
|
|
267
|
-
|
|
268
|
-
return serial.isCurrentTurn ? pending : (0, workers_1.deliverOnSerial)(serial, pending);
|
|
275
|
+
return (0, request_result_1.createZLinkRequest)((onAdmitted) => begin(signal, onAdmitted), (pending) => (serial.isCurrentTurn ? pending : (0, workers_1.deliverOnSerial)(serial, pending)));
|
|
269
276
|
},
|
|
270
277
|
yield(signal) {
|
|
271
278
|
const turn = (0, execution_1.requireZLinkYieldTurn)();
|
|
@@ -320,15 +327,15 @@ function wrapRoutedSpotSendCall(serial, transport, spot, message, spotRouterChan
|
|
|
320
327
|
function wrapRoutedSpotRequestCall(serial, transport, spot, request, spotRouterChannelIdForMesh, sourceSpotProvider) {
|
|
321
328
|
let selectedTimeoutMs;
|
|
322
329
|
const metadata = new Map();
|
|
323
|
-
const begin = (
|
|
330
|
+
const begin = (signal, onAdmitted) => {
|
|
324
331
|
// A request to the current Spot would wait behind the handler that owns
|
|
325
332
|
// the same Spot claim. Reject it before resolving a route or submitting
|
|
326
333
|
// transport work; one-way self-send remains a valid FIFO admission.
|
|
327
|
-
rejectSameSpotAsyncRequest(serial, spot.spotId, waitPolicy);
|
|
328
334
|
return startRequestOnSerial(serial, () => ({
|
|
329
335
|
pending: requestToSpotHandle(transport, spot, request, {
|
|
330
336
|
timeoutMs: selectedTimeoutMs,
|
|
331
337
|
signal,
|
|
338
|
+
onAdmitted,
|
|
332
339
|
metadata,
|
|
333
340
|
spotRouterChannelIdForMesh,
|
|
334
341
|
sourceSpot: sourceSpotProvider?.()
|
|
@@ -352,12 +359,13 @@ function wrapRoutedSpotRequestCall(serial, transport, spot, request, spotRouterC
|
|
|
352
359
|
return this;
|
|
353
360
|
},
|
|
354
361
|
submit(signal) {
|
|
355
|
-
|
|
356
|
-
return serial.isCurrentTurn ? pending : (0, workers_1.deliverOnSerial)(serial, pending);
|
|
362
|
+
rejectSameSpotAsyncRequest(serial, spot.spotId, 'async');
|
|
363
|
+
return (0, request_result_1.createZLinkRequest)((onAdmitted) => begin(signal, onAdmitted), (pending) => (serial.isCurrentTurn ? pending : (0, workers_1.deliverOnSerial)(serial, pending)));
|
|
357
364
|
},
|
|
358
365
|
yield(signal) {
|
|
359
366
|
const turn = (0, execution_1.requireZLinkYieldTurn)();
|
|
360
|
-
|
|
367
|
+
rejectSameSpotAsyncRequest(serial, spot.spotId, 'yield');
|
|
368
|
+
const pending = begin(signal);
|
|
361
369
|
return turn.yieldPromise(pending);
|
|
362
370
|
}
|
|
363
371
|
};
|
|
@@ -395,6 +403,7 @@ async function requestToSpotHandle(transport, spot, request, options = {}) {
|
|
|
395
403
|
packetName,
|
|
396
404
|
timeoutMs: options.timeoutMs,
|
|
397
405
|
signal: options.signal,
|
|
406
|
+
onAdmitted: options.onAdmitted,
|
|
398
407
|
metadata: options.metadata
|
|
399
408
|
};
|
|
400
409
|
if (options.sourceSpot !== undefined && transport.requestFromSpotToSpot !== undefined) {
|
|
@@ -23,6 +23,7 @@ interface ZLinkRoutedSpotPacketDispatchOptions {
|
|
|
23
23
|
}
|
|
24
24
|
interface ZLinkRoutedSpotPacketContext {
|
|
25
25
|
readonly channelName: string;
|
|
26
|
+
readonly onAdmitted?: () => void;
|
|
26
27
|
readonly contentType?: string;
|
|
27
28
|
readonly workOptions?: ZLinkSerialWorkOptions;
|
|
28
29
|
readonly admissionTimeoutMs?: number;
|
|
@@ -151,7 +151,7 @@ class ZLinkRoutedSpotPacketDispatch {
|
|
|
151
151
|
if (activation.serial.isCurrentTurn) {
|
|
152
152
|
throw (0, framework_errors_internal_1.createInternalFrameworkException)(framework_errors_internal_1.ZLinkFrameworkInternalErrorKind.InvalidOperation, `Spot '${spotId}' cannot await a request to its current serial turn.`);
|
|
153
153
|
}
|
|
154
|
-
await activation.serial.execute(runHandler, context.workOptions, instanceIntent ? runHandler : undefined);
|
|
154
|
+
await activation.serial.execute(runHandler, { ...context.workOptions, onAdmitted: context.onAdmitted }, instanceIntent ? runHandler : undefined);
|
|
155
155
|
}
|
|
156
156
|
}
|
|
157
157
|
catch (error) {
|
|
@@ -8,6 +8,7 @@ import type { ZLinkActorResponseOptions } from './spot-actor-packet-dispatch';
|
|
|
8
8
|
import type { ZLinkRemoteActorJoinActor, ZLinkRoutedActorTransferProvider } from './spot-remote-codec';
|
|
9
9
|
import type { ZLinkBackendSpotNode } from '../backend/contracts';
|
|
10
10
|
export interface ZLinkEntryActorRuntime {
|
|
11
|
+
releaseMembers?(meshName: string): Promise<void>;
|
|
11
12
|
resolveActor(actorId: string): ZLinkActor | undefined;
|
|
12
13
|
commitActorTransaction(actor: ZLinkActor, onJoined: () => Promise<void>): Promise<void>;
|
|
13
14
|
destroyActor(node: ZLinkBackendSpotNode, entryNodeRid: RoutingId, actor: ZLinkActor, signal?: AbortSignal): Promise<void>;
|
|
@@ -31,9 +31,6 @@ class ZLinkSpotSubscriptionDispatch {
|
|
|
31
31
|
}
|
|
32
32
|
const key = subscriptionKey(registration.channelName, registration.topic);
|
|
33
33
|
const existing = this.handlers.get(key) ?? [];
|
|
34
|
-
if (existing.some((entry) => entry.handlerType === registration.handlerType)) {
|
|
35
|
-
continue;
|
|
36
|
-
}
|
|
37
34
|
existing.push(registration);
|
|
38
35
|
this.handlers.set(key, existing);
|
|
39
36
|
this.options.nativeSpot.setSubscription(registration.channelName, registration.topic);
|
|
@@ -50,6 +50,7 @@ class ZLinkSpotTimerRegistry {
|
|
|
50
50
|
async add(name, periodMs, options, handlerType, serial, spot, providerResolver, signal, reportFailure) {
|
|
51
51
|
(0, TimerRegistrationValidator_1.validateTimerRegistration)(name, periodMs, options);
|
|
52
52
|
(0, abort_1.throwIfAborted)(signal);
|
|
53
|
+
(0, handler_instance_scope_1.prepareHandlerInstance)(providerResolver, handlerType);
|
|
53
54
|
const handler = await (0, handler_instance_scope_1.resolveLifecycleHandler)(spot, handlerType, providerResolver);
|
|
54
55
|
const prepared = await this.lane.run(() => this.prepareAddCore(name));
|
|
55
56
|
if (prepared.previous !== undefined)
|
|
@@ -134,7 +134,7 @@ export declare class ZLinkStreamSessionNodeRuntime {
|
|
|
134
134
|
private readonly receiveAbortController;
|
|
135
135
|
private receiveLoop;
|
|
136
136
|
private monitorLoop;
|
|
137
|
-
private
|
|
137
|
+
private receiveWake;
|
|
138
138
|
private receiveWorkSinceYield;
|
|
139
139
|
constructor(options: ZLinkStreamSessionNodeRuntimeOptions & ZLinkStreamLivenessOptions);
|
|
140
140
|
start(): void;
|
|
@@ -33,27 +33,6 @@ const systemLivenessClock = {
|
|
|
33
33
|
setTimer: (callback, delayMs) => setTimeout(callback, Math.min(delayMs, MAX_TIMER_DELAY_MS)),
|
|
34
34
|
clearTimer: (timer) => clearTimeout(timer)
|
|
35
35
|
};
|
|
36
|
-
class ZLinkStreamReceiveWake {
|
|
37
|
-
pending;
|
|
38
|
-
resolvePending;
|
|
39
|
-
finish = () => {
|
|
40
|
-
const resolve = this.resolvePending;
|
|
41
|
-
this.pending = undefined;
|
|
42
|
-
this.resolvePending = undefined;
|
|
43
|
-
resolve?.();
|
|
44
|
-
};
|
|
45
|
-
wait() {
|
|
46
|
-
if (this.pending !== undefined)
|
|
47
|
-
return this.pending;
|
|
48
|
-
this.pending = new Promise((resolve) => {
|
|
49
|
-
this.resolvePending = resolve;
|
|
50
|
-
});
|
|
51
|
-
return this.pending;
|
|
52
|
-
}
|
|
53
|
-
wake() {
|
|
54
|
-
this.finish();
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
36
|
class ZLinkStreamSessionRuntime {
|
|
58
37
|
options;
|
|
59
38
|
removeSession;
|
|
@@ -650,7 +629,7 @@ class ZLinkStreamSessionNodeRuntime {
|
|
|
650
629
|
receiveAbortController = new AbortController();
|
|
651
630
|
receiveLoop;
|
|
652
631
|
monitorLoop;
|
|
653
|
-
receiveWake
|
|
632
|
+
receiveWake;
|
|
654
633
|
receiveWorkSinceYield = 0;
|
|
655
634
|
constructor(options) {
|
|
656
635
|
this.options = options;
|
|
@@ -1113,13 +1092,20 @@ class ZLinkStreamSessionNodeRuntime {
|
|
|
1113
1092
|
});
|
|
1114
1093
|
}
|
|
1115
1094
|
async waitReceiveLoopWake(signal) {
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1095
|
+
const wake = new AbortController();
|
|
1096
|
+
this.receiveWake = wake;
|
|
1097
|
+
try {
|
|
1098
|
+
// Readiness, internal wake and shutdown share one cancellable wait;
|
|
1099
|
+
// no losing Promise retains reactions across receive cycles.
|
|
1100
|
+
await this.options.readablePoller.waitForReadable(AbortSignal.any([signal, wake.signal]));
|
|
1101
|
+
}
|
|
1102
|
+
finally {
|
|
1103
|
+
wake.abort();
|
|
1104
|
+
this.receiveWake = undefined;
|
|
1105
|
+
}
|
|
1120
1106
|
}
|
|
1121
1107
|
wakeReceiveLoop() {
|
|
1122
|
-
this.receiveWake
|
|
1108
|
+
this.receiveWake?.abort();
|
|
1123
1109
|
}
|
|
1124
1110
|
getOrCreateSession(routingId) {
|
|
1125
1111
|
const sessionId = (0, managed_stream_1.streamSessionIdFromRoutingId)(routingId);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zlink-systems/framework",
|
|
3
|
-
"version": "0.30.
|
|
3
|
+
"version": "0.30.1",
|
|
4
4
|
"license": "SEE LICENSE IN LICENSE",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
"dependencies": {
|
|
20
20
|
"@opentelemetry/api": "^1.9.1",
|
|
21
21
|
"@opentelemetry/api-logs": "^0.221.0",
|
|
22
|
-
"@zlink-systems/stream-wire": "0.30.
|
|
22
|
+
"@zlink-systems/stream-wire": "0.30.1",
|
|
23
23
|
"@zlink-systems/zlink": "1.19.0"
|
|
24
24
|
}
|
|
25
25
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { ActorId } from '../Common';
|
|
2
|
+
import type { ZLinkRequest } from '../Handlers/Attributes';
|
|
2
3
|
|
|
3
4
|
export interface ZLinkActorClient {
|
|
4
5
|
sendToActor(actorId: ActorId, message: unknown): ZLinkActorSendCall;
|
|
@@ -13,6 +14,6 @@ export interface ZLinkActorSendCall {
|
|
|
13
14
|
export interface ZLinkActorRequestCall {
|
|
14
15
|
metadata(key: string, value: string): this;
|
|
15
16
|
timeout(timeoutMs: number): this;
|
|
16
|
-
submit<TReply>(signal?: AbortSignal):
|
|
17
|
+
submit<TReply>(signal?: AbortSignal): ZLinkRequest<TReply>;
|
|
17
18
|
yield<TReply>(signal?: AbortSignal): Promise<TReply>;
|
|
18
19
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { ZLinkMessageMetadata } from '../Common';
|
|
2
|
+
import type { ZLinkRequest } from '../Handlers/Attributes';
|
|
2
3
|
|
|
3
4
|
export interface ZLinkSendCall {
|
|
4
5
|
metadata(key: string, value: string): this;
|
|
@@ -10,7 +11,7 @@ export interface ZLinkRequestCall {
|
|
|
10
11
|
metadata(key: string, value: string): this;
|
|
11
12
|
metadata(metadata: ZLinkMessageMetadata): this;
|
|
12
13
|
timeout(timeoutMs: number): this;
|
|
13
|
-
submit<TReply>(signal?: AbortSignal):
|
|
14
|
+
submit<TReply>(signal?: AbortSignal): ZLinkRequest<TReply>;
|
|
14
15
|
}
|
|
15
16
|
|
|
16
17
|
export interface ZLinkChannelRequestCall extends ZLinkRequestCall {
|
|
@@ -11,7 +11,7 @@ export interface ZLinkMessageMetadataPolicy {
|
|
|
11
11
|
class ImmutableZLinkMessageMetadata implements ZLinkMessageMetadata {
|
|
12
12
|
readonly values: ReadonlyMap<string, string>;
|
|
13
13
|
|
|
14
|
-
constructor(values:
|
|
14
|
+
constructor(values: Iterable<readonly [string, string]> = []) {
|
|
15
15
|
this.values = Object.freeze(new ImmutableMetadataMap(values));
|
|
16
16
|
}
|
|
17
17
|
|
|
@@ -23,12 +23,8 @@ class ImmutableZLinkMessageMetadata implements ZLinkMessageMetadata {
|
|
|
23
23
|
class ImmutableMetadataMap implements ReadonlyMap<string, string> {
|
|
24
24
|
readonly #values: Map<string, string>;
|
|
25
25
|
|
|
26
|
-
constructor(values:
|
|
27
|
-
this.#values = new Map(
|
|
28
|
-
typeof (values as ReadonlyMap<string, string>)[Symbol.iterator] === 'function'
|
|
29
|
-
? (values as ReadonlyMap<string, string>)
|
|
30
|
-
: Object.entries(values)
|
|
31
|
-
);
|
|
26
|
+
constructor(values: Iterable<readonly [string, string]>) {
|
|
27
|
+
this.#values = new Map(values);
|
|
32
28
|
}
|
|
33
29
|
|
|
34
30
|
get size(): number {
|
|
@@ -74,5 +70,14 @@ export const ZLinkMessageMetadataEmpty: ZLinkMessageMetadata = Object.freeze(
|
|
|
74
70
|
export function zlinkMessageMetadata(
|
|
75
71
|
values: ReadonlyMap<string, string> | Readonly<Record<string, string>>
|
|
76
72
|
): ZLinkMessageMetadata {
|
|
77
|
-
|
|
73
|
+
const entries =
|
|
74
|
+
typeof (values as ReadonlyMap<string, string>)[Symbol.iterator] === 'function'
|
|
75
|
+
? (values as ReadonlyMap<string, string>)
|
|
76
|
+
: Object.entries(values);
|
|
77
|
+
const size = Array.isArray(entries)
|
|
78
|
+
? entries.length
|
|
79
|
+
: (entries as ReadonlyMap<string, string>).size;
|
|
80
|
+
return size === 0
|
|
81
|
+
? ZLinkMessageMetadataEmpty
|
|
82
|
+
: Object.freeze(new ImmutableZLinkMessageMetadata(entries));
|
|
78
83
|
}
|
|
@@ -4,23 +4,25 @@ import {
|
|
|
4
4
|
type ZLinkPacketJsonContract
|
|
5
5
|
} from './JsonContract';
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
readonly jsonContract?: ZLinkPacketJsonContract;
|
|
18
|
-
}
|
|
7
|
+
import {
|
|
8
|
+
ZLINK_DECORATOR_METADATA,
|
|
9
|
+
readZLinkDecoratorMetadata,
|
|
10
|
+
type ZLinkDecoratorMetadata
|
|
11
|
+
} from '@zlink-systems/stream-wire/internal/json';
|
|
12
|
+
export {
|
|
13
|
+
ZLINK_DECORATOR_METADATA,
|
|
14
|
+
readZLinkDecoratorMetadata
|
|
15
|
+
} from '@zlink-systems/stream-wire/internal/json';
|
|
16
|
+
export type { ZLinkDecoratorMetadata } from '@zlink-systems/stream-wire/internal/json';
|
|
19
17
|
|
|
20
18
|
export function ZLinkHandlerGroup(groupName: string): ClassDecorator {
|
|
21
19
|
return classDecorator({ kind: 'handlerGroup', groupName });
|
|
22
20
|
}
|
|
23
21
|
|
|
22
|
+
export interface ZLinkRequest<TReply> extends Promise<TReply> {
|
|
23
|
+
readonly admitted: Promise<void>;
|
|
24
|
+
}
|
|
25
|
+
|
|
24
26
|
export function ZLinkRequest(packetName?: string): MethodDecorator {
|
|
25
27
|
return methodDecorator({ kind: 'request', packetName });
|
|
26
28
|
}
|
|
@@ -106,12 +108,3 @@ function appendMetadata(target: object, metadata: ZLinkDecoratorMetadata): void
|
|
|
106
108
|
writable: false
|
|
107
109
|
});
|
|
108
110
|
}
|
|
109
|
-
|
|
110
|
-
export function readZLinkDecoratorMetadata(target: object): readonly ZLinkDecoratorMetadata[] {
|
|
111
|
-
if (!Object.prototype.hasOwnProperty.call(target, ZLINK_DECORATOR_METADATA)) {
|
|
112
|
-
return [];
|
|
113
|
-
}
|
|
114
|
-
return (target as Record<symbol, unknown>)[
|
|
115
|
-
ZLINK_DECORATOR_METADATA
|
|
116
|
-
] as readonly ZLinkDecoratorMetadata[];
|
|
117
|
-
}
|