@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.mjs
CHANGED
|
@@ -1243,9 +1243,23 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
1243
1243
|
(ctx, emit) => {
|
|
1244
1244
|
const { serviceName, serviceInstanceId } = ctx;
|
|
1245
1245
|
const serviceInstances = this.instances.get(serviceName);
|
|
1246
|
-
|
|
1246
|
+
let instance = serviceInstances?.find(
|
|
1247
1247
|
(i) => i.uuid === serviceInstanceId
|
|
1248
1248
|
);
|
|
1249
|
+
if (!instance && serviceName && serviceInstanceId) {
|
|
1250
|
+
const bootstrapPlaceholder = serviceInstances?.find(
|
|
1251
|
+
(candidate) => candidate.isBootstrapPlaceholder && (!ctx.serviceTransportId || candidate.transports.some(
|
|
1252
|
+
(transport) => transport.uuid === ctx.serviceTransportId
|
|
1253
|
+
))
|
|
1254
|
+
);
|
|
1255
|
+
if (bootstrapPlaceholder) {
|
|
1256
|
+
instance = this.adoptBootstrapPlaceholderInstanceId(
|
|
1257
|
+
serviceName,
|
|
1258
|
+
bootstrapPlaceholder.uuid,
|
|
1259
|
+
serviceInstanceId
|
|
1260
|
+
);
|
|
1261
|
+
}
|
|
1262
|
+
}
|
|
1249
1263
|
if (!instance) {
|
|
1250
1264
|
return false;
|
|
1251
1265
|
}
|
|
@@ -2517,6 +2531,72 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
2517
2531
|
instances.filter((instance) => !instance.isBootstrapPlaceholder)
|
|
2518
2532
|
);
|
|
2519
2533
|
}
|
|
2534
|
+
adoptBootstrapPlaceholderInstanceId(serviceName, placeholderInstanceId, resolvedInstanceId) {
|
|
2535
|
+
if (!serviceName || !placeholderInstanceId || !resolvedInstanceId) {
|
|
2536
|
+
return void 0;
|
|
2537
|
+
}
|
|
2538
|
+
const instances = this.instances.get(serviceName);
|
|
2539
|
+
if (!instances?.length) {
|
|
2540
|
+
return void 0;
|
|
2541
|
+
}
|
|
2542
|
+
const resolvedInstance = instances.find(
|
|
2543
|
+
(instance) => instance.uuid === resolvedInstanceId
|
|
2544
|
+
);
|
|
2545
|
+
if (resolvedInstance) {
|
|
2546
|
+
return resolvedInstance;
|
|
2547
|
+
}
|
|
2548
|
+
const placeholder = instances.find(
|
|
2549
|
+
(instance) => instance.uuid === placeholderInstanceId && instance.isBootstrapPlaceholder
|
|
2550
|
+
);
|
|
2551
|
+
if (!placeholder) {
|
|
2552
|
+
return void 0;
|
|
2553
|
+
}
|
|
2554
|
+
const wasDependee = this.dependeeByInstance.has(placeholderInstanceId);
|
|
2555
|
+
const dependeeServiceName = this.dependeeByInstance.get(placeholderInstanceId) ?? serviceName;
|
|
2556
|
+
const requiredForReadiness = this.readinessDependeeByInstance.has(
|
|
2557
|
+
placeholderInstanceId
|
|
2558
|
+
);
|
|
2559
|
+
const lastHeartbeatAt = this.lastHeartbeatAtByInstance.get(placeholderInstanceId) ?? Date.now();
|
|
2560
|
+
const missedHeartbeats = this.missedHeartbeatsByInstance.get(placeholderInstanceId) ?? 0;
|
|
2561
|
+
const inFlight = this.runtimeStatusFallbackInFlightByInstance.has(
|
|
2562
|
+
placeholderInstanceId
|
|
2563
|
+
);
|
|
2564
|
+
this.dependeeByInstance.delete(placeholderInstanceId);
|
|
2565
|
+
this.readinessDependeeByInstance.delete(placeholderInstanceId);
|
|
2566
|
+
this.lastHeartbeatAtByInstance.delete(placeholderInstanceId);
|
|
2567
|
+
this.missedHeartbeatsByInstance.delete(placeholderInstanceId);
|
|
2568
|
+
this.runtimeStatusFallbackInFlightByInstance.delete(placeholderInstanceId);
|
|
2569
|
+
placeholder.uuid = resolvedInstanceId;
|
|
2570
|
+
placeholder.isBootstrapPlaceholder = false;
|
|
2571
|
+
placeholder.transports = placeholder.transports.map((transport) => ({
|
|
2572
|
+
...transport,
|
|
2573
|
+
serviceInstanceId: resolvedInstanceId
|
|
2574
|
+
}));
|
|
2575
|
+
if (wasDependee) {
|
|
2576
|
+
this.dependeeByInstance.set(resolvedInstanceId, dependeeServiceName);
|
|
2577
|
+
if (this.dependeesByService.has(dependeeServiceName)) {
|
|
2578
|
+
this.dependeesByService.get(dependeeServiceName).delete(
|
|
2579
|
+
placeholderInstanceId
|
|
2580
|
+
);
|
|
2581
|
+
this.dependeesByService.get(dependeeServiceName).add(resolvedInstanceId);
|
|
2582
|
+
}
|
|
2583
|
+
this.lastHeartbeatAtByInstance.set(resolvedInstanceId, lastHeartbeatAt);
|
|
2584
|
+
this.missedHeartbeatsByInstance.set(resolvedInstanceId, missedHeartbeats);
|
|
2585
|
+
}
|
|
2586
|
+
if (requiredForReadiness) {
|
|
2587
|
+
this.readinessDependeeByInstance.set(resolvedInstanceId, serviceName);
|
|
2588
|
+
if (this.readinessDependeesByService.has(serviceName)) {
|
|
2589
|
+
this.readinessDependeesByService.get(serviceName).delete(
|
|
2590
|
+
placeholderInstanceId
|
|
2591
|
+
);
|
|
2592
|
+
this.readinessDependeesByService.get(serviceName).add(resolvedInstanceId);
|
|
2593
|
+
}
|
|
2594
|
+
}
|
|
2595
|
+
if (inFlight) {
|
|
2596
|
+
this.runtimeStatusFallbackInFlightByInstance.add(resolvedInstanceId);
|
|
2597
|
+
}
|
|
2598
|
+
return placeholder;
|
|
2599
|
+
}
|
|
2520
2600
|
getHeartbeatMisses(serviceInstanceId, now = Date.now()) {
|
|
2521
2601
|
const observedMisses = this.missedHeartbeatsByInstance.get(serviceInstanceId) ?? 0;
|
|
2522
2602
|
const lastHeartbeatAt = this.lastHeartbeatAtByInstance.get(serviceInstanceId) ?? 0;
|