@kwirthmagnify/kwirth-common-back 0.5.50 → 0.5.52
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/IProvider.d.ts +79 -0
- package/package.json +1 -1
package/dist/IProvider.d.ts
CHANGED
|
@@ -7,6 +7,38 @@ import { IExtension } from './IExtension';
|
|
|
7
7
|
export interface IProviderSubscriber {
|
|
8
8
|
processProviderEvent(providerId: string, obj: any): void;
|
|
9
9
|
}
|
|
10
|
+
/**
|
|
11
|
+
* How a channel subscribes to a producer. The core hands one of these out already bound to the two
|
|
12
|
+
* ends — the producer and the channel asking for it — with 'clusterInfo.getProvider(id, this)'.
|
|
13
|
+
*
|
|
14
|
+
* It exists because a channel used to receive the provider OBJECT and call 'addSubscriber' on it,
|
|
15
|
+
* which meant the core could be bypassed without doing anything wrong, and therefore that its
|
|
16
|
+
* registry of who consumes what — the one the status graph is drawn from — was incomplete by
|
|
17
|
+
* construction. Going through the handle is what makes that registry true.
|
|
18
|
+
*
|
|
19
|
+
* ⚠️ The handle is NOT in the path of the data. It hands the provider the very same subscriber it
|
|
20
|
+
* was given, so events still travel straight from the producer to the consumer: no wrapper, no extra
|
|
21
|
+
* call, nothing per event. What runs is two functions per SUBSCRIPTION, which happens once when a tab
|
|
22
|
+
* opens. That is the whole reason it is shaped like this.
|
|
23
|
+
*
|
|
24
|
+
* One subscription per handle call, so a channel serving several instances subscribes once per
|
|
25
|
+
* instance with its own subscriber, and each one is unsubscribed on its own. The edge in the graph
|
|
26
|
+
* survives until the last of them is gone.
|
|
27
|
+
*/
|
|
28
|
+
export interface IProviderHandle {
|
|
29
|
+
/** Who produces: a provider ('events') or a pluvider ('plugin:agora'). */
|
|
30
|
+
readonly id: string;
|
|
31
|
+
/**
|
|
32
|
+
* Returns whatever the producer returned — normally a promise. It is handed back instead of
|
|
33
|
+
* swallowed because a provider that fails while taking a subscriber on board leaves an unhandled
|
|
34
|
+
* rejection, and that takes the whole core down. A consumer that wants to survive third-party
|
|
35
|
+
* providers wraps this in Promise.resolve().catch(); one that does not care ignores it.
|
|
36
|
+
*/
|
|
37
|
+
subscribe(subscriber: IProviderSubscriber, data?: any): unknown;
|
|
38
|
+
/** Changes what this subscriber wants. Providers may not implement it; then nothing happens. */
|
|
39
|
+
updateSubscription(subscriber: IProviderSubscriber, data?: any): unknown;
|
|
40
|
+
unsubscribe(subscriber: IProviderSubscriber): unknown;
|
|
41
|
+
}
|
|
10
42
|
/**
|
|
11
43
|
* Persistencia que el core inyecta al provider (mismo mecanismo que reciben los canales).
|
|
12
44
|
* El booleano 'secret' decide el destino: true -> Secret de Kubernetes, false -> ConfigMap.
|
|
@@ -64,6 +96,39 @@ export type IProviderFieldDef = IConfigFieldDef;
|
|
|
64
96
|
export interface IProviderStats {
|
|
65
97
|
/** Cuantos suscriptores tiene AHORA. Cero significa que esta emitiendo para nadie. */
|
|
66
98
|
subscribers: number;
|
|
99
|
+
/**
|
|
100
|
+
* ENTREGAS hechas desde que el provider arranco: una por cada vez que se llama a
|
|
101
|
+
* processProviderEvent, no una por evento producido. OPCIONAL: quien no lo lleve se muestra como
|
|
102
|
+
* "no informa", igual que el resto.
|
|
103
|
+
*
|
|
104
|
+
* Se cuentan entregas y no eventos a proposito. Un provider que produce mil eventos y los filtra
|
|
105
|
+
* todos no esta moviendo nada, y el numero util para quien opera es el trabajo que SE HACE. Ademas
|
|
106
|
+
* el sitio donde incrementar es inequivoco —justo donde ya se llama al suscriptor—, y eso hace que
|
|
107
|
+
* cablearlo en dieciseis providers no dependa de interpretar el codigo de cada uno.
|
|
108
|
+
*
|
|
109
|
+
* Es un ACUMULADO, no una tasa: quien lo lea resta dos lecturas y divide por el tiempo. El provider
|
|
110
|
+
* no debe saber nada de ventanas ni de medias — eso obligaria a guardar historia en el camino
|
|
111
|
+
* caliente, que es justo lo que no puede pasar.
|
|
112
|
+
*
|
|
113
|
+
* ⚠️ El incremento va JUNTO a la llamada al suscriptor, y es un entero. Nada
|
|
114
|
+
* de timestamps por evento, nada de arrays que crezcan, nada de objetos nuevos: lo que duele en
|
|
115
|
+
* Node no es el contador, es la basura que genera.
|
|
116
|
+
*/
|
|
117
|
+
events?: number;
|
|
118
|
+
/** Errores al entregar, con el mismo criterio: acumulado y barato. */
|
|
119
|
+
errors?: number;
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* What a provider writes its log with. The core builds it and hands it over with 'setLogger', so the
|
|
123
|
+
* id is already in place and the provider only writes the message.
|
|
124
|
+
*
|
|
125
|
+
* Three levels and no more: an 'info' that nobody can filter out is what buries a log, and a failure
|
|
126
|
+
* that goes out as 'info' is a failure nobody sees.
|
|
127
|
+
*/
|
|
128
|
+
export interface IProviderLogger {
|
|
129
|
+
info(message: unknown): void;
|
|
130
|
+
warning(message: unknown): void;
|
|
131
|
+
error(message: unknown): void;
|
|
67
132
|
}
|
|
68
133
|
/**
|
|
69
134
|
* Interface that all provider plugins must implement.
|
|
@@ -114,6 +179,20 @@ export interface IProvider extends IExtension {
|
|
|
114
179
|
* estructuras aqui convierte una consulta en trabajo para todos.
|
|
115
180
|
*/
|
|
116
181
|
getStats?(): IProviderStats;
|
|
182
|
+
/**
|
|
183
|
+
* The core hands the provider a logger that already knows who it is, right after building it.
|
|
184
|
+
*
|
|
185
|
+
* OPTIONAL, like everything in this block: a provider that does not implement it keeps writing
|
|
186
|
+
* wherever it was writing, and an older core that never calls it leaves the provider on its own
|
|
187
|
+
* fallback. Neither side needs the other to be up to date.
|
|
188
|
+
*
|
|
189
|
+
* Why it exists: channels get a 'backChannelObject' to log with, providers got nothing, so the
|
|
190
|
+
* only thing left to them was 'console.log'. That comes out with no timestamp, no level and no
|
|
191
|
+
* component — an error from a provider looks exactly like an informational line, and nothing can
|
|
192
|
+
* be filtered. With this, a provider's line reads '[provider] [ERROR] [longhorn] ...' and the
|
|
193
|
+
* provider does not even have to write its own id: the core puts it there.
|
|
194
|
+
*/
|
|
195
|
+
setLogger?(logger: IProviderLogger): void;
|
|
117
196
|
startProvider(): Promise<void>;
|
|
118
197
|
stopProvider(): Promise<void>;
|
|
119
198
|
router: any;
|