@cadenza.io/service 2.17.6 → 2.17.8
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 +92 -2
- package/dist/browser/index.js.map +1 -1
- package/dist/browser/index.mjs +92 -2
- 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 +92 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +92 -2
- 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;
|
|
@@ -6245,6 +6325,15 @@ function readConfiguredPort(value) {
|
|
|
6245
6325
|
function buildBootstrapUrl(protocol, address, port) {
|
|
6246
6326
|
return `${protocol}://${address}:${port}`;
|
|
6247
6327
|
}
|
|
6328
|
+
function readExplicitPortFromOrigin(raw) {
|
|
6329
|
+
const match = raw.match(
|
|
6330
|
+
/^[a-z]+:\/\/(?:\[[^\]]+\]|[^\/?#:]+):(\d+)(?:\/)?$/i
|
|
6331
|
+
);
|
|
6332
|
+
if (!match?.[1]) {
|
|
6333
|
+
return void 0;
|
|
6334
|
+
}
|
|
6335
|
+
return readConfiguredPort(match[1]);
|
|
6336
|
+
}
|
|
6248
6337
|
function resolveInjectedBootstrapUrl(injectedGlobalKey) {
|
|
6249
6338
|
if (typeof globalThis === "undefined") {
|
|
6250
6339
|
return void 0;
|
|
@@ -6334,7 +6423,8 @@ function resolveBootstrapEndpoint(options) {
|
|
|
6334
6423
|
"Bootstrap URL must be an origin without a path component."
|
|
6335
6424
|
);
|
|
6336
6425
|
}
|
|
6337
|
-
const
|
|
6426
|
+
const explicitPort = readExplicitPortFromOrigin(raw);
|
|
6427
|
+
const port2 = explicitPort ?? (parsed2.port ? readConfiguredPort(parsed2.port) : fallbackPort);
|
|
6338
6428
|
if (!port2) {
|
|
6339
6429
|
throw new Error(
|
|
6340
6430
|
"Bootstrap URL must include a port or CADENZA_DB_PORT must be provided."
|