@orion-js/echoes 2.9.0 → 2.9.1
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 +23 -21
- package/package.json +2 -2
|
@@ -16,30 +16,32 @@ var _requestsHandler = _interopRequireDefault(require("../requestsHandler"));
|
|
|
16
16
|
var _types = _interopRequireDefault(require("../echo/types"));
|
|
17
17
|
|
|
18
18
|
async function startService(options) {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
const
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
19
|
+
if (options.client) {
|
|
20
|
+
const kafka = new _kafkajs.Kafka(options.client);
|
|
21
|
+
_config.default.producer = kafka.producer(options.producer);
|
|
22
|
+
_config.default.consumer = kafka.consumer(options.consumer);
|
|
23
|
+
await _config.default.producer.connect();
|
|
24
|
+
await _config.default.consumer.connect();
|
|
25
|
+
|
|
26
|
+
for (const topic in options.echoes) {
|
|
27
|
+
const echo = options.echoes[topic];
|
|
28
|
+
if (echo.type !== _types.default.event) continue;
|
|
29
|
+
await _config.default.consumer.subscribe({
|
|
30
|
+
topic,
|
|
31
|
+
fromBeginning: options.readTopicsFromBeginning || false
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
_config.default.consumer.run({
|
|
36
|
+
eachMessage: async params => {
|
|
37
|
+
const echo = options.echoes[params.topic];
|
|
38
|
+
if (!echo) return;
|
|
39
|
+
if (echo.type !== _types.default.event) return;
|
|
40
|
+
await echo.onMessage(params);
|
|
41
|
+
}
|
|
31
42
|
});
|
|
32
43
|
}
|
|
33
44
|
|
|
34
|
-
_config.default.consumer.run({
|
|
35
|
-
eachMessage: async params => {
|
|
36
|
-
const echo = options.echoes[params.topic];
|
|
37
|
-
if (!echo) return;
|
|
38
|
-
if (echo.type !== _types.default.event) return;
|
|
39
|
-
await echo.onMessage(params);
|
|
40
|
-
}
|
|
41
|
-
});
|
|
42
|
-
|
|
43
45
|
if (options.requests) {
|
|
44
46
|
_config.default.requests = options.requests;
|
|
45
47
|
_config.default.echoes = options.echoes;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@orion-js/echoes",
|
|
3
|
-
"version": "2.9.
|
|
3
|
+
"version": "2.9.1",
|
|
4
4
|
"main": "lib/index.js",
|
|
5
5
|
"author": "nicolaslopezj",
|
|
6
6
|
"license": "MIT",
|
|
@@ -29,5 +29,5 @@
|
|
|
29
29
|
"publishConfig": {
|
|
30
30
|
"access": "public"
|
|
31
31
|
},
|
|
32
|
-
"gitHead": "
|
|
32
|
+
"gitHead": "dca2bc31711c1194786d22759dd9b3be019d8f66"
|
|
33
33
|
}
|