@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,7 +5,7 @@ export interface ZLinkActorClient {
|
|
|
5
5
|
}
|
|
6
6
|
export interface ZLinkActorSendCall {
|
|
7
7
|
metadata(key: string, value: string): this;
|
|
8
|
-
submit(
|
|
8
|
+
submit(): Promise<void>;
|
|
9
9
|
}
|
|
10
10
|
export interface ZLinkActorRequestCall {
|
|
11
11
|
metadata(key: string, value: string): this;
|
|
@@ -2,7 +2,7 @@ import type { ZLinkMessageMetadata } from '../Common';
|
|
|
2
2
|
export interface ZLinkSendCall {
|
|
3
3
|
metadata(key: string, value: string): this;
|
|
4
4
|
metadata(metadata: ZLinkMessageMetadata): this;
|
|
5
|
-
submit(
|
|
5
|
+
submit(): Promise<void>;
|
|
6
6
|
}
|
|
7
7
|
export interface ZLinkRequestCall {
|
|
8
8
|
metadata(key: string, value: string): this;
|
|
@@ -78,7 +78,6 @@ export interface ZLinkMeshNodeSocketConfig {
|
|
|
78
78
|
sendHighWaterMark: number;
|
|
79
79
|
receiveHighWaterMark: number;
|
|
80
80
|
receiveTimeoutMs?: number;
|
|
81
|
-
sendTimeoutMs?: number;
|
|
82
81
|
}
|
|
83
82
|
export interface ZLinkStreamSocketConfig {
|
|
84
83
|
maxMessageSize: number;
|
|
@@ -143,6 +142,8 @@ export interface ZLinkFanoutChannelBuilder {
|
|
|
143
142
|
subscriberConnections(): ZLinkEndpointConnections;
|
|
144
143
|
}
|
|
145
144
|
export interface ZLinkStreamNodeBuilder {
|
|
145
|
+
setHeartbeat(intervalMs: number, timeoutMs: number): this;
|
|
146
|
+
setIdleTimeout(timeoutMs: number): this;
|
|
146
147
|
bind(endpointOrPort?: string | number): this;
|
|
147
148
|
setBindHost(bindHost: string): this;
|
|
148
149
|
setAdvertiseHost(advertiseHost: string): this;
|
|
@@ -12,3 +12,6 @@ export declare const ZLINK_RELOCATION_MAX_BLOB_REFERENCE_BYTES = 4096;
|
|
|
12
12
|
export declare const AUTHORITY_ENVELOPE_MAX_BYTES: number;
|
|
13
13
|
export declare const CREATION_INTENT_MAX_BYTES: number;
|
|
14
14
|
export declare const CREATION_TERMINAL_ENVELOPE_MAX_BYTES: number;
|
|
15
|
+
export declare const DEFAULT_STREAM_HEARTBEAT_INTERVAL_MS = 1000;
|
|
16
|
+
export declare const DEFAULT_STREAM_HEARTBEAT_TIMEOUT_MS = 5000;
|
|
17
|
+
export declare const DEFAULT_STREAM_IDLE_TIMEOUT_MS = 0;
|
|
@@ -33,7 +33,7 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
33
33
|
};
|
|
34
34
|
})();
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
exports.CREATION_TERMINAL_ENVELOPE_MAX_BYTES = exports.CREATION_INTENT_MAX_BYTES = exports.AUTHORITY_ENVELOPE_MAX_BYTES = exports.ZLINK_RELOCATION_MAX_BLOB_REFERENCE_BYTES = exports.DEFAULT_WORKER_IDLE_TIMEOUT_MS = exports.DEFAULT_WORKER_MIN_THREADS = exports.DEFAULT_ACTIVATION_CONCURRENCY_LIMIT = exports.RELOCATION_STATE_CHUNK_DATA_MAX_BYTES = exports.DEFAULT_STREAM_NODE_MAX_MESSAGE_SIZE = void 0;
|
|
36
|
+
exports.DEFAULT_STREAM_IDLE_TIMEOUT_MS = exports.DEFAULT_STREAM_HEARTBEAT_TIMEOUT_MS = exports.DEFAULT_STREAM_HEARTBEAT_INTERVAL_MS = exports.CREATION_TERMINAL_ENVELOPE_MAX_BYTES = exports.CREATION_INTENT_MAX_BYTES = exports.AUTHORITY_ENVELOPE_MAX_BYTES = exports.ZLINK_RELOCATION_MAX_BLOB_REFERENCE_BYTES = exports.DEFAULT_WORKER_IDLE_TIMEOUT_MS = exports.DEFAULT_WORKER_MIN_THREADS = exports.DEFAULT_ACTIVATION_CONCURRENCY_LIMIT = exports.RELOCATION_STATE_CHUNK_DATA_MAX_BYTES = exports.DEFAULT_STREAM_NODE_MAX_MESSAGE_SIZE = void 0;
|
|
37
37
|
exports.defaultWorkerMaxThreads = defaultWorkerMaxThreads;
|
|
38
38
|
const os = __importStar(require("node:os"));
|
|
39
39
|
/** Default complete header plus payload size accepted by a StreamNode. */
|
|
@@ -52,3 +52,6 @@ exports.ZLINK_RELOCATION_MAX_BLOB_REFERENCE_BYTES = 4096;
|
|
|
52
52
|
exports.AUTHORITY_ENVELOPE_MAX_BYTES = 1024 * 1024;
|
|
53
53
|
exports.CREATION_INTENT_MAX_BYTES = 1024 * 1024;
|
|
54
54
|
exports.CREATION_TERMINAL_ENVELOPE_MAX_BYTES = 1024 * 1024;
|
|
55
|
+
exports.DEFAULT_STREAM_HEARTBEAT_INTERVAL_MS = 1_000;
|
|
56
|
+
exports.DEFAULT_STREAM_HEARTBEAT_TIMEOUT_MS = 5_000;
|
|
57
|
+
exports.DEFAULT_STREAM_IDLE_TIMEOUT_MS = 0;
|
|
@@ -522,6 +522,15 @@ class DefaultClientServerChannelServerBuilder {
|
|
|
522
522
|
}
|
|
523
523
|
class DefaultStreamNodeBuilder {
|
|
524
524
|
streamNode;
|
|
525
|
+
setHeartbeat(intervalMs, timeoutMs) {
|
|
526
|
+
this.streamNode.heartbeatIntervalMs = intervalMs;
|
|
527
|
+
this.streamNode.heartbeatTimeoutMs = timeoutMs;
|
|
528
|
+
return this;
|
|
529
|
+
}
|
|
530
|
+
setIdleTimeout(timeoutMs) {
|
|
531
|
+
this.streamNode.idleTimeoutMs = timeoutMs;
|
|
532
|
+
return this;
|
|
533
|
+
}
|
|
525
534
|
constructor(streamNode) {
|
|
526
535
|
this.streamNode = streamNode;
|
|
527
536
|
}
|
|
@@ -4,6 +4,7 @@ import type { ZLinkNetworkOptions } from './Builders';
|
|
|
4
4
|
export declare function normalizeWorkerOptions(value: ZLinkFrameworkRegistrationOptions['worker']): ZLinkWorkerOptions | undefined;
|
|
5
5
|
export declare function normalizeNetworkOptions(value: ZLinkFrameworkRegistrationOptions['network']): ZLinkNetworkOptions;
|
|
6
6
|
export declare function toChannelMap(channels: ZLinkFrameworkRegistrationOptions['channels'], network: ZLinkNetworkOptions): Map<string, ZLinkChannelOptions>;
|
|
7
|
+
export declare function normalizeStreamLiveness(options: ZLinkStreamNodeOptions): Required<Pick<ZLinkStreamNodeOptions, 'heartbeatIntervalMs' | 'heartbeatTimeoutMs' | 'idleTimeoutMs'>>;
|
|
7
8
|
export declare function toStreamNodeMap(streamNodes: ZLinkFrameworkRegistrationOptions['streamNodes'], network: ZLinkNetworkOptions): Map<string, ZLinkStreamNodeOptions>;
|
|
8
9
|
export declare function toRouteChannelOptions(options: ZLinkFrameworkRegistrationOptions): Map<string, ZLinkRouteChannelOptions>;
|
|
9
10
|
export declare function requirePositiveInteger(label: string, value: number | undefined): void;
|
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.normalizeWorkerOptions = normalizeWorkerOptions;
|
|
4
4
|
exports.normalizeNetworkOptions = normalizeNetworkOptions;
|
|
5
5
|
exports.toChannelMap = toChannelMap;
|
|
6
|
+
exports.normalizeStreamLiveness = normalizeStreamLiveness;
|
|
6
7
|
exports.toStreamNodeMap = toStreamNodeMap;
|
|
7
8
|
exports.toRouteChannelOptions = toRouteChannelOptions;
|
|
8
9
|
exports.requirePositiveInteger = requirePositiveInteger;
|
|
@@ -60,6 +61,20 @@ function toChannelMap(channels, network) {
|
|
|
60
61
|
];
|
|
61
62
|
}));
|
|
62
63
|
}
|
|
64
|
+
function normalizeStreamLiveness(options) {
|
|
65
|
+
const heartbeatIntervalMs = options.heartbeatIntervalMs ?? InternalDefaults_1.DEFAULT_STREAM_HEARTBEAT_INTERVAL_MS;
|
|
66
|
+
const heartbeatTimeoutMs = options.heartbeatTimeoutMs ?? InternalDefaults_1.DEFAULT_STREAM_HEARTBEAT_TIMEOUT_MS;
|
|
67
|
+
const idleTimeoutMs = options.idleTimeoutMs ?? InternalDefaults_1.DEFAULT_STREAM_IDLE_TIMEOUT_MS;
|
|
68
|
+
if (!Number.isFinite(heartbeatIntervalMs) || heartbeatIntervalMs <= 0)
|
|
69
|
+
throw new ConfigurationException_1.ZLinkConfigurationException('STREAM heartbeat interval must be positive.');
|
|
70
|
+
if (!Number.isFinite(heartbeatTimeoutMs) || heartbeatTimeoutMs <= 0)
|
|
71
|
+
throw new ConfigurationException_1.ZLinkConfigurationException('STREAM heartbeat timeout must be positive.');
|
|
72
|
+
if (heartbeatTimeoutMs <= heartbeatIntervalMs)
|
|
73
|
+
throw new ConfigurationException_1.ZLinkConfigurationException('STREAM heartbeat timeout must be greater than interval.');
|
|
74
|
+
if (!Number.isFinite(idleTimeoutMs) || idleTimeoutMs < 0)
|
|
75
|
+
throw new ConfigurationException_1.ZLinkConfigurationException('STREAM idle timeout must not be negative.');
|
|
76
|
+
return { heartbeatIntervalMs, heartbeatTimeoutMs, idleTimeoutMs };
|
|
77
|
+
}
|
|
63
78
|
function toStreamNodeMap(streamNodes, network) {
|
|
64
79
|
return new Map(Object.entries(streamNodes ?? {}).map(([name, streamNode]) => {
|
|
65
80
|
const normalized = normalizeListener(streamNode, network);
|
|
@@ -67,6 +82,7 @@ function toStreamNodeMap(streamNodes, network) {
|
|
|
67
82
|
name,
|
|
68
83
|
{
|
|
69
84
|
...normalized,
|
|
85
|
+
...normalizeStreamLiveness(streamNode),
|
|
70
86
|
maxMessageSize: streamNode.maxMessageSize ?? InternalDefaults_1.DEFAULT_STREAM_NODE_MAX_MESSAGE_SIZE
|
|
71
87
|
}
|
|
72
88
|
];
|
|
@@ -156,7 +156,6 @@ export interface ZLinkChannelOptions {
|
|
|
156
156
|
readonly weight?: number;
|
|
157
157
|
readonly sendHighWaterMark?: number;
|
|
158
158
|
readonly receiveHighWaterMark?: number;
|
|
159
|
-
readonly sendTimeoutMs?: number;
|
|
160
159
|
readonly maxMessageSize?: number;
|
|
161
160
|
};
|
|
162
161
|
readonly subscriber?: ZLinkClientCapabilityOptions;
|
|
@@ -165,7 +164,6 @@ export interface ZLinkClientCapabilityOptions {
|
|
|
165
164
|
readonly manualConnections?: readonly string[];
|
|
166
165
|
readonly sendHighWaterMark?: number;
|
|
167
166
|
readonly receiveHighWaterMark?: number;
|
|
168
|
-
readonly sendTimeoutMs?: number;
|
|
169
167
|
readonly maxMessageSize?: number;
|
|
170
168
|
}
|
|
171
169
|
export interface ZLinkPublisherCapabilityOptions {
|
|
@@ -184,7 +182,6 @@ export interface ZLinkRouteMeshChannelOptions {
|
|
|
184
182
|
readonly weight?: number;
|
|
185
183
|
readonly sendHighWaterMark?: number;
|
|
186
184
|
readonly receiveHighWaterMark?: number;
|
|
187
|
-
readonly sendTimeoutMs?: number;
|
|
188
185
|
readonly sendHandlers?: readonly ZLinkRouteChannelSendHandlerRegistration[];
|
|
189
186
|
readonly requestHandlers?: readonly ZLinkRouteChannelRequestHandlerRegistration[];
|
|
190
187
|
readonly handlers?: readonly ZLinkRouteChannelHandlerOptions[];
|
|
@@ -199,12 +196,14 @@ export interface ZLinkRouteChannelOptions {
|
|
|
199
196
|
readonly weight?: number;
|
|
200
197
|
readonly sendHighWaterMark?: number;
|
|
201
198
|
readonly receiveHighWaterMark?: number;
|
|
202
|
-
readonly sendTimeoutMs?: number;
|
|
203
199
|
readonly sendHandlers?: readonly ZLinkRouteChannelSendHandlerRegistration[];
|
|
204
200
|
readonly requestHandlers?: readonly ZLinkRouteChannelRequestHandlerRegistration[];
|
|
205
201
|
readonly handlers?: readonly ZLinkRouteChannelHandlerOptions[];
|
|
206
202
|
}
|
|
207
203
|
export interface ZLinkStreamNodeOptions {
|
|
204
|
+
readonly heartbeatIntervalMs?: number;
|
|
205
|
+
readonly heartbeatTimeoutMs?: number;
|
|
206
|
+
readonly idleTimeoutMs?: number;
|
|
208
207
|
readonly bind?: string;
|
|
209
208
|
readonly bindHost?: string;
|
|
210
209
|
readonly advertiseHost?: string;
|
|
@@ -359,7 +358,6 @@ export interface ZLinkSpotRouterCapabilityOptions {
|
|
|
359
358
|
readonly sendHighWaterMark?: number;
|
|
360
359
|
readonly receiveHighWaterMark?: number;
|
|
361
360
|
readonly receiveTimeoutMs?: number;
|
|
362
|
-
readonly sendTimeoutMs?: number;
|
|
363
361
|
}
|
|
364
362
|
export interface ZLinkSpotRouterPeerConnectionOptions {
|
|
365
363
|
readonly peerRid: RoutingId;
|
|
@@ -457,10 +457,8 @@ function requireSocketOptions(label, options) {
|
|
|
457
457
|
requireNonNegativeInteger(`${label} sendHighWaterMark`, options.sendHighWaterMark);
|
|
458
458
|
requireNonNegativeInteger(`${label} receiveHighWaterMark`, options.receiveHighWaterMark);
|
|
459
459
|
requireNonNegativeInteger(`${label} maxMessageSize`, options.maxMessageSize);
|
|
460
|
-
(0, SendTimeoutValidation_1.requireValidSendTimeoutMs)(`${label} sendTimeoutMs`, options.sendTimeoutMs);
|
|
461
460
|
}
|
|
462
461
|
function requireRouteMeshSocketOptions(label, options) {
|
|
463
462
|
requireNonNegativeInteger(`${label} sendHighWaterMark`, options.sendHighWaterMark);
|
|
464
463
|
requireNonNegativeInteger(`${label} receiveHighWaterMark`, options.receiveHighWaterMark);
|
|
465
|
-
(0, SendTimeoutValidation_1.requireValidSendTimeoutMs)(`${label} sendTimeoutMs`, options.sendTimeoutMs);
|
|
466
464
|
}
|
|
@@ -68,7 +68,7 @@ export interface ZLinkSpotSendCall {
|
|
|
68
68
|
instanceSpot(): this;
|
|
69
69
|
instanceSpot(instanceSpotType: string): this;
|
|
70
70
|
inMesh(meshName: string): this;
|
|
71
|
-
submit(
|
|
71
|
+
submit(): Promise<void>;
|
|
72
72
|
}
|
|
73
73
|
export interface ZLinkSpotRequestCall {
|
|
74
74
|
metadata(key: string, value: string): this;
|
|
@@ -36,10 +36,9 @@ export interface ZLinkSessionClient {
|
|
|
36
36
|
export interface ZLinkSessionSendCall {
|
|
37
37
|
metadata(key: string, value: string): this;
|
|
38
38
|
compress(enabled?: boolean): this;
|
|
39
|
-
|
|
40
|
-
submit(signal?: AbortSignal): Promise<void>;
|
|
39
|
+
submit(): Promise<void>;
|
|
41
40
|
}
|
|
42
41
|
export interface ZLinkSessionReplyCall {
|
|
43
42
|
compress(enabled?: boolean): this;
|
|
44
|
-
submit(
|
|
43
|
+
submit(): Promise<void>;
|
|
45
44
|
}
|
|
@@ -9,7 +9,7 @@ export interface ZLinkSessionActors {
|
|
|
9
9
|
export interface ZLinkSessionActor {
|
|
10
10
|
readonly actorId: string;
|
|
11
11
|
readonly ref: ActorRef;
|
|
12
|
-
relay(payload: ZLinkMessage
|
|
13
|
-
relay(dispatch: ZLinkSessionDispatchContext, payload: ZLinkMessage
|
|
12
|
+
relay(payload: ZLinkMessage): Promise<void>;
|
|
13
|
+
relay(dispatch: ZLinkSessionDispatchContext, payload: ZLinkMessage): Promise<void>;
|
|
14
14
|
notifyDisconnected(signal?: AbortSignal): Promise<void>;
|
|
15
15
|
}
|
|
@@ -28,24 +28,21 @@ class DefaultZLinkActorClient {
|
|
|
28
28
|
}
|
|
29
29
|
sendToActor(actorId, message) {
|
|
30
30
|
requireActorId(actorId);
|
|
31
|
-
return new DefaultZLinkActorSendCall((packetName, metadata
|
|
31
|
+
return new DefaultZLinkActorSendCall((packetName, metadata) => this.send(actorId, packetName, message, metadata), message);
|
|
32
32
|
}
|
|
33
33
|
requestToActor(actorId, request) {
|
|
34
34
|
requireActorId(actorId);
|
|
35
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
36
|
}
|
|
37
|
-
async send(actorId, explicitPacketName, message, metadata
|
|
38
|
-
|
|
39
|
-
const route = await this.resolveActorRoute(actorId, signal);
|
|
37
|
+
async send(actorId, explicitPacketName, message, metadata) {
|
|
38
|
+
const route = await this.resolveActorRoute(actorId);
|
|
40
39
|
const { meshName, actorRef: actor } = route;
|
|
41
40
|
this.throwIfKnownStale(meshName, actor);
|
|
42
41
|
const parts = this.createPacketParts(protocol_1.ZLinkStreamMessageKind.Send, undefined, explicitPacketName, message, metadata);
|
|
43
42
|
const messageFollow = createActorMessageFollowContext(route, parts, false);
|
|
44
43
|
const routedActor = (0, actor_message_follow_context_1.attachActorMessageFollowContext)(actor, messageFollow);
|
|
45
44
|
try {
|
|
46
|
-
const submissionCopies = (await this.options
|
|
47
|
-
.transportDeliveryGate?.()
|
|
48
|
-
?.waitBeforeSubmit(actorId, 'oneWay', signal)) ?? 1;
|
|
45
|
+
const submissionCopies = (await this.options.transportDeliveryGate?.()?.waitBeforeSubmit(actorId, 'oneWay')) ?? 1;
|
|
49
46
|
const handoff = this.options.handoffCapture?.(meshName, actor.actorId, parts, false, routedActor);
|
|
50
47
|
if (handoff !== undefined) {
|
|
51
48
|
const submissions = [handoff];
|
|
@@ -54,7 +51,7 @@ class DefaultZLinkActorClient {
|
|
|
54
51
|
if (duplicate !== undefined)
|
|
55
52
|
submissions.push(duplicate);
|
|
56
53
|
}
|
|
57
|
-
await
|
|
54
|
+
await Promise.all(submissions);
|
|
58
55
|
return { status: submission_result_1.ZLinkSubmitStatus.Submitted };
|
|
59
56
|
}
|
|
60
57
|
const node = this.requireNode(meshName);
|
|
@@ -370,10 +367,10 @@ class DefaultZLinkActorSendCall {
|
|
|
370
367
|
this.selectedMetadata.set(key, value);
|
|
371
368
|
return this;
|
|
372
369
|
}
|
|
373
|
-
async submit(
|
|
370
|
+
async submit() {
|
|
374
371
|
ensureSingleSubmit(this.executed);
|
|
375
372
|
this.executed = true;
|
|
376
|
-
const result = await this.submitter(this.packet ?? (0, packet_name_1.resolveFrameworkPacketName)(this.message, undefined, 'Actor'), this.selectedMetadata
|
|
373
|
+
const result = await this.submitter(this.packet ?? (0, packet_name_1.resolveFrameworkPacketName)(this.message, undefined, 'Actor'), this.selectedMetadata);
|
|
377
374
|
(0, submission_result_1.requireOneWayCompletion)(result, 'Actor send', framework_errors_internal_1.ZLinkFrameworkInternalErrorKind.ActorRouteNotFound);
|
|
378
375
|
}
|
|
379
376
|
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { type ZLinkSerialSchedulerOptions, type ZLinkSerialWorkOptions } from '../execution/serial-execution-queue';
|
|
1
|
+
import { ZLinkSerialExecutionQueue, type ZLinkSerialSchedulerOptions, type ZLinkSerialWorkOptions } from '../execution/serial-execution-queue';
|
|
2
2
|
export declare class ZLinkActorSerialExecutor {
|
|
3
3
|
private readonly actorId;
|
|
4
4
|
private readonly sourceSpotId;
|
|
5
5
|
private readonly scheduler;
|
|
6
|
-
constructor(actorId: string, sourceSpotId: unknown, options?: ZLinkSerialSchedulerOptions);
|
|
6
|
+
constructor(actorId: string, sourceSpotId: unknown, options?: ZLinkSerialSchedulerOptions, sharedOwner?: ZLinkSerialExecutionQueue);
|
|
7
7
|
execute<T>(operation: () => Promise<T> | T, workOptions?: ZLinkSerialWorkOptions): Promise<T>;
|
|
8
8
|
close(): Promise<void>;
|
|
9
9
|
private runRecord;
|
|
@@ -8,10 +8,10 @@ class ZLinkActorSerialExecutor {
|
|
|
8
8
|
actorId;
|
|
9
9
|
sourceSpotId;
|
|
10
10
|
scheduler;
|
|
11
|
-
constructor(actorId, sourceSpotId, options) {
|
|
11
|
+
constructor(actorId, sourceSpotId, options, sharedOwner) {
|
|
12
12
|
this.actorId = actorId;
|
|
13
13
|
this.sourceSpotId = sourceSpotId;
|
|
14
|
-
this.scheduler = new serial_execution_queue_1.ZLinkSerialExecutionQueue((record) => this.runRecord(record), options);
|
|
14
|
+
this.scheduler = new serial_execution_queue_1.ZLinkSerialExecutionQueue((record) => this.runRecord(record), options, sharedOwner);
|
|
15
15
|
}
|
|
16
16
|
execute(operation, workOptions) {
|
|
17
17
|
const boundOperation = (0, application_job_queue_scope_1.bindApplicationJobPermit)(() => (0, actor_execution_context_1.runZLinkActorExecution)(this.actorId, this.sourceSpotId, operation));
|
|
@@ -1,3 +1 @@
|
|
|
1
|
-
export
|
|
2
|
-
/** Only actual Store, delivery-gate, and handoff waits acquire a deadline handle. */
|
|
3
|
-
export declare function waitActorReply<T>(reply: Promise<T>, actorId: string, deadlineMs: number | undefined, signal?: AbortSignal): Promise<T>;
|
|
1
|
+
export { remainingRequestTimeout as remainingActorRequestTimeout, waitRequestReply as waitActorReply } from '../messaging/request-deadline';
|
|
@@ -1,31 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.remainingActorRequestTimeout =
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
function remainingActorRequestTimeout(actorId, deadlineMs) {
|
|
8
|
-
if (deadlineMs === undefined)
|
|
9
|
-
return undefined;
|
|
10
|
-
const remaining = deadlineMs - performance.now();
|
|
11
|
-
if (remaining <= 0) {
|
|
12
|
-
throw (0, framework_errors_internal_1.createInternalFrameworkException)(framework_errors_internal_1.ZLinkFrameworkInternalErrorKind.DeadlineExceeded, `Actor request '${actorId}' exceeded its deadline.`);
|
|
13
|
-
}
|
|
14
|
-
return Math.max(1, Math.ceil(remaining));
|
|
15
|
-
}
|
|
16
|
-
/** Only actual Store, delivery-gate, and handoff waits acquire a deadline handle. */
|
|
17
|
-
async function waitActorReply(reply, actorId, deadlineMs, signal) {
|
|
18
|
-
if (deadlineMs === undefined)
|
|
19
|
-
return await (0, abort_1.awaitWithAbort)(reply, signal);
|
|
20
|
-
let timer;
|
|
21
|
-
const timeout = new Promise((_resolve, reject) => {
|
|
22
|
-
const remaining = remainingActorRequestTimeout(actorId, deadlineMs);
|
|
23
|
-
timer = setTimeout(() => reject((0, framework_errors_internal_1.createInternalFrameworkException)(framework_errors_internal_1.ZLinkFrameworkInternalErrorKind.DeadlineExceeded, `Actor request '${actorId}' exceeded its deadline.`)), remaining);
|
|
24
|
-
});
|
|
25
|
-
try {
|
|
26
|
-
return await (0, abort_1.awaitWithAbort)(Promise.race([reply, timeout]), signal);
|
|
27
|
-
}
|
|
28
|
-
finally {
|
|
29
|
-
clearTimeout(timer);
|
|
30
|
-
}
|
|
31
|
-
}
|
|
3
|
+
exports.waitActorReply = exports.remainingActorRequestTimeout = void 0;
|
|
4
|
+
var request_deadline_1 = require("../messaging/request-deadline");
|
|
5
|
+
Object.defineProperty(exports, "remainingActorRequestTimeout", { enumerable: true, get: function () { return request_deadline_1.remainingRequestTimeout; } });
|
|
6
|
+
Object.defineProperty(exports, "waitActorReply", { enumerable: true, get: function () { return request_deadline_1.waitRequestReply; } });
|
|
@@ -6,11 +6,10 @@ export interface ZLinkActorRoutedJoinTransport {
|
|
|
6
6
|
canRouteChannel?(routerChannelId: string): boolean;
|
|
7
7
|
canRoutePacketChannel?(routerChannelId: string): boolean;
|
|
8
8
|
request<TReply>(routerChannelId: string, targetNodeRid: string, packetName: string | undefined, request: unknown, timeoutMs: number | undefined, signal?: AbortSignal): Promise<TReply>;
|
|
9
|
-
submit?(routerChannelId: string, targetNodeRid: string, packetName: string | undefined, message: unknown
|
|
10
|
-
submitInfrastructure?(routerChannelId: string, targetNodeRid: string, packetName: string | undefined, message: unknown
|
|
9
|
+
submit?(routerChannelId: string, targetNodeRid: string, packetName: string | undefined, message: unknown): Promise<ZLinkSubmitResult>;
|
|
10
|
+
submitInfrastructure?(routerChannelId: string, targetNodeRid: string, packetName: string | undefined, message: unknown): Promise<ZLinkSubmitResult>;
|
|
11
11
|
sendToSpot(spotRouteTarget: ZLinkSpotRouteTarget, message: unknown, options: {
|
|
12
12
|
readonly packetName?: string;
|
|
13
|
-
readonly signal?: AbortSignal;
|
|
14
13
|
}): Promise<ZLinkSubmitResult>;
|
|
15
14
|
requestRawToSpot?(spotRouteTarget: ZLinkSpotRouteTarget, request: Message, options: {
|
|
16
15
|
readonly timeoutMs?: number;
|
|
@@ -292,7 +292,6 @@ export interface ZLinkBackendDealerSocket extends ZLinkBackendConnectableSocket
|
|
|
292
292
|
sendHighWaterMark: number;
|
|
293
293
|
receiveHighWaterMark: number;
|
|
294
294
|
receiveTimeoutMs: number;
|
|
295
|
-
sendTimeoutMs: number;
|
|
296
295
|
maxMessageSize: number;
|
|
297
296
|
send(message: Message | readonly Message[]): Promise<void>;
|
|
298
297
|
request(message: Message | readonly Message[], timeoutMs?: number): Promise<readonly Message[]>;
|
|
@@ -319,7 +318,6 @@ export interface ZLinkBackendRouterSocket extends ZLinkBackendConnectableSocket
|
|
|
319
318
|
sendHighWaterMark: number;
|
|
320
319
|
receiveHighWaterMark: number;
|
|
321
320
|
receiveTimeoutMs: number;
|
|
322
|
-
sendTimeoutMs: number;
|
|
323
321
|
maxMessageSize: number;
|
|
324
322
|
setRoutingId(routingId: RoutingId): void;
|
|
325
323
|
recv(flags?: ZLinkBackendRecvFlags): Received | undefined;
|
|
@@ -354,14 +352,13 @@ export interface ZLinkBackendStreamPacket {
|
|
|
354
352
|
close(): void;
|
|
355
353
|
}
|
|
356
354
|
export interface ZLinkBackendStreamSocket extends ZLinkBackendSocket {
|
|
357
|
-
readonly sendTimeoutMs: number;
|
|
358
355
|
readonly sendHighWaterMark: number;
|
|
359
356
|
/** Framework stream ingress uses this bound for packet payload validation. */
|
|
360
357
|
maxMessageSize: number;
|
|
361
358
|
setTlsServer(cert: string, key: string, requireClientCert?: boolean): void;
|
|
362
359
|
recvPacket(packet: ZLinkBackendStreamPacket, flags?: ZLinkBackendRecvFlags): boolean;
|
|
363
360
|
send(routingId: RoutingId, payload: Message | readonly Message[], flags: ZLinkBackendSendFlags): boolean;
|
|
364
|
-
submit(routingId: RoutingId, payload: Message | readonly Message[]
|
|
361
|
+
submit(routingId: RoutingId, payload: Message | readonly Message[]): Promise<void>;
|
|
365
362
|
disconnectPeer(routingId: RoutingId): void;
|
|
366
363
|
bindActor(sessionRid: RoutingId, actor: ZLinkBackendActorRef, timeoutMs: number, signal?: AbortSignal): Promise<void>;
|
|
367
364
|
unbindActor(sessionRid: RoutingId, actorId: string, timeoutMs: number, signal?: AbortSignal): Promise<void>;
|
|
@@ -40,6 +40,8 @@ export declare function submitBindingReply(operation: ZLinkBindingReplyOperation
|
|
|
40
40
|
export declare function submitBindingAsyncSend(operation: ZLinkBindingAsyncSendOperation, payload: unknown): Promise<void>;
|
|
41
41
|
export declare function submitBindingSyncSend(operation: ZLinkBindingAsyncSendOperation, payload: unknown): void;
|
|
42
42
|
export declare function submitBindingRequest(operation: ZLinkBindingRequestOperation, payload: unknown, timeoutMs: number | undefined): Promise<readonly unknown[]>;
|
|
43
|
+
export declare function bindingRequestReply(submission: import('@zlink-systems/zlink').RequestSubmission, deadlineMs: number | undefined): Promise<import('@zlink-systems/zlink').Message[]>;
|
|
44
|
+
export declare function closeBindingReply(replies: readonly import('@zlink-systems/zlink').Message[]): void;
|
|
43
45
|
/**
|
|
44
46
|
* Closes a binding handle once. An already closed or terminated handle counts as
|
|
45
47
|
* closed. A busy close propagates to the caller.
|
|
@@ -8,6 +8,8 @@ exports.submitBindingReply = submitBindingReply;
|
|
|
8
8
|
exports.submitBindingAsyncSend = submitBindingAsyncSend;
|
|
9
9
|
exports.submitBindingSyncSend = submitBindingSyncSend;
|
|
10
10
|
exports.submitBindingRequest = submitBindingRequest;
|
|
11
|
+
exports.bindingRequestReply = bindingRequestReply;
|
|
12
|
+
exports.closeBindingReply = closeBindingReply;
|
|
11
13
|
exports.closeBindingHandle = closeBindingHandle;
|
|
12
14
|
exports.isContextTerminatedError = isContextTerminatedError;
|
|
13
15
|
exports.disableSocketLinger = disableSocketLinger;
|
|
@@ -15,6 +17,7 @@ exports.toNativeRoutingId = toNativeRoutingId;
|
|
|
15
17
|
exports.translateBindingResultError = translateBindingResultError;
|
|
16
18
|
exports.toNativeActorRef = toNativeActorRef;
|
|
17
19
|
const node_os_1 = require("node:os");
|
|
20
|
+
const request_deadline_1 = require("../../messaging/request-deadline");
|
|
18
21
|
const submission_result_1 = require("../../messaging/submission-result");
|
|
19
22
|
const node_backend_adapter_1 = require("../node-backend-adapter");
|
|
20
23
|
const runtime_values_1 = require("../runtime-values");
|
|
@@ -53,7 +56,7 @@ function submitBindingPublish(operation, payload) {
|
|
|
53
56
|
translated.operation === 'submit' &&
|
|
54
57
|
(translated.result === runtime_values_1.SubmitResult.Backpressured ||
|
|
55
58
|
translated.result === runtime_values_1.SubmitResult.NotAdmitted)) {
|
|
56
|
-
(0, submission_result_1.
|
|
59
|
+
(0, submission_result_1.requireClassicFanoutCompletion)({ status: submission_result_1.ZLinkSubmitStatus.Backpressured }, 'Classic fanout publish');
|
|
57
60
|
}
|
|
58
61
|
throw translated;
|
|
59
62
|
}
|
|
@@ -73,6 +76,7 @@ function submitBindingReply(operation, payload) {
|
|
|
73
76
|
}
|
|
74
77
|
}
|
|
75
78
|
async function submitBindingAsyncSend(operation, payload) {
|
|
79
|
+
let submission;
|
|
76
80
|
try {
|
|
77
81
|
let current;
|
|
78
82
|
const parts = Array.isArray(payload) ? payload : [payload];
|
|
@@ -81,10 +85,18 @@ async function submitBindingAsyncSend(operation, payload) {
|
|
|
81
85
|
current = current === undefined ? operation.message(nativePart) : current.message(nativePart);
|
|
82
86
|
}
|
|
83
87
|
current ??= operation.message(Buffer.alloc(0));
|
|
84
|
-
|
|
88
|
+
submission = current.submit();
|
|
85
89
|
}
|
|
86
90
|
catch (error) {
|
|
87
|
-
throw translateBindingResultError(error);
|
|
91
|
+
throw translateBindingResultError(error, 'submit');
|
|
92
|
+
}
|
|
93
|
+
if (submission.result === runtime_values_1.SubmitResult.Backpressured) {
|
|
94
|
+
try {
|
|
95
|
+
await submission.admitted;
|
|
96
|
+
}
|
|
97
|
+
catch (error) {
|
|
98
|
+
throw translateBindingResultError(error, 'completion');
|
|
99
|
+
}
|
|
88
100
|
}
|
|
89
101
|
}
|
|
90
102
|
function submitBindingSyncSend(operation, payload) {
|
|
@@ -103,6 +115,7 @@ function submitBindingSyncSend(operation, payload) {
|
|
|
103
115
|
}
|
|
104
116
|
}
|
|
105
117
|
async function submitBindingRequest(operation, payload, timeoutMs) {
|
|
118
|
+
const deadlineMs = timeoutMs === undefined ? undefined : performance.now() + timeoutMs;
|
|
106
119
|
try {
|
|
107
120
|
let current;
|
|
108
121
|
if (Array.isArray(payload)) {
|
|
@@ -119,12 +132,30 @@ async function submitBindingRequest(operation, payload, timeoutMs) {
|
|
|
119
132
|
if (timeoutMs !== undefined) {
|
|
120
133
|
current = current.timeout(timeoutMs);
|
|
121
134
|
}
|
|
122
|
-
return await current.submit()
|
|
135
|
+
return await bindingRequestReply(current.submit(), deadlineMs);
|
|
123
136
|
}
|
|
124
137
|
catch (error) {
|
|
125
138
|
throw translateBindingResultError(error);
|
|
126
139
|
}
|
|
127
140
|
}
|
|
141
|
+
async function bindingRequestReply(submission, deadlineMs) {
|
|
142
|
+
const reply = submission.reply;
|
|
143
|
+
if (submission.result === runtime_values_1.SubmitResult.Backpressured) {
|
|
144
|
+
try {
|
|
145
|
+
const [, replies] = await (0, request_deadline_1.waitRequestReply)(Promise.all([submission.admitted, reply]), 'Request', deadlineMs);
|
|
146
|
+
return replies;
|
|
147
|
+
}
|
|
148
|
+
catch (error) {
|
|
149
|
+
void reply.then(closeBindingReply, () => undefined);
|
|
150
|
+
throw error;
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
return reply;
|
|
154
|
+
}
|
|
155
|
+
function closeBindingReply(replies) {
|
|
156
|
+
for (const reply of replies)
|
|
157
|
+
reply.close();
|
|
158
|
+
}
|
|
128
159
|
/**
|
|
129
160
|
* Closes a binding handle once. An already closed or terminated handle counts as
|
|
130
161
|
* closed. A busy close propagates to the caller.
|
|
@@ -6,7 +6,7 @@ export declare class ZLinkDealerChannelClientTransport implements ZLinkChannelCl
|
|
|
6
6
|
private readonly dealer;
|
|
7
7
|
private readonly publisher?;
|
|
8
8
|
constructor(dealer: DealerSocket, publisher?: PubSocket | undefined);
|
|
9
|
-
send(channelName: string, packetName: string | undefined, message: Message,
|
|
9
|
+
send(channelName: string, packetName: string | undefined, message: Message, metadata?: ReadonlyMap<string, string>): Promise<ZLinkSubmitResult>;
|
|
10
10
|
request<TReply>(channelName: string, packetName: string | undefined, request: Message, timeoutMs: number | undefined, signal?: AbortSignal, metadata?: ReadonlyMap<string, string>): Promise<TReply>;
|
|
11
11
|
tryPublish(channelName: string, topic: string, packetName: string | undefined, event: Message, metadata?: ReadonlyMap<string, string>): ZLinkSubmitResult;
|
|
12
12
|
publish(channelName: string, topic: string, packetName: string | undefined, event: Message, signal?: AbortSignal, metadata?: ReadonlyMap<string, string>): Promise<ZLinkSubmitResult>;
|
|
@@ -16,8 +16,7 @@ class ZLinkDealerChannelClientTransport {
|
|
|
16
16
|
this.dealer = dealer;
|
|
17
17
|
this.publisher = publisher;
|
|
18
18
|
}
|
|
19
|
-
async send(channelName, packetName, message,
|
|
20
|
-
(0, abort_1.throwIfAborted)(signal);
|
|
19
|
+
async send(channelName, packetName, message, metadata = EMPTY_METADATA) {
|
|
21
20
|
// Call-scoped flow (spec 27 §4): the envelope flow pair does not outlive
|
|
22
21
|
// this outbound call.
|
|
23
22
|
await (0, flow_context_1.runWithOutboundFlow)(true, () => (0, channel_multipart_1.appendParts)(this.dealer.send(), (0, channel_envelope_1.encodeChannelEnvelopeParts)(3 /* ZLinkChannelMessageKind.Command */, channelName, packetName, message, undefined, undefined, undefined, undefined, true, metadata)).submit().admitted);
|
|
@@ -204,15 +204,14 @@ class NodeRawRouterPort extends NodeRawSocketPort {
|
|
|
204
204
|
this.socket.options.setConnectRoutingId(bindingRoutingId(routingId));
|
|
205
205
|
this.connect(endpoint);
|
|
206
206
|
}
|
|
207
|
-
|
|
207
|
+
send(targetRid, parts) {
|
|
208
208
|
this.requireOpen();
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
await submission.admitted;
|
|
212
|
-
}
|
|
209
|
+
requireParts(parts);
|
|
210
|
+
return (0, node_backend_adapter_support_1.submitBindingAsyncSend)(this.socket.send(bindingRoutingId(targetRid)), parts);
|
|
213
211
|
}
|
|
214
212
|
async request(targetRid, parts, timeoutMs) {
|
|
215
213
|
this.requireOpen();
|
|
214
|
+
const deadlineMs = performance.now() + timeoutMs;
|
|
216
215
|
let submission;
|
|
217
216
|
try {
|
|
218
217
|
submission = appendRequestParts(this.socket.request(bindingRoutingId(targetRid)), parts)
|
|
@@ -223,7 +222,7 @@ class NodeRawRouterPort extends NodeRawSocketPort {
|
|
|
223
222
|
throw (0, node_backend_adapter_support_1.translateBindingResultError)(error, 'submit');
|
|
224
223
|
}
|
|
225
224
|
try {
|
|
226
|
-
const replies = await
|
|
225
|
+
const replies = await (0, node_backend_adapter_support_1.bindingRequestReply)(submission, deadlineMs);
|
|
227
226
|
return copyAndClose(replies);
|
|
228
227
|
}
|
|
229
228
|
catch (error) {
|
|
@@ -257,15 +256,14 @@ class NodeRawDealerPort extends NodeRawSocketPort {
|
|
|
257
256
|
this.requireOpen();
|
|
258
257
|
this.socket.setRoutingId(bindingRoutingId(routingId));
|
|
259
258
|
}
|
|
260
|
-
|
|
259
|
+
send(parts) {
|
|
261
260
|
this.requireOpen();
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
await submission.admitted;
|
|
265
|
-
}
|
|
261
|
+
requireParts(parts);
|
|
262
|
+
return (0, node_backend_adapter_support_1.submitBindingAsyncSend)(this.socket.send(), parts);
|
|
266
263
|
}
|
|
267
264
|
async request(parts, timeoutMs) {
|
|
268
265
|
this.requireOpen();
|
|
266
|
+
const deadlineMs = performance.now() + timeoutMs;
|
|
269
267
|
let submission;
|
|
270
268
|
try {
|
|
271
269
|
submission = appendRequestParts(this.socket.request(), parts).timeout(timeoutMs).submit();
|
|
@@ -274,7 +272,7 @@ class NodeRawDealerPort extends NodeRawSocketPort {
|
|
|
274
272
|
throw (0, node_backend_adapter_support_1.translateBindingResultError)(error, 'submit');
|
|
275
273
|
}
|
|
276
274
|
try {
|
|
277
|
-
const replies = await
|
|
275
|
+
const replies = await (0, node_backend_adapter_support_1.bindingRequestReply)(submission, deadlineMs);
|
|
278
276
|
return copyAndClose(replies);
|
|
279
277
|
}
|
|
280
278
|
catch (error) {
|
|
@@ -286,13 +284,6 @@ class NodeRawDealerPort extends NodeRawSocketPort {
|
|
|
286
284
|
return receiveRecord(this.socket, dontWait);
|
|
287
285
|
}
|
|
288
286
|
}
|
|
289
|
-
async function requestReply(submission) {
|
|
290
|
-
if (submission.result === zlink_1.SubmitResult.Backpressured) {
|
|
291
|
-
const [, replies] = await Promise.all([submission.admitted, submission.reply]);
|
|
292
|
-
return replies;
|
|
293
|
-
}
|
|
294
|
-
return submission.reply;
|
|
295
|
-
}
|
|
296
287
|
class NodeRawMonitorPort {
|
|
297
288
|
monitor;
|
|
298
289
|
release;
|
|
@@ -326,14 +317,6 @@ class NodeRawMonitorPort {
|
|
|
326
317
|
this.release();
|
|
327
318
|
}
|
|
328
319
|
}
|
|
329
|
-
function appendSendParts(operation, parts) {
|
|
330
|
-
requireParts(parts);
|
|
331
|
-
let next = operation.message(parts[0]);
|
|
332
|
-
for (let index = 1; index < parts.length; index += 1) {
|
|
333
|
-
next = next.message(parts[index]);
|
|
334
|
-
}
|
|
335
|
-
return next;
|
|
336
|
-
}
|
|
337
320
|
function appendRequestParts(operation, parts) {
|
|
338
321
|
requireParts(parts);
|
|
339
322
|
let next = operation.message(parts[0]);
|
|
@@ -147,12 +147,10 @@ class ZLinkNodeRawMeshBackend {
|
|
|
147
147
|
selectObjectPlacement(stableType) {
|
|
148
148
|
const runtime = this.requireRuntime();
|
|
149
149
|
const localNodeRid = runtime.topology.localDescriptor().nodeRoutingId;
|
|
150
|
-
const status = runtime.topology.
|
|
150
|
+
const { status, descriptor } = runtime.topology.selectObjectPlacementWithStatus(stableType, (candidate) => candidate.nodeRoutingId === localNodeRid ||
|
|
151
151
|
runtime.isPeerRouteReady(candidate.nodeRoutingId));
|
|
152
152
|
if (status !== 'available')
|
|
153
153
|
return { kind: status };
|
|
154
|
-
const descriptor = runtime.topology.selectObjectPlacement(stableType, (candidate) => candidate.nodeRoutingId === localNodeRid ||
|
|
155
|
-
runtime.isPeerRouteReady(candidate.nodeRoutingId));
|
|
156
154
|
return descriptor === undefined
|
|
157
155
|
? { kind: 'unavailable' }
|
|
158
156
|
: {
|