@furvester/upstream-sync 1.0.0 → 1.0.2

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/README.md CHANGED
@@ -1,5 +1,5 @@
1
1
  # Upstream Sync
2
2
 
3
- [![CI/CD](https://github.com/Furvester/upstream-sync/actions/workflows/cicd.yml/badge.svg)](https://github.com/Furvester/upstream-sync/actions/workflows/cicd.yml)
3
+ [![Release](https://github.com/Furvester/upstream-sync/actions/workflows/release.yml/badge.svg)](https://github.com/Furvester/upstream-sync/actions/workflows/release.yml)
4
4
 
5
5
  Sync from upstream via RabbitMQ.
package/dist/index.js CHANGED
@@ -87,12 +87,14 @@ export class SyncManager {
87
87
  for (const service of this.upstreamServices) {
88
88
  await this.waitReady(`/${service.serviceName}/health`, service.serviceName);
89
89
  for (const entity of service.entities) {
90
- await this.preSyncEntity(service, entity);
90
+ await this.config.orm.em.fork().transactional(async (em) => {
91
+ await this.preSyncEntity(em, service, entity);
92
+ });
93
+ this.config.logger.info(`Entity with routing key ${entity.routingKeyPrefix} pre-synced`);
91
94
  }
92
95
  }
93
96
  }
94
- async preSyncEntity(service, entity) {
95
- const em = this.config.orm.em.fork();
97
+ async preSyncEntity(em, service, entity) {
96
98
  const versions = new Map((await em
97
99
  .createQueryBuilder(entity.preSync.entityClass)
98
100
  .select(["id", "upstreamVersion"])
@@ -146,9 +148,10 @@ export class SyncManager {
146
148
  }
147
149
  }
148
150
  catch {
149
- this.config.logger.info("Unable to verify health, backing off");
150
- await new Promise((resolve) => setTimeout(resolve, 5000));
151
+ // Noop
151
152
  }
153
+ this.config.logger.info("Unable to verify health, backing off");
154
+ await new Promise((resolve) => setTimeout(resolve, 5000));
152
155
  }
153
156
  throw new Error(`Service "${serviceName}" didn't turn ready within 60 seconds`);
154
157
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@furvester/upstream-sync",
3
- "version": "1.0.0",
3
+ "version": "1.0.2",
4
4
  "description": "Sync from upstream via RabbitMQ",
5
5
  "type": "module",
6
6
  "author": "Ben Scholzen 'DASPRiD'",