@kwirthmagnify/kwirth-common-back 0.5.53 → 0.5.54
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 +25 -10
- package/package.json +1 -1
package/dist/IProvider.d.ts
CHANGED
|
@@ -8,8 +8,13 @@ export interface IProviderSubscriber {
|
|
|
8
8
|
processProviderEvent(providerId: string, obj: any): void;
|
|
9
9
|
}
|
|
10
10
|
/**
|
|
11
|
-
* How a
|
|
12
|
-
* ends — the producer and
|
|
11
|
+
* How a consumer subscribes to a producer. The core hands one of these out already bound to the two
|
|
12
|
+
* ends — the producer and whoever asked for it — with 'clusterInfo.getProvider(id, this)'.
|
|
13
|
+
*
|
|
14
|
+
* The consumer is usually a channel, but it does NOT have to be: a PROVIDER may consume another
|
|
15
|
+
* provider, which is how a provider that owns shared configuration — cloud credentials, say — reaches
|
|
16
|
+
* the providers that need it. A provider subscribes from onProvidersReady(), never from
|
|
17
|
+
* startProvider(); see that method for why.
|
|
13
18
|
*
|
|
14
19
|
* It exists because a channel used to receive the provider OBJECT and call 'addSubscriber' on it,
|
|
15
20
|
* which meant the core could be bypassed without doing anything wrong, and therefore that its
|
|
@@ -118,12 +123,6 @@ export interface IProviderStats {
|
|
|
118
123
|
/** Errores al entregar, con el mismo criterio: acumulado y barato. */
|
|
119
124
|
errors?: number;
|
|
120
125
|
}
|
|
121
|
-
/**
|
|
122
|
-
* What a provider writes its log with. It is the common extension logger — the need turned out to be
|
|
123
|
-
* the same for senders, so it lives in IExtension. Kept as a name of its own because it is already
|
|
124
|
-
* published and providers compile against it.
|
|
125
|
-
*/
|
|
126
|
-
export type IProviderLogger = IExtensionLogger;
|
|
127
126
|
/**
|
|
128
127
|
* Interface that all provider plugins must implement.
|
|
129
128
|
* Use 'any' for clusterInfo to avoid pulling in kubernetes/docker dependencies.
|
|
@@ -183,10 +182,26 @@ export interface IProvider extends IExtension {
|
|
|
183
182
|
* Why it exists: channels get a 'backChannelObject' to log with, providers got nothing, so the
|
|
184
183
|
* only thing left to them was 'console.log'. That comes out with no timestamp, no level and no
|
|
185
184
|
* component — an error from a provider looks exactly like an informational line, and nothing can
|
|
186
|
-
* be filtered. With this, a provider's line reads '[
|
|
185
|
+
* be filtered. With this, a provider's line reads '[prov] [ERRO] [longhorn] ...' and the
|
|
187
186
|
* provider does not even have to write its own id: the core puts it there.
|
|
188
187
|
*/
|
|
189
|
-
setLogger?(logger:
|
|
188
|
+
setLogger?(logger: IExtensionLogger): void;
|
|
189
|
+
/**
|
|
190
|
+
* Called once, after EVERY provider and pluvider is registered and started. This is where a
|
|
191
|
+
* provider that CONSUMES another one subscribes to it.
|
|
192
|
+
*
|
|
193
|
+
* ⚠️ Do not subscribe from startProvider(). Whether the producer is registered by then depends on
|
|
194
|
+
* which startup loop instantiated it and on the order within that loop, so it would work or not
|
|
195
|
+
* for reasons you cannot see from your own code.
|
|
196
|
+
*
|
|
197
|
+
* 🔴 Whatever you subscribe to here, unsubscribe in stopProvider(). Skipping it does not leak one
|
|
198
|
+
* object: the producer keeps feeding an instance nobody uses any more, and every hot reload
|
|
199
|
+
* leaves another ghost behind holding whatever that instance held.
|
|
200
|
+
*
|
|
201
|
+
* OPTIONAL, like the rest of this block: a provider that does not implement it is never called,
|
|
202
|
+
* and an older core that does not know about it simply never calls anyone.
|
|
203
|
+
*/
|
|
204
|
+
onProvidersReady?(): void | Promise<void>;
|
|
190
205
|
startProvider(): Promise<void>;
|
|
191
206
|
stopProvider(): Promise<void>;
|
|
192
207
|
router: any;
|