wsp-ms-core 1.0.78-beta-3 → 1.0.78-beta-5

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.cjs CHANGED
@@ -36,7 +36,7 @@ __export(src_exports, {
36
36
  Country: () => Country,
37
37
  Currency: () => Currency,
38
38
  DateTime: () => DateTime,
39
- DefaultOutboxRunner: () => DefaultOutboxRunner,
39
+ DefaultMysqlOutboxRunner: () => DefaultMysqlOutboxRunner,
40
40
  DomainEntity: () => DomainEntity,
41
41
  DomainError: () => DomainError,
42
42
  DomainEvent: () => DomainEvent,
@@ -1662,11 +1662,11 @@ var MysqlConnection = class {
1662
1662
  }
1663
1663
  };
1664
1664
 
1665
- // src/infrastructure/runners/default-outbox-runner.ts
1666
- var DefaultOutboxRunner = class {
1667
- constructor(uowFactory, eventBusRepository, eventManager) {
1665
+ // src/infrastructure/runners/default-mysql-outbox-runner.ts
1666
+ var DefaultMysqlOutboxRunner = class {
1667
+ constructor(uowFactory, eventManager) {
1668
+ this.errors = [];
1668
1669
  this.uowFactory = uowFactory;
1669
- this.eventBusRepository = eventBusRepository;
1670
1670
  this.eventManager = eventManager;
1671
1671
  this.interval = Number(process.env.OUTBOX_RUNNER_INTERVAL_MS || 5e3);
1672
1672
  this.maxEvents = Number(process.env.OUTBOX_RUNNER_MAX_EVENTS || 20);
@@ -1683,10 +1683,10 @@ var DefaultOutboxRunner = class {
1683
1683
  async sleep() {
1684
1684
  return new Promise((r) => setTimeout(r, this.maxEvents));
1685
1685
  }
1686
- async processOutboxRecord(e) {
1686
+ async processOutboxRecord(e, eventBusRepository) {
1687
1687
  try {
1688
1688
  e.markProcessing();
1689
- await this.eventBusRepository.update(e);
1689
+ await eventBusRepository.update(e);
1690
1690
  await this.eventManager.send(e.topic, e.payload);
1691
1691
  e.markProcessed();
1692
1692
  } catch (error) {
@@ -1694,16 +1694,17 @@ var DefaultOutboxRunner = class {
1694
1694
  e.markWithError(type);
1695
1695
  throw new Error(type);
1696
1696
  } finally {
1697
- await this.eventBusRepository.update(e);
1697
+ await eventBusRepository.update(e);
1698
1698
  }
1699
1699
  }
1700
1700
  async process() {
1701
1701
  const uow = await this.uowFactory.create();
1702
+ const eventBusRepository = new EventBusMysqlRepository(uow.connection);
1702
1703
  await uow.execute(async () => {
1703
- const records = await this.eventBusRepository.listPending(this.maxEvents);
1704
+ const records = await eventBusRepository.listPending(this.maxEvents);
1704
1705
  for (let record of records) {
1705
1706
  try {
1706
- await this.processOutboxRecord(record);
1707
+ await this.processOutboxRecord(record, eventBusRepository);
1707
1708
  } catch (error) {
1708
1709
  this.addError({ eventUuid: record.eventUuid.value, error: error.toString() });
1709
1710
  }
@@ -1780,7 +1781,7 @@ var ExchangeRates = class _ExchangeRates extends BaseObject {
1780
1781
  Country,
1781
1782
  Currency,
1782
1783
  DateTime,
1783
- DefaultOutboxRunner,
1784
+ DefaultMysqlOutboxRunner,
1784
1785
  DomainEntity,
1785
1786
  DomainError,
1786
1787
  DomainEvent,