Skip to content

Commit 71ee3bd

Browse files
Spencerspalger
andauthored
[7.x] Test reverting "Add plugin status API (#75819)" (#76707) (#76728)
Co-authored-by: spalger <spalger@users.noreply.github.com> # Conflicts: # rfcs/text/0010_service_status.md
1 parent e1aa5f3 commit 71ee3bd

20 files changed

Lines changed: 31 additions & 915 deletions

docs/development/core/server/kibana-plugin-core-server.statusservicesetup.dependencies_.md

Lines changed: 0 additions & 13 deletions
This file was deleted.

docs/development/core/server/kibana-plugin-core-server.statusservicesetup.derivedstatus_.md

Lines changed: 0 additions & 20 deletions
This file was deleted.

docs/development/core/server/kibana-plugin-core-server.statusservicesetup.md

Lines changed: 0 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -12,73 +12,10 @@ API for accessing status of Core and this plugin's dependencies as well as for c
1212
export interface StatusServiceSetup
1313
```
1414

15-
## Remarks
16-
17-
By default, a plugin inherits it's current status from the most severe status level of any Core services and any plugins that it depends on. This default status is available on the API.
18-
19-
Plugins may customize their status calculation by calling the API with an Observable. Within this Observable, a plugin may choose to only depend on the status of some of its dependencies, to ignore severe status levels of particular Core services they are not concerned with, or to make its status dependent on other external services.
20-
21-
## Example 1
22-
23-
Customize a plugin's status to only depend on the status of SavedObjects:
24-
25-
```ts
26-
core.status.set(
27-
core.status.core$.pipe(
28-
. map((coreStatus) => {
29-
return coreStatus.savedObjects;
30-
}) ;
31-
);
32-
);
33-
34-
```
35-
36-
## Example 2
37-
38-
Customize a plugin's status to include an external service:
39-
40-
```ts
41-
const externalStatus$ = interval(1000).pipe(
42-
switchMap(async () => {
43-
const resp = await fetch(`https://myexternaldep.com/_healthz`);
44-
const body = await resp.json();
45-
if (body.ok) {
46-
return of({ level: ServiceStatusLevels.available, summary: 'External Service is up'});
47-
} else {
48-
return of({ level: ServiceStatusLevels.available, summary: 'External Service is unavailable'});
49-
}
50-
}),
51-
catchError((error) => {
52-
of({ level: ServiceStatusLevels.unavailable, summary: `External Service is down`, meta: { error }})
53-
})
54-
);
55-
56-
core.status.set(
57-
combineLatest([core.status.derivedStatus$, externalStatus$]).pipe(
58-
map(([derivedStatus, externalStatus]) => {
59-
if (externalStatus.level > derivedStatus) {
60-
return externalStatus;
61-
} else {
62-
return derivedStatus;
63-
}
64-
})
65-
)
66-
);
67-
68-
```
69-
7015
## Properties
7116

7217
| Property | Type | Description |
7318
| --- | --- | --- |
7419
| [core$](./kibana-plugin-core-server.statusservicesetup.core_.md) | <code>Observable&lt;CoreStatus&gt;</code> | Current status for all Core services. |
75-
| [dependencies$](./kibana-plugin-core-server.statusservicesetup.dependencies_.md) | <code>Observable&lt;Record&lt;string, ServiceStatus&gt;&gt;</code> | Current status for all plugins this plugin depends on. Each key of the <code>Record</code> is a plugin id. |
76-
| [derivedStatus$](./kibana-plugin-core-server.statusservicesetup.derivedstatus_.md) | <code>Observable&lt;ServiceStatus&gt;</code> | The status of this plugin as derived from its dependencies. |
7720
| [overall$](./kibana-plugin-core-server.statusservicesetup.overall_.md) | <code>Observable&lt;ServiceStatus&gt;</code> | Overall system status for all of Kibana. |
7821

79-
## Methods
80-
81-
| Method | Description |
82-
| --- | --- |
83-
| [set(status$)](./kibana-plugin-core-server.statusservicesetup.set.md) | Allows a plugin to specify a custom status dependent on its own criteria. Completely overrides the default inherited status. |
84-

docs/development/core/server/kibana-plugin-core-server.statusservicesetup.set.md

Lines changed: 0 additions & 28 deletions
This file was deleted.

src/core/server/legacy/legacy_service.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -323,9 +323,6 @@ export class LegacyService implements CoreService {
323323
status: {
324324
core$: setupDeps.core.status.core$,
325325
overall$: setupDeps.core.status.overall$,
326-
set: setupDeps.core.status.plugins.set.bind(null, 'legacy'),
327-
dependencies$: setupDeps.core.status.plugins.getDependenciesStatus$('legacy'),
328-
derivedStatus$: setupDeps.core.status.plugins.getDerivedStatus$('legacy'),
329326
},
330327
uiSettings: {
331328
register: setupDeps.core.uiSettings.register,

src/core/server/plugins/plugin_context.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -185,9 +185,6 @@ export function createPluginSetupContext<TPlugin, TPluginDependencies>(
185185
status: {
186186
core$: deps.status.core$,
187187
overall$: deps.status.overall$,
188-
set: deps.status.plugins.set.bind(null, plugin.name),
189-
dependencies$: deps.status.plugins.getDependenciesStatus$(plugin.name),
190-
derivedStatus$: deps.status.plugins.getDerivedStatus$(plugin.name),
191188
},
192189
uiSettings: {
193190
register: deps.uiSettings.register,

src/core/server/plugins/plugins_system.test.ts

Lines changed: 9 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -100,27 +100,15 @@ test('getPluginDependencies returns dependency tree of symbols', () => {
100100
pluginsSystem.addPlugin(createPlugin('no-dep'));
101101

102102
expect(pluginsSystem.getPluginDependencies()).toMatchInlineSnapshot(`
103-
Object {
104-
"asNames": Map {
105-
"plugin-a" => Array [
106-
"no-dep",
107-
],
108-
"plugin-b" => Array [
109-
"plugin-a",
110-
"no-dep",
111-
],
112-
"no-dep" => Array [],
113-
},
114-
"asOpaqueIds": Map {
115-
Symbol(plugin-a) => Array [
116-
Symbol(no-dep),
117-
],
118-
Symbol(plugin-b) => Array [
119-
Symbol(plugin-a),
120-
Symbol(no-dep),
121-
],
122-
Symbol(no-dep) => Array [],
123-
},
103+
Map {
104+
Symbol(plugin-a) => Array [
105+
Symbol(no-dep),
106+
],
107+
Symbol(plugin-b) => Array [
108+
Symbol(plugin-a),
109+
Symbol(no-dep),
110+
],
111+
Symbol(no-dep) => Array [],
124112
}
125113
`);
126114
});

src/core/server/plugins/plugins_system.ts

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,10 @@
2020
import { CoreContext } from '../core_context';
2121
import { Logger } from '../logging';
2222
import { PluginWrapper } from './plugin';
23-
import { DiscoveredPlugin, PluginName } from './types';
23+
import { DiscoveredPlugin, PluginName, PluginOpaqueId } from './types';
2424
import { createPluginSetupContext, createPluginStartContext } from './plugin_context';
2525
import { PluginsServiceSetupDeps, PluginsServiceStartDeps } from './plugins_service';
2626
import { withTimeout } from '../../utils';
27-
import { PluginDependencies } from '.';
2827

2928
const Sec = 1000;
3029
/** @internal */
@@ -46,19 +45,9 @@ export class PluginsSystem {
4645
* @returns a ReadonlyMap of each plugin and an Array of its available dependencies
4746
* @internal
4847
*/
49-
public getPluginDependencies(): PluginDependencies {
50-
const asNames = new Map(
51-
[...this.plugins].map(([name, plugin]) => [
52-
plugin.name,
53-
[
54-
...new Set([
55-
...plugin.requiredPlugins,
56-
...plugin.optionalPlugins.filter((optPlugin) => this.plugins.has(optPlugin)),
57-
]),
58-
].map((depId) => this.plugins.get(depId)!.name),
59-
])
60-
);
61-
const asOpaqueIds = new Map(
48+
public getPluginDependencies(): ReadonlyMap<PluginOpaqueId, PluginOpaqueId[]> {
49+
// Return dependency map of opaque ids
50+
return new Map(
6251
[...this.plugins].map(([name, plugin]) => [
6352
plugin.opaqueId,
6453
[
@@ -69,8 +58,6 @@ export class PluginsSystem {
6958
].map((depId) => this.plugins.get(depId)!.opaqueId),
7059
])
7160
);
72-
73-
return { asNames, asOpaqueIds };
7461
}
7562

7663
public async setupPlugins(deps: PluginsServiceSetupDeps) {

src/core/server/plugins/types.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -93,12 +93,6 @@ export type PluginName = string;
9393
/** @public */
9494
export type PluginOpaqueId = symbol;
9595

96-
/** @internal */
97-
export interface PluginDependencies {
98-
asNames: ReadonlyMap<PluginName, PluginName[]>;
99-
asOpaqueIds: ReadonlyMap<PluginOpaqueId, PluginOpaqueId[]>;
100-
}
101-
10296
/**
10397
* Describes the set of required and optional properties plugin can define in its
10498
* mandatory JSON manifest file.

src/core/server/server.api.md

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2858,17 +2858,10 @@ export type SharedGlobalConfig = RecursiveReadonly<{
28582858
// @public
28592859
export type StartServicesAccessor<TPluginsStart extends object = object, TStart = unknown> = () => Promise<[CoreStart, TPluginsStart, TStart]>;
28602860

2861-
// Warning: (ae-unresolved-link) The @link reference could not be resolved: The package "kibana" does not have an export "ServiceStatusSetup"
2862-
// Warning: (ae-unresolved-link) The @link reference could not be resolved: The package "kibana" does not have an export "ServiceStatusSetup"
2863-
//
28642861
// @public
28652862
export interface StatusServiceSetup {
28662863
core$: Observable<CoreStatus>;
2867-
dependencies$: Observable<Record<string, ServiceStatus>>;
2868-
// Warning: (ae-unresolved-link) The @link reference could not be resolved: The package "kibana" does not have an export "StatusSetup"
2869-
derivedStatus$: Observable<ServiceStatus>;
28702864
overall$: Observable<ServiceStatus>;
2871-
set(status$: Observable<ServiceStatus>): void;
28722865
}
28732866

28742867
// @public
@@ -2961,8 +2954,8 @@ export const validBodyOutput: readonly ["data", "stream"];
29612954
// src/core/server/legacy/types.ts:165:3 - (ae-forgotten-export) The symbol "LegacyNavLinkSpec" needs to be exported by the entry point index.d.ts
29622955
// src/core/server/legacy/types.ts:166:3 - (ae-forgotten-export) The symbol "LegacyAppSpec" needs to be exported by the entry point index.d.ts
29632956
// src/core/server/legacy/types.ts:167:16 - (ae-forgotten-export) The symbol "LegacyPluginSpec" needs to be exported by the entry point index.d.ts
2964-
// src/core/server/plugins/types.ts:272:3 - (ae-forgotten-export) The symbol "KibanaConfigType" needs to be exported by the entry point index.d.ts
2965-
// src/core/server/plugins/types.ts:272:3 - (ae-forgotten-export) The symbol "SharedGlobalConfigKeys" needs to be exported by the entry point index.d.ts
2966-
// src/core/server/plugins/types.ts:274:3 - (ae-forgotten-export) The symbol "PathConfigType" needs to be exported by the entry point index.d.ts
2957+
// src/core/server/plugins/types.ts:266:3 - (ae-forgotten-export) The symbol "KibanaConfigType" needs to be exported by the entry point index.d.ts
2958+
// src/core/server/plugins/types.ts:266:3 - (ae-forgotten-export) The symbol "SharedGlobalConfigKeys" needs to be exported by the entry point index.d.ts
2959+
// src/core/server/plugins/types.ts:268:3 - (ae-forgotten-export) The symbol "PathConfigType" needs to be exported by the entry point index.d.ts
29672960

29682961
```

0 commit comments

Comments
 (0)