wsp-ms-core 1.0.94 → 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.cjs +12 -8
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +2 -17
- package/dist/index.d.ts +2 -17
- package/dist/index.js +12 -8
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
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
|
|
656
|
+
private uovFactory;
|
|
672
657
|
private handlers;
|
|
673
|
-
constructor(
|
|
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
|
|
656
|
+
private uovFactory;
|
|
672
657
|
private handlers;
|
|
673
|
-
constructor(
|
|
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
|
@@ -1582,7 +1582,7 @@ var KafkaManager = class extends EventManager {
|
|
|
1582
1582
|
await this.execCallback(this._onMessage, `[New message detected for ${topic}]: ${message.value?.toString()}`);
|
|
1583
1583
|
const json = JSON.parse(String(message.value?.toString()));
|
|
1584
1584
|
await this.execRoute(topic, {
|
|
1585
|
-
topic: String(
|
|
1585
|
+
topic: String(topic),
|
|
1586
1586
|
producer: String(json.producer),
|
|
1587
1587
|
tenant: UUID.create(String(json.tenant)),
|
|
1588
1588
|
message: json.data
|
|
@@ -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(
|
|
1890
|
-
this.
|
|
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
|
|
1900
|
-
|
|
1901
|
-
|
|
1902
|
-
|
|
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");
|