@rsdk/kafka.common 3.0.1-next.0 → 3.0.2
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/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,16 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [3.0.2](https://github.com/R-Vision/rsdk/compare/v3.0.1...v3.0.2) (2023-08-07)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @rsdk/kafka.common
|
|
9
|
+
|
|
10
|
+
## [3.0.1](https://github.com/R-Vision/rsdk/compare/v3.0.0...v3.0.1) (2023-08-07)
|
|
11
|
+
|
|
12
|
+
### Bug Fixes
|
|
13
|
+
|
|
14
|
+
* **deps:** correctly peerDependencies ([349628f](https://github.com/R-Vision/rsdk/commit/349628f10da46a30d6c8b9f9387e010869318212))
|
|
15
|
+
|
|
6
16
|
## [3.0.1-next.0](https://github.com/R-Vision/rsdk/compare/v3.0.0...v3.0.1-next.0) (2023-08-07)
|
|
7
17
|
|
|
8
18
|
### Bug Fixes
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { CheckResult } from '@rsdk/core';
|
|
2
|
+
import type { Kafka } from 'kafkajs';
|
|
3
|
+
export declare class KafkaHealthcheck {
|
|
4
|
+
readonly kafkaClient: Kafka;
|
|
5
|
+
readonly neededTopics: string[];
|
|
6
|
+
constructor(kafkaClient: Kafka, neededTopics: string[]);
|
|
7
|
+
getMissingTopics(): Promise<string[]>;
|
|
8
|
+
check(): Promise<CheckResult>;
|
|
9
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.KafkaHealthcheck = void 0;
|
|
4
|
+
const core_1 = require("@rsdk/core");
|
|
5
|
+
class KafkaHealthcheck {
|
|
6
|
+
kafkaClient;
|
|
7
|
+
neededTopics;
|
|
8
|
+
constructor(kafkaClient, neededTopics) {
|
|
9
|
+
this.kafkaClient = kafkaClient;
|
|
10
|
+
this.neededTopics = neededTopics;
|
|
11
|
+
}
|
|
12
|
+
async getMissingTopics() {
|
|
13
|
+
const admin = this.kafkaClient.admin();
|
|
14
|
+
await admin.connect();
|
|
15
|
+
const topics = await admin.listTopics();
|
|
16
|
+
await admin.disconnect();
|
|
17
|
+
return this.neededTopics.filter((neededTopic) => !topics.includes(neededTopic));
|
|
18
|
+
}
|
|
19
|
+
async check() {
|
|
20
|
+
try {
|
|
21
|
+
const missingTopics = await this.getMissingTopics();
|
|
22
|
+
if (missingTopics.length > 0) {
|
|
23
|
+
return core_1.CheckResult.down({
|
|
24
|
+
missingTopics,
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
return core_1.CheckResult.up({});
|
|
28
|
+
}
|
|
29
|
+
catch (error) {
|
|
30
|
+
return core_1.CheckResult.down({
|
|
31
|
+
error: error.message,
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
exports.KafkaHealthcheck = KafkaHealthcheck;
|
|
37
|
+
//# sourceMappingURL=kafka.healthcheck.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"kafka.healthcheck.js","sourceRoot":"","sources":["../src/kafka.healthcheck.ts"],"names":[],"mappings":";;;AAAA,qCAAyC;AAGzC,MAAa,gBAAgB;IACN;IAA6B;IAAlD,YAAqB,WAAkB,EAAW,YAAsB;QAAnD,gBAAW,GAAX,WAAW,CAAO;QAAW,iBAAY,GAAZ,YAAY,CAAU;IAAG,CAAC;IAE5E,KAAK,CAAC,gBAAgB;QACpB,MAAM,KAAK,GAAG,IAAI,CAAC,WAAW,CAAC,KAAK,EAAE,CAAC;QAEvC,MAAM,KAAK,CAAC,OAAO,EAAE,CAAC;QAEtB,MAAM,MAAM,GAAG,MAAM,KAAK,CAAC,UAAU,EAAE,CAAC;QAExC,MAAM,KAAK,CAAC,UAAU,EAAE,CAAC;QACzB,OAAO,IAAI,CAAC,YAAY,CAAC,MAAM,CAC7B,CAAC,WAAW,EAAE,EAAE,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,WAAW,CAAC,CAC/C,CAAC;IACJ,CAAC;IAED,KAAK,CAAC,KAAK;QACT,IAAI;YACF,MAAM,aAAa,GAAG,MAAM,IAAI,CAAC,gBAAgB,EAAE,CAAC;YACpD,IAAI,aAAa,CAAC,MAAM,GAAG,CAAC,EAAE;gBAC5B,OAAO,kBAAW,CAAC,IAAI,CAAC;oBACtB,aAAa;iBACd,CAAC,CAAC;aACJ;YACD,OAAO,kBAAW,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;SAC3B;QAAC,OAAO,KAAc,EAAE;YACvB,OAAO,kBAAW,CAAC,IAAI,CAAC;gBACtB,KAAK,EAAG,KAAe,CAAC,OAAO;aAChC,CAAC,CAAC;SACJ;IACH,CAAC;CACF;AA/BD,4CA+BC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.KafkaTopicType = void 0;
|
|
4
|
+
var KafkaTopicType;
|
|
5
|
+
(function (KafkaTopicType) {
|
|
6
|
+
KafkaTopicType[KafkaTopicType["Consume"] = 0] = "Consume";
|
|
7
|
+
KafkaTopicType[KafkaTopicType["Produce"] = 1] = "Produce";
|
|
8
|
+
})(KafkaTopicType = exports.KafkaTopicType || (exports.KafkaTopicType = {}));
|
|
9
|
+
//# sourceMappingURL=kafka.metadata.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"kafka.metadata.js","sourceRoot":"","sources":["../src/kafka.metadata.ts"],"names":[],"mappings":";;;AAAA,IAAY,cAGX;AAHD,WAAY,cAAc;IACxB,yDAAO,CAAA;IACP,yDAAO,CAAA;AACT,CAAC,EAHW,cAAc,GAAd,sBAAc,KAAd,sBAAc,QAGzB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rsdk/kafka.common",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.2",
|
|
4
4
|
"description": "Common functionality for kafka consumers and producers",
|
|
5
5
|
"license": "Apache License 2.0",
|
|
6
6
|
"publishConfig": {
|
|
@@ -13,10 +13,10 @@
|
|
|
13
13
|
"peerDependencies": {
|
|
14
14
|
"@nestjs/common": "^10.1.3",
|
|
15
15
|
"@nestjs/microservices": "^10.1.3",
|
|
16
|
-
"@rsdk/common": "^3.0.
|
|
17
|
-
"@rsdk/core": "^3.0.
|
|
18
|
-
"@rsdk/logging": "^3.0.
|
|
19
|
-
"@rsdk/metadata": "^3.0.
|
|
16
|
+
"@rsdk/common": "^3.0.2",
|
|
17
|
+
"@rsdk/core": "^3.0.2",
|
|
18
|
+
"@rsdk/logging": "^3.0.2",
|
|
19
|
+
"@rsdk/metadata": "^3.0.2",
|
|
20
20
|
"kafkajs": "^2.2.4",
|
|
21
21
|
"lodash": "^4.17.21",
|
|
22
22
|
"rxjs": "^7.0.0"
|
|
@@ -24,5 +24,5 @@
|
|
|
24
24
|
"dependencies": {
|
|
25
25
|
"protobufjs": "^7.2.3"
|
|
26
26
|
},
|
|
27
|
-
"gitHead": "
|
|
27
|
+
"gitHead": "3ee33710bf18bfadf87a6da92b060e6a17481110"
|
|
28
28
|
}
|