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.d.ts CHANGED
@@ -579,14 +579,13 @@ declare class MysqlConnection implements DatabaseConnection<string, any[], RowDa
579
579
  close(): Promise<void>;
580
580
  }
581
581
 
582
- declare class DefaultOutboxRunner {
582
+ declare class DefaultMysqlOutboxRunner {
583
583
  private readonly uowFactory;
584
- private readonly eventBusRepository;
585
584
  private readonly eventManager;
586
585
  private readonly interval;
587
586
  private readonly maxEvents;
588
587
  private errors;
589
- constructor(uowFactory: BasicUnitOfWorkFactory, eventBusRepository: EventBusRepository, eventManager: EventManager);
588
+ constructor(uowFactory: BasicUnitOfWorkFactory, eventManager: EventManager);
590
589
  private addError;
591
590
  private logErrors;
592
591
  private sleep;
@@ -619,4 +618,4 @@ declare class StringVars {
619
618
  }): string;
620
619
  }
621
620
 
622
- export { BaseEntity, BaseEvent, BaseObject, BasicUnitOfWork, BasicUnitOfWorkFactory, Country, Currency, DatabaseConnection, DatabaseConnector, DateTime, DefaultOutboxRunner, DomainEntity, DomainError, DomainEvent, Email, ErrorManager, ErrorManagerHandleResult, ErrorTemplate, EventBus, EventBusMysqlRepository, EventBusRepository, EventManager, EventManagerConnection, ExchangeRates, FatalError, HttpController, HttpHealthCheckController, HttpNotFoundController, HttpRequest, HttpResponse, IntegrationEvent, InternalError, KafkaManager, Language, Logger, MysqlConnection, MysqlConnector, OutboxRecord, PaymentGateway, PaymentStatus, Price, ProcessStatus, RouteCallback, RoutesCallbackList, StringVars, UUID, UnitOfWork, UploadedFile, UsageError, ValueObject, adaptExpressErrorHandler, adaptExpressRoute };
621
+ export { BaseEntity, BaseEvent, BaseObject, BasicUnitOfWork, BasicUnitOfWorkFactory, Country, Currency, DatabaseConnection, DatabaseConnector, DateTime, DefaultMysqlOutboxRunner, DomainEntity, DomainError, DomainEvent, Email, ErrorManager, ErrorManagerHandleResult, ErrorTemplate, EventBus, EventBusMysqlRepository, EventBusRepository, EventManager, EventManagerConnection, ExchangeRates, FatalError, HttpController, HttpHealthCheckController, HttpNotFoundController, HttpRequest, HttpResponse, IntegrationEvent, InternalError, KafkaManager, Language, Logger, MysqlConnection, MysqlConnector, OutboxRecord, PaymentGateway, PaymentStatus, Price, ProcessStatus, RouteCallback, RoutesCallbackList, StringVars, UUID, UnitOfWork, UploadedFile, UsageError, ValueObject, adaptExpressErrorHandler, adaptExpressRoute };
package/dist/index.js CHANGED
@@ -1591,11 +1591,11 @@ var MysqlConnection = class {
1591
1591
  }
1592
1592
  };
1593
1593
 
1594
- // src/infrastructure/runners/default-outbox-runner.ts
1595
- var DefaultOutboxRunner = class {
1596
- constructor(uowFactory, eventBusRepository, eventManager) {
1594
+ // src/infrastructure/runners/default-mysql-outbox-runner.ts
1595
+ var DefaultMysqlOutboxRunner = class {
1596
+ constructor(uowFactory, eventManager) {
1597
+ this.errors = [];
1597
1598
  this.uowFactory = uowFactory;
1598
- this.eventBusRepository = eventBusRepository;
1599
1599
  this.eventManager = eventManager;
1600
1600
  this.interval = Number(process.env.OUTBOX_RUNNER_INTERVAL_MS || 5e3);
1601
1601
  this.maxEvents = Number(process.env.OUTBOX_RUNNER_MAX_EVENTS || 20);
@@ -1612,10 +1612,10 @@ var DefaultOutboxRunner = class {
1612
1612
  async sleep() {
1613
1613
  return new Promise((r) => setTimeout(r, this.maxEvents));
1614
1614
  }
1615
- async processOutboxRecord(e) {
1615
+ async processOutboxRecord(e, eventBusRepository) {
1616
1616
  try {
1617
1617
  e.markProcessing();
1618
- await this.eventBusRepository.update(e);
1618
+ await eventBusRepository.update(e);
1619
1619
  await this.eventManager.send(e.topic, e.payload);
1620
1620
  e.markProcessed();
1621
1621
  } catch (error) {
@@ -1623,16 +1623,17 @@ var DefaultOutboxRunner = class {
1623
1623
  e.markWithError(type);
1624
1624
  throw new Error(type);
1625
1625
  } finally {
1626
- await this.eventBusRepository.update(e);
1626
+ await eventBusRepository.update(e);
1627
1627
  }
1628
1628
  }
1629
1629
  async process() {
1630
1630
  const uow = await this.uowFactory.create();
1631
+ const eventBusRepository = new EventBusMysqlRepository(uow.connection);
1631
1632
  await uow.execute(async () => {
1632
- const records = await this.eventBusRepository.listPending(this.maxEvents);
1633
+ const records = await eventBusRepository.listPending(this.maxEvents);
1633
1634
  for (let record of records) {
1634
1635
  try {
1635
- await this.processOutboxRecord(record);
1636
+ await this.processOutboxRecord(record, eventBusRepository);
1636
1637
  } catch (error) {
1637
1638
  this.addError({ eventUuid: record.eventUuid.value, error: error.toString() });
1638
1639
  }
@@ -1708,7 +1709,7 @@ export {
1708
1709
  Country,
1709
1710
  Currency,
1710
1711
  DateTime,
1711
- DefaultOutboxRunner,
1712
+ DefaultMysqlOutboxRunner,
1712
1713
  DomainEntity,
1713
1714
  DomainError,
1714
1715
  DomainEvent,