@orion-js/echoes 2.9.1 → 2.10.3
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/lib/startService/index.js +18 -1
- package/package.json +4 -4
|
@@ -15,6 +15,8 @@ var _requestsHandler = _interopRequireDefault(require("../requestsHandler"));
|
|
|
15
15
|
|
|
16
16
|
var _types = _interopRequireDefault(require("../echo/types"));
|
|
17
17
|
|
|
18
|
+
const HEARTBEAT_INTERVAL_SECONDS = 3;
|
|
19
|
+
|
|
18
20
|
async function startService(options) {
|
|
19
21
|
if (options.client) {
|
|
20
22
|
const kafka = new _kafkajs.Kafka(options.client);
|
|
@@ -37,7 +39,22 @@ async function startService(options) {
|
|
|
37
39
|
const echo = options.echoes[params.topic];
|
|
38
40
|
if (!echo) return;
|
|
39
41
|
if (echo.type !== _types.default.event) return;
|
|
40
|
-
|
|
42
|
+
let intervalsCount = 0;
|
|
43
|
+
const interval = setInterval(async () => {
|
|
44
|
+
await params.heartbeat().catch(error => {
|
|
45
|
+
console.warn('Echoes: Error sending heartbeat:', error);
|
|
46
|
+
});
|
|
47
|
+
intervalsCount++;
|
|
48
|
+
|
|
49
|
+
if (intervalsCount % 10 === 0) {
|
|
50
|
+
console.warn(`Echoes: Event ${params.topic} is taking too long to process: ${intervalsCount * HEARTBEAT_INTERVAL_SECONDS}s`);
|
|
51
|
+
}
|
|
52
|
+
}, HEARTBEAT_INTERVAL_SECONDS * 1000);
|
|
53
|
+
await echo.onMessage(params).catch(error => {
|
|
54
|
+
clearInterval(interval);
|
|
55
|
+
throw error;
|
|
56
|
+
});
|
|
57
|
+
clearInterval(interval);
|
|
41
58
|
}
|
|
42
59
|
});
|
|
43
60
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@orion-js/echoes",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.10.3",
|
|
4
4
|
"main": "lib/index.js",
|
|
5
5
|
"author": "nicolaslopezj",
|
|
6
6
|
"license": "MIT",
|
|
@@ -12,11 +12,11 @@
|
|
|
12
12
|
"test:watch": "jest src --coverage --watch"
|
|
13
13
|
},
|
|
14
14
|
"dependencies": {
|
|
15
|
-
"@orion-js/helpers": "^2.
|
|
15
|
+
"@orion-js/helpers": "^2.10.0",
|
|
16
16
|
"@orion-js/schema": "^3.9.0",
|
|
17
17
|
"axios": "^0.23.0",
|
|
18
18
|
"jssha": "^3.2.0",
|
|
19
|
-
"kafkajs": "^
|
|
19
|
+
"kafkajs": "^2.2.4",
|
|
20
20
|
"serialize-javascript": "^5.0.1"
|
|
21
21
|
},
|
|
22
22
|
"devDependencies": {
|
|
@@ -29,5 +29,5 @@
|
|
|
29
29
|
"publishConfig": {
|
|
30
30
|
"access": "public"
|
|
31
31
|
},
|
|
32
|
-
"gitHead": "
|
|
32
|
+
"gitHead": "30a4b8f24d4fd596818058305488368844920479"
|
|
33
33
|
}
|