@cadenza.io/service 2.17.6 → 2.17.7
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/browser/index.js +81 -1
- package/dist/browser/index.js.map +1 -1
- package/dist/browser/index.mjs +81 -1
- package/dist/browser/index.mjs.map +1 -1
- package/dist/index.d.mts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +81 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +81 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/browser/index.js
CHANGED
|
@@ -1294,9 +1294,23 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
1294
1294
|
(ctx, emit) => {
|
|
1295
1295
|
const { serviceName, serviceInstanceId } = ctx;
|
|
1296
1296
|
const serviceInstances = this.instances.get(serviceName);
|
|
1297
|
-
|
|
1297
|
+
let instance = serviceInstances?.find(
|
|
1298
1298
|
(i) => i.uuid === serviceInstanceId
|
|
1299
1299
|
);
|
|
1300
|
+
if (!instance && serviceName && serviceInstanceId) {
|
|
1301
|
+
const bootstrapPlaceholder = serviceInstances?.find(
|
|
1302
|
+
(candidate) => candidate.isBootstrapPlaceholder && (!ctx.serviceTransportId || candidate.transports.some(
|
|
1303
|
+
(transport) => transport.uuid === ctx.serviceTransportId
|
|
1304
|
+
))
|
|
1305
|
+
);
|
|
1306
|
+
if (bootstrapPlaceholder) {
|
|
1307
|
+
instance = this.adoptBootstrapPlaceholderInstanceId(
|
|
1308
|
+
serviceName,
|
|
1309
|
+
bootstrapPlaceholder.uuid,
|
|
1310
|
+
serviceInstanceId
|
|
1311
|
+
);
|
|
1312
|
+
}
|
|
1313
|
+
}
|
|
1300
1314
|
if (!instance) {
|
|
1301
1315
|
return false;
|
|
1302
1316
|
}
|
|
@@ -2568,6 +2582,72 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
2568
2582
|
instances.filter((instance) => !instance.isBootstrapPlaceholder)
|
|
2569
2583
|
);
|
|
2570
2584
|
}
|
|
2585
|
+
adoptBootstrapPlaceholderInstanceId(serviceName, placeholderInstanceId, resolvedInstanceId) {
|
|
2586
|
+
if (!serviceName || !placeholderInstanceId || !resolvedInstanceId) {
|
|
2587
|
+
return void 0;
|
|
2588
|
+
}
|
|
2589
|
+
const instances = this.instances.get(serviceName);
|
|
2590
|
+
if (!instances?.length) {
|
|
2591
|
+
return void 0;
|
|
2592
|
+
}
|
|
2593
|
+
const resolvedInstance = instances.find(
|
|
2594
|
+
(instance) => instance.uuid === resolvedInstanceId
|
|
2595
|
+
);
|
|
2596
|
+
if (resolvedInstance) {
|
|
2597
|
+
return resolvedInstance;
|
|
2598
|
+
}
|
|
2599
|
+
const placeholder = instances.find(
|
|
2600
|
+
(instance) => instance.uuid === placeholderInstanceId && instance.isBootstrapPlaceholder
|
|
2601
|
+
);
|
|
2602
|
+
if (!placeholder) {
|
|
2603
|
+
return void 0;
|
|
2604
|
+
}
|
|
2605
|
+
const wasDependee = this.dependeeByInstance.has(placeholderInstanceId);
|
|
2606
|
+
const dependeeServiceName = this.dependeeByInstance.get(placeholderInstanceId) ?? serviceName;
|
|
2607
|
+
const requiredForReadiness = this.readinessDependeeByInstance.has(
|
|
2608
|
+
placeholderInstanceId
|
|
2609
|
+
);
|
|
2610
|
+
const lastHeartbeatAt = this.lastHeartbeatAtByInstance.get(placeholderInstanceId) ?? Date.now();
|
|
2611
|
+
const missedHeartbeats = this.missedHeartbeatsByInstance.get(placeholderInstanceId) ?? 0;
|
|
2612
|
+
const inFlight = this.runtimeStatusFallbackInFlightByInstance.has(
|
|
2613
|
+
placeholderInstanceId
|
|
2614
|
+
);
|
|
2615
|
+
this.dependeeByInstance.delete(placeholderInstanceId);
|
|
2616
|
+
this.readinessDependeeByInstance.delete(placeholderInstanceId);
|
|
2617
|
+
this.lastHeartbeatAtByInstance.delete(placeholderInstanceId);
|
|
2618
|
+
this.missedHeartbeatsByInstance.delete(placeholderInstanceId);
|
|
2619
|
+
this.runtimeStatusFallbackInFlightByInstance.delete(placeholderInstanceId);
|
|
2620
|
+
placeholder.uuid = resolvedInstanceId;
|
|
2621
|
+
placeholder.isBootstrapPlaceholder = false;
|
|
2622
|
+
placeholder.transports = placeholder.transports.map((transport) => ({
|
|
2623
|
+
...transport,
|
|
2624
|
+
serviceInstanceId: resolvedInstanceId
|
|
2625
|
+
}));
|
|
2626
|
+
if (wasDependee) {
|
|
2627
|
+
this.dependeeByInstance.set(resolvedInstanceId, dependeeServiceName);
|
|
2628
|
+
if (this.dependeesByService.has(dependeeServiceName)) {
|
|
2629
|
+
this.dependeesByService.get(dependeeServiceName).delete(
|
|
2630
|
+
placeholderInstanceId
|
|
2631
|
+
);
|
|
2632
|
+
this.dependeesByService.get(dependeeServiceName).add(resolvedInstanceId);
|
|
2633
|
+
}
|
|
2634
|
+
this.lastHeartbeatAtByInstance.set(resolvedInstanceId, lastHeartbeatAt);
|
|
2635
|
+
this.missedHeartbeatsByInstance.set(resolvedInstanceId, missedHeartbeats);
|
|
2636
|
+
}
|
|
2637
|
+
if (requiredForReadiness) {
|
|
2638
|
+
this.readinessDependeeByInstance.set(resolvedInstanceId, serviceName);
|
|
2639
|
+
if (this.readinessDependeesByService.has(serviceName)) {
|
|
2640
|
+
this.readinessDependeesByService.get(serviceName).delete(
|
|
2641
|
+
placeholderInstanceId
|
|
2642
|
+
);
|
|
2643
|
+
this.readinessDependeesByService.get(serviceName).add(resolvedInstanceId);
|
|
2644
|
+
}
|
|
2645
|
+
}
|
|
2646
|
+
if (inFlight) {
|
|
2647
|
+
this.runtimeStatusFallbackInFlightByInstance.add(resolvedInstanceId);
|
|
2648
|
+
}
|
|
2649
|
+
return placeholder;
|
|
2650
|
+
}
|
|
2571
2651
|
getHeartbeatMisses(serviceInstanceId, now = Date.now()) {
|
|
2572
2652
|
const observedMisses = this.missedHeartbeatsByInstance.get(serviceInstanceId) ?? 0;
|
|
2573
2653
|
const lastHeartbeatAt = this.lastHeartbeatAtByInstance.get(serviceInstanceId) ?? 0;
|