@kwirthmagnify/kwirth-provider-kafka 0.1.12 → 0.1.14
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/back.js +22 -3
- package/package.json +1 -1
package/back.js
CHANGED
|
@@ -18603,6 +18603,18 @@ module.exports = __toCommonJS(index_exports);
|
|
|
18603
18603
|
var import_kafkajs = __toESM(require_kafkajs(), 1);
|
|
18604
18604
|
var KafkaProvider = class {
|
|
18605
18605
|
constructor(_clusterInfo, _kwirthData) {
|
|
18606
|
+
/*
|
|
18607
|
+
Starts writing to the console — what it did before — and the core replaces it as soon as the
|
|
18608
|
+
provider is built. With an older core nobody calls setLogger and everything stays as it was.
|
|
18609
|
+
*/
|
|
18610
|
+
this.log = {
|
|
18611
|
+
info: (message) => console.log(`[kafka] ${message}`),
|
|
18612
|
+
warning: (message) => console.warn(`[kafka] ${message}`),
|
|
18613
|
+
error: (message) => console.error(`[kafka] ${message}`)
|
|
18614
|
+
};
|
|
18615
|
+
this.setLogger = (logger) => {
|
|
18616
|
+
this.log = logger;
|
|
18617
|
+
};
|
|
18606
18618
|
this.id = "kafka";
|
|
18607
18619
|
this.providesRouter = false;
|
|
18608
18620
|
this.router = void 0;
|
|
@@ -18621,12 +18633,18 @@ var KafkaProvider = class {
|
|
|
18621
18633
|
|
|
18622
18634
|
Sigue siendo barato: recorre conexiones, no mensajes, y de esas hay un puñado.
|
|
18623
18635
|
*/
|
|
18636
|
+
/*
|
|
18637
|
+
Entregas desde que arranco: una por mensaje aceptado y suscriptor. A diferencia del recuento de
|
|
18638
|
+
suscriptores, aqui NO hay que deduplicar — si el mismo suscriptor recibe por dos conexiones, son
|
|
18639
|
+
dos entregas y dos veces el trabajo.
|
|
18640
|
+
*/
|
|
18641
|
+
this.deliveries = 0;
|
|
18624
18642
|
this.getStats = () => {
|
|
18625
18643
|
const unicos = /* @__PURE__ */ new Set();
|
|
18626
18644
|
for (const entry of this.connections.values()) {
|
|
18627
18645
|
for (const s of entry.subscribers.keys()) unicos.add(s);
|
|
18628
18646
|
}
|
|
18629
|
-
return { subscribers: unicos.size };
|
|
18647
|
+
return { subscribers: unicos.size, events: this.deliveries };
|
|
18630
18648
|
};
|
|
18631
18649
|
// ── IProvider ──────────────────────────────────────────────────────────────
|
|
18632
18650
|
this.addSubscriber = async (subscriber, providerConfig) => {
|
|
@@ -18718,11 +18736,11 @@ var KafkaProvider = class {
|
|
|
18718
18736
|
await this.handleMessage(entry, topic, message.value?.toString());
|
|
18719
18737
|
}
|
|
18720
18738
|
}).catch((err) => {
|
|
18721
|
-
|
|
18739
|
+
this.log.error(`consumer run error (key=${key}): ${err}`);
|
|
18722
18740
|
entry.running = false;
|
|
18723
18741
|
});
|
|
18724
18742
|
} catch (err) {
|
|
18725
|
-
|
|
18743
|
+
this.log.error(`failed to start consumer (key=${key}): ${err}`);
|
|
18726
18744
|
entry.running = false;
|
|
18727
18745
|
}
|
|
18728
18746
|
}
|
|
@@ -18765,6 +18783,7 @@ var KafkaProvider = class {
|
|
|
18765
18783
|
const mapping = connConfig.spaces.find((s) => s.topic === topic);
|
|
18766
18784
|
if (!mapping) continue;
|
|
18767
18785
|
if (mapping.types && mapping.types.length > 0 && !mapping.types.includes(value?.type)) continue;
|
|
18786
|
+
this.deliveries++;
|
|
18768
18787
|
subscriber.processProviderEvent(this.id, {
|
|
18769
18788
|
last: {
|
|
18770
18789
|
type: "event",
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"id": "kafka",
|
|
5
5
|
"name": "@kwirthmagnify/kwirth-provider-kafka",
|
|
6
6
|
"displayName": "Kafka Provider",
|
|
7
|
-
"version": "0.1.
|
|
7
|
+
"version": "0.1.14",
|
|
8
8
|
"description": "Kafka provider plugin for Kwirth — subscribes to Kafka topics and dispatches events grouped by spaces",
|
|
9
9
|
"requiresRestart": false,
|
|
10
10
|
"requiresExtension": []
|