@kwirthmagnify/kwirth-provider-kafka 0.1.11 → 0.1.13
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 -0
- package/package.json +1 -1
package/back.js
CHANGED
|
@@ -18613,6 +18613,27 @@ var KafkaProvider = class {
|
|
|
18613
18613
|
this.connections = /* @__PURE__ */ new Map();
|
|
18614
18614
|
// accumulated data store, same shape as BusinessProvider: space -> type -> messages[]
|
|
18615
18615
|
this.data = /* @__PURE__ */ new Map();
|
|
18616
|
+
/*
|
|
18617
|
+
Cuantos consumidores tiene AHORA (IProvider.getStats, opcional desde kwirth-common-back 0.5.50).
|
|
18618
|
+
|
|
18619
|
+
Aqui no vale sumar los de cada conexion: un mismo suscriptor puede estar en varias a la vez —es
|
|
18620
|
+
justo lo que permite este provider— y la suma lo contaria dos veces. Se cuentan UNICOS.
|
|
18621
|
+
|
|
18622
|
+
Sigue siendo barato: recorre conexiones, no mensajes, y de esas hay un puñado.
|
|
18623
|
+
*/
|
|
18624
|
+
/*
|
|
18625
|
+
Entregas desde que arranco: una por mensaje aceptado y suscriptor. A diferencia del recuento de
|
|
18626
|
+
suscriptores, aqui NO hay que deduplicar — si el mismo suscriptor recibe por dos conexiones, son
|
|
18627
|
+
dos entregas y dos veces el trabajo.
|
|
18628
|
+
*/
|
|
18629
|
+
this.deliveries = 0;
|
|
18630
|
+
this.getStats = () => {
|
|
18631
|
+
const unicos = /* @__PURE__ */ new Set();
|
|
18632
|
+
for (const entry of this.connections.values()) {
|
|
18633
|
+
for (const s of entry.subscribers.keys()) unicos.add(s);
|
|
18634
|
+
}
|
|
18635
|
+
return { subscribers: unicos.size, events: this.deliveries };
|
|
18636
|
+
};
|
|
18616
18637
|
// ── IProvider ──────────────────────────────────────────────────────────────
|
|
18617
18638
|
this.addSubscriber = async (subscriber, providerConfig) => {
|
|
18618
18639
|
if (!providerConfig?.connections?.length) return;
|
|
@@ -18750,6 +18771,7 @@ var KafkaProvider = class {
|
|
|
18750
18771
|
const mapping = connConfig.spaces.find((s) => s.topic === topic);
|
|
18751
18772
|
if (!mapping) continue;
|
|
18752
18773
|
if (mapping.types && mapping.types.length > 0 && !mapping.types.includes(value?.type)) continue;
|
|
18774
|
+
this.deliveries++;
|
|
18753
18775
|
subscriber.processProviderEvent(this.id, {
|
|
18754
18776
|
last: {
|
|
18755
18777
|
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.13",
|
|
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": []
|