@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
|
@@ -13,6 +13,7 @@ export interface ZLinkLocalSpotRouteDispatcher {
|
|
|
13
13
|
request<TReply>(spotId: RoutingId, packetName: string | undefined, request: unknown, context: {
|
|
14
14
|
readonly channelName: string;
|
|
15
15
|
readonly signal?: AbortSignal;
|
|
16
|
+
readonly onAdmitted?: () => void;
|
|
16
17
|
readonly metadata?: ReadonlyMap<string, string>;
|
|
17
18
|
}): Promise<TReply>;
|
|
18
19
|
}
|
|
@@ -39,10 +40,10 @@ export declare class ZLinkSpotRouteDispatchStrategy {
|
|
|
39
40
|
canRoutePacketChannel(routerChannelId: string): boolean;
|
|
40
41
|
routeSendToSpot(spotRouteTarget: ZLinkSpotRouteTarget, packetName: string | undefined, message: unknown, metadata?: ReadonlyMap<string, string>): Promise<void>;
|
|
41
42
|
private routeSendToSpotScoped;
|
|
42
|
-
routeRequestToSpot<TReply>(spotRouteTarget: ZLinkSpotRouteTarget, packetName: string | undefined, request: unknown, timeoutMs: number | undefined, signal?: AbortSignal, metadata?: ReadonlyMap<string, string
|
|
43
|
+
routeRequestToSpot<TReply>(spotRouteTarget: ZLinkSpotRouteTarget, packetName: string | undefined, request: unknown, timeoutMs: number | undefined, signal?: AbortSignal, metadata?: ReadonlyMap<string, string>, onAdmitted?: () => void): Promise<TReply>;
|
|
43
44
|
private routeRequestToSpotScoped;
|
|
44
|
-
routeRequestFromSpotToSpot<TReply>(sourceSpot: ZLinkBackendSpot, spotRouteTarget: ZLinkSpotRouteTarget, packetName: string | undefined, request: unknown, timeoutMs: number | undefined, signal?: AbortSignal): Promise<TReply>;
|
|
45
|
+
routeRequestFromSpotToSpot<TReply>(sourceSpot: ZLinkBackendSpot, spotRouteTarget: ZLinkSpotRouteTarget, packetName: string | undefined, request: unknown, timeoutMs: number | undefined, signal?: AbortSignal, onAdmitted?: () => void): Promise<TReply>;
|
|
45
46
|
routeSendFromSpotToSpot(sourceSpot: ZLinkBackendSpot, spotRouteTarget: ZLinkSpotRouteTarget, packetName: string | undefined, message: unknown, metadata?: ReadonlyMap<string, string>): Promise<void>;
|
|
46
|
-
routeRequestRawFromSpotToSpot(sourceSpot: ZLinkBackendSpot, spotRouteTarget: ZLinkSpotRouteTarget, request: Message, timeoutMs: number | undefined, signal?: AbortSignal): Promise<readonly Message[]>;
|
|
47
|
-
routeRequestRawToSpot(spotRouteTarget: ZLinkSpotRouteTarget, request: Message, timeoutMs: number | undefined, signal?: AbortSignal): Promise<readonly Message[]>;
|
|
47
|
+
routeRequestRawFromSpotToSpot(sourceSpot: ZLinkBackendSpot, spotRouteTarget: ZLinkSpotRouteTarget, request: Message, timeoutMs: number | undefined, signal?: AbortSignal, onAdmitted?: () => void): Promise<readonly Message[]>;
|
|
48
|
+
routeRequestRawToSpot(spotRouteTarget: ZLinkSpotRouteTarget, request: Message, timeoutMs: number | undefined, signal?: AbortSignal, onAdmitted?: () => void): Promise<readonly Message[]>;
|
|
48
49
|
}
|
|
@@ -70,58 +70,58 @@ class ZLinkSpotRouteDispatchStrategy {
|
|
|
70
70
|
}
|
|
71
71
|
await this.routerSocketTransport.send(spotRouteTarget, parts, ZLINK_SEND_DONT_WAIT);
|
|
72
72
|
}
|
|
73
|
-
routeRequestToSpot(spotRouteTarget, packetName, request, timeoutMs, signal, metadata) {
|
|
74
|
-
return (0, flow_context_1.runWithOutboundFlow)(this.options.flowCreationEnabled?.() ?? true, () => this.routeRequestToSpotScoped(spotRouteTarget, packetName, request, timeoutMs, signal, metadata));
|
|
73
|
+
routeRequestToSpot(spotRouteTarget, packetName, request, timeoutMs, signal, metadata, onAdmitted) {
|
|
74
|
+
return (0, flow_context_1.runWithOutboundFlow)(this.options.flowCreationEnabled?.() ?? true, () => this.routeRequestToSpotScoped(spotRouteTarget, packetName, request, timeoutMs, signal, metadata, onAdmitted));
|
|
75
75
|
}
|
|
76
|
-
async routeRequestToSpotScoped(spotRouteTarget, packetName, request, timeoutMs, signal, metadata) {
|
|
76
|
+
async routeRequestToSpotScoped(spotRouteTarget, packetName, request, timeoutMs, signal, metadata, onAdmitted) {
|
|
77
77
|
(0, abort_1.throwIfAborted)(signal);
|
|
78
78
|
const localSpotRouteNode = this.targets.localRouteNode(spotRouteTarget);
|
|
79
79
|
if (localSpotRouteNode !== undefined) {
|
|
80
|
-
return this.localTransport.request(spotRouteTarget.routerChannelId, spotRouteTarget.spotId, packetName, request, timeoutMs, signal);
|
|
80
|
+
return this.localTransport.request(spotRouteTarget.routerChannelId, spotRouteTarget.spotId, packetName, request, timeoutMs, signal, onAdmitted);
|
|
81
81
|
}
|
|
82
82
|
const codecs = (0, channel_framework_packets_1.codecsForFrameworkPacket)(packetName, this.options.codecs);
|
|
83
83
|
const parts = (0, channel_envelope_1.encodeChannelEnvelopeParts)(1 /* ZLinkChannelMessageKind.Request */, spotRouteTarget.routerChannelId, packetName, request, timeoutMs, undefined, codecs, undefined, this.options.flowCreationEnabled?.() ?? true, metadata);
|
|
84
84
|
if (this.targets.hasNamedSpotNode(spotRouteTarget.routerChannelId)) {
|
|
85
|
-
const namedSpotNodeRequest = this.spotNodeTransport.request(spotRouteTarget, parts, codecs, timeoutMs, signal);
|
|
85
|
+
const namedSpotNodeRequest = this.spotNodeTransport.request(spotRouteTarget, parts, codecs, timeoutMs, signal, onAdmitted);
|
|
86
86
|
if (namedSpotNodeRequest !== undefined)
|
|
87
87
|
return namedSpotNodeRequest;
|
|
88
88
|
}
|
|
89
89
|
if (this.bridgeTransport.has(spotRouteTarget.routerChannelId)) {
|
|
90
|
-
return this.bridgeTransport.request(spotRouteTarget, parts, codecs, timeoutMs, signal);
|
|
90
|
+
return this.bridgeTransport.request(spotRouteTarget, parts, codecs, timeoutMs, signal, onAdmitted);
|
|
91
91
|
}
|
|
92
92
|
if (this.targets.hasBoundRouteRouter(spotRouteTarget.routerChannelId)) {
|
|
93
|
-
return this.routerSocketTransport.request(spotRouteTarget, parts, codecs, ZLINK_SEND_DONT_WAIT, timeoutMs, signal);
|
|
93
|
+
return this.routerSocketTransport.request(spotRouteTarget, parts, codecs, ZLINK_SEND_DONT_WAIT, timeoutMs, signal, onAdmitted);
|
|
94
94
|
}
|
|
95
|
-
const spotNodeRequest = this.spotNodeTransport.request(spotRouteTarget, parts, codecs, timeoutMs, signal);
|
|
95
|
+
const spotNodeRequest = this.spotNodeTransport.request(spotRouteTarget, parts, codecs, timeoutMs, signal, onAdmitted);
|
|
96
96
|
if (spotNodeRequest !== undefined) {
|
|
97
97
|
return spotNodeRequest;
|
|
98
98
|
}
|
|
99
|
-
return this.routerSocketTransport.request(spotRouteTarget, parts, codecs, 0, timeoutMs, signal);
|
|
99
|
+
return this.routerSocketTransport.request(spotRouteTarget, parts, codecs, 0, timeoutMs, signal, onAdmitted);
|
|
100
100
|
}
|
|
101
|
-
routeRequestFromSpotToSpot(sourceSpot, spotRouteTarget, packetName, request, timeoutMs, signal) {
|
|
102
|
-
return this.sourceSpotRouter.request(sourceSpot, spotRouteTarget, packetName, request, timeoutMs, signal);
|
|
101
|
+
routeRequestFromSpotToSpot(sourceSpot, spotRouteTarget, packetName, request, timeoutMs, signal, onAdmitted) {
|
|
102
|
+
return this.sourceSpotRouter.request(sourceSpot, spotRouteTarget, packetName, request, timeoutMs, signal, onAdmitted);
|
|
103
103
|
}
|
|
104
104
|
async routeSendFromSpotToSpot(sourceSpot, spotRouteTarget, packetName, message, metadata) {
|
|
105
105
|
await this.sourceSpotRouter.send(sourceSpot, spotRouteTarget, packetName, message, metadata);
|
|
106
106
|
}
|
|
107
|
-
routeRequestRawFromSpotToSpot(sourceSpot, spotRouteTarget, request, timeoutMs, signal) {
|
|
108
|
-
return this.sourceSpotRouter.requestRaw(sourceSpot, spotRouteTarget, request, timeoutMs, signal);
|
|
107
|
+
routeRequestRawFromSpotToSpot(sourceSpot, spotRouteTarget, request, timeoutMs, signal, onAdmitted) {
|
|
108
|
+
return this.sourceSpotRouter.requestRaw(sourceSpot, spotRouteTarget, request, timeoutMs, signal, onAdmitted);
|
|
109
109
|
}
|
|
110
|
-
async routeRequestRawToSpot(spotRouteTarget, request, timeoutMs, signal) {
|
|
110
|
+
async routeRequestRawToSpot(spotRouteTarget, request, timeoutMs, signal, onAdmitted) {
|
|
111
111
|
(0, abort_1.throwIfAborted)(signal);
|
|
112
112
|
if (this.targets.hasNamedSpotNode(spotRouteTarget.routerChannelId)) {
|
|
113
|
-
const namedSpotNodeRequest = this.spotNodeTransport.requestRaw(spotRouteTarget, request, timeoutMs, signal);
|
|
113
|
+
const namedSpotNodeRequest = this.spotNodeTransport.requestRaw(spotRouteTarget, request, timeoutMs, signal, onAdmitted);
|
|
114
114
|
if (namedSpotNodeRequest !== undefined)
|
|
115
115
|
return namedSpotNodeRequest;
|
|
116
116
|
}
|
|
117
117
|
if (this.bridgeTransport.has(spotRouteTarget.routerChannelId)) {
|
|
118
|
-
return this.bridgeTransport.requestRaw(spotRouteTarget, request, timeoutMs, signal);
|
|
118
|
+
return this.bridgeTransport.requestRaw(spotRouteTarget, request, timeoutMs, signal, onAdmitted);
|
|
119
119
|
}
|
|
120
|
-
const spotNodeRequest = this.spotNodeTransport.requestRaw(spotRouteTarget, request, timeoutMs, signal);
|
|
120
|
+
const spotNodeRequest = this.spotNodeTransport.requestRaw(spotRouteTarget, request, timeoutMs, signal, onAdmitted);
|
|
121
121
|
if (spotNodeRequest !== undefined) {
|
|
122
122
|
return spotNodeRequest;
|
|
123
123
|
}
|
|
124
|
-
return this.routerSocketTransport.requestRaw(spotRouteTarget, request, timeoutMs, signal);
|
|
124
|
+
return this.routerSocketTransport.requestRaw(spotRouteTarget, request, timeoutMs, signal, onAdmitted);
|
|
125
125
|
}
|
|
126
126
|
}
|
|
127
127
|
exports.ZLinkSpotRouteDispatchStrategy = ZLinkSpotRouteDispatchStrategy;
|
|
@@ -56,7 +56,7 @@ function encodeCanonicalActorJoinRecoverySavedWork(input) {
|
|
|
56
56
|
const request = Buffer.from(input.request);
|
|
57
57
|
const replyContentType = operationId === undefined
|
|
58
58
|
? null
|
|
59
|
-
:
|
|
59
|
+
: (nullableText(input.replyContentType ?? null, 'Actor Join reply content type') ?? null);
|
|
60
60
|
const metadata = encodeMetadataJson({
|
|
61
61
|
Request: {
|
|
62
62
|
ActorId: requireText(input.actorId, 'Actor id'),
|
|
@@ -167,7 +167,7 @@ function decodeCanonicalActorJoinRecoverySavedWork(encoded) {
|
|
|
167
167
|
const operationLow = integer(metadata.OperationIdLow, 'OperationIdLow');
|
|
168
168
|
const hasOperation = operationHigh !== 0n || operationLow !== 0n;
|
|
169
169
|
const replyContentType = nullableText(metadata.ReplyContentType, 'ReplyContentType');
|
|
170
|
-
if (hasOperation
|
|
170
|
+
if (!hasOperation && replyContentType !== undefined) {
|
|
171
171
|
throw new TypeError('Canonical Actor Join recovery reply identity is invalid.');
|
|
172
172
|
}
|
|
173
173
|
const targetNodeRid = base64(metadata.TargetNodeRid, 'TargetNodeRid');
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export interface PeerRouteObservation {
|
|
2
|
+
readonly generation?: bigint;
|
|
3
|
+
readonly ready: boolean;
|
|
4
|
+
}
|
|
5
|
+
export interface DurableServiceRequestPort {
|
|
6
|
+
readonly requestStopSignal?: AbortSignal;
|
|
7
|
+
observePeerRoute(target: string): PeerRouteObservation;
|
|
8
|
+
observePeerRouteChanged(listener: (target: string) => void): () => void;
|
|
9
|
+
observePeerConnectionIntentRemoved(listener: (target: string) => void): () => void;
|
|
10
|
+
requestService(target: string, parts: readonly Uint8Array[], timeoutMs: number, onAdmitted?: () => void): Promise<readonly Buffer[]>;
|
|
11
|
+
}
|
|
12
|
+
/** Actor model §8.1: a ready edge or a typed transport failure owns replay. */
|
|
13
|
+
export declare function requestDurableService(port: DurableServiceRequestPort, target: string, parts: readonly Uint8Array[], deadlineMs: number, operationKind: string, signal?: AbortSignal, onSubmitted?: (signal: AbortSignal) => Promise<void>): Promise<readonly Buffer[]>;
|
|
14
|
+
export declare function durableRequestCanReplay(error: unknown): boolean;
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.requestDurableService = requestDurableService;
|
|
4
|
+
exports.durableRequestCanReplay = durableRequestCanReplay;
|
|
5
|
+
const abort_1 = require("../abort");
|
|
6
|
+
const runtime_values_1 = require("../backend/runtime-values");
|
|
7
|
+
const framework_errors_internal_1 = require("../framework-errors-internal");
|
|
8
|
+
/** Actor model §8.1: a ready edge or a typed transport failure owns replay. */
|
|
9
|
+
async function requestDurableService(port, target, parts, deadlineMs, operationKind, signal, onSubmitted) {
|
|
10
|
+
let wasAdmitted = false;
|
|
11
|
+
const stop = new AbortController();
|
|
12
|
+
const exhausted = (cause) => (0, framework_errors_internal_1.createInternalFrameworkException)(wasAdmitted
|
|
13
|
+
? framework_errors_internal_1.ZLinkFrameworkInternalErrorKind.DeadlineExceeded
|
|
14
|
+
: framework_errors_internal_1.ZLinkFrameworkInternalErrorKind.RouteNotConnected, `${operationKind} exhausted its end-to-end deadline.`, true, cause);
|
|
15
|
+
const timer = setTimeout(() => stop.abort(exhausted()), Math.max(0, Math.ceil(deadlineMs - performance.now())));
|
|
16
|
+
const unobserveIntent = port.observePeerConnectionIntentRemoved((rid) => {
|
|
17
|
+
if (rid === target)
|
|
18
|
+
stop.abort((0, framework_errors_internal_1.createInternalFrameworkException)(framework_errors_internal_1.ZLinkFrameworkInternalErrorKind.RouteNotConnected, `${operationKind} target node lifecycle ended.`, true));
|
|
19
|
+
});
|
|
20
|
+
const cancellation = AbortSignal.any([
|
|
21
|
+
stop.signal,
|
|
22
|
+
...(signal === undefined ? [] : [signal]),
|
|
23
|
+
...(port.requestStopSignal === undefined ? [] : [port.requestStopSignal])
|
|
24
|
+
]);
|
|
25
|
+
try {
|
|
26
|
+
for (;;) {
|
|
27
|
+
cancellation.throwIfAborted();
|
|
28
|
+
const remainingMs = Math.ceil(deadlineMs - performance.now());
|
|
29
|
+
if (remainingMs <= 0)
|
|
30
|
+
throw exhausted();
|
|
31
|
+
let changed;
|
|
32
|
+
const transition = new Promise((resolve) => {
|
|
33
|
+
changed = resolve;
|
|
34
|
+
});
|
|
35
|
+
let submittedGeneration;
|
|
36
|
+
const attemptStop = new AbortController();
|
|
37
|
+
const attemptSignal = AbortSignal.any([cancellation, attemptStop.signal]);
|
|
38
|
+
const unobserveRoute = port.observePeerRouteChanged((rid) => {
|
|
39
|
+
if (rid !== target)
|
|
40
|
+
return;
|
|
41
|
+
const route = port.observePeerRoute(target);
|
|
42
|
+
if (submittedGeneration === undefined
|
|
43
|
+
? route.ready
|
|
44
|
+
: route.generation !== undefined && route.generation !== submittedGeneration) {
|
|
45
|
+
changed();
|
|
46
|
+
attemptStop.abort();
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
try {
|
|
50
|
+
const route = port.observePeerRoute(target);
|
|
51
|
+
if (!route.ready) {
|
|
52
|
+
await (0, abort_1.awaitWithAbort)(transition, cancellation);
|
|
53
|
+
continue;
|
|
54
|
+
}
|
|
55
|
+
submittedGeneration = route.generation;
|
|
56
|
+
const reply = port.requestService(target, parts, remainingMs, () => {
|
|
57
|
+
wasAdmitted = true;
|
|
58
|
+
});
|
|
59
|
+
const request = onSubmitted === undefined
|
|
60
|
+
? reply
|
|
61
|
+
: Promise.race([
|
|
62
|
+
reply,
|
|
63
|
+
Promise.resolve()
|
|
64
|
+
.then(() => onSubmitted(attemptSignal))
|
|
65
|
+
.then(() => reply)
|
|
66
|
+
]);
|
|
67
|
+
const result = await (0, abort_1.awaitWithAbort)(Promise.race([request.then((parts) => ({ parts })), transition.then(() => undefined)]), cancellation);
|
|
68
|
+
if (result !== undefined)
|
|
69
|
+
return result.parts;
|
|
70
|
+
}
|
|
71
|
+
catch (error) {
|
|
72
|
+
cancellation.throwIfAborted();
|
|
73
|
+
if (!durableRequestCanReplay(error))
|
|
74
|
+
throw error;
|
|
75
|
+
if ((0, runtime_values_1.isZLinkBackendResultError)(error) && error.operation === 'request')
|
|
76
|
+
wasAdmitted = true;
|
|
77
|
+
}
|
|
78
|
+
finally {
|
|
79
|
+
attemptStop.abort();
|
|
80
|
+
unobserveRoute();
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
finally {
|
|
85
|
+
clearTimeout(timer);
|
|
86
|
+
unobserveIntent();
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
function durableRequestCanReplay(error) {
|
|
90
|
+
if (!(0, runtime_values_1.isZLinkBackendResultError)(error))
|
|
91
|
+
return false;
|
|
92
|
+
return error.operation === 'request'
|
|
93
|
+
? error.result === runtime_values_1.RequestResult.NotConnected || error.result === runtime_values_1.RequestResult.TimedOut
|
|
94
|
+
: error.result === runtime_values_1.SubmitResult.NotConnected ||
|
|
95
|
+
error.result === runtime_values_1.SubmitResult.NotFound ||
|
|
96
|
+
error.result === runtime_values_1.SubmitResult.NotAdmitted ||
|
|
97
|
+
error.result === runtime_values_1.SubmitResult.Backpressured;
|
|
98
|
+
}
|
|
@@ -10,5 +10,6 @@ export type ZLinkOperationIdentityKey = string & {
|
|
|
10
10
|
readonly [operationKeyBrand]: true;
|
|
11
11
|
};
|
|
12
12
|
export declare function operationIdentityKey(operationId: ZLinkOperationIdentity128): ZLinkOperationIdentityKey;
|
|
13
|
+
export declare function validateOperationIdentity(operationId: ZLinkOperationIdentity128): void;
|
|
13
14
|
export declare function createRandomOperationIdentity(source?: (size: number) => Buffer): ZLinkOperationIdentity128;
|
|
14
15
|
export {};
|
|
@@ -2,18 +2,22 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ZLINK_NATIVE_CORRELATION_OPERATION_NAMESPACE = exports.OPERATION_IDENTITY_BYTES = void 0;
|
|
4
4
|
exports.operationIdentityKey = operationIdentityKey;
|
|
5
|
+
exports.validateOperationIdentity = validateOperationIdentity;
|
|
5
6
|
exports.createRandomOperationIdentity = createRandomOperationIdentity;
|
|
6
7
|
const stream_wire_1 = require("@zlink-systems/stream-wire");
|
|
7
8
|
const node_crypto_1 = require("node:crypto");
|
|
8
9
|
exports.OPERATION_IDENTITY_BYTES = 16;
|
|
9
10
|
exports.ZLINK_NATIVE_CORRELATION_OPERATION_NAMESPACE = 2n;
|
|
10
11
|
function operationIdentityKey(operationId) {
|
|
12
|
+
validateOperationIdentity(operationId);
|
|
13
|
+
return `${operationId.high.toString(16)}:${operationId.low.toString(16)}`;
|
|
14
|
+
}
|
|
15
|
+
function validateOperationIdentity(operationId) {
|
|
11
16
|
requireUnsigned64(operationId.high, 'operationId.high');
|
|
12
17
|
requireUnsigned64(operationId.low, 'operationId.low');
|
|
13
18
|
if (operationId.high === 0n && operationId.low === 0n) {
|
|
14
19
|
throw new RangeError('Operation identity must not be all zero.');
|
|
15
20
|
}
|
|
16
|
-
return `${operationId.high.toString(16)}:${operationId.low.toString(16)}`;
|
|
17
21
|
}
|
|
18
22
|
function createRandomOperationIdentity(source = node_crypto_1.randomBytes) {
|
|
19
23
|
for (;;) {
|
|
@@ -17,6 +17,7 @@ export interface RawServiceRequestResult {
|
|
|
17
17
|
/** An M6A application frame already owned by the Framework runtime. */
|
|
18
18
|
type ServiceApplicationPayloadInput = ServiceApplicationPayload | Buffer;
|
|
19
19
|
export interface RawServiceIngressRecord {
|
|
20
|
+
readonly onAdmitted?: () => void;
|
|
20
21
|
readonly command: number;
|
|
21
22
|
readonly flags: number;
|
|
22
23
|
readonly sourceRoutingId: string;
|
|
@@ -63,6 +64,7 @@ export declare class RawServiceMeshRuntime {
|
|
|
63
64
|
private readonly expectedPeers;
|
|
64
65
|
private readonly endpointOnlyPeers;
|
|
65
66
|
private readonly peerConnectionIntentRemoved;
|
|
67
|
+
private readonly peerRouteChanged;
|
|
66
68
|
/**
|
|
67
69
|
* The last observed Core selected route of each RID (Core ROUTER §10.1):
|
|
68
70
|
* RID -> route generation. Only `observeSelectedRoutes` replaces it.
|
|
@@ -70,10 +72,12 @@ export declare class RawServiceMeshRuntime {
|
|
|
70
72
|
private selectedRoutes;
|
|
71
73
|
private readonly bindingPort;
|
|
72
74
|
private readonly applicationJobQueue;
|
|
75
|
+
private readonly nodeMailboxOwner;
|
|
73
76
|
private readonly peerAdmissionSealed?;
|
|
74
77
|
private readonly applicationJobStop;
|
|
75
78
|
private receiveAcquisition?;
|
|
76
79
|
private receivePermit?;
|
|
80
|
+
private receiveRotation?;
|
|
77
81
|
private readonly controlSends;
|
|
78
82
|
private infrastructureFailure?;
|
|
79
83
|
private readonly onReceiveReady?;
|
|
@@ -88,6 +92,7 @@ export declare class RawServiceMeshRuntime {
|
|
|
88
92
|
private router?;
|
|
89
93
|
private nextCorrelation;
|
|
90
94
|
private serviceIngress?;
|
|
95
|
+
private serviceIngressAccepts?;
|
|
91
96
|
private closed;
|
|
92
97
|
constructor(options: RawServiceMeshRuntimeOptions);
|
|
93
98
|
start(): void;
|
|
@@ -98,6 +103,11 @@ export declare class RawServiceMeshRuntime {
|
|
|
98
103
|
disconnectPeer(endpoint: string, nodeRoutingId: string, lifecycleGeneration?: bigint): void;
|
|
99
104
|
disconnectPeerEndpoint(endpoint: string): void;
|
|
100
105
|
observePeerConnectionIntentRemoved(listener: (nodeRoutingId: string) => void): () => void;
|
|
106
|
+
observePeerRoute(nodeRoutingId: string): import('./durable-service-request').PeerRouteObservation;
|
|
107
|
+
get requestStopSignal(): AbortSignal;
|
|
108
|
+
observePeerRouteChanged(listener: (nodeRoutingId: string) => void): () => void;
|
|
109
|
+
hasSelectedPeerRoute(nodeRoutingId: string): boolean;
|
|
110
|
+
private notifyPeerRouteChanged;
|
|
101
111
|
private notifyPeerConnectionIntentRemoved;
|
|
102
112
|
announcePeer(nodeRoutingId: string): Promise<boolean>;
|
|
103
113
|
isPeerRouteReady(nodeRoutingId: string, lifecycleGeneration?: bigint): boolean;
|
|
@@ -108,17 +118,18 @@ export declare class RawServiceMeshRuntime {
|
|
|
108
118
|
readonly channelWeight?: number;
|
|
109
119
|
readonly state?: 'draining';
|
|
110
120
|
}): Promise<void>;
|
|
121
|
+
private publishLocalDescriptor;
|
|
111
122
|
replaceDiscoveredNotRequired(descriptors: readonly ServiceNodeDescriptor[]): void;
|
|
112
123
|
isObjectClientNodeDirectTarget(nodeRoutingId: string): boolean;
|
|
113
|
-
sendToNode(targetNodeRoutingId: string, payload: ServiceApplicationPayloadInput): Promise<boolean>;
|
|
124
|
+
sendToNode(targetNodeRoutingId: string, payload: ServiceApplicationPayloadInput): boolean | Promise<boolean>;
|
|
114
125
|
sendToChannel(channelName: string, payload: ServiceApplicationPayloadInput): Promise<SubmitResult>;
|
|
115
|
-
requestToNode(targetNodeRoutingId: string, payload: ServiceApplicationPayloadInput, timeoutMs: number): PendingOperation<RawServiceRequestResult>;
|
|
116
|
-
requestToChannel(channelName: string, payload: ServiceApplicationPayloadInput, timeoutMs: number): PendingOperation<RawServiceRequestResult>;
|
|
126
|
+
requestToNode(targetNodeRoutingId: string, payload: ServiceApplicationPayloadInput, timeoutMs: number, onAdmitted?: () => void): PendingOperation<RawServiceRequestResult>;
|
|
127
|
+
requestToChannel(channelName: string, payload: ServiceApplicationPayloadInput, timeoutMs: number, onAdmitted?: () => void): PendingOperation<RawServiceRequestResult>;
|
|
117
128
|
private selectChannelTarget;
|
|
118
|
-
setServiceIngress(handler: RawServiceIngressHandler): void;
|
|
129
|
+
setServiceIngress(handler: RawServiceIngressHandler, accepts?: (command: number) => boolean): void;
|
|
119
130
|
reserveLocalIngress(signal?: AbortSignal): Promise<ApplicationIngressRecordOwner>;
|
|
120
131
|
sendService(targetNodeRoutingId: string, parts: readonly Uint8Array[]): Promise<boolean>;
|
|
121
|
-
requestService(targetNodeRoutingId: string, parts: readonly Uint8Array[], timeoutMs: number): Promise<readonly Buffer[]>;
|
|
132
|
+
requestService(targetNodeRoutingId: string, parts: readonly Uint8Array[], timeoutMs: number, onAdmitted?: () => void): Promise<readonly Buffer[]>;
|
|
122
133
|
replyService(record: Pick<RawServiceIngressRecord, 'sourceRoutingId' | 'sourceRoute' | 'requestSequence' | 'reply'>, parts: readonly Uint8Array[]): void;
|
|
123
134
|
reply(request: ServiceMailboxRecord, payload: ServiceApplicationPayloadInput, terminalResult?: number, failureCode?: number): void;
|
|
124
135
|
pumpOne(nowMs?: number, observe?: RawServicePumpObserver): Promise<RawServicePumpResult>;
|
|
@@ -126,9 +137,15 @@ export declare class RawServiceMeshRuntime {
|
|
|
126
137
|
/** Returns whether a receive budget ended before no-data; idle ticks only maintain peers. */
|
|
127
138
|
pumpBatch(receiveReady?: boolean, routeReady?: boolean): Promise<boolean>;
|
|
128
139
|
private receiveOne;
|
|
140
|
+
private finishReceive;
|
|
129
141
|
private reportProtocolError;
|
|
130
142
|
private replyGenericProtocolError;
|
|
131
143
|
private processReceived;
|
|
144
|
+
private receiveProtocolFailure;
|
|
145
|
+
private processAdmission;
|
|
146
|
+
private processLiveness;
|
|
147
|
+
private processApplicationReceived;
|
|
148
|
+
private enqueueOrdinaryRecord;
|
|
132
149
|
expireOperations(nowMs: number, turnDeadlineMs: number): number;
|
|
133
150
|
get pendingOperationCount(): number;
|
|
134
151
|
tickLiveness(nowMs?: number): ServiceLivenessTick;
|