@midwayjs/kafka 3.4.9 → 3.4.10
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/framework.js +9 -3
- package/dist/kafka.js +12 -18
- package/package.json +4 -4
package/dist/framework.js
CHANGED
|
@@ -22,9 +22,15 @@ let MidwayKafkaFramework = class MidwayKafkaFramework extends core_1.BaseFramewo
|
|
|
22
22
|
});
|
|
23
23
|
}
|
|
24
24
|
async run() {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
25
|
+
try {
|
|
26
|
+
await this.app.connect(this.configurationOptions.kafkaConfig, this.configurationOptions.consumerConfig);
|
|
27
|
+
await this.loadSubscriber();
|
|
28
|
+
this.logger.info('Kafka consumer server start success');
|
|
29
|
+
}
|
|
30
|
+
catch (error) {
|
|
31
|
+
this.logger.error('Kafka consumer connect fail', error);
|
|
32
|
+
await this.app.closeConnection();
|
|
33
|
+
}
|
|
28
34
|
}
|
|
29
35
|
async loadSubscriber() {
|
|
30
36
|
const subscriberModules = (0, decorator_1.listModule)(decorator_1.MS_CONSUMER_KEY, module => {
|
package/dist/kafka.js
CHANGED
|
@@ -16,24 +16,18 @@ class KafkaConsumerServer extends stream_1.EventEmitter {
|
|
|
16
16
|
});
|
|
17
17
|
}
|
|
18
18
|
async connect(options, consumerOptions) {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
this.
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
});
|
|
32
|
-
}
|
|
33
|
-
catch (error) {
|
|
34
|
-
this.loggers.error('Kafka consumer connect fail', error);
|
|
35
|
-
await this.closeConnection();
|
|
36
|
-
}
|
|
19
|
+
this.connection = new kafkajs_1.Kafka(options).consumer(consumerOptions);
|
|
20
|
+
this.connection.on('consumer.connect', () => {
|
|
21
|
+
this.loggers.info('Kafka consumer connected!');
|
|
22
|
+
});
|
|
23
|
+
this.connection.on('consumer.disconnect', err => {
|
|
24
|
+
if (err) {
|
|
25
|
+
this.loggers.error('Kafka consumer disconnected', err);
|
|
26
|
+
}
|
|
27
|
+
else {
|
|
28
|
+
this.loggers.info('Kafka consumer disconnected!');
|
|
29
|
+
}
|
|
30
|
+
});
|
|
37
31
|
}
|
|
38
32
|
async closeConnection() {
|
|
39
33
|
try {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@midwayjs/kafka",
|
|
3
|
-
"version": "3.4.
|
|
3
|
+
"version": "3.4.10",
|
|
4
4
|
"description": "Midway Framework for kafka",
|
|
5
5
|
"main": "dist/index",
|
|
6
6
|
"typings": "index.d.ts",
|
|
@@ -33,10 +33,10 @@
|
|
|
33
33
|
},
|
|
34
34
|
"homepage": "https://github.com/midwayjs/midway#readme",
|
|
35
35
|
"devDependencies": {
|
|
36
|
-
"@midwayjs/core": "^3.4.
|
|
36
|
+
"@midwayjs/core": "^3.4.10",
|
|
37
37
|
"@midwayjs/decorator": "^3.4.4",
|
|
38
38
|
"@midwayjs/logger": "^2.15.0",
|
|
39
|
-
"@midwayjs/mock": "^3.4.
|
|
39
|
+
"@midwayjs/mock": "^3.4.10"
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
42
|
"kafkajs": "2.1.0"
|
|
@@ -44,5 +44,5 @@
|
|
|
44
44
|
"engines": {
|
|
45
45
|
"node": ">=12"
|
|
46
46
|
},
|
|
47
|
-
"gitHead": "
|
|
47
|
+
"gitHead": "aeb117633ecbc3299002b220f436dc3b5450d361"
|
|
48
48
|
}
|