wsp-ms-core 1.0.88 → 1.0.90
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 +30 -33
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +2 -4
- package/dist/index.d.ts +2 -4
- package/dist/index.js +30 -33
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
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
|
|
644
|
+
private readonly databaseConnector;
|
|
645
645
|
private readonly eventManager;
|
|
646
|
-
private readonly interval;
|
|
647
|
-
private readonly maxEvents;
|
|
648
646
|
private topics;
|
|
649
|
-
constructor(
|
|
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
|
|
644
|
+
private readonly databaseConnector;
|
|
645
645
|
private readonly eventManager;
|
|
646
|
-
private readonly interval;
|
|
647
|
-
private readonly maxEvents;
|
|
648
646
|
private topics;
|
|
649
|
-
constructor(
|
|
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,56 +1835,53 @@ var InboxMysqlRepository = class {
|
|
|
1835
1835
|
|
|
1836
1836
|
// src/infrastructure/runners/default-mysql-inbox-runner.ts
|
|
1837
1837
|
var DefaultMysqlInboxRunner = class {
|
|
1838
|
-
constructor(
|
|
1838
|
+
constructor(databaseConnector, eventManager) {
|
|
1839
1839
|
this.topics = [];
|
|
1840
|
-
this.
|
|
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
|
-
let record = new InboxRecord(
|
|
1847
|
-
UUID.create(),
|
|
1848
|
-
e.tenant,
|
|
1849
|
-
e.topic,
|
|
1850
|
-
e.producer,
|
|
1851
|
-
JSON.stringify(e.message),
|
|
1852
|
-
ProcessStatus.PENDING
|
|
1853
|
-
);
|
|
1854
1844
|
try {
|
|
1845
|
+
let record = new InboxRecord(
|
|
1846
|
+
UUID.create(),
|
|
1847
|
+
e.tenant,
|
|
1848
|
+
e.topic,
|
|
1849
|
+
e.producer,
|
|
1850
|
+
JSON.stringify(e.message),
|
|
1851
|
+
ProcessStatus.PENDING
|
|
1852
|
+
);
|
|
1855
1853
|
await repository.create(record);
|
|
1856
1854
|
} catch (error) {
|
|
1857
|
-
|
|
1858
|
-
record.markWithError(type);
|
|
1859
|
-
throw new Error(type);
|
|
1860
|
-
} finally {
|
|
1861
|
-
await repository.update(record);
|
|
1855
|
+
throw new Error(String(error.type));
|
|
1862
1856
|
}
|
|
1863
1857
|
}
|
|
1864
1858
|
subscribeTo(topic) {
|
|
1865
1859
|
this.topics.push(topic);
|
|
1866
1860
|
}
|
|
1867
1861
|
async process() {
|
|
1868
|
-
|
|
1869
|
-
|
|
1870
|
-
|
|
1871
|
-
|
|
1872
|
-
|
|
1873
|
-
|
|
1874
|
-
|
|
1875
|
-
|
|
1876
|
-
|
|
1877
|
-
console.log(
|
|
1878
|
-
}
|
|
1862
|
+
for (let topic of this.topics) {
|
|
1863
|
+
try {
|
|
1864
|
+
this.eventManager.onSubscribe((data) => {
|
|
1865
|
+
console.log(data);
|
|
1866
|
+
});
|
|
1867
|
+
this.eventManager.onMessage((data) => {
|
|
1868
|
+
console.log(data);
|
|
1869
|
+
});
|
|
1870
|
+
this.eventManager.onError((data) => {
|
|
1871
|
+
console.log(data);
|
|
1872
|
+
});
|
|
1873
|
+
this.eventManager.route(topic, async (e) => {
|
|
1874
|
+
await this.saveEvent(e, new InboxMysqlRepository(await this.databaseConnector.getConnection()));
|
|
1875
|
+
});
|
|
1876
|
+
} catch (error) {
|
|
1877
|
+
console.log(error.toString());
|
|
1879
1878
|
}
|
|
1880
|
-
|
|
1881
|
-
|
|
1879
|
+
}
|
|
1880
|
+
await this.eventManager.start();
|
|
1882
1881
|
}
|
|
1883
1882
|
async start() {
|
|
1884
1883
|
console.log("[inbox-runner]: start");
|
|
1885
|
-
|
|
1886
|
-
await this.process();
|
|
1887
|
-
}
|
|
1884
|
+
await this.process();
|
|
1888
1885
|
}
|
|
1889
1886
|
};
|
|
1890
1887
|
|