wsp-ms-core 1.0.93 → 1.0.95
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 +44 -16
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +29 -3
- package/dist/index.d.ts +29 -3
- package/dist/index.js +43 -16
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -36,6 +36,7 @@ __export(src_exports, {
|
|
|
36
36
|
Country: () => Country,
|
|
37
37
|
Currency: () => Currency,
|
|
38
38
|
DateTime: () => DateTime,
|
|
39
|
+
DefaultMysqlInboxProcessor: () => DefaultMysqlInboxProcessor,
|
|
39
40
|
DefaultMysqlInboxRunner: () => DefaultMysqlInboxRunner,
|
|
40
41
|
DefaultMysqlOutboxRunner: () => DefaultMysqlOutboxRunner,
|
|
41
42
|
DomainEntity: () => DomainEntity,
|
|
@@ -1655,7 +1656,7 @@ var KafkaManager = class extends EventManager {
|
|
|
1655
1656
|
await this.execCallback(this._onMessage, `[New message detected for ${topic}]: ${message.value?.toString()}`);
|
|
1656
1657
|
const json = JSON.parse(String(message.value?.toString()));
|
|
1657
1658
|
await this.execRoute(topic, {
|
|
1658
|
-
topic: String(
|
|
1659
|
+
topic: String(topic),
|
|
1659
1660
|
producer: String(json.producer),
|
|
1660
1661
|
tenant: UUID.create(String(json.tenant)),
|
|
1661
1662
|
message: json.data
|
|
@@ -1810,7 +1811,7 @@ var DefaultMysqlOutboxRunner = class {
|
|
|
1810
1811
|
}
|
|
1811
1812
|
}
|
|
1812
1813
|
async sleep() {
|
|
1813
|
-
return new Promise((r) => setTimeout(r, this.
|
|
1814
|
+
return new Promise((r) => setTimeout(r, this.interval));
|
|
1814
1815
|
}
|
|
1815
1816
|
async processOutboxRecord(e, eventBusRepository) {
|
|
1816
1817
|
try {
|
|
@@ -1831,7 +1832,7 @@ var DefaultMysqlOutboxRunner = class {
|
|
|
1831
1832
|
await eventBusRepository.update(e);
|
|
1832
1833
|
}
|
|
1833
1834
|
}
|
|
1834
|
-
async
|
|
1835
|
+
async processRecords() {
|
|
1835
1836
|
const uow = await this.uowFactory.create();
|
|
1836
1837
|
const eventBusRepository = new EventBusMysqlRepository(uow.connection);
|
|
1837
1838
|
await uow.execute(async () => {
|
|
@@ -1849,7 +1850,7 @@ var DefaultMysqlOutboxRunner = class {
|
|
|
1849
1850
|
async start() {
|
|
1850
1851
|
console.log("[outbox-runner]: start");
|
|
1851
1852
|
for (; ; ) {
|
|
1852
|
-
await this.
|
|
1853
|
+
await this.processRecords();
|
|
1853
1854
|
await this.sleep();
|
|
1854
1855
|
}
|
|
1855
1856
|
}
|
|
@@ -1914,7 +1915,6 @@ var DefaultMysqlInboxRunner = class {
|
|
|
1914
1915
|
this.eventManager = eventManager;
|
|
1915
1916
|
}
|
|
1916
1917
|
async saveEvent(e, repository) {
|
|
1917
|
-
console.log(e);
|
|
1918
1918
|
try {
|
|
1919
1919
|
let record = new InboxRecord(
|
|
1920
1920
|
UUID.create(),
|
|
@@ -1926,24 +1926,23 @@ var DefaultMysqlInboxRunner = class {
|
|
|
1926
1926
|
);
|
|
1927
1927
|
await repository.create(record);
|
|
1928
1928
|
} catch (error) {
|
|
1929
|
-
console.log(error);
|
|
1930
1929
|
throw error;
|
|
1931
1930
|
}
|
|
1932
1931
|
}
|
|
1933
1932
|
subscribeTo(topic) {
|
|
1934
1933
|
this.topics.push(topic);
|
|
1935
1934
|
}
|
|
1936
|
-
async
|
|
1935
|
+
async processEvents() {
|
|
1936
|
+
this.eventManager.onSubscribe((data) => {
|
|
1937
|
+
console.log(data);
|
|
1938
|
+
});
|
|
1939
|
+
this.eventManager.onMessage((data) => {
|
|
1940
|
+
});
|
|
1941
|
+
this.eventManager.onError((data) => {
|
|
1942
|
+
console.log(data);
|
|
1943
|
+
});
|
|
1937
1944
|
for (let topic of this.topics) {
|
|
1938
1945
|
try {
|
|
1939
|
-
this.eventManager.onSubscribe((data) => {
|
|
1940
|
-
console.log(data);
|
|
1941
|
-
});
|
|
1942
|
-
this.eventManager.onMessage((data) => {
|
|
1943
|
-
});
|
|
1944
|
-
this.eventManager.onError((data) => {
|
|
1945
|
-
console.log(data);
|
|
1946
|
-
});
|
|
1947
1946
|
this.eventManager.route(topic, async (e) => {
|
|
1948
1947
|
await this.saveEvent(e, new InboxMysqlRepository(await this.databaseConnector.getConnection()));
|
|
1949
1948
|
});
|
|
@@ -1955,7 +1954,35 @@ var DefaultMysqlInboxRunner = class {
|
|
|
1955
1954
|
}
|
|
1956
1955
|
async start() {
|
|
1957
1956
|
console.log("[inbox-runner]: start");
|
|
1958
|
-
await this.
|
|
1957
|
+
await this.processEvents();
|
|
1958
|
+
}
|
|
1959
|
+
};
|
|
1960
|
+
|
|
1961
|
+
// src/infrastructure/runners/default-mysql-inbox-processor.ts
|
|
1962
|
+
var DefaultMysqlInboxProcessor = class {
|
|
1963
|
+
constructor(repository) {
|
|
1964
|
+
this.repository = repository;
|
|
1965
|
+
}
|
|
1966
|
+
async sleep() {
|
|
1967
|
+
return new Promise((r) => setTimeout(r, 5e3));
|
|
1968
|
+
}
|
|
1969
|
+
addHandlerForTopic(topic, handler) {
|
|
1970
|
+
this.handlers.set(topic, handler);
|
|
1971
|
+
}
|
|
1972
|
+
async processRecords() {
|
|
1973
|
+
const records = await this.repository.listPending(20);
|
|
1974
|
+
for (let record of records) {
|
|
1975
|
+
if (this.handlers.has(record.topic)) {
|
|
1976
|
+
await this.handlers.get(record.topic)(record);
|
|
1977
|
+
}
|
|
1978
|
+
}
|
|
1979
|
+
}
|
|
1980
|
+
async start() {
|
|
1981
|
+
console.log("[inbox-runner-processor]: start");
|
|
1982
|
+
for (; ; ) {
|
|
1983
|
+
await this.processRecords();
|
|
1984
|
+
await this.sleep();
|
|
1985
|
+
}
|
|
1959
1986
|
}
|
|
1960
1987
|
};
|
|
1961
1988
|
|
|
@@ -2019,6 +2046,7 @@ var ExchangeRates = class _ExchangeRates extends BaseObject {
|
|
|
2019
2046
|
Country,
|
|
2020
2047
|
Currency,
|
|
2021
2048
|
DateTime,
|
|
2049
|
+
DefaultMysqlInboxProcessor,
|
|
2022
2050
|
DefaultMysqlInboxRunner,
|
|
2023
2051
|
DefaultMysqlOutboxRunner,
|
|
2024
2052
|
DomainEntity,
|