@cadenza.io/service 2.17.77 → 2.17.78

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/index.mjs CHANGED
@@ -762,6 +762,18 @@ function normalizeServiceRegistryInsertResult(tableName, ctx, queryData, rawResu
762
762
  }
763
763
  return result;
764
764
  }
765
+ function shouldTraceIotDbRegistryPath(localServiceName, targetServiceName) {
766
+ return targetServiceName === "IotDbService" && localServiceName !== "IotDbService";
767
+ }
768
+ function summarizeTransportDescriptors(transports) {
769
+ return transports.map((transport) => ({
770
+ uuid: transport.uuid,
771
+ serviceInstanceId: transport.serviceInstanceId,
772
+ role: transport.role,
773
+ origin: transport.origin,
774
+ protocols: transport.protocols
775
+ }));
776
+ }
765
777
  function resolveServiceRegistryInsertTask(tableName, queryData = {}, options = {}) {
766
778
  const remoteInsertTask = CadenzaService.createCadenzaDBInsertTask(
767
779
  tableName,
@@ -1152,6 +1164,21 @@ var ServiceRegistry = class _ServiceRegistry {
1152
1164
  trackedInstance.acceptingWork = snapshot.acceptingWork;
1153
1165
  trackedInstance.reportedAt = trackedInstance.reportedAt ?? (/* @__PURE__ */ new Date()).toISOString();
1154
1166
  }
1167
+ if (shouldTraceIotDbRegistryPath(this.serviceName, serviceName)) {
1168
+ console.log("[CADENZA_REGISTRY_DEBUG] handle_instance_update", {
1169
+ localServiceName: this.serviceName,
1170
+ localServiceInstanceId: this.serviceInstanceId,
1171
+ targetServiceName: serviceName,
1172
+ targetServiceInstanceId: uuid8,
1173
+ existingInstance: !!existing,
1174
+ deleted,
1175
+ remoteInterest: this.deputies.has(serviceName) || this.remoteIntents.has(serviceName) || this.remoteSignals.has(serviceName),
1176
+ hasDeputies: this.deputies.has(serviceName),
1177
+ hasRemoteIntents: this.remoteIntents.has(serviceName),
1178
+ hasRemoteSignals: this.remoteSignals.has(serviceName),
1179
+ transports: trackedInstance ? summarizeTransportDescriptors(trackedInstance.transports) : []
1180
+ });
1181
+ }
1155
1182
  if (!serviceInstance.isBootstrapPlaceholder) {
1156
1183
  this.reconcileBootstrapPlaceholderInstance(serviceName, uuid8, emit);
1157
1184
  }
@@ -1207,6 +1234,27 @@ var ServiceRegistry = class _ServiceRegistry {
1207
1234
  break;
1208
1235
  }
1209
1236
  }
1237
+ if (shouldTraceIotDbRegistryPath(
1238
+ this.serviceName,
1239
+ ownerInstance?.serviceName ?? ctx.serviceName ?? void 0
1240
+ )) {
1241
+ console.log("[CADENZA_REGISTRY_DEBUG] handle_transport_update", {
1242
+ localServiceName: this.serviceName,
1243
+ localServiceInstanceId: this.serviceInstanceId,
1244
+ transport: {
1245
+ uuid: transport.uuid,
1246
+ serviceInstanceId: transport.serviceInstanceId,
1247
+ role: transport.role,
1248
+ origin: transport.origin,
1249
+ protocols: transport.protocols,
1250
+ deleted: transport.deleted
1251
+ },
1252
+ ownerFound: !!ownerInstance,
1253
+ ownerServiceName: ownerInstance?.serviceName,
1254
+ ownerInstanceId: ownerInstance?.uuid,
1255
+ ownerTransports: ownerInstance ? summarizeTransportDescriptors(ownerInstance.transports) : []
1256
+ });
1257
+ }
1210
1258
  if (!ownerInstance) {
1211
1259
  return false;
1212
1260
  }
@@ -1621,6 +1669,44 @@ var ServiceRegistry = class _ServiceRegistry {
1621
1669
  let retries = __retries ?? 0;
1622
1670
  let triedInstances = __triedInstances ?? [];
1623
1671
  const preferredRole = this.getRoutingTransportRole();
1672
+ const allInstances = this.instances.get(__serviceName) ?? [];
1673
+ const candidateDiagnostics = shouldTraceIotDbRegistryPath(
1674
+ this.serviceName,
1675
+ __serviceName ?? void 0
1676
+ ) ? allInstances.map((instance) => ({
1677
+ uuid: instance.uuid,
1678
+ isActive: instance.isActive,
1679
+ isNonResponsive: instance.isNonResponsive,
1680
+ isBlocked: instance.isBlocked,
1681
+ isFrontend: instance.isFrontend,
1682
+ transports: summarizeTransportDescriptors(instance.transports),
1683
+ selectedTransport: instance.isFrontend ? null : this.selectTransportForInstance(
1684
+ instance,
1685
+ context,
1686
+ preferredRole
1687
+ ) ? {
1688
+ uuid: this.selectTransportForInstance(
1689
+ instance,
1690
+ context,
1691
+ preferredRole
1692
+ ).uuid,
1693
+ role: this.selectTransportForInstance(
1694
+ instance,
1695
+ context,
1696
+ preferredRole
1697
+ ).role,
1698
+ origin: this.selectTransportForInstance(
1699
+ instance,
1700
+ context,
1701
+ preferredRole
1702
+ ).origin,
1703
+ protocols: this.selectTransportForInstance(
1704
+ instance,
1705
+ context,
1706
+ preferredRole
1707
+ ).protocols
1708
+ } : null
1709
+ })) : void 0;
1624
1710
  const instances = this.instances.get(__serviceName)?.filter((instance) => {
1625
1711
  if (targetServiceInstanceId && instance.uuid !== targetServiceInstanceId) {
1626
1712
  return false;
@@ -1653,6 +1739,20 @@ var ServiceRegistry = class _ServiceRegistry {
1653
1739
  }
1654
1740
  return (a.numberOfRunningGraphs ?? 0) - (b.numberOfRunningGraphs ?? 0);
1655
1741
  });
1742
+ if (candidateDiagnostics) {
1743
+ console.log("[CADENZA_REGISTRY_DEBUG] get_balanced_instance", {
1744
+ localServiceName: this.serviceName,
1745
+ localServiceInstanceId: this.serviceInstanceId,
1746
+ targetServiceName: __serviceName,
1747
+ preferredRole,
1748
+ useSocket: this.useSocket,
1749
+ targetServiceInstanceId,
1750
+ retries,
1751
+ triedInstances,
1752
+ candidateDiagnostics,
1753
+ filteredInstanceIds: instances?.map((instance) => instance.uuid) ?? []
1754
+ });
1755
+ }
1656
1756
  if (!instances || instances.length === 0 || retries > this.retryCount) {
1657
1757
  context.errored = true;
1658
1758
  context.__error = this.isFrontend && preferredRole === "public" ? `No public transport available for ${__serviceName}.` : `No routeable ${preferredRole} transport available for ${__serviceName}. Retries: ${retries}.`;
@@ -2779,6 +2879,27 @@ var ServiceRegistry = class _ServiceRegistry {
2779
2879
  instance,
2780
2880
  this.useSocket ? "socket" : "rest"
2781
2881
  );
2882
+ if (shouldTraceIotDbRegistryPath(this.serviceName, instance.serviceName)) {
2883
+ console.log("[CADENZA_REGISTRY_DEBUG] ensure_dependee_client_for_instance", {
2884
+ localServiceName: this.serviceName,
2885
+ localServiceInstanceId: this.serviceInstanceId,
2886
+ targetServiceName: instance.serviceName,
2887
+ targetServiceInstanceId: instance.uuid,
2888
+ useSocket: this.useSocket,
2889
+ routeableRole: this.getRoutingTransportRole(),
2890
+ hasDeputies: this.deputies.has(instance.serviceName),
2891
+ hasRemoteIntents: this.remoteIntents.has(instance.serviceName),
2892
+ hasRemoteSignals: this.remoteSignals.has(instance.serviceName),
2893
+ clientCreatedTransportIds: instance.clientCreatedTransportIds ?? [],
2894
+ transports: summarizeTransportDescriptors(instance.transports),
2895
+ selectedTransport: transport ? {
2896
+ uuid: transport.uuid,
2897
+ role: transport.role,
2898
+ origin: transport.origin,
2899
+ protocols: transport.protocols
2900
+ } : null
2901
+ });
2902
+ }
2782
2903
  if (!transport || this.hasTransportClientCreated(instance, transport.uuid)) {
2783
2904
  return false;
2784
2905
  }