@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
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { ActorId } from '../Common';
|
|
2
|
+
import type { ZLinkRequest } from '../Handlers/Attributes';
|
|
2
3
|
export interface ZLinkActorClient {
|
|
3
4
|
sendToActor(actorId: ActorId, message: unknown): ZLinkActorSendCall;
|
|
4
5
|
requestToActor(actorId: ActorId, request: unknown): ZLinkActorRequestCall;
|
|
@@ -10,6 +11,6 @@ export interface ZLinkActorSendCall {
|
|
|
10
11
|
export interface ZLinkActorRequestCall {
|
|
11
12
|
metadata(key: string, value: string): this;
|
|
12
13
|
timeout(timeoutMs: number): this;
|
|
13
|
-
submit<TReply>(signal?: AbortSignal):
|
|
14
|
+
submit<TReply>(signal?: AbortSignal): ZLinkRequest<TReply>;
|
|
14
15
|
yield<TReply>(signal?: AbortSignal): Promise<TReply>;
|
|
15
16
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { ZLinkMessageMetadata } from '../Common';
|
|
2
|
+
import type { ZLinkRequest } from '../Handlers/Attributes';
|
|
2
3
|
export interface ZLinkSendCall {
|
|
3
4
|
metadata(key: string, value: string): this;
|
|
4
5
|
metadata(metadata: ZLinkMessageMetadata): this;
|
|
@@ -8,7 +9,7 @@ export interface ZLinkRequestCall {
|
|
|
8
9
|
metadata(key: string, value: string): this;
|
|
9
10
|
metadata(metadata: ZLinkMessageMetadata): this;
|
|
10
11
|
timeout(timeoutMs: number): this;
|
|
11
|
-
submit<TReply>(signal?: AbortSignal):
|
|
12
|
+
submit<TReply>(signal?: AbortSignal): ZLinkRequest<TReply>;
|
|
12
13
|
}
|
|
13
14
|
export interface ZLinkChannelRequestCall extends ZLinkRequestCall {
|
|
14
15
|
yield<TReply>(signal?: AbortSignal): Promise<TReply>;
|
|
@@ -4,7 +4,7 @@ exports.ZLinkMessageMetadataEmpty = void 0;
|
|
|
4
4
|
exports.zlinkMessageMetadata = zlinkMessageMetadata;
|
|
5
5
|
class ImmutableZLinkMessageMetadata {
|
|
6
6
|
values;
|
|
7
|
-
constructor(values =
|
|
7
|
+
constructor(values = []) {
|
|
8
8
|
this.values = Object.freeze(new ImmutableMetadataMap(values));
|
|
9
9
|
}
|
|
10
10
|
find(key) {
|
|
@@ -14,9 +14,7 @@ class ImmutableZLinkMessageMetadata {
|
|
|
14
14
|
class ImmutableMetadataMap {
|
|
15
15
|
#values;
|
|
16
16
|
constructor(values) {
|
|
17
|
-
this.#values = new Map(
|
|
18
|
-
? values
|
|
19
|
-
: Object.entries(values));
|
|
17
|
+
this.#values = new Map(values);
|
|
20
18
|
}
|
|
21
19
|
get size() {
|
|
22
20
|
return this.#values.size;
|
|
@@ -45,5 +43,13 @@ class ImmutableMetadataMap {
|
|
|
45
43
|
}
|
|
46
44
|
exports.ZLinkMessageMetadataEmpty = Object.freeze(new ImmutableZLinkMessageMetadata());
|
|
47
45
|
function zlinkMessageMetadata(values) {
|
|
48
|
-
|
|
46
|
+
const entries = typeof values[Symbol.iterator] === 'function'
|
|
47
|
+
? values
|
|
48
|
+
: Object.entries(values);
|
|
49
|
+
const size = Array.isArray(entries)
|
|
50
|
+
? entries.length
|
|
51
|
+
: entries.size;
|
|
52
|
+
return size === 0
|
|
53
|
+
? exports.ZLinkMessageMetadataEmpty
|
|
54
|
+
: Object.freeze(new ImmutableZLinkMessageMetadata(entries));
|
|
49
55
|
}
|
|
@@ -1,16 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
export
|
|
3
|
-
export interface ZLinkDecoratorMetadata {
|
|
4
|
-
readonly kind: string;
|
|
5
|
-
readonly packetName?: string;
|
|
6
|
-
readonly groupName?: string;
|
|
7
|
-
readonly methodName?: string;
|
|
8
|
-
readonly meshName?: string;
|
|
9
|
-
readonly channelName?: string;
|
|
10
|
-
readonly topic?: string;
|
|
11
|
-
readonly jsonContract?: ZLinkPacketJsonContract;
|
|
12
|
-
}
|
|
1
|
+
export { ZLINK_DECORATOR_METADATA, readZLinkDecoratorMetadata } from '@zlink-systems/stream-wire/internal/json';
|
|
2
|
+
export type { ZLinkDecoratorMetadata } from '@zlink-systems/stream-wire/internal/json';
|
|
13
3
|
export declare function ZLinkHandlerGroup(groupName: string): ClassDecorator;
|
|
4
|
+
export interface ZLinkRequest<TReply> extends Promise<TReply> {
|
|
5
|
+
readonly admitted: Promise<void>;
|
|
6
|
+
}
|
|
14
7
|
export declare function ZLinkRequest(packetName?: string): MethodDecorator;
|
|
15
8
|
export declare function ZLinkSend(packetName?: string): MethodDecorator;
|
|
16
9
|
export declare function ZLinkPublish(packetName?: string): MethodDecorator;
|
|
@@ -21,4 +14,3 @@ export declare function ZLinkSpotActorSend(packetName?: string): MethodDecorator
|
|
|
21
14
|
export declare function ZLinkSpotActorRequest(packetName?: string): MethodDecorator;
|
|
22
15
|
export declare function ZLinkStreamPacket(): MethodDecorator;
|
|
23
16
|
export declare function ZLinkStreamRaw(): MethodDecorator;
|
|
24
|
-
export declare function readZLinkDecoratorMetadata(target: object): readonly ZLinkDecoratorMetadata[];
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ZLINK_DECORATOR_METADATA = void 0;
|
|
3
|
+
exports.readZLinkDecoratorMetadata = exports.ZLINK_DECORATOR_METADATA = void 0;
|
|
4
4
|
exports.ZLinkHandlerGroup = ZLinkHandlerGroup;
|
|
5
5
|
exports.ZLinkRequest = ZLinkRequest;
|
|
6
6
|
exports.ZLinkSend = ZLinkSend;
|
|
@@ -13,9 +13,11 @@ exports.ZLinkSpotActorSend = ZLinkSpotActorSend;
|
|
|
13
13
|
exports.ZLinkSpotActorRequest = ZLinkSpotActorRequest;
|
|
14
14
|
exports.ZLinkStreamPacket = ZLinkStreamPacket;
|
|
15
15
|
exports.ZLinkStreamRaw = ZLinkStreamRaw;
|
|
16
|
-
exports.readZLinkDecoratorMetadata = readZLinkDecoratorMetadata;
|
|
17
16
|
const JsonContract_1 = require("./JsonContract");
|
|
18
|
-
|
|
17
|
+
const json_1 = require("@zlink-systems/stream-wire/internal/json");
|
|
18
|
+
var json_2 = require("@zlink-systems/stream-wire/internal/json");
|
|
19
|
+
Object.defineProperty(exports, "ZLINK_DECORATOR_METADATA", { enumerable: true, get: function () { return json_2.ZLINK_DECORATOR_METADATA; } });
|
|
20
|
+
Object.defineProperty(exports, "readZLinkDecoratorMetadata", { enumerable: true, get: function () { return json_2.readZLinkDecoratorMetadata; } });
|
|
19
21
|
function ZLinkHandlerGroup(groupName) {
|
|
20
22
|
return classDecorator({ kind: 'handlerGroup', groupName });
|
|
21
23
|
}
|
|
@@ -68,17 +70,11 @@ function methodDecorator(metadata) {
|
|
|
68
70
|
});
|
|
69
71
|
}
|
|
70
72
|
function appendMetadata(target, metadata) {
|
|
71
|
-
const current = readZLinkDecoratorMetadata(target);
|
|
72
|
-
Object.defineProperty(target,
|
|
73
|
+
const current = (0, json_1.readZLinkDecoratorMetadata)(target);
|
|
74
|
+
Object.defineProperty(target, json_1.ZLINK_DECORATOR_METADATA, {
|
|
73
75
|
configurable: true,
|
|
74
76
|
enumerable: false,
|
|
75
77
|
value: [...current, metadata],
|
|
76
78
|
writable: false
|
|
77
79
|
});
|
|
78
80
|
}
|
|
79
|
-
function readZLinkDecoratorMetadata(target) {
|
|
80
|
-
if (!Object.prototype.hasOwnProperty.call(target, exports.ZLINK_DECORATOR_METADATA)) {
|
|
81
|
-
return [];
|
|
82
|
-
}
|
|
83
|
-
return target[exports.ZLINK_DECORATOR_METADATA];
|
|
84
|
-
}
|
|
@@ -1,46 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
export type ZLinkJsonSchema
|
|
3
|
-
readonly type: 'boolean';
|
|
4
|
-
} | {
|
|
5
|
-
readonly type: 'string';
|
|
6
|
-
} | {
|
|
7
|
-
readonly type: 'number';
|
|
8
|
-
} | {
|
|
9
|
-
readonly type: 'int32';
|
|
10
|
-
} | {
|
|
11
|
-
readonly type: 'uint32';
|
|
12
|
-
} | {
|
|
13
|
-
readonly type: 'int64';
|
|
14
|
-
} | {
|
|
15
|
-
readonly type: 'uint64';
|
|
16
|
-
} | {
|
|
17
|
-
readonly type: 'bytes';
|
|
18
|
-
} | {
|
|
19
|
-
readonly type: 'enum';
|
|
20
|
-
readonly names: readonly string[];
|
|
21
|
-
} | {
|
|
22
|
-
readonly type: 'nullable';
|
|
23
|
-
readonly value: ZLinkJsonSchema;
|
|
24
|
-
} | {
|
|
25
|
-
readonly type: 'array';
|
|
26
|
-
readonly items: ZLinkJsonSchema;
|
|
27
|
-
} | {
|
|
28
|
-
readonly type: 'record';
|
|
29
|
-
readonly values: ZLinkJsonSchema;
|
|
30
|
-
} | {
|
|
31
|
-
readonly type: 'object';
|
|
32
|
-
readonly properties: Readonly<Record<string, ZLinkJsonSchema>>;
|
|
33
|
-
readonly required: readonly string[];
|
|
34
|
-
/** Unknown properties are ignored during decoding unless this is false. */
|
|
35
|
-
readonly additionalProperties?: boolean;
|
|
36
|
-
};
|
|
37
|
-
/**
|
|
38
|
-
* Describes the request and optional reply fields carried under one packet
|
|
39
|
-
* name by the default JSON serializer.
|
|
40
|
-
*/
|
|
41
|
-
export interface ZLinkPacketJsonContract {
|
|
42
|
-
readonly payload: ZLinkJsonSchema;
|
|
43
|
-
readonly reply?: ZLinkJsonSchema;
|
|
44
|
-
}
|
|
45
|
-
export declare function defineZLinkPacketJsonContract(packetName: string, contract: ZLinkPacketJsonContract): ZLinkPacketJsonContract;
|
|
46
|
-
export declare function readZLinkPacketJsonContract(packetName: string): ZLinkPacketJsonContract | undefined;
|
|
1
|
+
export { defineZLinkPacketJsonContract, readZLinkPacketJsonContract } from '@zlink-systems/stream-wire/internal/json';
|
|
2
|
+
export type { ZLinkJsonSchema, ZLinkPacketJsonContract } from '@zlink-systems/stream-wire/internal/json';
|
|
@@ -1,155 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.defineZLinkPacketJsonContract =
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
function defineZLinkPacketJsonContract(packetName, contract) {
|
|
8
|
-
if (packetName.trim().length === 0) {
|
|
9
|
-
throw new TypeError('ZLink packet name must not be empty.');
|
|
10
|
-
}
|
|
11
|
-
const runtimeContract = contract;
|
|
12
|
-
if (typeof runtimeContract !== 'object' || runtimeContract === null) {
|
|
13
|
-
throw new TypeError('ZLink packet JSON contract must be an object.');
|
|
14
|
-
}
|
|
15
|
-
const normalizedContract = runtimeContract;
|
|
16
|
-
const normalized = Object.freeze({
|
|
17
|
-
payload: normalizeJsonSchema(normalizedContract.payload, new Set(), 0),
|
|
18
|
-
...(normalizedContract.reply === undefined
|
|
19
|
-
? {}
|
|
20
|
-
: { reply: normalizeJsonSchema(normalizedContract.reply, new Set(), 0) })
|
|
21
|
-
});
|
|
22
|
-
const contracts = packetJsonContracts();
|
|
23
|
-
const current = contracts.get(packetName);
|
|
24
|
-
if (current !== undefined && canonicalContract(current) !== canonicalContract(normalized)) {
|
|
25
|
-
throw new TypeError(`ZLink packet '${packetName}' has conflicting JSON contracts in one process.`);
|
|
26
|
-
}
|
|
27
|
-
if (current !== undefined)
|
|
28
|
-
return current;
|
|
29
|
-
contracts.set(packetName, normalized);
|
|
30
|
-
return normalized;
|
|
31
|
-
}
|
|
32
|
-
function readZLinkPacketJsonContract(packetName) {
|
|
33
|
-
return packetJsonContracts().get(packetName);
|
|
34
|
-
}
|
|
35
|
-
function normalizeJsonSchema(schema, parents, depth) {
|
|
36
|
-
// Keep the runtime boundary defensive for JavaScript callers even though
|
|
37
|
-
// the TypeScript signature describes the accepted shape.
|
|
38
|
-
const runtimeSchema = schema;
|
|
39
|
-
if (typeof runtimeSchema !== 'object' ||
|
|
40
|
-
runtimeSchema === null ||
|
|
41
|
-
depth > MAX_CONTRACT_SCHEMA_DEPTH) {
|
|
42
|
-
throw new TypeError(`ZLink packet JSON schema must be an acyclic object with at most ${MAX_CONTRACT_SCHEMA_DEPTH} levels.`);
|
|
43
|
-
}
|
|
44
|
-
const normalizedSchema = runtimeSchema;
|
|
45
|
-
if (parents.has(normalizedSchema))
|
|
46
|
-
throw new TypeError('ZLink packet JSON schema must not contain a cycle.');
|
|
47
|
-
const nextParents = new Set(parents).add(normalizedSchema);
|
|
48
|
-
switch (normalizedSchema.type) {
|
|
49
|
-
case 'boolean':
|
|
50
|
-
case 'string':
|
|
51
|
-
case 'number':
|
|
52
|
-
case 'int32':
|
|
53
|
-
case 'uint32':
|
|
54
|
-
case 'int64':
|
|
55
|
-
case 'uint64':
|
|
56
|
-
case 'bytes':
|
|
57
|
-
return Object.freeze({ type: normalizedSchema.type });
|
|
58
|
-
case 'enum': {
|
|
59
|
-
if (!Array.isArray(normalizedSchema.names) ||
|
|
60
|
-
normalizedSchema.names.length === 0 ||
|
|
61
|
-
normalizedSchema.names.some((name) => typeof name !== 'string' || name.length === 0)) {
|
|
62
|
-
throw new TypeError('ZLink packet enum schema requires non-empty string names.');
|
|
63
|
-
}
|
|
64
|
-
if (new Set(normalizedSchema.names).size !== normalizedSchema.names.length) {
|
|
65
|
-
throw new TypeError('ZLink packet enum schema names must be unique.');
|
|
66
|
-
}
|
|
67
|
-
return Object.freeze({ type: 'enum', names: Object.freeze([...normalizedSchema.names]) });
|
|
68
|
-
}
|
|
69
|
-
case 'nullable':
|
|
70
|
-
return Object.freeze({
|
|
71
|
-
type: 'nullable',
|
|
72
|
-
value: normalizeJsonSchema(normalizedSchema.value, nextParents, depth + 1)
|
|
73
|
-
});
|
|
74
|
-
case 'array':
|
|
75
|
-
return Object.freeze({
|
|
76
|
-
type: 'array',
|
|
77
|
-
items: normalizeJsonSchema(normalizedSchema.items, nextParents, depth + 1)
|
|
78
|
-
});
|
|
79
|
-
case 'record':
|
|
80
|
-
return Object.freeze({
|
|
81
|
-
type: 'record',
|
|
82
|
-
values: normalizeJsonSchema(normalizedSchema.values, nextParents, depth + 1)
|
|
83
|
-
});
|
|
84
|
-
case 'object': {
|
|
85
|
-
const runtimeProperties = normalizedSchema.properties;
|
|
86
|
-
if (typeof runtimeProperties !== 'object' ||
|
|
87
|
-
runtimeProperties === null ||
|
|
88
|
-
Array.isArray(runtimeProperties)) {
|
|
89
|
-
throw new TypeError('ZLink packet object schema properties must be an object.');
|
|
90
|
-
}
|
|
91
|
-
if (!Array.isArray(normalizedSchema.required) ||
|
|
92
|
-
normalizedSchema.required.some((name) => typeof name !== 'string' || name.length === 0)) {
|
|
93
|
-
throw new TypeError('ZLink packet object schema required must contain property names.');
|
|
94
|
-
}
|
|
95
|
-
if (normalizedSchema.additionalProperties !== undefined &&
|
|
96
|
-
typeof normalizedSchema.additionalProperties !== 'boolean') {
|
|
97
|
-
throw new TypeError('ZLink packet object schema additionalProperties must be boolean.');
|
|
98
|
-
}
|
|
99
|
-
const properties = {};
|
|
100
|
-
for (const [name, property] of Object.entries(runtimeProperties)) {
|
|
101
|
-
if (isPrototypeKey(name)) {
|
|
102
|
-
throw new TypeError(`ZLink packet JSON property '${name}' is not allowed.`);
|
|
103
|
-
}
|
|
104
|
-
properties[name] = normalizeJsonSchema(property, nextParents, depth + 1);
|
|
105
|
-
}
|
|
106
|
-
if (new Set(normalizedSchema.required).size !== normalizedSchema.required.length) {
|
|
107
|
-
throw new TypeError('ZLink packet JSON required properties must be unique.');
|
|
108
|
-
}
|
|
109
|
-
for (const name of normalizedSchema.required) {
|
|
110
|
-
if (isPrototypeKey(name)) {
|
|
111
|
-
throw new TypeError(`ZLink packet JSON property '${name}' is not allowed.`);
|
|
112
|
-
}
|
|
113
|
-
if (!Object.prototype.hasOwnProperty.call(properties, name)) {
|
|
114
|
-
throw new TypeError(`ZLink packet JSON required property '${name}' has no property schema.`);
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
return Object.freeze({
|
|
118
|
-
type: 'object',
|
|
119
|
-
properties: Object.freeze(properties),
|
|
120
|
-
required: Object.freeze([...normalizedSchema.required]),
|
|
121
|
-
...(normalizedSchema.additionalProperties === undefined
|
|
122
|
-
? {}
|
|
123
|
-
: { additionalProperties: normalizedSchema.additionalProperties })
|
|
124
|
-
});
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
throw new TypeError(`ZLink packet JSON schema type '${String(normalizedSchema.type)}' is not supported.`);
|
|
128
|
-
}
|
|
129
|
-
function packetJsonContracts() {
|
|
130
|
-
const root = globalThis;
|
|
131
|
-
let contracts = root[ZLINK_PACKET_JSON_CONTRACTS];
|
|
132
|
-
if (contracts === undefined) {
|
|
133
|
-
contracts = new Map();
|
|
134
|
-
Object.defineProperty(root, ZLINK_PACKET_JSON_CONTRACTS, {
|
|
135
|
-
configurable: false,
|
|
136
|
-
enumerable: false,
|
|
137
|
-
value: contracts,
|
|
138
|
-
writable: false
|
|
139
|
-
});
|
|
140
|
-
}
|
|
141
|
-
return contracts;
|
|
142
|
-
}
|
|
143
|
-
function canonicalContract(value) {
|
|
144
|
-
if (Array.isArray(value))
|
|
145
|
-
return `[${value.map(canonicalContract).join(',')}]`;
|
|
146
|
-
if (typeof value !== 'object' || value === null)
|
|
147
|
-
return JSON.stringify(value);
|
|
148
|
-
return `{${Object.entries(value)
|
|
149
|
-
.sort(([left], [right]) => (left < right ? -1 : left > right ? 1 : 0))
|
|
150
|
-
.map(([key, item]) => `${JSON.stringify(key)}:${canonicalContract(item)}`)
|
|
151
|
-
.join(',')}}`;
|
|
152
|
-
}
|
|
153
|
-
function isPrototypeKey(name) {
|
|
154
|
-
return name === '__proto__' || name === 'prototype' || name === 'constructor';
|
|
155
|
-
}
|
|
3
|
+
exports.readZLinkPacketJsonContract = exports.defineZLinkPacketJsonContract = void 0;
|
|
4
|
+
var json_1 = require("@zlink-systems/stream-wire/internal/json");
|
|
5
|
+
Object.defineProperty(exports, "defineZLinkPacketJsonContract", { enumerable: true, get: function () { return json_1.defineZLinkPacketJsonContract; } });
|
|
6
|
+
Object.defineProperty(exports, "readZLinkPacketJsonContract", { enumerable: true, get: function () { return json_1.readZLinkPacketJsonContract; } });
|
|
@@ -2,6 +2,7 @@ import type { ZLinkActor } from '../Actors';
|
|
|
2
2
|
import type { ZLinkChannelRequestCall, ZLinkPublishCall, ZLinkSendCall } from '../Channels';
|
|
3
3
|
import type { RoutingId, SpotId, Type, ZLinkMessageMetadata } from '../Common';
|
|
4
4
|
import type { ZLinkSpotTimerHandler } from '../Handlers';
|
|
5
|
+
import type { ZLinkRequest } from '../Handlers/Attributes';
|
|
5
6
|
import type { ZLinkTimer, ZLinkTimerOptions } from '../Timers';
|
|
6
7
|
import type { ZLinkEntrySpot, ZLinkInstanceSpot, ZLinkSpot, ZLinkSpotRelocationReadyCall } from './ZLinkSpot';
|
|
7
8
|
export interface ZLinkActorHandlerRegistry {
|
|
@@ -77,7 +78,7 @@ export interface ZLinkSpotRequestCall {
|
|
|
77
78
|
instanceSpot(instanceSpotType: string): this;
|
|
78
79
|
inMesh(meshName: string): this;
|
|
79
80
|
timeout(timeoutMs: number): this;
|
|
80
|
-
submit<TReply>(signal?: AbortSignal):
|
|
81
|
+
submit<TReply>(signal?: AbortSignal): ZLinkRequest<TReply>;
|
|
81
82
|
yield<TReply>(signal?: AbortSignal): Promise<TReply>;
|
|
82
83
|
}
|
|
83
84
|
export declare enum ZLinkSpotCreateState {
|
|
@@ -11,7 +11,7 @@ import type { ZLinkFrameworkRegistration } from './contracts/Configuration/Regis
|
|
|
11
11
|
import type { ZLinkCodecSerializerRegistration, ZLinkFrameworkRegistrationOptions, ZLinkStreamCodecRegistration } from './contracts/Configuration/RegistrationTypes';
|
|
12
12
|
import { captureZLinkExecutionTurn } from './runtime/execution';
|
|
13
13
|
export { registerHandlerFilterScope as registerIntegrationHandlerFilterScope, type ZLinkHandlerFilterScopeRunner } from './runtime/channels/handler-filter-scope';
|
|
14
|
-
export { disposeOwnedInstance as disposeIntegrationHandler, disposeOwnedInstances as disposeIntegrationHandlers } from './runtime/handlers/handler-instance-scope';
|
|
14
|
+
export { registerHandlerInstanceScopeFactory as registerIntegrationHandlerInstanceScopeFactory, disposeOwnedInstance as disposeIntegrationHandler, disposeOwnedInstances as disposeIntegrationHandlers } from './runtime/handlers/handler-instance-scope';
|
|
15
15
|
export interface ZLinkNestIntegrationRuntimeHost extends Pick<import('./contracts').ZLinkFrameworkRuntime, 'shutdown'> {
|
|
16
16
|
readonly channelRuntimeOptions: unknown;
|
|
17
17
|
readonly routeMeshRuntimeOptions: ZLinkRouteMeshRuntimeOptions;
|
package/dist/nest-integration.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.disposeIntegrationHandlers = exports.disposeIntegrationHandler = exports.registerIntegrationHandlerFilterScope = exports.validateSessionReplacementCallbackTimeout = exports.validateMessageFollowDuration = exports.validateActorTransferTimeout = exports.registerSpotFactory = exports.registerEntrySpot = exports.validateRoutingIdPrefix = exports.registerRelocationStore = exports.registerActorFactory = exports.ZLinkSpotActorRequest = exports.ZLinkSpotActorSend = exports.hasSpotPublisherClient = exports.hasSpotNode = exports.hasActorManager = exports.normalizeFrameworkRegistration = exports.createFrameworkRegistration = exports.ZLinkConfigurationException = void 0;
|
|
3
|
+
exports.disposeIntegrationHandlers = exports.disposeIntegrationHandler = exports.registerIntegrationHandlerInstanceScopeFactory = exports.registerIntegrationHandlerFilterScope = exports.validateSessionReplacementCallbackTimeout = exports.validateMessageFollowDuration = exports.validateActorTransferTimeout = exports.registerSpotFactory = exports.registerEntrySpot = exports.validateRoutingIdPrefix = exports.registerRelocationStore = exports.registerActorFactory = exports.ZLinkSpotActorRequest = exports.ZLinkSpotActorSend = exports.hasSpotPublisherClient = exports.hasSpotNode = exports.hasActorManager = exports.normalizeFrameworkRegistration = exports.createFrameworkRegistration = exports.ZLinkConfigurationException = void 0;
|
|
4
4
|
exports.createIntegrationDispatchOptionsBuilder = createIntegrationDispatchOptionsBuilder;
|
|
5
5
|
exports.createIntegrationInboundDispatchOptionsBuilder = createIntegrationInboundDispatchOptionsBuilder;
|
|
6
6
|
exports.createIntegrationLocationOptionsBuilder = createIntegrationLocationOptionsBuilder;
|
|
@@ -46,6 +46,7 @@ const execution_1 = require("./runtime/execution");
|
|
|
46
46
|
var handler_filter_scope_1 = require("./runtime/channels/handler-filter-scope");
|
|
47
47
|
Object.defineProperty(exports, "registerIntegrationHandlerFilterScope", { enumerable: true, get: function () { return handler_filter_scope_1.registerHandlerFilterScope; } });
|
|
48
48
|
var handler_instance_scope_1 = require("./runtime/handlers/handler-instance-scope");
|
|
49
|
+
Object.defineProperty(exports, "registerIntegrationHandlerInstanceScopeFactory", { enumerable: true, get: function () { return handler_instance_scope_1.registerHandlerInstanceScopeFactory; } });
|
|
49
50
|
Object.defineProperty(exports, "disposeIntegrationHandler", { enumerable: true, get: function () { return handler_instance_scope_1.disposeOwnedInstance; } });
|
|
50
51
|
Object.defineProperty(exports, "disposeIntegrationHandlers", { enumerable: true, get: function () { return handler_instance_scope_1.disposeOwnedInstances; } });
|
|
51
52
|
function createIntegrationDispatchOptionsBuilder(dispatch) {
|
|
@@ -11,7 +11,7 @@ export interface ZLinkActorClientOptions {
|
|
|
11
11
|
readonly defaultRequestTimeoutMs?: number;
|
|
12
12
|
readonly staleActorRefReporter?: (meshName: string, actorId: string) => void;
|
|
13
13
|
readonly staleActorRefPredicate?: (meshName: string, actor: ActorRef) => boolean;
|
|
14
|
-
readonly handoffCapture?: (meshName: string, actorId: string, parts: readonly Message[], returnResponse: boolean, actor: ActorRef, deadlineUnixMs?: number) => Promise<unknown> | undefined;
|
|
14
|
+
readonly handoffCapture?: (meshName: string, actorId: string, parts: readonly Message[], returnResponse: boolean, actor: ActorRef, deadlineUnixMs?: number, onAdmitted?: () => void) => Promise<unknown> | undefined;
|
|
15
15
|
readonly sendErrorReporter?: (error: unknown) => void;
|
|
16
16
|
readonly routeTransport?: ZLinkActorRoutedJoinTransport;
|
|
17
17
|
readonly transportDeliveryGate?: () => {
|
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.DefaultZLinkActorClient = void 0;
|
|
4
4
|
exports.forwardEncodedActorPacket = forwardEncodedActorPacket;
|
|
5
5
|
const stream_wire_1 = require("@zlink-systems/stream-wire");
|
|
6
|
+
const request_result_1 = require("../messaging/request-result");
|
|
6
7
|
const contracts_1 = require("../../contracts");
|
|
7
8
|
const CoreTypes_1 = require("../../contracts/Common/CoreTypes");
|
|
8
9
|
const abort_1 = require("../abort");
|
|
@@ -32,7 +33,7 @@ class DefaultZLinkActorClient {
|
|
|
32
33
|
}
|
|
33
34
|
requestToActor(actorId, request) {
|
|
34
35
|
requireActorId(actorId);
|
|
35
|
-
return new DefaultZLinkActorRequestCall((packetName, timeoutMs, metadata, signal) => this.request(actorId, packetName, request, timeoutMs, metadata, signal, 'async'), (packetName, timeoutMs, metadata, signal) => this.request(actorId, packetName, request, timeoutMs, metadata, signal, 'yield'), actorId, request, this.options.defaultRequestTimeoutMs);
|
|
36
|
+
return new DefaultZLinkActorRequestCall((packetName, timeoutMs, metadata, signal, onAdmitted) => this.request(actorId, packetName, request, timeoutMs, metadata, signal, 'async', onAdmitted), (packetName, timeoutMs, metadata, signal) => this.request(actorId, packetName, request, timeoutMs, metadata, signal, 'yield'), actorId, request, this.options.defaultRequestTimeoutMs);
|
|
36
37
|
}
|
|
37
38
|
async send(actorId, explicitPacketName, message, metadata) {
|
|
38
39
|
const route = await this.resolveActorRoute(actorId);
|
|
@@ -82,7 +83,7 @@ class DefaultZLinkActorClient {
|
|
|
82
83
|
closeMessages(parts);
|
|
83
84
|
}
|
|
84
85
|
}
|
|
85
|
-
async request(actorId, explicitPacketName, request, timeoutMs, metadata, signal, waitPolicy = 'async') {
|
|
86
|
+
async request(actorId, explicitPacketName, request, timeoutMs, metadata, signal, waitPolicy = 'async', onAdmitted) {
|
|
86
87
|
(0, abort_1.throwIfAborted)(signal);
|
|
87
88
|
const sourceSpotId = (0, actor_execution_context_1.currentZLinkActorExecution)()?.spotId ?? (0, execution_1.currentZLinkSpotSerialSourceId)();
|
|
88
89
|
const effectiveTimeoutMs = timeoutMs ?? this.options.defaultRequestTimeoutMs;
|
|
@@ -109,18 +110,18 @@ class DefaultZLinkActorClient {
|
|
|
109
110
|
const submissionCopies = delivery === undefined
|
|
110
111
|
? 1
|
|
111
112
|
: ((await (0, actor_request_deadline_1.waitActorReply)(delivery, actorId, deadlineMs, signal)) ?? 1);
|
|
112
|
-
const handoff = this.options.handoffCapture?.(meshName, actor.actorId, parts, true, routedActor, deadlineUnixMs);
|
|
113
|
+
const handoff = this.options.handoffCapture?.(meshName, actor.actorId, parts, true, routedActor, deadlineUnixMs, onAdmitted);
|
|
113
114
|
if (handoff !== undefined) {
|
|
114
115
|
const submissions = [handoff];
|
|
115
116
|
for (let copy = 1; copy < submissionCopies; copy++) {
|
|
116
|
-
const duplicate = this.options.handoffCapture?.(meshName, actor.actorId, parts, true, routedActor, deadlineUnixMs);
|
|
117
|
+
const duplicate = this.options.handoffCapture?.(meshName, actor.actorId, parts, true, routedActor, deadlineUnixMs, onAdmitted);
|
|
117
118
|
if (duplicate !== undefined)
|
|
118
119
|
submissions.push(duplicate);
|
|
119
120
|
}
|
|
120
121
|
const replies = await (0, actor_request_deadline_1.waitActorReply)(Promise.all(submissions), actorId, deadlineMs, signal);
|
|
121
122
|
return replies[0];
|
|
122
123
|
}
|
|
123
|
-
return await this.submitActorRequest(meshName, toBackendActorRef(actor), parts, (0, actor_request_deadline_1.remainingActorRequestTimeout)(actorId, deadlineMs), signal, route, messageFollow);
|
|
124
|
+
return await this.submitActorRequest(meshName, toBackendActorRef(actor), parts, (0, actor_request_deadline_1.remainingActorRequestTimeout)(actorId, deadlineMs), signal, route, messageFollow, onAdmitted);
|
|
124
125
|
}
|
|
125
126
|
catch (error) {
|
|
126
127
|
if (isStaleActorError(error)) {
|
|
@@ -204,7 +205,7 @@ class DefaultZLinkActorClient {
|
|
|
204
205
|
throw mapSubmitError(error, 'Actor send');
|
|
205
206
|
}
|
|
206
207
|
}
|
|
207
|
-
async submitActorRequest(meshName, actor, parts, timeoutMs, signal, route, messageFollowContext) {
|
|
208
|
+
async submitActorRequest(meshName, actor, parts, timeoutMs, signal, route, messageFollowContext, onAdmitted) {
|
|
208
209
|
const node = this.requireNode(meshName);
|
|
209
210
|
if (this.options.routeTransport !== undefined &&
|
|
210
211
|
String(node.status().routingId) !== String(actor.nodeRid) &&
|
|
@@ -228,7 +229,7 @@ class DefaultZLinkActorClient {
|
|
|
228
229
|
returnResponse: true,
|
|
229
230
|
messageFollowContext
|
|
230
231
|
});
|
|
231
|
-
const reply = await (0, actor_routed_json_request_1.requestRoutedJsonReply)(this.options.routeTransport, remoteActorRouteTarget(route), relay, { timeoutMs, signal }, `Remote Actor request is not available for '${actor.actorId}'.`, (replyParts) => JSON.parse(replyParts[0]?.getString('utf8') ?? '{}'));
|
|
232
|
+
const reply = await (0, actor_routed_json_request_1.requestRoutedJsonReply)(this.options.routeTransport, remoteActorRouteTarget(route), relay, { timeoutMs, signal, onAdmitted }, `Remote Actor request is not available for '${actor.actorId}'.`, (replyParts) => JSON.parse(replyParts[0]?.getString('utf8') ?? '{}'));
|
|
232
233
|
if (reply.ok !== true) {
|
|
233
234
|
throw (0, framework_errors_internal_1.createInternalFrameworkException)(remoteRelayErrorKind(reply.errorKind), typeof reply.error === 'string'
|
|
234
235
|
? reply.error
|
|
@@ -242,7 +243,8 @@ class DefaultZLinkActorClient {
|
|
|
242
243
|
}
|
|
243
244
|
const completion = await completions.submit(() => node.requestToActor(actor, toMessageLikeParts(parts), {
|
|
244
245
|
flags: runtime_values_1.ZLINK_BACKEND_SEND_NONE,
|
|
245
|
-
timeoutMs
|
|
246
|
+
timeoutMs,
|
|
247
|
+
onAdmitted
|
|
246
248
|
}), signal);
|
|
247
249
|
if (completion.terminalResult !== runtime_values_1.RequestResult.Ok) {
|
|
248
250
|
(0, backend_1.closeMeshCompletion)(completion);
|
|
@@ -405,7 +407,8 @@ class DefaultZLinkActorRequestCall {
|
|
|
405
407
|
return this;
|
|
406
408
|
}
|
|
407
409
|
submit(signal) {
|
|
408
|
-
|
|
410
|
+
this.rejectSelfActorRequest();
|
|
411
|
+
return (0, request_result_1.createZLinkRequest)((onAdmitted) => this.execute('async', signal, onAdmitted));
|
|
409
412
|
}
|
|
410
413
|
yield(signal) {
|
|
411
414
|
this.rejectSelfActorRequest();
|
|
@@ -413,13 +416,12 @@ class DefaultZLinkActorRequestCall {
|
|
|
413
416
|
const pending = this.execute('yield', signal);
|
|
414
417
|
return turn.yieldPromise(pending);
|
|
415
418
|
}
|
|
416
|
-
execute(waitPolicy, signal) {
|
|
419
|
+
execute(waitPolicy, signal, onAdmitted) {
|
|
417
420
|
ensureSingleSubmit(this.executed);
|
|
418
|
-
this.rejectSelfActorRequest();
|
|
419
421
|
this.executed = true;
|
|
420
422
|
(0, abort_1.throwIfAborted)(signal);
|
|
421
423
|
const submitter = waitPolicy === 'async' ? this.asyncSubmitter : this.yieldSubmitter;
|
|
422
|
-
return submitter(this.packet ?? (0, packet_name_1.resolveFrameworkPacketName)(this.request, undefined, 'Actor'), this.timeoutMs ?? this.defaultRequestTimeoutMs, this.selectedMetadata, signal);
|
|
424
|
+
return submitter(this.packet ?? (0, packet_name_1.resolveFrameworkPacketName)(this.request, undefined, 'Actor'), this.timeoutMs ?? this.defaultRequestTimeoutMs, this.selectedMetadata, signal, onAdmitted);
|
|
423
425
|
}
|
|
424
426
|
rejectSelfActorRequest() {
|
|
425
427
|
const current = (0, actor_execution_context_1.currentZLinkActorExecution)();
|
|
@@ -142,7 +142,7 @@ export declare class ZLinkActorHandoffCoordinator {
|
|
|
142
142
|
*/
|
|
143
143
|
failPending(actorId: string, reason: unknown): void;
|
|
144
144
|
cancel(actorId: string): void;
|
|
145
|
-
capture(origin: ApplicationJobOrigin, actorId: string, parts: readonly Message[], returnResponse?: boolean, remoteBoundSessionTarget?: ZLinkRemoteBoundSessionTarget, fallbackActorRef?: ActorRef, deadlineUnixMs?: number, messageFollowOrigin?: ZLinkMessageFollowOrigin, provisionalReplay?: ZLinkActorHandoffDispatch): Promise<unknown> | undefined;
|
|
145
|
+
capture(origin: ApplicationJobOrigin, actorId: string, parts: readonly Message[], returnResponse?: boolean, remoteBoundSessionTarget?: ZLinkRemoteBoundSessionTarget, fallbackActorRef?: ActorRef, deadlineUnixMs?: number, messageFollowOrigin?: ZLinkMessageFollowOrigin, provisionalReplay?: ZLinkActorHandoffDispatch, onAdmitted?: () => void): Promise<unknown> | undefined;
|
|
146
146
|
snapshot(actorId: string): readonly ZLinkActorHandoffPacket[];
|
|
147
147
|
snapshotCoreBacklog(actorId: string): readonly ZLinkActorHandoffPacket[];
|
|
148
148
|
/**
|
|
@@ -422,7 +422,7 @@ class ZLinkActorHandoffCoordinator {
|
|
|
422
422
|
pending.reject?.(error);
|
|
423
423
|
}
|
|
424
424
|
}
|
|
425
|
-
capture(origin, actorId, parts, returnResponse = false, remoteBoundSessionTarget, fallbackActorRef, deadlineUnixMs, messageFollowOrigin, provisionalReplay) {
|
|
425
|
+
capture(origin, actorId, parts, returnResponse = false, remoteBoundSessionTarget, fallbackActorRef, deadlineUnixMs, messageFollowOrigin, provisionalReplay, onAdmitted) {
|
|
426
426
|
const incomingContext = (0, actor_message_follow_context_1.actorMessageFollowContext)(fallbackActorRef);
|
|
427
427
|
const originalDeadlineUnixMs = deadlineUnixMs ?? incomingContext?.deadlineUnixMs ?? packetDeadlineUnixMs(parts);
|
|
428
428
|
const handoff = this.active.get(actorId);
|
|
@@ -502,6 +502,7 @@ class ZLinkActorHandoffCoordinator {
|
|
|
502
502
|
});
|
|
503
503
|
});
|
|
504
504
|
(0, application_job_queue_scope_1.releaseApplicationJobPermitForDurableHandoff)();
|
|
505
|
+
onAdmitted?.();
|
|
505
506
|
if (handoff.prefixRelease !== undefined) {
|
|
506
507
|
try {
|
|
507
508
|
this.admitPendingPrefix(actorId, handoff, handoff.prefixRelease);
|
|
@@ -535,7 +536,7 @@ class ZLinkActorHandoffCoordinator {
|
|
|
535
536
|
return Promise.reject(actorLocationStale(actorId));
|
|
536
537
|
}
|
|
537
538
|
const packet = encodePacket(0, parts, returnResponse, remoteBoundSessionTarget, fallbackActorRef, incomingContext, messageFollowOrigin);
|
|
538
|
-
return this.enqueueMessageFollow(followRoute, actorId, packet);
|
|
539
|
+
return this.enqueueMessageFollow(followRoute, actorId, packet, onAdmitted);
|
|
539
540
|
}
|
|
540
541
|
this.options.onMarker?.('message_follow_rejected', actorId);
|
|
541
542
|
return Promise.reject(actorLocationStale(actorId));
|
|
@@ -581,7 +582,7 @@ class ZLinkActorHandoffCoordinator {
|
|
|
581
582
|
return Promise.reject(error);
|
|
582
583
|
}
|
|
583
584
|
const packet = encodePacket(0, parts, returnResponse, remoteBoundSessionTarget, fallbackActorRef, context, messageFollowOrigin);
|
|
584
|
-
return this.enqueueMessageFollow(followRoute, actorId, packet);
|
|
585
|
+
return this.enqueueMessageFollow(followRoute, actorId, packet, onAdmitted);
|
|
585
586
|
}
|
|
586
587
|
snapshot(actorId) {
|
|
587
588
|
const handoff = this.requireActive(actorId);
|
|
@@ -932,7 +933,7 @@ class ZLinkActorHandoffCoordinator {
|
|
|
932
933
|
}
|
|
933
934
|
return undefined;
|
|
934
935
|
}
|
|
935
|
-
enqueueMessageFollow(entry, actorId, packet) {
|
|
936
|
+
enqueueMessageFollow(entry, actorId, packet, onAdmitted) {
|
|
936
937
|
const context = packet.messageFollowContext;
|
|
937
938
|
const duplicate = entry.operations.get(context.operationId);
|
|
938
939
|
if (duplicate !== undefined) {
|
|
@@ -942,6 +943,7 @@ class ZLinkActorHandoffCoordinator {
|
|
|
942
943
|
this.options.onMarker?.('message_follow_rejected', actorId);
|
|
943
944
|
return Promise.reject(actorLocationStale(actorId));
|
|
944
945
|
}
|
|
946
|
+
onAdmitted?.();
|
|
945
947
|
return duplicate.result;
|
|
946
948
|
}
|
|
947
949
|
const bytes = packetBytes(packet);
|
|
@@ -963,6 +965,7 @@ class ZLinkActorHandoffCoordinator {
|
|
|
963
965
|
replyRouteId: context.replyRouteId,
|
|
964
966
|
result
|
|
965
967
|
});
|
|
968
|
+
onAdmitted?.();
|
|
966
969
|
entry.tail = entry.tail.then(async () => {
|
|
967
970
|
try {
|
|
968
971
|
resolve(await this.relayMessageFollow(actorId, entry, packet));
|
|
@@ -29,6 +29,7 @@ export interface ZLinkActorJoinRelocation {
|
|
|
29
29
|
};
|
|
30
30
|
/** Target's advertised relocation state chunk cap from the accepted admission reply. */
|
|
31
31
|
readonly advertisedReceiveChunkLimitBytes?: number;
|
|
32
|
+
readonly deadlineAtMs?: number;
|
|
32
33
|
readonly signal?: AbortSignal;
|
|
33
34
|
}): Promise<{
|
|
34
35
|
readonly actorRef: ZLinkBackendActorRef;
|
|
@@ -68,15 +68,12 @@ class ZLinkLocalNativeActorJoin {
|
|
|
68
68
|
throw new Error('Local Actor Join requires a valid target generation and stateful membership runtime.');
|
|
69
69
|
}
|
|
70
70
|
const membershipEpoch = location.membershipEpoch + 1n;
|
|
71
|
+
const currentActor = (0, actor_runtime_state_1.toFrameworkActorRef)(actorRef, meshName);
|
|
72
|
+
const authorityOwnerGeneration = state.locationGeneration ?? actorRef.generation;
|
|
71
73
|
const commit = async (spot) => {
|
|
72
74
|
(0, abort_1.throwIfAborted)(signal);
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
}
|
|
76
|
-
else {
|
|
77
|
-
await this.options.locationLifecycle?.notifyActorJoinedSpot(actorType, actor.context.actorId, meshName, storeSpotId, spotGeneration, membershipEpoch, node.status().lifecycleGeneration);
|
|
78
|
-
}
|
|
79
|
-
const committedActor = node.restoreActorAuthority(actor.context.actorId, actorType, actorRef.generation, state.locationGeneration ?? actorRef.generation, target.spotKind === contracts_1.ZLinkSpotKind.Entry ? undefined : String(target.spotId), spotGeneration, membershipEpoch);
|
|
75
|
+
await this.options.locationLifecycle?.commitActorMembership(actorType, currentActor, authorityOwnerGeneration, storeSpotId, spotGeneration, target.spotKind === contracts_1.ZLinkSpotKind.Entry ? contracts_1.ZLinkSpotKind.Entry : contracts_1.ZLinkSpotKind.User, node.status().lifecycleGeneration);
|
|
76
|
+
const committedActor = node.restoreActorAuthority(actor.context.actorId, actorType, actorRef.generation, authorityOwnerGeneration, target.spotKind === contracts_1.ZLinkSpotKind.Entry ? undefined : String(target.spotId), spotGeneration, membershipEpoch);
|
|
80
77
|
state.setNativeActorRef(committedActor);
|
|
81
78
|
if (target.spotKind === contracts_1.ZLinkSpotKind.Entry)
|
|
82
79
|
state.clearJoinedSpot();
|
|
@@ -120,6 +117,7 @@ class ZLinkLocalNativeActorJoin {
|
|
|
120
117
|
return submitJoinWhenConnected(() => completions.submit(submit, signal), timeoutMs, signal);
|
|
121
118
|
}
|
|
122
119
|
async relocateRemoteActorJoin(node, actor, state, actorRef, target, request, timeoutMs, signal, completionOperationId, entrySpot) {
|
|
120
|
+
const deadlineAtMs = timeoutMs === undefined ? undefined : performance.now() + timeoutMs;
|
|
123
121
|
const actorType = state.actorType;
|
|
124
122
|
if (actorType === undefined) {
|
|
125
123
|
throw (0, framework_errors_internal_1.createInternalFrameworkException)(framework_errors_internal_1.ZLinkFrameworkInternalErrorKind.ActorRouteNotFound, `Actor '${actor.context.actorId}' canonical remote Join identity is not configured.`);
|
|
@@ -214,6 +212,7 @@ class ZLinkLocalNativeActorJoin {
|
|
|
214
212
|
target,
|
|
215
213
|
relocationId,
|
|
216
214
|
completionOperationId,
|
|
215
|
+
deadlineAtMs,
|
|
217
216
|
...(control.canonicalHandoffId === undefined || canonicalAdmission === undefined
|
|
218
217
|
? {}
|
|
219
218
|
: {
|
|
@@ -227,11 +226,9 @@ class ZLinkLocalNativeActorJoin {
|
|
|
227
226
|
},
|
|
228
227
|
requestContentType: canonicalAdmission.request.contentType,
|
|
229
228
|
request: Buffer.from(canonicalAdmission.request.payload),
|
|
230
|
-
...(completionOperationId === undefined
|
|
229
|
+
...(completionOperationId === undefined || control.replyContentType === undefined
|
|
231
230
|
? {}
|
|
232
|
-
: {
|
|
233
|
-
replyContentType: control.replyContentType ?? stream_wire_1.ZlinkStreamContentType.Raw
|
|
234
|
-
}),
|
|
231
|
+
: { replyContentType: control.replyContentType }),
|
|
235
232
|
reply: completionOperationId === undefined
|
|
236
233
|
? Buffer.alloc(0)
|
|
237
234
|
: Buffer.from(admission.parts[0]?.data() ?? []),
|
|
@@ -239,7 +236,7 @@ class ZLinkLocalNativeActorJoin {
|
|
|
239
236
|
expectedOwnerLeaseGeneration: actorAuthorityFence.ownerLeaseGeneration,
|
|
240
237
|
targetNodeGeneration: target.targetNodeGeneration,
|
|
241
238
|
targetSpotGeneration: control.location.spotGeneration,
|
|
242
|
-
targetAuthorityOwnerGeneration: actorAuthorityFence.authorityOwnerGeneration
|
|
239
|
+
targetAuthorityOwnerGeneration: actorAuthorityFence.authorityOwnerGeneration,
|
|
243
240
|
targetSpotAuthorityOwnerGeneration: target.authorityOwnerGeneration ?? 1n
|
|
244
241
|
}
|
|
245
242
|
}),
|