@openstatus/health-kafka 0.1.4-dev.0 → 0.1.4

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/mod.d.cts CHANGED
@@ -16,6 +16,11 @@ interface KafkaLikeAdmin {
16
16
  /** Fetch cluster metadata from the connected broker. */
17
17
  describeCluster(): PromiseLike<KafkaClusterDescription>;
18
18
  }
19
+ /** What a healthy check resolves with. */
20
+ interface KafkaBrokerCount {
21
+ /** Number of brokers currently in the cluster. */
22
+ readonly brokers: number;
23
+ }
19
24
  /** Options for `kafkaProbe()`. */
20
25
  interface KafkaProbeOptions extends ProbeOverrides {
21
26
  /** A connected `kafkajs` `Admin` client. */
@@ -25,5 +30,5 @@ interface KafkaProbeOptions extends ProbeOverrides {
25
30
  declare function kafkaProbe(options: KafkaProbeOptions): Probe;
26
31
  //# sourceMappingURL=mod.d.ts.map
27
32
  //#endregion
28
- export { KafkaClusterDescription, KafkaLikeAdmin, KafkaProbeOptions, kafkaDefaultName, kafkaProbe };
33
+ export { KafkaBrokerCount, KafkaClusterDescription, KafkaLikeAdmin, KafkaProbeOptions, kafkaDefaultName, kafkaProbe };
29
34
  //# sourceMappingURL=mod.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"mod.d.cts","names":[],"sources":["../src/mod.ts"],"sourcesContent":[],"mappings":";;;;;AA4CoC,cArBvB,gBAAA,GAqBuB,OAAA;;AAAyB,UAlB5C,uBAAA,CAkB4C;;;;;;;UAZ5C,cAAA;;qBAEI,YAAY;;;UAIhB,iBAAA,SAA0B;;kBAEzB;;;iBAIF,UAAA,UAAoB,oBAAoB"}
1
+ {"version":3,"file":"mod.d.cts","names":[],"sources":["../src/mod.ts"],"sourcesContent":[],"mappings":";;;;AAkDA;AAA0B,cA3Bb,gBAAA,GA2Ba,OAAA;;AAA8B,UAxBvC,uBAAA,CAwBuC;EAAK;;;;;;UAlB5C,cAAA;;qBAEI,YAAY;;;UAIhB,gBAAA;;;;;UAMA,iBAAA,SAA0B;;kBAEzB;;;iBAIF,UAAA,UAAoB,oBAAoB"}
package/dist/mod.d.ts CHANGED
@@ -16,6 +16,11 @@ interface KafkaLikeAdmin {
16
16
  /** Fetch cluster metadata from the connected broker. */
17
17
  describeCluster(): PromiseLike<KafkaClusterDescription>;
18
18
  }
19
+ /** What a healthy check resolves with. */
20
+ interface KafkaBrokerCount {
21
+ /** Number of brokers currently in the cluster. */
22
+ readonly brokers: number;
23
+ }
19
24
  /** Options for `kafkaProbe()`. */
20
25
  interface KafkaProbeOptions extends ProbeOverrides {
21
26
  /** A connected `kafkajs` `Admin` client. */
@@ -25,5 +30,5 @@ interface KafkaProbeOptions extends ProbeOverrides {
25
30
  declare function kafkaProbe(options: KafkaProbeOptions): Probe;
26
31
  //# sourceMappingURL=mod.d.ts.map
27
32
  //#endregion
28
- export { KafkaClusterDescription, KafkaLikeAdmin, KafkaProbeOptions, kafkaDefaultName, kafkaProbe };
33
+ export { KafkaBrokerCount, KafkaClusterDescription, KafkaLikeAdmin, KafkaProbeOptions, kafkaDefaultName, kafkaProbe };
29
34
  //# sourceMappingURL=mod.d.ts.map
package/dist/mod.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"mod.d.ts","names":[],"sources":["../src/mod.ts"],"sourcesContent":[],"mappings":";;;;;AA4CoC,cArBvB,gBAAA,GAqBuB,OAAA;;AAAyB,UAlB5C,uBAAA,CAkB4C;;;;;;;UAZ5C,cAAA;;qBAEI,YAAY;;;UAIhB,iBAAA,SAA0B;;kBAEzB;;;iBAIF,UAAA,UAAoB,oBAAoB"}
1
+ {"version":3,"file":"mod.d.ts","names":[],"sources":["../src/mod.ts"],"sourcesContent":[],"mappings":";;;;AAkDA;AAA0B,cA3Bb,gBAAA,GA2Ba,OAAA;;AAA8B,UAxBvC,uBAAA,CAwBuC;EAAK;;;;;;UAlB5C,cAAA;;qBAEI,YAAY;;;UAIhB,gBAAA;;;;;UAMA,iBAAA,SAA0B;;kBAEzB;;;iBAIF,UAAA,UAAoB,oBAAoB"}
package/dist/mod.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"mod.js","names":["options: KafkaProbeOptions","admin: KafkaLikeAdmin"],"sources":["../src/mod.ts"],"sourcesContent":["/**\n * Kafka probe for `@openstatus/health`: describes the cluster through a\n * connected KafkaJS-style `Admin` client and fails when no broker answers.\n *\n * ```ts\n * import { Kafka } from \"kafkajs\";\n * import { kafkaProbe } from \"@openstatus/health-kafka\";\n *\n * const admin = new Kafka({ brokers }).admin();\n * await admin.connect();\n * const probe = kafkaProbe({ admin });\n * ```\n *\n * @module\n */\n\nimport {\n type Probe,\n ProbeConfigError,\n type ProbeOverrides,\n} from \"@openstatus/health\";\n\n/** Probe name when `name` is unset. */\nexport const kafkaDefaultName = \"kafka\";\n\n/** What `describeCluster()` resolves to. */\nexport interface KafkaClusterDescription {\n /** The brokers currently in the cluster. */\n readonly brokers: readonly { readonly nodeId: number }[];\n}\n\n/** The subset of a KafkaJS `Admin` client the probe uses. */\nexport interface KafkaLikeAdmin {\n /** Fetch cluster metadata from the connected broker. */\n describeCluster(): PromiseLike<KafkaClusterDescription>;\n}\n\n/** Options for `kafkaProbe()`. */\nexport interface KafkaProbeOptions extends ProbeOverrides {\n /** A connected `kafkajs` `Admin` client. */\n readonly admin: KafkaLikeAdmin;\n}\n\n/** A probe that describes the cluster and expects at least one broker; non-critical by default. Throws `ProbeConfigError` without `describeCluster()`. */\nexport function kafkaProbe(options: KafkaProbeOptions): Probe {\n const admin = options.admin;\n if (typeof admin?.describeCluster !== \"function\") {\n throw new ProbeConfigError(\n \"kafkaProbe\",\n \"admin\",\n `must expose describeCluster(), got ${describe(admin)}`,\n );\n }\n return {\n name: options.name ?? kafkaDefaultName,\n critical: options.critical ?? false,\n timeoutMs: options.timeoutMs,\n skip: options.skip,\n run: async () => {\n const cluster = await admin.describeCluster();\n const brokers = cluster?.brokers;\n if (!Array.isArray(brokers)) throw new Error(\"unexpected response shape\");\n if (brokers.length === 0) throw new Error(\"no brokers in cluster\");\n return { brokers: brokers.length };\n },\n };\n}\n\nfunction describe(admin: KafkaLikeAdmin): string {\n if (admin == null) return String(admin);\n if (typeof admin !== \"object\") return typeof admin;\n const keys = Object.keys(admin);\n return keys.length === 0\n ? \"an object with no keys\"\n : `an object with keys ${keys.slice(0, 8).join(\", \")}`;\n}\n"],"mappings":";;;;AAuBA,MAAa,mBAAmB;;AAqBhC,SAAgB,WAAWA,SAAmC;CAC5D,MAAM,QAAQ,QAAQ;AACtB,YAAW,OAAO,oBAAoB,WACpC,OAAM,IAAI,iBACR,cACA,UACC,qCAAqC,SAAS,MAAM,CAAC;AAG1D,QAAO;EACL,MAAM,QAAQ,QAAQ;EACtB,UAAU,QAAQ,YAAY;EAC9B,WAAW,QAAQ;EACnB,MAAM,QAAQ;EACd,KAAK,YAAY;GACf,MAAM,UAAU,MAAM,MAAM,iBAAiB;GAC7C,MAAM,UAAU,SAAS;AACzB,QAAK,MAAM,QAAQ,QAAQ,CAAE,OAAM,IAAI,MAAM;AAC7C,OAAI,QAAQ,WAAW,EAAG,OAAM,IAAI,MAAM;AAC1C,UAAO,EAAE,SAAS,QAAQ,OAAQ;EACnC;CACF;AACF;AAED,SAAS,SAASC,OAA+B;AAC/C,KAAI,SAAS,KAAM,QAAO,OAAO,MAAM;AACvC,YAAW,UAAU,SAAU,eAAc;CAC7C,MAAM,OAAO,OAAO,KAAK,MAAM;AAC/B,QAAO,KAAK,WAAW,IACnB,4BACC,sBAAsB,KAAK,MAAM,GAAG,EAAE,CAAC,KAAK,KAAK,CAAC;AACxD"}
1
+ {"version":3,"file":"mod.js","names":["options: KafkaProbeOptions","admin: KafkaLikeAdmin"],"sources":["../src/mod.ts"],"sourcesContent":["/**\n * Kafka probe for `@openstatus/health`: describes the cluster through a\n * connected KafkaJS-style `Admin` client and fails when no broker answers.\n *\n * ```ts\n * import { Kafka } from \"kafkajs\";\n * import { kafkaProbe } from \"@openstatus/health-kafka\";\n *\n * const admin = new Kafka({ brokers }).admin();\n * await admin.connect();\n * const probe = kafkaProbe({ admin });\n * ```\n *\n * @module\n */\n\nimport {\n type Probe,\n ProbeConfigError,\n type ProbeOverrides,\n} from \"@openstatus/health\";\n\n/** Probe name when `name` is unset. */\nexport const kafkaDefaultName = \"kafka\";\n\n/** What `describeCluster()` resolves to. */\nexport interface KafkaClusterDescription {\n /** The brokers currently in the cluster. */\n readonly brokers: readonly { readonly nodeId: number }[];\n}\n\n/** The subset of a KafkaJS `Admin` client the probe uses. */\nexport interface KafkaLikeAdmin {\n /** Fetch cluster metadata from the connected broker. */\n describeCluster(): PromiseLike<KafkaClusterDescription>;\n}\n\n/** What a healthy check resolves with. */\nexport interface KafkaBrokerCount {\n /** Number of brokers currently in the cluster. */\n readonly brokers: number;\n}\n\n/** Options for `kafkaProbe()`. */\nexport interface KafkaProbeOptions extends ProbeOverrides {\n /** A connected `kafkajs` `Admin` client. */\n readonly admin: KafkaLikeAdmin;\n}\n\n/** A probe that describes the cluster and expects at least one broker; non-critical by default. Throws `ProbeConfigError` without `describeCluster()`. */\nexport function kafkaProbe(options: KafkaProbeOptions): Probe {\n const admin = options.admin;\n if (typeof admin?.describeCluster !== \"function\") {\n throw new ProbeConfigError(\n \"kafkaProbe\",\n \"admin\",\n `must expose describeCluster(), got ${describe(admin)}`,\n );\n }\n return {\n name: options.name ?? kafkaDefaultName,\n critical: options.critical ?? false,\n timeoutMs: options.timeoutMs,\n skip: options.skip,\n run: async (): Promise<KafkaBrokerCount> => {\n const cluster = await admin.describeCluster();\n const brokers = cluster?.brokers;\n if (!Array.isArray(brokers)) throw new Error(\"unexpected response shape\");\n if (brokers.length === 0) throw new Error(\"no brokers in cluster\");\n return { brokers: brokers.length };\n },\n };\n}\n\nfunction describe(admin: KafkaLikeAdmin): string {\n if (admin == null) return String(admin);\n if (typeof admin !== \"object\") return typeof admin;\n const keys = Object.keys(admin);\n return keys.length === 0\n ? \"an object with no keys\"\n : `an object with keys ${keys.slice(0, 8).join(\", \")}`;\n}\n"],"mappings":";;;;AAuBA,MAAa,mBAAmB;;AA2BhC,SAAgB,WAAWA,SAAmC;CAC5D,MAAM,QAAQ,QAAQ;AACtB,YAAW,OAAO,oBAAoB,WACpC,OAAM,IAAI,iBACR,cACA,UACC,qCAAqC,SAAS,MAAM,CAAC;AAG1D,QAAO;EACL,MAAM,QAAQ,QAAQ;EACtB,UAAU,QAAQ,YAAY;EAC9B,WAAW,QAAQ;EACnB,MAAM,QAAQ;EACd,KAAK,YAAuC;GAC1C,MAAM,UAAU,MAAM,MAAM,iBAAiB;GAC7C,MAAM,UAAU,SAAS;AACzB,QAAK,MAAM,QAAQ,QAAQ,CAAE,OAAM,IAAI,MAAM;AAC7C,OAAI,QAAQ,WAAW,EAAG,OAAM,IAAI,MAAM;AAC1C,UAAO,EAAE,SAAS,QAAQ,OAAQ;EACnC;CACF;AACF;AAED,SAAS,SAASC,OAA+B;AAC/C,KAAI,SAAS,KAAM,QAAO,OAAO,MAAM;AACvC,YAAW,UAAU,SAAU,eAAc;CAC7C,MAAM,OAAO,OAAO,KAAK,MAAM;AAC/B,QAAO,KAAK,WAAW,IACnB,4BACC,sBAAsB,KAAK,MAAM,GAAG,EAAE,CAAC,KAAK,KAAK,CAAC;AACxD"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openstatus/health-kafka",
3
- "version": "0.1.4-dev.0",
3
+ "version": "0.1.4",
4
4
  "description": "Kafka probe for @openstatus/health",
5
5
  "keywords": [
6
6
  "openstatus",
@@ -48,7 +48,7 @@
48
48
  "node": ">=22"
49
49
  },
50
50
  "peerDependencies": {
51
- "@openstatus/health": "^0.1.4-dev.0",
51
+ "@openstatus/health": "^0.1.4",
52
52
  "kafkajs": ">=2.0.0"
53
53
  },
54
54
  "peerDependenciesMeta": {