@cadenza.io/service 2.5.0 → 2.6.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/index.mjs CHANGED
@@ -314,6 +314,7 @@ function summarizeResponderStatuses(statuses) {
314
314
  }
315
315
 
316
316
  // src/registry/ServiceRegistry.ts
317
+ var META_SERVICE_REGISTRY_FULL_SYNC_INTENT = "meta-service-registry-full-sync";
317
318
  var ServiceRegistry = class _ServiceRegistry {
318
319
  /**
319
320
  * Initializes a private constructor for managing service instances, remote signals,
@@ -632,57 +633,58 @@ var ServiceRegistry = class _ServiceRegistry {
632
633
  },
633
634
  "Handles status update from socket broadcast"
634
635
  ).doOn("meta.socket_client.status_received");
635
- const mergeSyncDataTask = CadenzaService.createUniqueMetaTask(
636
- "Merge sync data",
637
- (ctx) => {
638
- let joinedContext = {};
639
- ctx.joinedContexts.forEach((ctx2) => {
640
- joinedContext = { ...joinedContext, ...ctx2 };
641
- });
642
- return joinedContext;
643
- }
644
- ).emits("meta.service_registry.initial_sync_complete").then(
636
+ this.fullSyncTask = CadenzaService.createMetaTask(
637
+ "Full sync",
638
+ async (ctx) => {
639
+ const inquiryResult = await CadenzaService.inquire(
640
+ META_SERVICE_REGISTRY_FULL_SYNC_INTENT,
641
+ {
642
+ syncScope: "service-registry-full-sync"
643
+ },
644
+ ctx.inquiryOptions ?? ctx.__inquiryOptions ?? {}
645
+ );
646
+ const signalToTaskMaps = (inquiryResult.signalToTaskMaps ?? []).filter((m) => !!m.isGlobal).map((m) => ({
647
+ signalName: m.signalName,
648
+ serviceName: m.serviceName,
649
+ deleted: !!m.deleted
650
+ }));
651
+ const intentToTaskMaps = (inquiryResult.intentToTaskMaps ?? []).map(
652
+ (m) => ({
653
+ intentName: m.intentName,
654
+ taskName: m.taskName,
655
+ taskVersion: m.taskVersion ?? 1,
656
+ serviceName: m.serviceName,
657
+ deleted: !!m.deleted
658
+ })
659
+ );
660
+ const serviceInstances = (inquiryResult.serviceInstances ?? []).filter(
661
+ (instance) => !instance.deleted && !!instance.isActive && !instance.isNonResponsive && !instance.isBlocked
662
+ ).map((instance) => ({
663
+ uuid: instance.uuid,
664
+ address: instance.address,
665
+ port: instance.port,
666
+ serviceName: instance.serviceName,
667
+ isActive: !!instance.isActive,
668
+ isNonResponsive: !!instance.isNonResponsive,
669
+ isBlocked: !!instance.isBlocked,
670
+ health: instance.health ?? {},
671
+ exposed: !!instance.exposed,
672
+ created: instance.created,
673
+ isFrontend: !!instance.isFrontend
674
+ }));
675
+ return {
676
+ ...ctx,
677
+ signalToTaskMaps,
678
+ intentToTaskMaps,
679
+ serviceInstances,
680
+ __inquiryMeta: inquiryResult.__inquiryMeta
681
+ };
682
+ },
683
+ "Runs service registry full sync through one distributed inquiry intent."
684
+ ).doOn("meta.sync_requested").emits("meta.service_registry.initial_sync_complete").then(
645
685
  this.handleGlobalSignalRegistrationTask,
646
686
  this.handleGlobalIntentRegistrationTask
647
687
  );
648
- this.fullSyncTask = CadenzaService.createMetaRoutine("Full sync", [
649
- CadenzaService.createCadenzaDBQueryTask("signal_to_task_map", {
650
- filter: {
651
- isGlobal: true
652
- },
653
- fields: ["signal_name", "service_name", "deleted"]
654
- }).then(mergeSyncDataTask),
655
- CadenzaService.createCadenzaDBQueryTask("intent_to_task_map", {
656
- fields: [
657
- "intent_name",
658
- "task_name",
659
- "task_version",
660
- "service_name",
661
- "deleted"
662
- ]
663
- }).then(mergeSyncDataTask),
664
- CadenzaService.createCadenzaDBQueryTask("service_instance", {
665
- filter: {
666
- deleted: false,
667
- is_active: true,
668
- is_non_responsive: false,
669
- is_blocked: false
670
- },
671
- fields: [
672
- "uuid",
673
- "address",
674
- "port",
675
- "service_name",
676
- "is_active",
677
- "is_non_responsive",
678
- "is_blocked",
679
- "health",
680
- "exposed",
681
- "created",
682
- "is_frontend"
683
- ]
684
- }).then(mergeSyncDataTask)
685
- ]).doOn("meta.sync_requested");
686
688
  this.getInstanceById = CadenzaService.createMetaTask(
687
689
  "Get instance by id",
688
690
  (context) => {