@zlink-systems/framework 0.27.0 → 0.29.0
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/dist/.tsbuildinfo +1 -1
- package/dist/contracts/Actors/ZLinkActorClient.d.ts +1 -1
- package/dist/contracts/Channels/Calls.d.ts +1 -1
- package/dist/contracts/Configuration/Builders.d.ts +2 -1
- package/dist/contracts/Configuration/Configs.d.ts +0 -1
- package/dist/contracts/Configuration/InternalDefaults.d.ts +3 -0
- package/dist/contracts/Configuration/InternalDefaults.js +4 -1
- package/dist/contracts/Configuration/RegistrationBuilders.js +9 -0
- package/dist/contracts/Configuration/RegistrationNormalizers.d.ts +1 -0
- package/dist/contracts/Configuration/RegistrationNormalizers.js +16 -0
- package/dist/contracts/Configuration/RegistrationTypes.d.ts +3 -5
- package/dist/contracts/Configuration/RegistrationValidators.js +0 -2
- package/dist/contracts/Spots/Contracts.d.ts +1 -1
- package/dist/contracts/Streams/BoundSessionContracts.d.ts +1 -1
- package/dist/contracts/Streams/IZLinkSession.d.ts +2 -3
- package/dist/contracts/Streams/IZLinkSessionActor.d.ts +2 -2
- package/dist/runtime/actors/actor-client.js +7 -10
- package/dist/runtime/actors/actor-mailbox.d.ts +2 -2
- package/dist/runtime/actors/actor-mailbox.js +2 -2
- package/dist/runtime/actors/actor-request-deadline.d.ts +1 -3
- package/dist/runtime/actors/actor-request-deadline.js +4 -29
- package/dist/runtime/actors/actor-routed-join-transport.d.ts +2 -3
- package/dist/runtime/backend/contracts/index.d.ts +1 -4
- package/dist/runtime/backend/node/node-backend-adapter-support.d.ts +2 -0
- package/dist/runtime/backend/node/node-backend-adapter-support.js +35 -4
- 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 +1 -2
- package/dist/runtime/backend/node/node-raw-binding-port.js +10 -27
- package/dist/runtime/backend/node/node-raw-mesh-backend.js +1 -3
- package/dist/runtime/backend/node/node-socket-backend-adapter.js +1 -1
- package/dist/runtime/channels/channel-clients.js +8 -10
- package/dist/runtime/channels/channel-envelope.d.ts +1 -1
- package/dist/runtime/channels/channel-envelope.js +4 -10
- package/dist/runtime/channels/channel-outbound-operations.d.ts +2 -2
- package/dist/runtime/channels/channel-outbound-operations.js +20 -36
- package/dist/runtime/channels/channel-runtime-manager.d.ts +4 -4
- package/dist/runtime/channels/channel-runtime-manager.js +8 -8
- package/dist/runtime/channels/channel-socket-options.js +0 -10
- package/dist/runtime/channels/channel-socket-registry.d.ts +1 -1
- package/dist/runtime/channels/channel-socket-registry.js +3 -14
- package/dist/runtime/channels/channel-transports.d.ts +10 -14
- package/dist/runtime/channels/channel-transports.js +11 -14
- package/dist/runtime/channels/local-spot-route-transport.d.ts +1 -1
- package/dist/runtime/channels/local-spot-route-transport.js +1 -3
- package/dist/runtime/channels/router-socket-spot-route-transport.d.ts +1 -1
- package/dist/runtime/channels/router-socket-spot-route-transport.js +2 -2
- package/dist/runtime/channels/source-spot-router.d.ts +1 -1
- package/dist/runtime/channels/source-spot-router.js +2 -4
- package/dist/runtime/channels/spot-node-route-transport.d.ts +1 -1
- package/dist/runtime/channels/spot-node-route-transport.js +2 -3
- package/dist/runtime/channels/spot-route-bridge-transport.d.ts +1 -1
- package/dist/runtime/channels/spot-route-bridge-transport.js +2 -2
- package/dist/runtime/channels/spot-route-dispatch-strategy.d.ts +2 -4
- package/dist/runtime/channels/spot-route-dispatch-strategy.js +11 -12
- package/dist/runtime/execution/serial-execution-queue.d.ts +12 -3
- package/dist/runtime/execution/serial-execution-queue.js +116 -28
- package/dist/runtime/foundation/operation-registry.d.ts +3 -2
- package/dist/runtime/foundation/operation-registry.js +5 -1
- package/dist/runtime/foundation/raw-service-mesh-runtime.js +17 -11
- package/dist/runtime/foundation/service-authority-payload-codec.d.ts +0 -2
- package/dist/runtime/foundation/service-authority-payload-codec.js +0 -43
- package/dist/runtime/foundation/service-stateful-registry.d.ts +4 -3
- package/dist/runtime/foundation/service-stateful-registry.js +5 -2
- package/dist/runtime/foundation/service-stateful-runtime.d.ts +1 -8
- package/dist/runtime/foundation/service-stateful-runtime.js +78 -126
- package/dist/runtime/foundation/service-stateful-wire-codec.d.ts +0 -11
- package/dist/runtime/foundation/service-stateful-wire-codec.js +1 -23
- package/dist/runtime/foundation/service-topology-registry.d.ts +5 -0
- package/dist/runtime/foundation/service-topology-registry.js +16 -17
- package/dist/runtime/host/actor-packet-relay.d.ts +2 -2
- package/dist/runtime/host/actor-packet-relay.js +8 -10
- package/dist/runtime/host/index.js +1 -15
- package/dist/runtime/host/instance-activation-authority.d.ts +0 -1
- package/dist/runtime/host/instance-activation-authority.js +46 -97
- package/dist/runtime/host/remote-bound-session-relay.js +8 -8
- package/dist/runtime/host/spot-address-transport.d.ts +1 -9
- package/dist/runtime/host/spot-address-transport.js +47 -87
- package/dist/runtime/host/stateful-authority-route-runtime.d.ts +1 -0
- package/dist/runtime/host/stateful-authority-route-runtime.js +17 -9
- package/dist/runtime/locations/domain-store-contract.d.ts +1 -0
- package/dist/runtime/locations/in-memory-authority-store.d.ts +2 -0
- package/dist/runtime/locations/in-memory-authority-store.js +22 -8
- package/dist/runtime/locations/in-memory-location-store.d.ts +1 -0
- package/dist/runtime/locations/in-memory-location-store.js +3 -0
- package/dist/runtime/locations/internal-store-contracts.d.ts +1 -1
- package/dist/runtime/locations/location-store-repository.d.ts +1 -0
- package/dist/runtime/locations/location-store-repository.js +98 -53
- package/dist/runtime/messaging/request-deadline.d.ts +3 -0
- package/dist/runtime/messaging/request-deadline.js +39 -0
- package/dist/runtime/messaging/submission-result.d.ts +2 -1
- package/dist/runtime/messaging/submission-result.js +11 -4
- package/dist/runtime/spots/spot-outbound.d.ts +3 -5
- package/dist/runtime/spots/spot-outbound.js +12 -15
- package/dist/runtime/spots/spot-serial-executor.js +4 -1
- package/dist/runtime/spots/spot-serial-turn-executor.d.ts +3 -0
- package/dist/runtime/spots/spot-serial-turn-executor.js +5 -0
- package/dist/runtime/streams/bound-actor-relay-sender.d.ts +2 -2
- package/dist/runtime/streams/bound-actor-relay-sender.js +14 -14
- package/dist/runtime/streams/bound-session-service.js +1 -1
- package/dist/runtime/streams/index.d.ts +2 -3
- package/dist/runtime/streams/index.js +6 -5
- package/dist/runtime/streams/managed-stream.d.ts +2 -2
- package/dist/runtime/streams/managed-stream.js +3 -5
- package/dist/runtime/streams/native-fallback-bound-session.js +13 -16
- package/dist/runtime/streams/protocol.js +0 -9
- package/dist/runtime/streams/session-calls.d.ts +5 -7
- package/dist/runtime/streams/session-calls.js +6 -23
- package/dist/runtime/streams/session-context.d.ts +4 -8
- package/dist/runtime/streams/session-context.js +3 -32
- package/dist/runtime/streams/session-serial-executor.d.ts +0 -1
- package/dist/runtime/streams/session-serial-executor.js +0 -3
- package/dist/runtime/streams/stream-message-utils.d.ts +0 -1
- package/dist/runtime/streams/stream-message-utils.js +0 -20
- package/dist/runtime/streams/stream-session-runtime.d.ts +6 -3
- package/dist/runtime/streams/stream-session-runtime.js +40 -85
- package/package.json +3 -3
- package/src/contracts/Actors/ZLinkActorClient.ts +1 -1
- package/src/contracts/Channels/Calls.ts +1 -1
- package/src/contracts/Configuration/Builders.ts +2 -1
- package/src/contracts/Configuration/Configs.ts +0 -1
- package/src/contracts/Configuration/InternalDefaults.ts +4 -0
- package/src/contracts/Configuration/RegistrationBuilders.ts +13 -3
- package/src/contracts/Configuration/RegistrationNormalizers.ts +25 -0
- package/src/contracts/Configuration/RegistrationTypes.ts +3 -5
- package/src/contracts/Configuration/RegistrationValidators.ts +0 -4
- package/src/contracts/Spots/Contracts.ts +1 -1
- package/src/contracts/Streams/BoundSessionContracts.ts +1 -1
- package/src/contracts/Streams/IZLinkSession.ts +2 -3
- package/src/contracts/Streams/IZLinkSessionActor.ts +2 -6
- package/src/runtime/actors/actor-client.ts +9 -15
- package/src/runtime/actors/actor-mailbox.ts +7 -2
- package/src/runtime/actors/actor-request-deadline.ts +4 -49
- package/src/runtime/actors/actor-routed-join-transport.ts +3 -5
- package/src/runtime/backend/contracts/index.ts +1 -8
- package/src/runtime/backend/node/node-backend-adapter-support.ts +45 -5
- package/src/runtime/backend/node/node-dealer-channel-client-transport.ts +0 -2
- package/src/runtime/backend/node/node-raw-binding-port.ts +15 -41
- package/src/runtime/backend/node/node-raw-mesh-backend.ts +1 -7
- package/src/runtime/backend/node/node-socket-backend-adapter.ts +1 -1
- package/src/runtime/channels/channel-clients.ts +9 -19
- package/src/runtime/channels/channel-envelope.ts +16 -28
- package/src/runtime/channels/channel-outbound-operations.ts +36 -38
- package/src/runtime/channels/channel-runtime-manager.ts +6 -28
- package/src/runtime/channels/channel-socket-options.ts +0 -13
- package/src/runtime/channels/channel-socket-registry.ts +3 -17
- package/src/runtime/channels/channel-transports.ts +7 -33
- package/src/runtime/channels/local-spot-route-transport.ts +1 -5
- package/src/runtime/channels/router-socket-spot-route-transport.ts +2 -6
- package/src/runtime/channels/source-spot-router.ts +2 -9
- package/src/runtime/channels/spot-node-route-transport.ts +2 -7
- package/src/runtime/channels/spot-route-bridge-transport.ts +5 -12
- package/src/runtime/channels/spot-route-dispatch-strategy.ts +11 -30
- package/src/runtime/execution/serial-execution-queue.ts +117 -29
- package/src/runtime/foundation/operation-registry.ts +16 -9
- package/src/runtime/foundation/raw-service-mesh-runtime.ts +17 -14
- package/src/runtime/foundation/service-authority-payload-codec.ts +0 -46
- package/src/runtime/foundation/service-stateful-registry.ts +10 -5
- package/src/runtime/foundation/service-stateful-runtime.ts +103 -181
- package/src/runtime/foundation/service-stateful-wire-codec.ts +0 -25
- package/src/runtime/foundation/service-topology-registry.ts +30 -20
- package/src/runtime/host/actor-packet-relay.ts +8 -15
- package/src/runtime/host/index.ts +2 -26
- package/src/runtime/host/instance-activation-authority.ts +58 -125
- package/src/runtime/host/remote-bound-session-relay.ts +8 -16
- package/src/runtime/host/spot-address-transport.ts +107 -166
- package/src/runtime/host/stateful-authority-route-runtime.ts +22 -9
- package/src/runtime/locations/domain-store-contract.ts +5 -0
- package/src/runtime/locations/in-memory-authority-store.ts +42 -8
- package/src/runtime/locations/in-memory-location-store.ts +8 -0
- package/src/runtime/locations/internal-store-contracts.ts +1 -0
- package/src/runtime/locations/location-store-repository.ts +130 -68
- package/src/runtime/messaging/request-deadline.ts +58 -0
- package/src/runtime/messaging/submission-result.ts +18 -4
- package/src/runtime/protocol/service_wire_pilot_codec.generated.ts +1 -1
- package/src/runtime/spots/spot-outbound.ts +14 -24
- package/src/runtime/spots/spot-serial-executor.ts +4 -1
- package/src/runtime/spots/spot-serial-turn-executor.ts +10 -0
- package/src/runtime/streams/bound-actor-relay-sender.ts +12 -26
- package/src/runtime/streams/bound-session-service.ts +1 -1
- package/src/runtime/streams/index.ts +5 -5
- package/src/runtime/streams/managed-stream.ts +3 -13
- package/src/runtime/streams/native-fallback-bound-session.ts +13 -25
- package/src/runtime/streams/protocol.ts +0 -13
- package/src/runtime/streams/session-calls.ts +8 -34
- package/src/runtime/streams/session-context.ts +6 -47
- package/src/runtime/streams/session-serial-executor.ts +0 -8
- package/src/runtime/streams/stream-message-utils.ts +1 -27
- package/src/runtime/streams/stream-session-runtime.ts +54 -97
- package/dist/runtime/streams/session-requests.d.ts +0 -25
- package/dist/runtime/streams/session-requests.js +0 -101
- package/src/runtime/streams/session-requests.ts +0 -110
|
@@ -5,6 +5,6 @@ export declare class ZLinkSourceSpotRouter {
|
|
|
5
5
|
private readonly defaultRequestTimeoutMs;
|
|
6
6
|
constructor(defaultRequestTimeoutMs: number | undefined);
|
|
7
7
|
request<TReply>(sourceSpot: ZLinkBackendSpot, target: ZLinkSpotRouteTarget, packetName: string | undefined, request: unknown, timeoutMs: number | undefined, signal?: AbortSignal): Promise<TReply>;
|
|
8
|
-
send(sourceSpot: ZLinkBackendSpot, target: ZLinkSpotRouteTarget, packetName: string | undefined, message: unknown,
|
|
8
|
+
send(sourceSpot: ZLinkBackendSpot, target: ZLinkSpotRouteTarget, packetName: string | undefined, message: unknown, metadata?: ReadonlyMap<string, string>): Promise<void>;
|
|
9
9
|
requestRaw(sourceSpot: ZLinkBackendSpot, target: ZLinkSpotRouteTarget, request: Message, timeoutMs: number | undefined, signal?: AbortSignal): Promise<readonly Message[]>;
|
|
10
10
|
}
|
|
@@ -26,14 +26,12 @@ class ZLinkSourceSpotRouter {
|
|
|
26
26
|
(0, channel_envelope_1.closeMessages)(parts);
|
|
27
27
|
}
|
|
28
28
|
}
|
|
29
|
-
async send(sourceSpot, target, packetName, message,
|
|
30
|
-
(0, abort_1.throwIfAborted)(signal);
|
|
29
|
+
async send(sourceSpot, target, packetName, message, metadata) {
|
|
31
30
|
const parts = [
|
|
32
31
|
(0, spot_direct_envelope_1.encodeSpotDirectEnvelope)(3 /* ZLinkChannelMessageKind.Command */, target.routerChannelId, packetName, message, metadata)
|
|
33
32
|
];
|
|
34
33
|
try {
|
|
35
|
-
|
|
36
|
-
await (0, abort_1.awaitWithAbort)(sourceSpot.sendToSpot(target.targetNodeRid, target.spotId, parts), signal);
|
|
34
|
+
await sourceSpot.sendToSpot(target.targetNodeRid, target.spotId, parts);
|
|
37
35
|
}
|
|
38
36
|
finally {
|
|
39
37
|
(0, channel_envelope_1.closeMessages)(parts);
|
|
@@ -7,7 +7,7 @@ export declare class ZLinkSpotNodeRouteTransport {
|
|
|
7
7
|
private readonly registration;
|
|
8
8
|
private readonly targets;
|
|
9
9
|
constructor(registration: ZLinkFrameworkRegistration, targets: ZLinkSpotRouteTargetResolver);
|
|
10
|
-
send(target: ZLinkSpotRouteTarget, parts: readonly Message[]
|
|
10
|
+
send(target: ZLinkSpotRouteTarget, parts: readonly Message[]): Promise<boolean>;
|
|
11
11
|
request<TReply>(target: ZLinkSpotRouteTarget, parts: readonly Message[], codecs: ZLinkChannelEnvelopeCodecRegistry | undefined, timeoutMs: number | undefined, signal?: AbortSignal): Promise<TReply> | undefined;
|
|
12
12
|
requestRaw(target: ZLinkSpotRouteTarget, request: Message, timeoutMs: number | undefined, signal?: AbortSignal): Promise<readonly Message[]> | undefined;
|
|
13
13
|
}
|
|
@@ -11,14 +11,13 @@ class ZLinkSpotNodeRouteTransport {
|
|
|
11
11
|
this.registration = registration;
|
|
12
12
|
this.targets = targets;
|
|
13
13
|
}
|
|
14
|
-
async send(target, parts
|
|
14
|
+
async send(target, parts) {
|
|
15
15
|
const router = this.targets.spotNodeRouter(target.routerChannelId);
|
|
16
16
|
if (router === undefined) {
|
|
17
17
|
return false;
|
|
18
18
|
}
|
|
19
19
|
try {
|
|
20
|
-
(
|
|
21
|
-
await (0, abort_1.awaitWithAbort)(router.sendToSpot(target.targetNodeRid, target.spotId, parts), signal);
|
|
20
|
+
await router.sendToSpot(target.targetNodeRid, target.spotId, parts);
|
|
22
21
|
return true;
|
|
23
22
|
}
|
|
24
23
|
finally {
|
|
@@ -7,7 +7,7 @@ export declare class ZLinkSpotRouteBridgeTransport {
|
|
|
7
7
|
private readonly defaultRequestTimeoutMs;
|
|
8
8
|
constructor(bridges: ReadonlyMap<string, ZLinkBackendSpotRouteBridge>, defaultRequestTimeoutMs: number | undefined);
|
|
9
9
|
has(routerChannelId: string): boolean;
|
|
10
|
-
send(target: ZLinkSpotRouteTarget, parts: readonly Message[]
|
|
10
|
+
send(target: ZLinkSpotRouteTarget, parts: readonly Message[]): Promise<void>;
|
|
11
11
|
request<TReply>(target: ZLinkSpotRouteTarget, parts: readonly Message[], codecs: ZLinkChannelEnvelopeCodecRegistry | undefined, timeoutMs: number | undefined, signal?: AbortSignal): Promise<TReply>;
|
|
12
12
|
requestRaw(target: ZLinkSpotRouteTarget, request: Message, timeoutMs: number | undefined, signal?: AbortSignal): Promise<readonly Message[]>;
|
|
13
13
|
private requireBridge;
|
|
@@ -15,10 +15,10 @@ class ZLinkSpotRouteBridgeTransport {
|
|
|
15
15
|
has(routerChannelId) {
|
|
16
16
|
return this.bridges.has(routerChannelId);
|
|
17
17
|
}
|
|
18
|
-
async send(target, parts
|
|
18
|
+
async send(target, parts) {
|
|
19
19
|
const bridge = this.requireBridge(target.routerChannelId);
|
|
20
20
|
try {
|
|
21
|
-
await (0,
|
|
21
|
+
await (0, channel_multipart_1.appendParts)(bridge.send(target.routerChannelId, target.targetNodeRid, target.spotId), parts).submit();
|
|
22
22
|
}
|
|
23
23
|
finally {
|
|
24
24
|
(0, channel_envelope_1.closeMessages)(parts);
|
|
@@ -8,8 +8,6 @@ import type { ZLinkChannelSocketRegistry } from './channel-socket-registry';
|
|
|
8
8
|
export interface ZLinkLocalSpotRouteDispatcher {
|
|
9
9
|
send(spotId: RoutingId, packetName: string | undefined, message: unknown, context: {
|
|
10
10
|
readonly channelName: string;
|
|
11
|
-
readonly admissionTimeoutMs?: number;
|
|
12
|
-
readonly signal?: AbortSignal;
|
|
13
11
|
readonly metadata?: ReadonlyMap<string, string>;
|
|
14
12
|
}): Promise<void>;
|
|
15
13
|
request<TReply>(spotId: RoutingId, packetName: string | undefined, request: unknown, context: {
|
|
@@ -39,12 +37,12 @@ export declare class ZLinkSpotRouteDispatchStrategy {
|
|
|
39
37
|
spotRouteNode(routerChannelId: string): ZLinkBackendSpotNode | undefined;
|
|
40
38
|
canRouteChannel(routerChannelId: string): boolean;
|
|
41
39
|
canRoutePacketChannel(routerChannelId: string): boolean;
|
|
42
|
-
routeSendToSpot(spotRouteTarget: ZLinkSpotRouteTarget, packetName: string | undefined, message: unknown,
|
|
40
|
+
routeSendToSpot(spotRouteTarget: ZLinkSpotRouteTarget, packetName: string | undefined, message: unknown, metadata?: ReadonlyMap<string, string>): Promise<void>;
|
|
43
41
|
private routeSendToSpotScoped;
|
|
44
42
|
routeRequestToSpot<TReply>(spotRouteTarget: ZLinkSpotRouteTarget, packetName: string | undefined, request: unknown, timeoutMs: number | undefined, signal?: AbortSignal, metadata?: ReadonlyMap<string, string>): Promise<TReply>;
|
|
45
43
|
private routeRequestToSpotScoped;
|
|
46
44
|
routeRequestFromSpotToSpot<TReply>(sourceSpot: ZLinkBackendSpot, spotRouteTarget: ZLinkSpotRouteTarget, packetName: string | undefined, request: unknown, timeoutMs: number | undefined, signal?: AbortSignal): Promise<TReply>;
|
|
47
|
-
routeSendFromSpotToSpot(sourceSpot: ZLinkBackendSpot, spotRouteTarget: ZLinkSpotRouteTarget, packetName: string | undefined, message: unknown,
|
|
45
|
+
routeSendFromSpotToSpot(sourceSpot: ZLinkBackendSpot, spotRouteTarget: ZLinkSpotRouteTarget, packetName: string | undefined, message: unknown, metadata?: ReadonlyMap<string, string>): Promise<void>;
|
|
48
46
|
routeRequestRawFromSpotToSpot(sourceSpot: ZLinkBackendSpot, spotRouteTarget: ZLinkSpotRouteTarget, request: Message, timeoutMs: number | undefined, signal?: AbortSignal): Promise<readonly Message[]>;
|
|
49
47
|
routeRequestRawToSpot(spotRouteTarget: ZLinkSpotRouteTarget, request: Message, timeoutMs: number | undefined, signal?: AbortSignal): Promise<readonly Message[]>;
|
|
50
48
|
}
|
|
@@ -41,35 +41,34 @@ class ZLinkSpotRouteDispatchStrategy {
|
|
|
41
41
|
canRoutePacketChannel(routerChannelId) {
|
|
42
42
|
return this.targets.canRoutePacketChannel(routerChannelId);
|
|
43
43
|
}
|
|
44
|
-
routeSendToSpot(spotRouteTarget, packetName, message,
|
|
44
|
+
routeSendToSpot(spotRouteTarget, packetName, message, metadata) {
|
|
45
45
|
// Call-scoped flow (spec 27 §4): the envelope flow pair lives only for
|
|
46
46
|
// the duration of this outbound call, never in the caller's context.
|
|
47
|
-
return (0, flow_context_1.runWithOutboundFlow)(this.options.flowCreationEnabled?.() ?? true, () => this.routeSendToSpotScoped(spotRouteTarget, packetName, message,
|
|
47
|
+
return (0, flow_context_1.runWithOutboundFlow)(this.options.flowCreationEnabled?.() ?? true, () => this.routeSendToSpotScoped(spotRouteTarget, packetName, message, metadata));
|
|
48
48
|
}
|
|
49
|
-
async routeSendToSpotScoped(spotRouteTarget, packetName, message,
|
|
50
|
-
(0, abort_1.throwIfAborted)(signal);
|
|
49
|
+
async routeSendToSpotScoped(spotRouteTarget, packetName, message, metadata) {
|
|
51
50
|
const localSpotRouteNode = this.targets.localRouteNode(spotRouteTarget);
|
|
52
51
|
if (localSpotRouteNode !== undefined) {
|
|
53
|
-
await this.localTransport.send(spotRouteTarget.routerChannelId, spotRouteTarget.spotId, packetName, message,
|
|
52
|
+
await this.localTransport.send(spotRouteTarget.routerChannelId, spotRouteTarget.spotId, packetName, message, metadata);
|
|
54
53
|
return;
|
|
55
54
|
}
|
|
56
55
|
const parts = (0, channel_envelope_1.encodeChannelEnvelopeParts)(3 /* ZLinkChannelMessageKind.Command */, spotRouteTarget.routerChannelId, packetName, message, undefined, undefined, (0, channel_framework_packets_1.codecsForFrameworkPacket)(packetName, this.options.codecs), undefined, this.options.flowCreationEnabled?.() ?? true, metadata);
|
|
57
56
|
if (this.targets.hasNamedSpotNode(spotRouteTarget.routerChannelId) &&
|
|
58
|
-
(await this.spotNodeTransport.send(spotRouteTarget, parts
|
|
57
|
+
(await this.spotNodeTransport.send(spotRouteTarget, parts))) {
|
|
59
58
|
return;
|
|
60
59
|
}
|
|
61
60
|
if (this.bridgeTransport.has(spotRouteTarget.routerChannelId)) {
|
|
62
|
-
await this.bridgeTransport.send(spotRouteTarget, parts
|
|
61
|
+
await this.bridgeTransport.send(spotRouteTarget, parts);
|
|
63
62
|
return;
|
|
64
63
|
}
|
|
65
64
|
if (this.targets.hasBoundRouteRouter(spotRouteTarget.routerChannelId)) {
|
|
66
|
-
await this.routerSocketTransport.send(spotRouteTarget, parts, ZLINK_SEND_DONT_WAIT
|
|
65
|
+
await this.routerSocketTransport.send(spotRouteTarget, parts, ZLINK_SEND_DONT_WAIT);
|
|
67
66
|
return;
|
|
68
67
|
}
|
|
69
|
-
if (await this.spotNodeTransport.send(spotRouteTarget, parts
|
|
68
|
+
if (await this.spotNodeTransport.send(spotRouteTarget, parts)) {
|
|
70
69
|
return;
|
|
71
70
|
}
|
|
72
|
-
await this.routerSocketTransport.send(spotRouteTarget, parts, ZLINK_SEND_DONT_WAIT
|
|
71
|
+
await this.routerSocketTransport.send(spotRouteTarget, parts, ZLINK_SEND_DONT_WAIT);
|
|
73
72
|
}
|
|
74
73
|
routeRequestToSpot(spotRouteTarget, packetName, request, timeoutMs, signal, metadata) {
|
|
75
74
|
return (0, flow_context_1.runWithOutboundFlow)(this.options.flowCreationEnabled?.() ?? true, () => this.routeRequestToSpotScoped(spotRouteTarget, packetName, request, timeoutMs, signal, metadata));
|
|
@@ -102,8 +101,8 @@ class ZLinkSpotRouteDispatchStrategy {
|
|
|
102
101
|
routeRequestFromSpotToSpot(sourceSpot, spotRouteTarget, packetName, request, timeoutMs, signal) {
|
|
103
102
|
return this.sourceSpotRouter.request(sourceSpot, spotRouteTarget, packetName, request, timeoutMs, signal);
|
|
104
103
|
}
|
|
105
|
-
async routeSendFromSpotToSpot(sourceSpot, spotRouteTarget, packetName, message,
|
|
106
|
-
await this.sourceSpotRouter.send(sourceSpot, spotRouteTarget, packetName, message,
|
|
104
|
+
async routeSendFromSpotToSpot(sourceSpot, spotRouteTarget, packetName, message, metadata) {
|
|
105
|
+
await this.sourceSpotRouter.send(sourceSpot, spotRouteTarget, packetName, message, metadata);
|
|
107
106
|
}
|
|
108
107
|
routeRequestRawFromSpotToSpot(sourceSpot, spotRouteTarget, request, timeoutMs, signal) {
|
|
109
108
|
return this.sourceSpotRouter.requestRaw(sourceSpot, spotRouteTarget, request, timeoutMs, signal);
|
|
@@ -36,20 +36,23 @@ export interface ZLinkSerialWorkPreparation {
|
|
|
36
36
|
*/
|
|
37
37
|
export declare class ZLinkSerialExecutionQueue {
|
|
38
38
|
private readonly executeRecord;
|
|
39
|
+
private readonly sharedOwner?;
|
|
39
40
|
private readonly application;
|
|
40
41
|
private readonly lifecycle;
|
|
41
42
|
private activeLifecycle?;
|
|
43
|
+
private activeRecord?;
|
|
44
|
+
/** The admitted node itself owns ready membership; no second readiness flag. */
|
|
45
|
+
private ownerMembership?;
|
|
42
46
|
private readonly ownerTimeBudget;
|
|
43
47
|
private readonly lifecycleBurstLimit;
|
|
44
48
|
private nextAcceptedSequence;
|
|
45
|
-
private
|
|
46
|
-
private drainScheduled;
|
|
49
|
+
private readonly consumer?;
|
|
47
50
|
private lifecycleStreak;
|
|
48
51
|
private lifecycleDebt;
|
|
49
52
|
private claimStartedAt?;
|
|
50
53
|
private closed;
|
|
51
54
|
private readonly idleWaiters;
|
|
52
|
-
constructor(executeRecord: (record: ZLinkSerialWorkRecord<unknown>) => Promise<void>, options?: ZLinkSerialSchedulerOptions);
|
|
55
|
+
constructor(executeRecord: (record: ZLinkSerialWorkRecord<unknown>) => Promise<void>, options?: ZLinkSerialSchedulerOptions, sharedOwner?: ZLinkSerialExecutionQueue | undefined);
|
|
53
56
|
submit<T>(operation: () => Promise<T> | T, options?: ZLinkSerialWorkOptions, context?: unknown): Promise<T>;
|
|
54
57
|
submitDetached<T>(operation: () => Promise<T> | T, onError: (error: unknown) => void, options?: ZLinkSerialWorkOptions, context?: unknown): void;
|
|
55
58
|
/**
|
|
@@ -73,7 +76,13 @@ export declare class ZLinkSerialExecutionQueue {
|
|
|
73
76
|
get admissionClosed(): boolean;
|
|
74
77
|
private admit;
|
|
75
78
|
private scheduleDrain;
|
|
79
|
+
/** Notifications carry no payload, admission sequence, result Promise, or host permit. */
|
|
80
|
+
private enqueueMailboxTurn;
|
|
81
|
+
/** Called only by the shared scheduler's consumer, never by a producer. */
|
|
82
|
+
private consumeMailbox;
|
|
83
|
+
private finishMailbox;
|
|
76
84
|
private drain;
|
|
85
|
+
private prepareSelected;
|
|
77
86
|
private selectNext;
|
|
78
87
|
private takeSelected;
|
|
79
88
|
private takeLifecycle;
|
|
@@ -13,21 +13,25 @@ exports.ZLINK_DEFAULT_SERIAL_SCHEDULER_OPTIONS = Object.freeze({
|
|
|
13
13
|
*/
|
|
14
14
|
class ZLinkSerialExecutionQueue {
|
|
15
15
|
executeRecord;
|
|
16
|
+
sharedOwner;
|
|
16
17
|
application;
|
|
17
18
|
lifecycle;
|
|
18
19
|
activeLifecycle;
|
|
20
|
+
activeRecord;
|
|
21
|
+
/** The admitted node itself owns ready membership; no second readiness flag. */
|
|
22
|
+
ownerMembership;
|
|
19
23
|
ownerTimeBudget;
|
|
20
24
|
lifecycleBurstLimit;
|
|
21
25
|
nextAcceptedSequence = 1n;
|
|
22
|
-
|
|
23
|
-
drainScheduled = false;
|
|
26
|
+
consumer;
|
|
24
27
|
lifecycleStreak = 0;
|
|
25
28
|
lifecycleDebt = false;
|
|
26
29
|
claimStartedAt;
|
|
27
30
|
closed = false;
|
|
28
31
|
idleWaiters = [];
|
|
29
|
-
constructor(executeRecord, options = {}) {
|
|
32
|
+
constructor(executeRecord, options = {}, sharedOwner) {
|
|
30
33
|
this.executeRecord = executeRecord;
|
|
34
|
+
this.sharedOwner = sharedOwner;
|
|
31
35
|
const configured = { ...exports.ZLINK_DEFAULT_SERIAL_SCHEDULER_OPTIONS, ...options };
|
|
32
36
|
validateNonNegative(configured.ownerTimeBudget, 'ownerTimeBudget');
|
|
33
37
|
validatePositive(configured.lifecycleBurstLimit, 'lifecycleBurstLimit');
|
|
@@ -35,6 +39,8 @@ class ZLinkSerialExecutionQueue {
|
|
|
35
39
|
this.lifecycle = createLane();
|
|
36
40
|
this.ownerTimeBudget = configured.ownerTimeBudget;
|
|
37
41
|
this.lifecycleBurstLimit = configured.lifecycleBurstLimit;
|
|
42
|
+
if (sharedOwner === undefined)
|
|
43
|
+
this.consumer = { running: false, scheduled: false };
|
|
38
44
|
}
|
|
39
45
|
submit(operation, options = {}, context) {
|
|
40
46
|
try {
|
|
@@ -79,11 +85,14 @@ class ZLinkSerialExecutionQueue {
|
|
|
79
85
|
return this.admit(operation, { lane: 'lifecycle' }, context, undefined, true);
|
|
80
86
|
}
|
|
81
87
|
visitPendingApplication(visitor) {
|
|
82
|
-
for (const record of this.application.records)
|
|
83
|
-
|
|
88
|
+
for (const record of this.application.records) {
|
|
89
|
+
if (record.mailbox === undefined)
|
|
90
|
+
visitor(record);
|
|
91
|
+
}
|
|
84
92
|
}
|
|
85
93
|
get hasPendingWork() {
|
|
86
|
-
return (this.
|
|
94
|
+
return (this.consumer?.running === true ||
|
|
95
|
+
this.activeRecord !== undefined ||
|
|
87
96
|
this.activeLifecycle !== undefined ||
|
|
88
97
|
this.application.records.length > 0 ||
|
|
89
98
|
this.lifecycle.records.length > 0);
|
|
@@ -127,7 +136,7 @@ class ZLinkSerialExecutionQueue {
|
|
|
127
136
|
if (this.application.records.length > 0 || this.lifecycle.records.length > 0) {
|
|
128
137
|
this.scheduleDrain();
|
|
129
138
|
}
|
|
130
|
-
else if (
|
|
139
|
+
else if (this.consumer?.running !== true) {
|
|
131
140
|
this.resolveIdleWaiters();
|
|
132
141
|
}
|
|
133
142
|
}
|
|
@@ -176,18 +185,90 @@ class ZLinkSerialExecutionQueue {
|
|
|
176
185
|
return result;
|
|
177
186
|
}
|
|
178
187
|
scheduleDrain() {
|
|
179
|
-
if (this.
|
|
188
|
+
if (this.sharedOwner !== undefined) {
|
|
189
|
+
if (this.activeRecord !== undefined)
|
|
190
|
+
return;
|
|
191
|
+
// Ready membership in the existing owner queue is the only notification state.
|
|
192
|
+
if (this.ownerMembership !== undefined)
|
|
193
|
+
return;
|
|
194
|
+
this.enqueueMailboxTurn(() => this.consumeMailbox());
|
|
195
|
+
return;
|
|
196
|
+
}
|
|
197
|
+
const consumer = this.consumer;
|
|
198
|
+
if (consumer.scheduled || consumer.running)
|
|
180
199
|
return;
|
|
181
|
-
|
|
200
|
+
consumer.scheduled = true;
|
|
182
201
|
queueMicrotask(() => {
|
|
183
|
-
|
|
202
|
+
consumer.scheduled = false;
|
|
184
203
|
void this.drain();
|
|
185
204
|
});
|
|
186
205
|
}
|
|
206
|
+
/** Notifications carry no payload, admission sequence, result Promise, or host permit. */
|
|
207
|
+
enqueueMailboxTurn(operation) {
|
|
208
|
+
const entry = {
|
|
209
|
+
acceptedSequence: 0n,
|
|
210
|
+
lane: 'application',
|
|
211
|
+
mailbox: this,
|
|
212
|
+
operation,
|
|
213
|
+
operationEnvelope: false,
|
|
214
|
+
preparationState: 'ready',
|
|
215
|
+
resolve: unexpectedMailboxSettlement,
|
|
216
|
+
reject: unexpectedMailboxSettlement,
|
|
217
|
+
release: unexpectedMailboxSettlement,
|
|
218
|
+
fail: unexpectedMailboxSettlement
|
|
219
|
+
};
|
|
220
|
+
const owner = this.sharedOwner;
|
|
221
|
+
owner.application.records.push(entry);
|
|
222
|
+
this.ownerMembership = entry;
|
|
223
|
+
owner.scheduleDrain();
|
|
224
|
+
}
|
|
225
|
+
/** Called only by the shared scheduler's consumer, never by a producer. */
|
|
226
|
+
consumeMailbox() {
|
|
227
|
+
const selection = this.selectNext();
|
|
228
|
+
if (selection === undefined) {
|
|
229
|
+
if (!this.hasPendingWork)
|
|
230
|
+
this.resolveIdleWaiters();
|
|
231
|
+
return;
|
|
232
|
+
}
|
|
233
|
+
const record = selection.record;
|
|
234
|
+
if (!this.prepareSelected(selection))
|
|
235
|
+
return;
|
|
236
|
+
this.takeSelected(selection);
|
|
237
|
+
if (record.preparationState === 'failed') {
|
|
238
|
+
record.preparation?.cancel();
|
|
239
|
+
record.fail(record.preparationError);
|
|
240
|
+
this.scheduleDrain();
|
|
241
|
+
return;
|
|
242
|
+
}
|
|
243
|
+
this.activeRecord = record;
|
|
244
|
+
// The operation can submit Spot turns, including Yield continuations. Its
|
|
245
|
+
// Actor claim remains held until terminal settlement returns to this gate.
|
|
246
|
+
let terminal;
|
|
247
|
+
try {
|
|
248
|
+
terminal = Promise.resolve(record.operation());
|
|
249
|
+
}
|
|
250
|
+
catch (error) {
|
|
251
|
+
terminal = Promise.reject(error);
|
|
252
|
+
}
|
|
253
|
+
void terminal.then((value) => this.finishMailbox(record, () => record.resolve(value)), (error) => this.finishMailbox(record, () => record.reject(error)));
|
|
254
|
+
}
|
|
255
|
+
finishMailbox(record, settle) {
|
|
256
|
+
this.enqueueMailboxTurn(() => {
|
|
257
|
+
settle();
|
|
258
|
+
record.release();
|
|
259
|
+
record.preparation?.cancel();
|
|
260
|
+
this.activeRecord = undefined;
|
|
261
|
+
if (this.selectNext() !== undefined)
|
|
262
|
+
this.scheduleDrain();
|
|
263
|
+
else if (!this.hasPendingWork)
|
|
264
|
+
this.resolveIdleWaiters();
|
|
265
|
+
});
|
|
266
|
+
}
|
|
187
267
|
async drain() {
|
|
188
|
-
|
|
268
|
+
const consumer = this.consumer;
|
|
269
|
+
if (consumer.running)
|
|
189
270
|
return;
|
|
190
|
-
|
|
271
|
+
consumer.running = true;
|
|
191
272
|
let waitingForPreparation = false;
|
|
192
273
|
try {
|
|
193
274
|
for (;;) {
|
|
@@ -195,20 +276,7 @@ class ZLinkSerialExecutionQueue {
|
|
|
195
276
|
if (selection === undefined)
|
|
196
277
|
break;
|
|
197
278
|
const record = selection.record;
|
|
198
|
-
if (selection
|
|
199
|
-
const applicationHead = this.application.records[0];
|
|
200
|
-
if (this.application.records.length > 0 &&
|
|
201
|
-
!this.cancelPreparationForRearbitration(applicationHead)) {
|
|
202
|
-
waitingForPreparation = true;
|
|
203
|
-
break;
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
|
-
if (record.preparationState === 'idle') {
|
|
207
|
-
this.startPreparation(record);
|
|
208
|
-
waitingForPreparation = true;
|
|
209
|
-
break;
|
|
210
|
-
}
|
|
211
|
-
if (record.preparationState === 'pending' || record.preparationState === 'canceling') {
|
|
279
|
+
if (!this.prepareSelected(selection)) {
|
|
212
280
|
waitingForPreparation = true;
|
|
213
281
|
break;
|
|
214
282
|
}
|
|
@@ -220,7 +288,10 @@ class ZLinkSerialExecutionQueue {
|
|
|
220
288
|
}
|
|
221
289
|
this.claimStartedAt ??= performance.now();
|
|
222
290
|
try {
|
|
223
|
-
if (record.
|
|
291
|
+
if (record.mailbox !== undefined) {
|
|
292
|
+
record.operation();
|
|
293
|
+
}
|
|
294
|
+
else if (record.operationEnvelope) {
|
|
224
295
|
try {
|
|
225
296
|
const outcome = record.operation();
|
|
226
297
|
void Promise.resolve(outcome).then((value) => {
|
|
@@ -240,6 +311,8 @@ class ZLinkSerialExecutionQueue {
|
|
|
240
311
|
}
|
|
241
312
|
}
|
|
242
313
|
catch (error) {
|
|
314
|
+
if (record.mailbox !== undefined)
|
|
315
|
+
throw error;
|
|
243
316
|
record.fail(error);
|
|
244
317
|
}
|
|
245
318
|
finally {
|
|
@@ -252,7 +325,7 @@ class ZLinkSerialExecutionQueue {
|
|
|
252
325
|
}
|
|
253
326
|
}
|
|
254
327
|
finally {
|
|
255
|
-
|
|
328
|
+
consumer.running = false;
|
|
256
329
|
this.claimStartedAt = undefined;
|
|
257
330
|
if (!waitingForPreparation && this.selectNext() !== undefined) {
|
|
258
331
|
this.scheduleDrain();
|
|
@@ -264,6 +337,16 @@ class ZLinkSerialExecutionQueue {
|
|
|
264
337
|
}
|
|
265
338
|
}
|
|
266
339
|
}
|
|
340
|
+
prepareSelected(selection) {
|
|
341
|
+
if (selection.lane === 'lifecycle' &&
|
|
342
|
+
this.application.records.length > 0 &&
|
|
343
|
+
!this.cancelPreparationForRearbitration(this.application.records[0]))
|
|
344
|
+
return false;
|
|
345
|
+
const record = selection.record;
|
|
346
|
+
if (record.preparationState === 'idle')
|
|
347
|
+
this.startPreparation(record);
|
|
348
|
+
return record.preparationState !== 'pending' && record.preparationState !== 'canceling';
|
|
349
|
+
}
|
|
267
350
|
selectNext() {
|
|
268
351
|
const lifecycleOwner = this.activeLifecycle?.context;
|
|
269
352
|
const applicationRecord = lifecycleOwner === undefined
|
|
@@ -291,6 +374,8 @@ class ZLinkSerialExecutionQueue {
|
|
|
291
374
|
if (record !== selection.record) {
|
|
292
375
|
throw new Error('The selected serial work record changed before owner claim.');
|
|
293
376
|
}
|
|
377
|
+
if (selection.record.mailbox !== undefined)
|
|
378
|
+
selection.record.mailbox.ownerMembership = undefined;
|
|
294
379
|
return record;
|
|
295
380
|
}
|
|
296
381
|
takeLifecycle() {
|
|
@@ -402,6 +487,9 @@ function createLane() {
|
|
|
402
487
|
records: []
|
|
403
488
|
};
|
|
404
489
|
}
|
|
490
|
+
function unexpectedMailboxSettlement() {
|
|
491
|
+
throw new Error('A mailbox notification has no independent terminal result.');
|
|
492
|
+
}
|
|
405
493
|
function validatePositive(value, field) {
|
|
406
494
|
if (!Number.isSafeInteger(value) || value < 1) {
|
|
407
495
|
throw new RangeError(`${field} must be a positive safe integer.`);
|
|
@@ -14,7 +14,7 @@ export interface PendingOperation<T> {
|
|
|
14
14
|
readonly promise: Promise<T>;
|
|
15
15
|
}
|
|
16
16
|
/** Owns request completion so reply, timeout, cancellation, and shutdown race safely. */
|
|
17
|
-
export declare class OperationRegistry<T> {
|
|
17
|
+
export declare class OperationRegistry<T, Context = unknown> {
|
|
18
18
|
private readonly clock;
|
|
19
19
|
private readonly onPendingChanged?;
|
|
20
20
|
private readonly entries;
|
|
@@ -22,11 +22,12 @@ export declare class OperationRegistry<T> {
|
|
|
22
22
|
private deadlineCursor?;
|
|
23
23
|
private closed;
|
|
24
24
|
constructor(clock?: OperationClock, onPendingChanged?: (() => void) | undefined);
|
|
25
|
-
register(timeoutMs: number, timeoutOwner?: 'registry' | 'sender'): PendingOperation<T>;
|
|
25
|
+
register(timeoutMs: number, timeoutOwner?: 'registry' | 'sender', context?: Context): PendingOperation<T>;
|
|
26
26
|
complete(id: bigint, value: T): boolean;
|
|
27
27
|
fail(id: bigint, reason: unknown): boolean;
|
|
28
28
|
cancel(id: bigint, message?: string): boolean;
|
|
29
29
|
isPending(id: bigint): boolean;
|
|
30
|
+
context(id: bigint): Context | undefined;
|
|
30
31
|
close(reason?: string): void;
|
|
31
32
|
get size(): number;
|
|
32
33
|
expire(nowMs: number, turnDeadlineMs: number): number;
|
|
@@ -34,7 +34,7 @@ class OperationRegistry {
|
|
|
34
34
|
this.clock = clock;
|
|
35
35
|
this.onPendingChanged = onPendingChanged;
|
|
36
36
|
}
|
|
37
|
-
register(timeoutMs, timeoutOwner = 'registry') {
|
|
37
|
+
register(timeoutMs, timeoutOwner = 'registry', context) {
|
|
38
38
|
if (this.closed)
|
|
39
39
|
throw new Error('Operation registry is closed.');
|
|
40
40
|
if (!Number.isFinite(timeoutMs) || timeoutMs < 0) {
|
|
@@ -48,6 +48,7 @@ class OperationRegistry {
|
|
|
48
48
|
reject = onReject;
|
|
49
49
|
});
|
|
50
50
|
const entry = {
|
|
51
|
+
context,
|
|
51
52
|
deadlineMs: timeoutOwner === 'registry' ? this.clock.now() + timeoutMs : undefined,
|
|
52
53
|
resolve,
|
|
53
54
|
reject
|
|
@@ -77,6 +78,9 @@ class OperationRegistry {
|
|
|
77
78
|
isPending(id) {
|
|
78
79
|
return this.entries.has(id);
|
|
79
80
|
}
|
|
81
|
+
context(id) {
|
|
82
|
+
return this.entries.get(id)?.context;
|
|
83
|
+
}
|
|
80
84
|
close(reason = 'Operation registry closed.') {
|
|
81
85
|
if (this.closed)
|
|
82
86
|
return;
|
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.RawServiceMeshRuntime = exports.RAW_MESH_RECEIVE_TIME_BUDGET_MS = void 0;
|
|
4
4
|
const node_os_1 = require("node:os");
|
|
5
5
|
const application_ingress_record_owner_1 = require("../application-jobs/application-ingress-record-owner");
|
|
6
|
+
const submission_result_1 = require("../messaging/submission-result");
|
|
6
7
|
const runtime_values_1 = require("../backend/runtime-values");
|
|
7
8
|
const service_wire_codec_generated_1 = require("../protocol/service_wire_codec.generated");
|
|
8
9
|
const operation_registry_1 = require("./operation-registry");
|
|
@@ -564,16 +565,16 @@ class RawServiceMeshRuntime {
|
|
|
564
565
|
const record = livenessCodec.decodeLivenessRecord(received.parts[0]);
|
|
565
566
|
if (record.command === service_wire_m6a_codec_1.M6aServiceWireCommand.livenessProbe) {
|
|
566
567
|
const ack = this.liveness.acknowledgeProbe(received.sourceRid, peer.connectionId, record.probeId);
|
|
567
|
-
|
|
568
|
-
(await this.send(received.sourceRid, [
|
|
569
|
-
livenessCodec.encodeLivenessRecord({
|
|
570
|
-
command: service_wire_m6a_codec_1.M6aServiceWireCommand.livenessAck,
|
|
571
|
-
probeId: record.probeId
|
|
572
|
-
})
|
|
573
|
-
]));
|
|
574
|
-
if (!sent) {
|
|
568
|
+
if (ack === undefined)
|
|
575
569
|
return 'protocolError';
|
|
576
|
-
|
|
570
|
+
const sent = await this.send(received.sourceRid, [
|
|
571
|
+
livenessCodec.encodeLivenessRecord({
|
|
572
|
+
command: service_wire_m6a_codec_1.M6aServiceWireCommand.livenessAck,
|
|
573
|
+
probeId: record.probeId
|
|
574
|
+
})
|
|
575
|
+
]);
|
|
576
|
+
if (!sent)
|
|
577
|
+
return 'dropped';
|
|
577
578
|
}
|
|
578
579
|
else {
|
|
579
580
|
this.liveness.acknowledge(received.sourceRid, peer.connectionId, record.probeId, nowMs);
|
|
@@ -962,8 +963,13 @@ class RawServiceMeshRuntime {
|
|
|
962
963
|
await this.requireStarted().send(targetNodeRoutingId, parts);
|
|
963
964
|
return true;
|
|
964
965
|
}
|
|
965
|
-
catch {
|
|
966
|
-
|
|
966
|
+
catch (error) {
|
|
967
|
+
if ((0, runtime_values_1.isZLinkBackendResultError)(error) && error.operation === 'submit') {
|
|
968
|
+
const terminal = (0, submission_result_1.submitToRequestResult)(error.result, error.phase);
|
|
969
|
+
if (terminal === runtime_values_1.RequestResult.NotConnected || terminal === runtime_values_1.RequestResult.NotFound)
|
|
970
|
+
return false;
|
|
971
|
+
}
|
|
972
|
+
throw error;
|
|
967
973
|
}
|
|
968
974
|
}
|
|
969
975
|
}
|
|
@@ -42,8 +42,6 @@ export interface ServiceUserSpotAuthorityPayload {
|
|
|
42
42
|
readonly ownerNodeRid: string;
|
|
43
43
|
readonly ownerNodeGeneration: bigint;
|
|
44
44
|
}
|
|
45
|
-
/** Replaces only authority-relocation-state and preserves the canonical owner payload. */
|
|
46
|
-
export declare function replaceServiceAuthorityRelocationState(payload: Uint8Array, relocationState: Uint8Array): Buffer;
|
|
47
45
|
export declare function encodeServiceUserSpotAuthorityPayload(value: ServiceUserSpotAuthorityPayload): Buffer;
|
|
48
46
|
export declare function encodeServiceInstanceAuthorityPayload(value: ServiceInstanceAuthorityPayload): Buffer;
|
|
49
47
|
export declare function decodeServiceReadySpotAuthority(payload: Uint8Array): ServiceReadySpotAuthority | undefined;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.replaceServiceAuthorityRelocationState = replaceServiceAuthorityRelocationState;
|
|
4
3
|
exports.encodeServiceUserSpotAuthorityPayload = encodeServiceUserSpotAuthorityPayload;
|
|
5
4
|
exports.encodeServiceInstanceAuthorityPayload = encodeServiceInstanceAuthorityPayload;
|
|
6
5
|
exports.decodeServiceReadySpotAuthority = decodeServiceReadySpotAuthority;
|
|
@@ -21,48 +20,6 @@ const AUTHORITY_MAGIC = Buffer.from([0x5a, 0x4c, 0x41, 0x55]);
|
|
|
21
20
|
const AUTHORITY_FORMAT_VERSION = 1;
|
|
22
21
|
const AUTHORITY_FLAGS = 0;
|
|
23
22
|
const FATAL_UTF8 = new TextDecoder('utf-8', { fatal: true });
|
|
24
|
-
/** Replaces only authority-relocation-state and preserves the canonical owner payload. */
|
|
25
|
-
function replaceServiceAuthorityRelocationState(payload, relocationState) {
|
|
26
|
-
const bytes = Buffer.from(payload);
|
|
27
|
-
const reader = new AuthorityReader(bytes);
|
|
28
|
-
reader.expect(AUTHORITY_MAGIC);
|
|
29
|
-
if (reader.u8() !== AUTHORITY_FORMAT_VERSION || reader.u16() !== AUTHORITY_FLAGS) {
|
|
30
|
-
throw new TypeError('Authority payload header is invalid.');
|
|
31
|
-
}
|
|
32
|
-
const bodyLength = reader.u32();
|
|
33
|
-
const body = reader.takeReader(bodyLength);
|
|
34
|
-
const checksumOffset = reader.offset;
|
|
35
|
-
const checksum = reader.u32();
|
|
36
|
-
if (!reader.done || (0, service_relocation_runtime_1.crc32c)(bytes.subarray(0, checksumOffset)) !== checksum) {
|
|
37
|
-
throw new TypeError('Authority payload checksum is invalid.');
|
|
38
|
-
}
|
|
39
|
-
body.u8();
|
|
40
|
-
body.u8();
|
|
41
|
-
body.skip(body.u16());
|
|
42
|
-
body.text8();
|
|
43
|
-
body.nonZeroU64();
|
|
44
|
-
body.text8();
|
|
45
|
-
body.rid();
|
|
46
|
-
body.nonZeroU64();
|
|
47
|
-
const relocationOffset = body.offset;
|
|
48
|
-
body.bool8();
|
|
49
|
-
body.skip(body.u32());
|
|
50
|
-
const relocationEnd = body.offset;
|
|
51
|
-
const currentBody = bytes.subarray(11, 11 + bodyLength);
|
|
52
|
-
const nextBody = Buffer.concat([
|
|
53
|
-
currentBody.subarray(0, relocationOffset),
|
|
54
|
-
Buffer.from(relocationState),
|
|
55
|
-
currentBody.subarray(relocationEnd)
|
|
56
|
-
]);
|
|
57
|
-
const envelope = Buffer.concat([
|
|
58
|
-
AUTHORITY_MAGIC,
|
|
59
|
-
Buffer.of(AUTHORITY_FORMAT_VERSION),
|
|
60
|
-
u16(AUTHORITY_FLAGS),
|
|
61
|
-
u32(nextBody.byteLength),
|
|
62
|
-
nextBody
|
|
63
|
-
]);
|
|
64
|
-
return Buffer.concat([envelope, u32((0, service_relocation_runtime_1.crc32c)(envelope))]);
|
|
65
|
-
}
|
|
66
23
|
function encodeServiceUserSpotAuthorityPayload(value) {
|
|
67
24
|
const spot = conditional(2, concat(rid(value.spotId, 'spotId'), text8(value.stableType, 'stableType'), Buffer.of(1)));
|
|
68
25
|
const object = conditional(2, spot);
|
|
@@ -129,14 +129,15 @@ export declare class ServiceStatefulRegistry {
|
|
|
129
129
|
runTurn<T>(owner: string, work: () => T | Promise<T>): Promise<T>;
|
|
130
130
|
private updateBindingMembership;
|
|
131
131
|
}
|
|
132
|
-
export declare class ServiceTerminalOperationRegistry<T> {
|
|
132
|
+
export declare class ServiceTerminalOperationRegistry<T, Context = unknown> {
|
|
133
133
|
private readonly operations;
|
|
134
|
-
constructor(operations?: OperationRegistry<T>);
|
|
135
|
-
register(timeoutMs: number, timeoutOwner?: 'registry' | 'sender'): PendingOperation<T>;
|
|
134
|
+
constructor(operations?: OperationRegistry<T, Context>);
|
|
135
|
+
register(timeoutMs: number, timeoutOwner?: 'registry' | 'sender', context?: Context): PendingOperation<T>;
|
|
136
136
|
reply(id: bigint, value: T): boolean;
|
|
137
137
|
fail(id: bigint, error: unknown): boolean;
|
|
138
138
|
cancel(id: bigint): boolean;
|
|
139
139
|
isPending(id: bigint): boolean;
|
|
140
|
+
context(id: bigint): Context | undefined;
|
|
140
141
|
get size(): number;
|
|
141
142
|
expire(nowMs: number, turnDeadlineMs: number): number;
|
|
142
143
|
close(): void;
|