@kwirthmagnify/kwirth-provider-http-pull-push 0.1.4 → 0.1.6
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 +24 -7
- package/package.json +1 -1
package/back.js
CHANGED
|
@@ -322,6 +322,18 @@ var Poller = class {
|
|
|
322
322
|
// src/back/index.ts
|
|
323
323
|
var HttpPullPushProvider = class {
|
|
324
324
|
constructor(_clusterInfo, _kwirthData, storage, fetcher = httpFetcher) {
|
|
325
|
+
/*
|
|
326
|
+
Starts writing to the console — what it did before — and the core replaces it as soon as the
|
|
327
|
+
provider is built. With an older core nobody calls setLogger and everything stays as it was.
|
|
328
|
+
*/
|
|
329
|
+
this.log = {
|
|
330
|
+
info: (message) => console.log(`[http-pull-push] ${message}`),
|
|
331
|
+
warning: (message) => console.warn(`[http-pull-push] ${message}`),
|
|
332
|
+
error: (message) => console.error(`[http-pull-push] ${message}`)
|
|
333
|
+
};
|
|
334
|
+
this.setLogger = (logger) => {
|
|
335
|
+
this.log = logger;
|
|
336
|
+
};
|
|
325
337
|
this.id = "http-pull-push";
|
|
326
338
|
this.providesRouter = false;
|
|
327
339
|
this.router = void 0;
|
|
@@ -337,7 +349,11 @@ var HttpPullPushProvider = class {
|
|
|
337
349
|
lo que ya se tiene, no se calcula —, y de aqui sale que kwirth pueda decir si esto esta siendo
|
|
338
350
|
consumido o emitiendo para nadie.
|
|
339
351
|
*/
|
|
340
|
-
|
|
352
|
+
/*
|
|
353
|
+
Entregas desde que arranco: una por llamada a un suscriptor. Filtra por configuracion antes de entregar.
|
|
354
|
+
*/
|
|
355
|
+
this.deliveries = 0;
|
|
356
|
+
this.getStats = () => ({ subscribers: this.subscribers.size, events: this.deliveries });
|
|
341
357
|
this.pollers = /* @__PURE__ */ new Map();
|
|
342
358
|
this.started = false;
|
|
343
359
|
// ── IProvider ───────────────────────────────────────────────────────────────
|
|
@@ -345,9 +361,9 @@ var HttpPullPushProvider = class {
|
|
|
345
361
|
try {
|
|
346
362
|
const configs = await this.store.load();
|
|
347
363
|
this.configs = new Map(configs.map((c) => [c.name, c]));
|
|
348
|
-
|
|
364
|
+
this.log.info(`${this.configs.size} connection(s) loaded`);
|
|
349
365
|
} catch (err) {
|
|
350
|
-
|
|
366
|
+
this.log.error(`Could not load connections: ${err}`);
|
|
351
367
|
}
|
|
352
368
|
this.started = true;
|
|
353
369
|
this.reconcile();
|
|
@@ -424,7 +440,7 @@ Gotchas:
|
|
|
424
440
|
await this.applyConfigs(incoming);
|
|
425
441
|
res.status(200).json({ ok: true });
|
|
426
442
|
} catch (err) {
|
|
427
|
-
|
|
443
|
+
this.log.error(`Error saving connections: ${err}`);
|
|
428
444
|
res.status(500).json({ errors: [String(err)] });
|
|
429
445
|
}
|
|
430
446
|
});
|
|
@@ -433,7 +449,7 @@ Gotchas:
|
|
|
433
449
|
const result = await this.testConnection(req.body);
|
|
434
450
|
res.status(200).json(result);
|
|
435
451
|
} catch (err) {
|
|
436
|
-
|
|
452
|
+
this.log.error(`Error testing connection: ${err}`);
|
|
437
453
|
res.status(500).json({ ok: false, durationMs: 0, error: String(err) });
|
|
438
454
|
}
|
|
439
455
|
});
|
|
@@ -584,9 +600,10 @@ Gotchas:
|
|
|
584
600
|
for (const [subscriber, entry] of this.subscribers) {
|
|
585
601
|
if (entry.configs !== void 0 && !entry.configs.has(event.config)) continue;
|
|
586
602
|
try {
|
|
603
|
+
this.deliveries++;
|
|
587
604
|
subscriber.processProviderEvent(this.id, event);
|
|
588
605
|
} catch (err) {
|
|
589
|
-
|
|
606
|
+
this.log.error(`Subscriber failed processing '${event.config}': ${err}`);
|
|
590
607
|
}
|
|
591
608
|
}
|
|
592
609
|
};
|
|
@@ -598,7 +615,7 @@ Gotchas:
|
|
|
598
615
|
this.warnUnknown = (data) => {
|
|
599
616
|
if (!data?.configs) return;
|
|
600
617
|
for (const name of data.configs) {
|
|
601
|
-
if (!this.configs.has(name))
|
|
618
|
+
if (!this.configs.has(name)) this.log.warning(`Subscription to unknown connection '${name}' \u2014 ignored`);
|
|
602
619
|
}
|
|
603
620
|
};
|
|
604
621
|
this.store = new ConfigStore(storage);
|
package/package.json
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
"id": "http-pull-push",
|
|
8
8
|
"name": "@kwirthmagnify/kwirth-provider-http-pull-push",
|
|
9
9
|
"displayName": "HTTP Pull-Push Provider",
|
|
10
|
-
"version": "0.1.
|
|
10
|
+
"version": "0.1.6",
|
|
11
11
|
"description": "HTTP polling provider for Kwirth — pulls remote HTTP endpoints on a schedule and pushes each result to the subscribed channels",
|
|
12
12
|
"website": "https://kwirthmagnify.dev",
|
|
13
13
|
"requiresRestart": true,
|