@zlink-systems/framework 0.29.0 → 0.30.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/Configuration/Builders.d.ts +1 -2
- package/dist/contracts/Configuration/Configs.d.ts +0 -5
- package/dist/contracts/Configuration/RegistrationBuilders.js +6 -4
- package/dist/contracts/Configuration/RegistrationTypes.d.ts +1 -6
- package/dist/contracts/Configuration/RegistrationValidators.js +4 -4
- package/dist/contracts/Configuration/index.d.ts +1 -1
- package/dist/internal.d.ts +1 -0
- package/dist/internal.js +3 -1
- package/dist/runtime/actors/actor-handoff.d.ts +3 -2
- package/dist/runtime/actors/actor-handoff.js +9 -4
- package/dist/runtime/actors/actor-runtime-contracts.d.ts +1 -0
- package/dist/runtime/actors/index.d.ts +2 -0
- package/dist/runtime/actors/index.js +21 -6
- package/dist/runtime/application-jobs/application-ingress-record-owner.d.ts +3 -1
- package/dist/runtime/application-jobs/application-ingress-record-owner.js +6 -1
- package/dist/runtime/application-jobs/application-job-queue-scope.d.ts +3 -1
- package/dist/runtime/application-jobs/application-job-queue-scope.js +5 -0
- package/dist/runtime/application-jobs/contracts.d.ts +5 -1
- package/dist/runtime/backend/contracts/index.d.ts +10 -19
- package/dist/runtime/backend/mesh-completion-table.d.ts +6 -4
- package/dist/runtime/backend/mesh-completion-table.js +28 -18
- package/dist/runtime/backend/mesh-dispatch-pump.js +21 -25
- package/dist/runtime/backend/node/node-backend-adapter-factory.js +6 -1
- package/dist/runtime/backend/node/node-backend-adapter-support.d.ts +3 -3
- package/dist/runtime/backend/node/node-backend-adapter-support.js +24 -29
- package/dist/runtime/backend/node/node-mesh-backend-adapter.d.ts +1 -9
- package/dist/runtime/backend/node/node-mesh-backend-adapter.js +1 -1
- package/dist/runtime/backend/node/node-raw-binding-port.js +11 -6
- package/dist/runtime/backend/node/node-raw-mesh-backend.d.ts +10 -12
- package/dist/runtime/backend/node/node-raw-mesh-backend.js +64 -98
- package/dist/runtime/backend/node/node-socket-backend-adapter.js +10 -5
- package/dist/runtime/backend/raw-binding-port.d.ts +9 -2
- package/dist/runtime/channels/channel-receive-loops.js +3 -3
- package/dist/runtime/channels/channel-runtime-lifecycle.js +2 -1
- package/dist/runtime/channels/channel-socket-registry.d.ts +10 -3
- package/dist/runtime/channels/channel-socket-registry.js +59 -82
- package/dist/runtime/diagnostics/message-flow.d.ts +1 -0
- package/dist/runtime/diagnostics/message-flow.js +3 -3
- package/dist/runtime/foundation/raw-service-mesh-runtime.d.ts +15 -1
- package/dist/runtime/foundation/raw-service-mesh-runtime.js +193 -64
- package/dist/runtime/foundation/service-liveness-registry.d.ts +20 -8
- package/dist/runtime/foundation/service-liveness-registry.js +57 -44
- package/dist/runtime/foundation/service-mailbox.d.ts +3 -0
- package/dist/runtime/foundation/service-mailbox.js +2 -1
- package/dist/runtime/foundation/service-stateful-runtime.d.ts +7 -6
- package/dist/runtime/foundation/service-stateful-runtime.js +60 -41
- package/dist/runtime/foundation/service-stateful-wire-codec.d.ts +5 -2
- package/dist/runtime/foundation/service-stateful-wire-codec.js +43 -61
- package/dist/runtime/foundation/service-topology-registry.d.ts +5 -3
- package/dist/runtime/foundation/service-topology-registry.js +9 -4
- package/dist/runtime/handlers/handler-instance-scope.js +1 -1
- package/dist/runtime/host/actor-packet-relay.js +7 -7
- package/dist/runtime/host/actor-placement-coordinator.d.ts +2 -1
- package/dist/runtime/host/actor-placement-coordinator.js +2 -1
- package/dist/runtime/host/actor-runtime-options-factory.d.ts +2 -1
- package/dist/runtime/host/actor-runtime-options-factory.js +2 -1
- package/dist/runtime/host/application-job-queue.d.ts +11 -4
- package/dist/runtime/host/application-job-queue.js +66 -10
- package/dist/runtime/host/entry-actor-runtime.js +1 -1
- package/dist/runtime/host/index.d.ts +1 -1
- package/dist/runtime/host/index.js +18 -13
- package/dist/runtime/host/instance-activation-authority.d.ts +2 -1
- package/dist/runtime/host/instance-activation-authority.js +89 -25
- package/dist/runtime/host/service-relocation-host-runtime.js +2 -2
- package/dist/runtime/host/spot-address-transport.d.ts +1 -0
- package/dist/runtime/host/spot-address-transport.js +25 -12
- package/dist/runtime/host/spot-runtime-options-factory.js +2 -2
- package/dist/runtime/host/user-spot-creation-coordinator.d.ts +1 -0
- package/dist/runtime/host/user-spot-creation-coordinator.js +1 -0
- package/dist/runtime/locations/domain-store-contract.d.ts +3 -2
- package/dist/runtime/locations/in-memory-authority-store.d.ts +5 -2
- package/dist/runtime/locations/in-memory-authority-store.js +107 -14
- package/dist/runtime/locations/in-memory-location-store.d.ts +3 -3
- package/dist/runtime/locations/in-memory-location-store.js +31 -13
- package/dist/runtime/locations/internal-location-contracts.d.ts +8 -0
- package/dist/runtime/locations/location-store-repository.d.ts +4 -2
- package/dist/runtime/locations/location-store-repository.js +209 -33
- package/dist/runtime/locations/resolvers.d.ts +2 -1
- package/dist/runtime/locations/resolvers.js +10 -1
- package/dist/runtime/messaging/submission-result.d.ts +1 -1
- package/dist/runtime/messaging/submission-result.js +2 -2
- package/dist/runtime/spots/formal-remote-actor-admission-registry.d.ts +2 -0
- package/dist/runtime/spots/index.d.ts +4 -3
- package/dist/runtime/spots/index.js +14 -14
- package/dist/runtime/spots/spot-activation.d.ts +2 -1
- package/dist/runtime/spots/spot-activation.js +4 -4
- package/dist/runtime/spots/spot-actor-admission-coordinator.d.ts +2 -1
- package/dist/runtime/spots/spot-actor-admission-coordinator.js +11 -10
- package/dist/runtime/spots/spot-actor-packet-dispatch.d.ts +4 -1
- package/dist/runtime/spots/spot-actor-packet-dispatch.js +7 -5
- package/dist/runtime/spots/spot-actor-packet-drain.js +2 -0
- package/dist/runtime/spots/spot-actor-packet-relay-dispatch.js +1 -0
- package/dist/runtime/spots/spot-entry-activation.d.ts +1 -0
- package/dist/runtime/spots/spot-entry-activation.js +6 -1
- package/dist/runtime/spots/spot-node-runtime-manager.d.ts +3 -1
- package/dist/runtime/spots/spot-node-runtime-manager.js +10 -11
- package/dist/runtime/spots/spot-routing-internal.d.ts +6 -0
- package/dist/runtime/spots/spot-runtime-ports.d.ts +2 -1
- package/dist/runtime/spots/spot-serial-executor.d.ts +1 -0
- package/dist/runtime/spots/spot-serial-executor.js +10 -1
- package/dist/runtime/streams/stream-session-runtime.js +1 -1
- package/package.json +3 -3
- package/src/contracts/Configuration/Builders.ts +1 -2
- package/src/contracts/Configuration/Configs.ts +0 -6
- package/src/contracts/Configuration/RegistrationBuilders.ts +8 -12
- package/src/contracts/Configuration/RegistrationTypes.ts +1 -6
- package/src/contracts/Configuration/RegistrationValidators.ts +9 -10
- package/src/contracts/Configuration/index.ts +1 -6
- package/src/internal.ts +1 -0
- package/src/runtime/actors/actor-handoff.ts +13 -4
- package/src/runtime/actors/actor-runtime-contracts.ts +4 -0
- package/src/runtime/actors/index.ts +77 -42
- package/src/runtime/application-jobs/application-ingress-record-owner.ts +12 -2
- package/src/runtime/application-jobs/application-job-queue-scope.ts +6 -1
- package/src/runtime/application-jobs/contracts.ts +14 -1
- package/src/runtime/backend/contracts/index.ts +10 -18
- package/src/runtime/backend/mesh-completion-table.ts +36 -19
- package/src/runtime/backend/mesh-dispatch-pump.ts +19 -22
- package/src/runtime/backend/node/node-backend-adapter-factory.ts +12 -5
- package/src/runtime/backend/node/node-backend-adapter-support.ts +31 -29
- package/src/runtime/backend/node/node-mesh-backend-adapter.ts +3 -10
- package/src/runtime/backend/node/node-raw-binding-port.ts +19 -10
- package/src/runtime/backend/node/node-raw-mesh-backend.ts +81 -111
- package/src/runtime/backend/node/node-socket-backend-adapter.ts +12 -8
- package/src/runtime/backend/raw-binding-port.ts +12 -2
- package/src/runtime/channels/channel-receive-loops.ts +3 -3
- package/src/runtime/channels/channel-runtime-lifecycle.ts +7 -1
- package/src/runtime/channels/channel-socket-registry.ts +84 -130
- package/src/runtime/diagnostics/message-flow.ts +1 -1
- package/src/runtime/foundation/raw-service-mesh-runtime.ts +268 -70
- package/src/runtime/foundation/service-liveness-registry.ts +68 -59
- package/src/runtime/foundation/service-mailbox.ts +7 -1
- package/src/runtime/foundation/service-stateful-runtime.ts +109 -77
- package/src/runtime/foundation/service-stateful-wire-codec.ts +55 -79
- package/src/runtime/foundation/service-topology-registry.ts +13 -7
- package/src/runtime/handlers/handler-instance-scope.ts +2 -1
- package/src/runtime/host/actor-packet-relay.ts +7 -0
- package/src/runtime/host/actor-placement-coordinator.ts +8 -2
- package/src/runtime/host/actor-runtime-options-factory.ts +7 -0
- package/src/runtime/host/application-job-queue.ts +77 -10
- package/src/runtime/host/entry-actor-runtime.ts +1 -0
- package/src/runtime/host/index.ts +30 -7
- package/src/runtime/host/instance-activation-authority.ts +132 -27
- package/src/runtime/host/service-relocation-host-runtime.ts +2 -0
- package/src/runtime/host/spot-address-transport.ts +45 -22
- package/src/runtime/host/spot-runtime-options-factory.ts +2 -0
- package/src/runtime/host/user-spot-creation-coordinator.ts +8 -0
- package/src/runtime/locations/domain-store-contract.ts +6 -2
- package/src/runtime/locations/in-memory-authority-store.ts +153 -12
- package/src/runtime/locations/in-memory-location-store.ts +39 -13
- package/src/runtime/locations/internal-location-contracts.ts +10 -0
- package/src/runtime/locations/location-store-repository.ts +295 -36
- package/src/runtime/locations/resolvers.ts +25 -2
- package/src/runtime/messaging/submission-result.ts +2 -2
- package/src/runtime/spots/formal-remote-actor-admission-registry.ts +2 -0
- package/src/runtime/spots/index.ts +16 -0
- package/src/runtime/spots/spot-activation.ts +5 -0
- package/src/runtime/spots/spot-actor-admission-coordinator.ts +13 -0
- package/src/runtime/spots/spot-actor-packet-dispatch.ts +10 -0
- package/src/runtime/spots/spot-actor-packet-drain.ts +2 -0
- package/src/runtime/spots/spot-actor-packet-relay-dispatch.ts +1 -0
- package/src/runtime/spots/spot-entry-activation.ts +7 -0
- package/src/runtime/spots/spot-node-runtime-manager.ts +14 -12
- package/src/runtime/spots/spot-routing-internal.ts +14 -0
- package/src/runtime/spots/spot-runtime-ports.ts +2 -0
- package/src/runtime/spots/spot-serial-executor.ts +10 -4
- package/src/runtime/streams/stream-session-runtime.ts +1 -1
|
@@ -4,6 +4,7 @@ exports.ZLinkChannelSocketRegistry = void 0;
|
|
|
4
4
|
const disposal_1 = require("../disposal");
|
|
5
5
|
const stream_wire_1 = require("@zlink-systems/stream-wire");
|
|
6
6
|
const node_crypto_1 = require("node:crypto");
|
|
7
|
+
const zlink_1 = require("@zlink-systems/zlink");
|
|
7
8
|
const contracts_1 = require("../../contracts");
|
|
8
9
|
const CoreTypes_1 = require("../../contracts/Common/CoreTypes");
|
|
9
10
|
const RegistrationBuilderPolicy_1 = require("../../contracts/Configuration/RegistrationBuilderPolicy");
|
|
@@ -46,7 +47,6 @@ class ZLinkChannelSocketRegistry {
|
|
|
46
47
|
clientServerServerDescriptors = new Map();
|
|
47
48
|
clientServerPublicWeights = new Map();
|
|
48
49
|
routeMeshPublicWeights = new Map();
|
|
49
|
-
clientServerAdmittedClients = new Map();
|
|
50
50
|
clientServerServerPeers = new Map();
|
|
51
51
|
disposal = new disposal_1.RuntimeDisposal();
|
|
52
52
|
ownedResources = new Set();
|
|
@@ -83,8 +83,6 @@ class ZLinkChannelSocketRegistry {
|
|
|
83
83
|
...this.routeRouters.values()
|
|
84
84
|
];
|
|
85
85
|
for (const socket of new Set([
|
|
86
|
-
...this.clientDealers.values(),
|
|
87
|
-
...clientServerConnections.map((value) => value.dealer),
|
|
88
86
|
...this.channelRouters.values(),
|
|
89
87
|
...this.routeRouters.values()
|
|
90
88
|
]))
|
|
@@ -93,7 +91,8 @@ class ZLinkChannelSocketRegistry {
|
|
|
93
91
|
this.clientServerServerDescriptors.clear();
|
|
94
92
|
this.clientServerPublicWeights.clear();
|
|
95
93
|
this.routeMeshPublicWeights.clear();
|
|
96
|
-
this.
|
|
94
|
+
for (const peers of this.clientServerServerPeers.values())
|
|
95
|
+
peers.clear();
|
|
97
96
|
this.clientServerServerPeers.clear();
|
|
98
97
|
this.clientServerMonitorHandlers.clear();
|
|
99
98
|
this.fanoutMonitorHandlers.clear();
|
|
@@ -152,7 +151,6 @@ class ZLinkChannelSocketRegistry {
|
|
|
152
151
|
}
|
|
153
152
|
const dealer = this.adapter.createDealerSocket(this.context);
|
|
154
153
|
this.clientDealers.set(channelName, dealer);
|
|
155
|
-
this.registerReceiveFlowSocket(dealer);
|
|
156
154
|
dealer.setChannelName(channelName);
|
|
157
155
|
if (channel?.routingId !== undefined && channel.routingId.length > 0) {
|
|
158
156
|
dealer.setRoutingId(deriveRoutingId(channel.routingId, 'dealer'));
|
|
@@ -202,8 +200,7 @@ class ZLinkChannelSocketRegistry {
|
|
|
202
200
|
event.nativeEvent !== internal_event_contracts_1.ZLinkSocketNativeEventType.HandshakeFailedAuth)
|
|
203
201
|
return;
|
|
204
202
|
const routingId = String(event.routingId);
|
|
205
|
-
this.clientServerServerPeers.delete(
|
|
206
|
-
this.clientServerAdmittedClients.get(channelName)?.delete(routingId);
|
|
203
|
+
this.clientServerServerPeers.get(channelName)?.delete(routingId);
|
|
207
204
|
});
|
|
208
205
|
}
|
|
209
206
|
const endpoint = advertisedEndpoint(router.lastEndpoint ?? channel.server.bind, channel.server.advertiseHost);
|
|
@@ -278,7 +275,6 @@ class ZLinkChannelSocketRegistry {
|
|
|
278
275
|
const created = [dealer];
|
|
279
276
|
try {
|
|
280
277
|
this.clientServerConnections.set(connectionId, connection);
|
|
281
|
-
this.registerReceiveFlowSocket(dealer);
|
|
282
278
|
dealer.setChannelName(channelName);
|
|
283
279
|
dealer.setRoutingId(`cs-client-${(0, node_crypto_1.randomUUID)()}`);
|
|
284
280
|
applySocketConfig(dealer, {
|
|
@@ -325,7 +321,6 @@ class ZLinkChannelSocketRegistry {
|
|
|
325
321
|
}
|
|
326
322
|
catch (error) {
|
|
327
323
|
this.clientServerConnections.delete(connectionId);
|
|
328
|
-
this.unregisterReceiveFlowSocket(dealer);
|
|
329
324
|
void Promise.allSettled(created.map(async (resource) => {
|
|
330
325
|
await resource.dispose();
|
|
331
326
|
this.ownedResources.delete(resource);
|
|
@@ -375,7 +370,6 @@ class ZLinkChannelSocketRegistry {
|
|
|
375
370
|
catch {
|
|
376
371
|
// The socket close below releases an endpoint that is already disconnected.
|
|
377
372
|
}
|
|
378
|
-
this.unregisterReceiveFlowSocket(current.dealer);
|
|
379
373
|
if (current.readablePoller !== undefined) {
|
|
380
374
|
current.readablePoller.dispose();
|
|
381
375
|
this.ownedResources.delete(current.readablePoller);
|
|
@@ -430,9 +424,8 @@ class ZLinkChannelSocketRegistry {
|
|
|
430
424
|
const admitted = this.clientServerDiscovery.admitClientServer(descriptor, connectionId);
|
|
431
425
|
if (admitted) {
|
|
432
426
|
const now = performance.now();
|
|
433
|
-
connection.
|
|
434
|
-
connection.
|
|
435
|
-
connection.outstandingProbeId = undefined;
|
|
427
|
+
connection.liveness = new service_liveness_registry_1.ServiceLivenessConnection(connectionId, now);
|
|
428
|
+
connection.dealer.receiveAdmission = connection.liveness;
|
|
436
429
|
this.clientServerReadyIdentities.set(connectionId, {
|
|
437
430
|
channelName: descriptor.channelName,
|
|
438
431
|
serverRoutingId: descriptor.serverRoutingId,
|
|
@@ -451,9 +444,8 @@ class ZLinkChannelSocketRegistry {
|
|
|
451
444
|
const connection = this.clientServerConnections.get(connectionId);
|
|
452
445
|
if (connection?.readyConnectionId === connectionId) {
|
|
453
446
|
connection.readyConnectionId = undefined;
|
|
454
|
-
connection.
|
|
455
|
-
connection.
|
|
456
|
-
connection.outstandingProbeId = undefined;
|
|
447
|
+
connection.liveness = undefined;
|
|
448
|
+
connection.dealer.receiveAdmission = undefined;
|
|
457
449
|
}
|
|
458
450
|
}
|
|
459
451
|
this.notifyClientServerTopology(channelName);
|
|
@@ -657,7 +649,18 @@ class ZLinkChannelSocketRegistry {
|
|
|
657
649
|
for (const handler of this.clientServerMonitorHandlers.get(channelName) ?? [])
|
|
658
650
|
handler();
|
|
659
651
|
}
|
|
660
|
-
|
|
652
|
+
clientServerServerPeersForChannel(channelName) {
|
|
653
|
+
let peers = this.clientServerServerPeers.get(channelName);
|
|
654
|
+
if (peers === undefined) {
|
|
655
|
+
peers = new Map();
|
|
656
|
+
this.clientServerServerPeers.set(channelName, peers);
|
|
657
|
+
}
|
|
658
|
+
return peers;
|
|
659
|
+
}
|
|
660
|
+
tryHandleClientServerControl(channelName, received, router, peers = this.clientServerServerPeersForChannel(channelName)) {
|
|
661
|
+
const routingId = String(received.routingId);
|
|
662
|
+
const peer = peers.get(routingId);
|
|
663
|
+
peer?.liveness.recordReceived();
|
|
661
664
|
if (received.parts.length === 0)
|
|
662
665
|
return false;
|
|
663
666
|
const first = received.parts[0];
|
|
@@ -674,8 +677,8 @@ class ZLinkChannelSocketRegistry {
|
|
|
674
677
|
else if (record.kind === 'livenessAck' &&
|
|
675
678
|
received.parts.length === 1 &&
|
|
676
679
|
received.replyToken === null) {
|
|
677
|
-
if (!this.acceptClientServerServerLivenessAck(
|
|
678
|
-
this.reportStaleClientServerLivenessAck(channelName,
|
|
680
|
+
if (!this.acceptClientServerServerLivenessAck(peer, record.probeId)) {
|
|
681
|
+
this.reportStaleClientServerLivenessAck(channelName, routingId, record.probeId);
|
|
679
682
|
}
|
|
680
683
|
return true;
|
|
681
684
|
}
|
|
@@ -694,7 +697,7 @@ class ZLinkChannelSocketRegistry {
|
|
|
694
697
|
else {
|
|
695
698
|
const normalizedEffectiveMaxMessageBytes = Math.min((0, client_server_service_wire_1.normalizeClientServerMessageLimit)(router.maxMessageSize), record.hello.normalizedEffectiveMaxMessageBytes);
|
|
696
699
|
reply = (0, client_server_service_wire_1.encodeClientServerAdmit)(descriptor, normalizedEffectiveMaxMessageBytes);
|
|
697
|
-
this.admitClientServerServerPeer(channelName,
|
|
700
|
+
this.admitClientServerServerPeer(channelName, routingId, normalizedEffectiveMaxMessageBytes);
|
|
698
701
|
}
|
|
699
702
|
}
|
|
700
703
|
}
|
|
@@ -704,7 +707,7 @@ class ZLinkChannelSocketRegistry {
|
|
|
704
707
|
if (received.replyToken !== null) {
|
|
705
708
|
const message = runtime_message_1.ZLinkBufferMessage.from(reply);
|
|
706
709
|
try {
|
|
707
|
-
router.reply(
|
|
710
|
+
router.reply(routingId, received.replyToken, message);
|
|
708
711
|
}
|
|
709
712
|
finally {
|
|
710
713
|
message.close();
|
|
@@ -720,37 +723,33 @@ class ZLinkChannelSocketRegistry {
|
|
|
720
723
|
if (connectionId === undefined)
|
|
721
724
|
continue;
|
|
722
725
|
this.drainClientServerControl(connectionId, connection);
|
|
723
|
-
if (connection.
|
|
726
|
+
if (connection.liveness === undefined)
|
|
724
727
|
continue;
|
|
725
|
-
if (
|
|
728
|
+
if (connection.liveness.isExpired(nowMs)) {
|
|
726
729
|
this.restartClientServerAdmission(connectionId, connection);
|
|
727
730
|
continue;
|
|
728
731
|
}
|
|
729
|
-
|
|
732
|
+
const probeId = connection.liveness.tryGetProbe(nowMs, () => this.allocateClientServerProbeId());
|
|
733
|
+
if (probeId === undefined)
|
|
730
734
|
continue;
|
|
731
|
-
connection.nextProbeAt = nowMs + CLIENT_SERVER_PROBE_INTERVAL_MS;
|
|
732
|
-
const probeId = connection.outstandingProbeId ?? this.allocateClientServerProbeId();
|
|
733
|
-
connection.outstandingProbeId = probeId;
|
|
734
735
|
this.requestClientServerLiveness(connectionId, connection, probeId);
|
|
735
736
|
}
|
|
736
|
-
for (const
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
737
|
+
for (const peers of this.clientServerServerPeers.values()) {
|
|
738
|
+
for (const [routingId, peer] of peers) {
|
|
739
|
+
if (peer.liveness.isExpired(nowMs)) {
|
|
740
|
+
peers.delete(routingId);
|
|
741
|
+
try {
|
|
742
|
+
this.channelRouters.get(peer.channelName)?.disconnectPeer(peer.routingId);
|
|
743
|
+
}
|
|
744
|
+
catch (error) {
|
|
745
|
+
this.oneWayFailureSink?.(error);
|
|
746
|
+
}
|
|
747
|
+
continue;
|
|
745
748
|
}
|
|
746
|
-
|
|
749
|
+
const probeId = peer.liveness.tryGetProbe(nowMs, () => this.allocateClientServerProbeId());
|
|
750
|
+
if (probeId !== undefined)
|
|
751
|
+
this.requestClientServerServerLiveness(peer, probeId);
|
|
747
752
|
}
|
|
748
|
-
if (nowMs < peer.nextProbeAt)
|
|
749
|
-
continue;
|
|
750
|
-
peer.nextProbeAt = nowMs + CLIENT_SERVER_PROBE_INTERVAL_MS;
|
|
751
|
-
const probeId = peer.outstandingProbeId ?? this.allocateClientServerProbeId();
|
|
752
|
-
peer.outstandingProbeId = probeId;
|
|
753
|
-
this.requestClientServerServerLiveness(peer, probeId);
|
|
754
753
|
}
|
|
755
754
|
this.tickFanoutLiveness(nowMs);
|
|
756
755
|
}
|
|
@@ -1040,6 +1039,7 @@ class ZLinkChannelSocketRegistry {
|
|
|
1040
1039
|
}
|
|
1041
1040
|
}
|
|
1042
1041
|
drainClientServerControl(connectionId, connection) {
|
|
1042
|
+
const admission = connection.liveness;
|
|
1043
1043
|
for (;;) {
|
|
1044
1044
|
if (connection.readablePoller === undefined || !connection.readablePoller.wait(0))
|
|
1045
1045
|
return;
|
|
@@ -1048,6 +1048,7 @@ class ZLinkChannelSocketRegistry {
|
|
|
1048
1048
|
connection.readablePoller.markDrained();
|
|
1049
1049
|
return;
|
|
1050
1050
|
}
|
|
1051
|
+
admission?.recordReceived();
|
|
1051
1052
|
try {
|
|
1052
1053
|
if (received.parts.length !== 1 || !(0, client_server_service_wire_1.isClientServerControlFrame)(received.parts[0].data())) {
|
|
1053
1054
|
throw new configuration_1.ZLinkConfigurationException(`ClientServer '${connection.channelName}' received an unsolicited application frame.`);
|
|
@@ -1164,13 +1165,13 @@ class ZLinkChannelSocketRegistry {
|
|
|
1164
1165
|
if (connection.readyConnectionId === connectionId) {
|
|
1165
1166
|
connection.readyConnectionId = undefined;
|
|
1166
1167
|
}
|
|
1167
|
-
connection.
|
|
1168
|
-
connection.
|
|
1169
|
-
connection.outstandingProbeId = undefined;
|
|
1168
|
+
connection.liveness = undefined;
|
|
1169
|
+
connection.dealer.receiveAdmission = undefined;
|
|
1170
1170
|
}
|
|
1171
1171
|
this.notifyClientServerTopology(identity.channelName);
|
|
1172
1172
|
}
|
|
1173
1173
|
requestClientServerLiveness(connectionId, connection, probeId) {
|
|
1174
|
+
const admission = connection.liveness;
|
|
1174
1175
|
const message = runtime_message_1.ZLinkBufferMessage.from((0, client_server_service_wire_1.encodeClientServerLivenessProbe)(probeId));
|
|
1175
1176
|
void connection.dealer
|
|
1176
1177
|
.request(message, CLIENT_SERVER_PEER_DEADLINE_MS)
|
|
@@ -1179,17 +1180,17 @@ class ZLinkChannelSocketRegistry {
|
|
|
1179
1180
|
const current = this.clientServerConnections.get(connectionId);
|
|
1180
1181
|
if (current === undefined ||
|
|
1181
1182
|
current.physicalConnectionId !== connection.physicalConnectionId ||
|
|
1183
|
+
current.liveness !== admission ||
|
|
1182
1184
|
parts.length !== 1)
|
|
1183
1185
|
return;
|
|
1184
1186
|
const record = (0, client_server_service_wire_1.decodeClientServerControl)(parts[0].data());
|
|
1185
1187
|
if (record.kind !== 'livenessAck')
|
|
1186
1188
|
return;
|
|
1187
|
-
if (
|
|
1189
|
+
if (admission === undefined ||
|
|
1190
|
+
!admission.acknowledge(record.probeId, performance.now())) {
|
|
1188
1191
|
this.reportStaleClientServerLivenessAck(connection.channelName, connectionId, record.probeId);
|
|
1189
1192
|
return;
|
|
1190
1193
|
}
|
|
1191
|
-
current.outstandingProbeId = undefined;
|
|
1192
|
-
current.deadlineAt = performance.now() + CLIENT_SERVER_PEER_DEADLINE_MS;
|
|
1193
1194
|
}
|
|
1194
1195
|
finally {
|
|
1195
1196
|
closeMessages(parts);
|
|
@@ -1199,23 +1200,13 @@ class ZLinkChannelSocketRegistry {
|
|
|
1199
1200
|
.finally(() => message.close());
|
|
1200
1201
|
}
|
|
1201
1202
|
admitClientServerServerPeer(channelName, routingId, normalizedEffectiveMaxMessageBytes) {
|
|
1202
|
-
const key = clientServerServerPeerKey(channelName, routingId);
|
|
1203
|
-
const now = performance.now();
|
|
1204
1203
|
const peer = {
|
|
1205
1204
|
channelName,
|
|
1206
1205
|
routingId,
|
|
1207
|
-
physicalConnectionId: Symbol(key),
|
|
1208
1206
|
normalizedEffectiveMaxMessageBytes,
|
|
1209
|
-
|
|
1210
|
-
deadlineAt: now + CLIENT_SERVER_PEER_DEADLINE_MS
|
|
1207
|
+
liveness: new service_liveness_registry_1.ServiceLivenessConnection(clientServerServerPeerKey(channelName, routingId), performance.now())
|
|
1211
1208
|
};
|
|
1212
|
-
this.
|
|
1213
|
-
let clients = this.clientServerAdmittedClients.get(channelName);
|
|
1214
|
-
if (clients === undefined) {
|
|
1215
|
-
clients = new Set();
|
|
1216
|
-
this.clientServerAdmittedClients.set(channelName, clients);
|
|
1217
|
-
}
|
|
1218
|
-
clients.add(routingId);
|
|
1209
|
+
this.clientServerServerPeersForChannel(channelName).set(routingId, peer);
|
|
1219
1210
|
this.ensureClientServerLivenessTimer();
|
|
1220
1211
|
}
|
|
1221
1212
|
requestClientServerServerLiveness(peer, probeId) {
|
|
@@ -1228,33 +1219,22 @@ class ZLinkChannelSocketRegistry {
|
|
|
1228
1219
|
.catch((error) => this.oneWayFailureSink?.(error))
|
|
1229
1220
|
.finally(() => message.close());
|
|
1230
1221
|
}
|
|
1231
|
-
acceptClientServerServerLivenessAck(
|
|
1232
|
-
|
|
1233
|
-
if (peer === undefined || peer.outstandingProbeId !== probeId)
|
|
1234
|
-
return false;
|
|
1235
|
-
peer.outstandingProbeId = undefined;
|
|
1236
|
-
peer.deadlineAt = performance.now() + CLIENT_SERVER_PEER_DEADLINE_MS;
|
|
1237
|
-
return true;
|
|
1222
|
+
acceptClientServerServerLivenessAck(peer, probeId) {
|
|
1223
|
+
return peer?.liveness.acknowledge(probeId, performance.now()) ?? false;
|
|
1238
1224
|
}
|
|
1239
1225
|
reportStaleClientServerLivenessAck(channelName, peer, probeId) {
|
|
1240
1226
|
this.oneWayFailureSink?.((0, framework_errors_internal_1.createInternalFrameworkException)(framework_errors_internal_1.ZLinkFrameworkInternalErrorKind.RequestProtocolError, `ClientServer '${channelName}' ignored stale or duplicate liveness ACK '${probeId}' from '${peer}'.`, false));
|
|
1241
1227
|
}
|
|
1242
1228
|
pushClientServerDescriptorUpdate(channelName, descriptor) {
|
|
1243
1229
|
const router = this.channelRouters.get(channelName);
|
|
1244
|
-
const
|
|
1245
|
-
if (router === undefined ||
|
|
1230
|
+
const peers = this.clientServerServerPeers.get(channelName);
|
|
1231
|
+
if (router === undefined || peers === undefined)
|
|
1246
1232
|
return;
|
|
1247
|
-
for (const routingId of
|
|
1248
|
-
const peer = this.clientServerServerPeers.get(clientServerServerPeerKey(channelName, routingId));
|
|
1249
|
-
if (peer === undefined) {
|
|
1250
|
-
clients.delete(routingId);
|
|
1251
|
-
continue;
|
|
1252
|
-
}
|
|
1233
|
+
for (const [routingId, peer] of peers) {
|
|
1253
1234
|
const message = runtime_message_1.ZLinkBufferMessage.from((0, client_server_service_wire_1.encodeClientServerUpdate)(descriptor, peer.normalizedEffectiveMaxMessageBytes));
|
|
1254
1235
|
void router
|
|
1255
1236
|
.send(routingId, message)
|
|
1256
1237
|
.catch((error) => {
|
|
1257
|
-
clients.delete(routingId);
|
|
1258
1238
|
this.oneWayFailureSink?.(error);
|
|
1259
1239
|
})
|
|
1260
1240
|
.finally(() => message.close());
|
|
@@ -1338,7 +1318,7 @@ class ZLinkChannelSocketRegistry {
|
|
|
1338
1318
|
router.peerWeight = rawAvailabilityWeight(weight);
|
|
1339
1319
|
}
|
|
1340
1320
|
registerReceiveFlowSocket(socket) {
|
|
1341
|
-
this.applicationJobQueue?.registerReceiveFlowTarget(socket, (state) => socket.setReceiveFlowState(state === 'paused' ?
|
|
1321
|
+
this.applicationJobQueue?.registerReceiveFlowTarget(socket, (state) => socket.setReceiveFlowState(state === 'paused' ? zlink_1.ReceiveFlowState.PAUSED : zlink_1.ReceiveFlowState.RUNNING), this.oneWayFailureSink);
|
|
1342
1322
|
}
|
|
1343
1323
|
unregisterReceiveFlowSocket(socket) {
|
|
1344
1324
|
this.applicationJobQueue?.unregisterReceiveFlowTarget(socket);
|
|
@@ -1463,7 +1443,7 @@ function deriveRoutingId(baseRoutingId, suffix) {
|
|
|
1463
1443
|
}
|
|
1464
1444
|
function applyFanoutPublisherSocketOptions(publisher, channel) {
|
|
1465
1445
|
publisher.noDrop = channel.noDrop ?? false;
|
|
1466
|
-
publisher.sendTimeoutMs =
|
|
1446
|
+
publisher.sendTimeoutMs = channel.sendTimeoutMs ?? DEFAULT_SEND_TIMEOUT_MS;
|
|
1467
1447
|
}
|
|
1468
1448
|
function fanoutDiscoveryConnectionId(connectionId) {
|
|
1469
1449
|
return `fanout:${connectionId.replaceAll('\0', '/')}`;
|
|
@@ -1506,6 +1486,3 @@ function applySocketConfig(socket, config) {
|
|
|
1506
1486
|
socket.maxMessageSize = config.maxMessageSize;
|
|
1507
1487
|
}
|
|
1508
1488
|
}
|
|
1509
|
-
function configuredSendTimeoutMs(value) {
|
|
1510
|
-
return value ?? DEFAULT_SEND_TIMEOUT_MS;
|
|
1511
|
-
}
|
|
@@ -10,6 +10,7 @@ export interface ZLinkDiagnosticsContext {
|
|
|
10
10
|
readonly sourceMeshGeneration: bigint;
|
|
11
11
|
}
|
|
12
12
|
export declare const DEFAULT_ZLINK_DIAGNOSTICS: ZLinkDiagnosticsOptions;
|
|
13
|
+
export declare const telemetryLogger: import("@opentelemetry/api-logs").Logger;
|
|
13
14
|
export declare function effectiveMessageFlow(ctx: ZLinkDiagnosticsContext): ZLinkMessageFlowLogMode;
|
|
14
15
|
export declare function createMessageFlowModeCell(dispatch: {
|
|
15
16
|
diagnostics?: ZLinkDiagnosticsOptions;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ZLinkMessageFlowTracer = exports.DEFAULT_ZLINK_DIAGNOSTICS = void 0;
|
|
3
|
+
exports.ZLinkMessageFlowTracer = exports.telemetryLogger = exports.DEFAULT_ZLINK_DIAGNOSTICS = void 0;
|
|
4
4
|
exports.effectiveMessageFlow = effectiveMessageFlow;
|
|
5
5
|
exports.createMessageFlowModeCell = createMessageFlowModeCell;
|
|
6
6
|
exports.createDiagnosticsContext = createDiagnosticsContext;
|
|
@@ -18,7 +18,7 @@ exports.DEFAULT_ZLINK_DIAGNOSTICS = {
|
|
|
18
18
|
sampleRate: 1,
|
|
19
19
|
includeMessageSizes: false
|
|
20
20
|
};
|
|
21
|
-
|
|
21
|
+
exports.telemetryLogger = api_logs_1.logs.getLogger('@zlink-systems/framework');
|
|
22
22
|
const telemetryTracer = api_1.trace.getTracer('@zlink-systems/framework');
|
|
23
23
|
let diagnosticsGeneration = 0n;
|
|
24
24
|
function effectiveMessageFlow(ctx) {
|
|
@@ -165,7 +165,7 @@ class ZLinkMessageFlowTracer {
|
|
|
165
165
|
publishToLogger(record) {
|
|
166
166
|
try {
|
|
167
167
|
const severityNumber = record.eventId === DISPATCH_ERROR_EVENT_ID ? api_logs_1.SeverityNumber.ERROR : api_logs_1.SeverityNumber.INFO;
|
|
168
|
-
telemetryLogger.emit({
|
|
168
|
+
exports.telemetryLogger.emit({
|
|
169
169
|
eventName: record.eventId,
|
|
170
170
|
timestamp: record.timestamp,
|
|
171
171
|
severityNumber,
|
|
@@ -29,6 +29,8 @@ export interface RawServiceIngressRecord {
|
|
|
29
29
|
}
|
|
30
30
|
export type RawServiceIngressHandler = (record: RawServiceIngressRecord) => RawServicePumpResult | undefined | Promise<RawServicePumpResult | undefined>;
|
|
31
31
|
export interface RawServiceMeshRuntimeOptions {
|
|
32
|
+
readonly onReceiveReady?: () => void;
|
|
33
|
+
readonly infrastructureTaskRunner?: import('../spots/spot-actor-join-dispatch').ZLinkDetachedTaskRunner;
|
|
32
34
|
readonly onPendingOperationsChanged?: () => void;
|
|
33
35
|
readonly descriptor: ServiceNodeDescriptor;
|
|
34
36
|
readonly resolveAdvertisedEndpoint?: (boundEndpoint: string) => string;
|
|
@@ -70,6 +72,12 @@ export declare class RawServiceMeshRuntime {
|
|
|
70
72
|
private readonly applicationJobQueue;
|
|
71
73
|
private readonly peerAdmissionSealed?;
|
|
72
74
|
private readonly applicationJobStop;
|
|
75
|
+
private receiveAcquisition?;
|
|
76
|
+
private receivePermit?;
|
|
77
|
+
private readonly controlSends;
|
|
78
|
+
private infrastructureFailure?;
|
|
79
|
+
private readonly onReceiveReady?;
|
|
80
|
+
private readonly infrastructureTaskRunner?;
|
|
73
81
|
private readonly onPeerNotRequired?;
|
|
74
82
|
private readonly onPeerDisconnected?;
|
|
75
83
|
private readonly onProtocolError?;
|
|
@@ -123,7 +131,7 @@ export declare class RawServiceMeshRuntime {
|
|
|
123
131
|
private processReceived;
|
|
124
132
|
expireOperations(nowMs: number, turnDeadlineMs: number): number;
|
|
125
133
|
get pendingOperationCount(): number;
|
|
126
|
-
tickLiveness(nowMs?: number):
|
|
134
|
+
tickLiveness(nowMs?: number): ServiceLivenessTick;
|
|
127
135
|
/**
|
|
128
136
|
* The socket's one route observer (Core ROUTER §10.1). It replaces the
|
|
129
137
|
* observation with Core's selected-route snapshot, ends the admission of
|
|
@@ -144,6 +152,12 @@ export declare class RawServiceMeshRuntime {
|
|
|
144
152
|
private selectBilateralConnection;
|
|
145
153
|
private removePeer;
|
|
146
154
|
private requireStarted;
|
|
155
|
+
private sendControl;
|
|
156
|
+
private submitControl;
|
|
157
|
+
private startControlSend;
|
|
158
|
+
private reportInfrastructureFailure;
|
|
159
|
+
private observeInfrastructureFailure;
|
|
147
160
|
private send;
|
|
161
|
+
private sendFailure;
|
|
148
162
|
}
|
|
149
163
|
export {};
|