@kwirthmagnify/kwirth-common-back 0.5.51 → 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 +58 -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.
|
|
@@ -86,6 +118,18 @@ export interface IProviderStats {
|
|
|
86
118
|
/** Errores al entregar, con el mismo criterio: acumulado y barato. */
|
|
87
119
|
errors?: number;
|
|
88
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;
|
|
132
|
+
}
|
|
89
133
|
/**
|
|
90
134
|
* Interface that all provider plugins must implement.
|
|
91
135
|
* Use 'any' for clusterInfo to avoid pulling in kubernetes/docker dependencies.
|
|
@@ -135,6 +179,20 @@ export interface IProvider extends IExtension {
|
|
|
135
179
|
* estructuras aqui convierte una consulta en trabajo para todos.
|
|
136
180
|
*/
|
|
137
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;
|
|
138
196
|
startProvider(): Promise<void>;
|
|
139
197
|
stopProvider(): Promise<void>;
|
|
140
198
|
router: any;
|