wsp-ms-core 1.0.88 → 1.0.89

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.d.mts CHANGED
@@ -641,12 +641,10 @@ declare class DefaultMysqlOutboxRunner {
641
641
  }
642
642
 
643
643
  declare class DefaultMysqlInboxRunner {
644
- private readonly uowFactory;
644
+ private readonly databaseConnector;
645
645
  private readonly eventManager;
646
- private readonly interval;
647
- private readonly maxEvents;
648
646
  private topics;
649
- constructor(uowFactory: BasicUnitOfWorkFactory, eventManager: EventManager);
647
+ constructor(databaseConnector: DatabaseConnector, eventManager: EventManager);
650
648
  private saveEvent;
651
649
  subscribeTo(topic: string): void;
652
650
  private process;
package/dist/index.d.ts CHANGED
@@ -641,12 +641,10 @@ declare class DefaultMysqlOutboxRunner {
641
641
  }
642
642
 
643
643
  declare class DefaultMysqlInboxRunner {
644
- private readonly uowFactory;
644
+ private readonly databaseConnector;
645
645
  private readonly eventManager;
646
- private readonly interval;
647
- private readonly maxEvents;
648
646
  private topics;
649
- constructor(uowFactory: BasicUnitOfWorkFactory, eventManager: EventManager);
647
+ constructor(databaseConnector: DatabaseConnector, eventManager: EventManager);
650
648
  private saveEvent;
651
649
  subscribeTo(topic: string): void;
652
650
  private process;
package/dist/index.js CHANGED
@@ -1835,12 +1835,10 @@ var InboxMysqlRepository = class {
1835
1835
 
1836
1836
  // src/infrastructure/runners/default-mysql-inbox-runner.ts
1837
1837
  var DefaultMysqlInboxRunner = class {
1838
- constructor(uowFactory, eventManager) {
1838
+ constructor(databaseConnector, eventManager) {
1839
1839
  this.topics = [];
1840
- this.uowFactory = uowFactory;
1840
+ this.databaseConnector = databaseConnector;
1841
1841
  this.eventManager = eventManager;
1842
- this.interval = Number(process.env.OUTBOX_RUNNER_INTERVAL_MS || 5e3);
1843
- this.maxEvents = Number(process.env.OUTBOX_RUNNER_MAX_EVENTS || 20);
1844
1842
  }
1845
1843
  async saveEvent(e, repository) {
1846
1844
  let record = new InboxRecord(
@@ -1865,26 +1863,26 @@ var DefaultMysqlInboxRunner = class {
1865
1863
  this.topics.push(topic);
1866
1864
  }
1867
1865
  async process() {
1868
- const uow = await this.uowFactory.create();
1869
- const inboxRepository = new InboxMysqlRepository(uow.connection);
1870
- return await uow.execute(async () => {
1871
- for (let topic of this.topics) {
1872
- try {
1873
- this.eventManager.route(topic, async (e) => {
1874
- await this.saveEvent(e, inboxRepository);
1875
- });
1876
- } catch (error) {
1877
- console.log(error.toString());
1878
- }
1866
+ for (let topic of this.topics) {
1867
+ try {
1868
+ this.eventManager.onSubscribe((data) => {
1869
+ console.log(data);
1870
+ });
1871
+ this.eventManager.onMessage((data) => {
1872
+ console.log(data);
1873
+ });
1874
+ this.eventManager.route(topic, async (e) => {
1875
+ await this.saveEvent(e, new InboxMysqlRepository(await this.databaseConnector.getConnection()));
1876
+ });
1877
+ } catch (error) {
1878
+ console.log(error.toString());
1879
1879
  }
1880
- await this.eventManager.start();
1881
- });
1880
+ }
1881
+ await this.eventManager.start();
1882
1882
  }
1883
1883
  async start() {
1884
1884
  console.log("[inbox-runner]: start");
1885
- for (; ; ) {
1886
- await this.process();
1887
- }
1885
+ await this.process();
1888
1886
  }
1889
1887
  };
1890
1888