@kwirthmagnify/kwirth-common-back 0.5.52 → 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/IExtension.d.ts +18 -0
- package/dist/IProvider.d.ts +26 -17
- package/dist/ISender.d.ts +13 -1
- package/package.json +1 -1
package/dist/IExtension.d.ts
CHANGED
|
@@ -1,4 +1,22 @@
|
|
|
1
1
|
import { IExtensionExportOptions, IExtensionImportResult } from '@kwirthmagnify/kwirth-common';
|
|
2
|
+
/**
|
|
3
|
+
* What an extension writes its log with. The core builds it knowing who the extension is, so the
|
|
4
|
+
* line comes out identified — '[prov] [ERRO] [longhorn] ...' — and the extension only writes the
|
|
5
|
+
* message.
|
|
6
|
+
*
|
|
7
|
+
* It lives here, and not next to one family's contract, because the need is the same for all of
|
|
8
|
+
* them: before this, anything that was not a channel had only `console.log`, which comes out with no
|
|
9
|
+
* timestamp, no level and no component, and turns a failure into something that reads like a routine
|
|
10
|
+
* trace.
|
|
11
|
+
*
|
|
12
|
+
* Three levels and no more. An `info` nobody can filter out is what buries a log, and a failure that
|
|
13
|
+
* goes out as `info` is a failure nobody sees.
|
|
14
|
+
*/
|
|
15
|
+
export interface IExtensionLogger {
|
|
16
|
+
info(message: unknown): void;
|
|
17
|
+
warning(message: unknown): void;
|
|
18
|
+
error(message: unknown): void;
|
|
19
|
+
}
|
|
2
20
|
export interface IExtension {
|
|
3
21
|
exportConfig?(options: IExtensionExportOptions): Promise<unknown>;
|
|
4
22
|
importConfig?(config: unknown): Promise<IExtensionImportResult>;
|
package/dist/IProvider.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { KwirthData, IConfigFieldDef } from '@kwirthmagnify/kwirth-common';
|
|
2
|
-
import { IExtension } from './IExtension';
|
|
2
|
+
import { IExtension, IExtensionLogger } from './IExtension';
|
|
3
3
|
/**
|
|
4
4
|
* Minimal interface representing the channel side that providers interact with.
|
|
5
5
|
* Providers only need to call processProviderEvent on their subscribers.
|
|
@@ -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,18 +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. 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
|
-
}
|
|
133
126
|
/**
|
|
134
127
|
* Interface that all provider plugins must implement.
|
|
135
128
|
* Use 'any' for clusterInfo to avoid pulling in kubernetes/docker dependencies.
|
|
@@ -189,10 +182,26 @@ export interface IProvider extends IExtension {
|
|
|
189
182
|
* Why it exists: channels get a 'backChannelObject' to log with, providers got nothing, so the
|
|
190
183
|
* only thing left to them was 'console.log'. That comes out with no timestamp, no level and no
|
|
191
184
|
* 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 '[
|
|
185
|
+
* be filtered. With this, a provider's line reads '[prov] [ERRO] [longhorn] ...' and the
|
|
193
186
|
* provider does not even have to write its own id: the core puts it there.
|
|
194
187
|
*/
|
|
195
|
-
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>;
|
|
196
205
|
startProvider(): Promise<void>;
|
|
197
206
|
stopProvider(): Promise<void>;
|
|
198
207
|
router: any;
|
package/dist/ISender.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ISenderMessage, ISenderConfig, ISenderAccess, ISenderStoredConfig, ISenderResult, TConfigFieldType, IConfigFieldDef, IExtensionNodeMeta } from '@kwirthmagnify/kwirth-common';
|
|
2
|
-
import { IExtension } from './IExtension';
|
|
2
|
+
import { IExtension, IExtensionLogger } from './IExtension';
|
|
3
3
|
export { ISenderMessage, ISenderConfig, ISenderAccess, ISenderStoredConfig, ISenderResult };
|
|
4
4
|
/** @deprecated usa TConfigFieldType, comun a todas las extensiones. */
|
|
5
5
|
export type SenderFieldType = TConfigFieldType;
|
|
@@ -17,6 +17,18 @@ export interface ISender extends IExtension {
|
|
|
17
17
|
getConfigSchema?(): ISenderFieldDef[];
|
|
18
18
|
getNodeMeta?(): ISenderNodeMeta;
|
|
19
19
|
send(configName: string, message: ISenderMessage): Promise<ISenderResult | void>;
|
|
20
|
+
/**
|
|
21
|
+
* The core hands the sender a logger that already knows who it is, as soon as it builds it.
|
|
22
|
+
*
|
|
23
|
+
* OPTIONAL and read defensively, like the rest: a sender that does not implement it keeps writing
|
|
24
|
+
* wherever it was writing, and an older core that never calls it leaves the sender on its own
|
|
25
|
+
* fallback.
|
|
26
|
+
*
|
|
27
|
+
* ⚠️ This is for what the sender says ABOUT ITSELF — a delivery that failed, a configuration it
|
|
28
|
+
* could not read. It is not the place for what it delivers: a sender's job is to put a message
|
|
29
|
+
* somewhere, and that somewhere is decided by its configuration, not by this.
|
|
30
|
+
*/
|
|
31
|
+
setLogger?(logger: IExtensionLogger): void;
|
|
20
32
|
sendBatch?(configName: string, messages: ISenderMessage[]): Promise<ISenderResult | void>;
|
|
21
33
|
fetchStatus?(configName: string, externalId: string): Promise<string | undefined>;
|
|
22
34
|
evalFilter?(configName: string, message: ISenderMessage, forward: () => Promise<void>): Promise<void>;
|