wsp-ms-core 1.0.95 → 1.0.96

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
@@ -651,26 +651,11 @@ declare class DefaultMysqlInboxRunner {
651
651
  start(): Promise<void>;
652
652
  }
653
653
 
654
- interface InboxRepository {
655
- create(event: InboxRecord): Promise<void>;
656
- update(event: InboxRecord): Promise<void>;
657
- listPending(limit: number): Promise<InboxRecord[]>;
658
- }
659
-
660
- declare class InboxMysqlRepository implements InboxRepository {
661
- private readonly connection;
662
- constructor(connection: DatabaseConnection);
663
- private recordToRowValues;
664
- create(record: InboxRecord): Promise<void>;
665
- update(record: InboxRecord): Promise<void>;
666
- listPending(limit: number): Promise<InboxRecord[]>;
667
- }
668
-
669
654
  type InboxHandlerProcessor = (record: InboxRecord) => void;
670
655
  declare class DefaultMysqlInboxProcessor {
671
- private repository;
656
+ private uovFactory;
672
657
  private handlers;
673
- constructor(repository: InboxMysqlRepository);
658
+ constructor(uowFactory: BasicUnitOfWorkFactory);
674
659
  private sleep;
675
660
  addHandlerForTopic(topic: string, handler: InboxHandlerProcessor): void;
676
661
  processRecords(): Promise<void>;
package/dist/index.d.ts CHANGED
@@ -651,26 +651,11 @@ declare class DefaultMysqlInboxRunner {
651
651
  start(): Promise<void>;
652
652
  }
653
653
 
654
- interface InboxRepository {
655
- create(event: InboxRecord): Promise<void>;
656
- update(event: InboxRecord): Promise<void>;
657
- listPending(limit: number): Promise<InboxRecord[]>;
658
- }
659
-
660
- declare class InboxMysqlRepository implements InboxRepository {
661
- private readonly connection;
662
- constructor(connection: DatabaseConnection);
663
- private recordToRowValues;
664
- create(record: InboxRecord): Promise<void>;
665
- update(record: InboxRecord): Promise<void>;
666
- listPending(limit: number): Promise<InboxRecord[]>;
667
- }
668
-
669
654
  type InboxHandlerProcessor = (record: InboxRecord) => void;
670
655
  declare class DefaultMysqlInboxProcessor {
671
- private repository;
656
+ private uovFactory;
672
657
  private handlers;
673
- constructor(repository: InboxMysqlRepository);
658
+ constructor(uowFactory: BasicUnitOfWorkFactory);
674
659
  private sleep;
675
660
  addHandlerForTopic(topic: string, handler: InboxHandlerProcessor): void;
676
661
  processRecords(): Promise<void>;
package/dist/index.js CHANGED
@@ -1886,8 +1886,8 @@ var DefaultMysqlInboxRunner = class {
1886
1886
 
1887
1887
  // src/infrastructure/runners/default-mysql-inbox-processor.ts
1888
1888
  var DefaultMysqlInboxProcessor = class {
1889
- constructor(repository) {
1890
- this.repository = repository;
1889
+ constructor(uowFactory) {
1890
+ this.uovFactory = uowFactory;
1891
1891
  }
1892
1892
  async sleep() {
1893
1893
  return new Promise((r) => setTimeout(r, 5e3));
@@ -1896,12 +1896,16 @@ var DefaultMysqlInboxProcessor = class {
1896
1896
  this.handlers.set(topic, handler);
1897
1897
  }
1898
1898
  async processRecords() {
1899
- const records = await this.repository.listPending(20);
1900
- for (let record of records) {
1901
- if (this.handlers.has(record.topic)) {
1902
- await this.handlers.get(record.topic)(record);
1899
+ const uow = await this.uovFactory.create();
1900
+ const repository = new InboxMysqlRepository(uow.connection);
1901
+ await uow.execute(async () => {
1902
+ const records = await repository.listPending(20);
1903
+ for (let record of records) {
1904
+ if (this.handlers.has(record.topic)) {
1905
+ await this.handlers.get(record.topic)(record);
1906
+ }
1903
1907
  }
1904
- }
1908
+ });
1905
1909
  }
1906
1910
  async start() {
1907
1911
  console.log("[inbox-runner-processor]: start");