Expose Elasticsearch from start and deprecate from setup (#59886) (#60163)

* Expose Elasticsearch from start and deprecate from setup

* Expose client under legacy namespace, add deprecated note

* Update migration guide

Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
This commit is contained in:
Rudolf Meijering 2020-03-16 12:33:37 +01:00 committed by GitHub
parent 97233dde54
commit 66d5b223b5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
21 changed files with 210 additions and 35 deletions

View file

@ -0,0 +1,13 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
[Home](./index.md) &gt; [kibana-plugin-server](./kibana-plugin-server.md) &gt; [CoreStart](./kibana-plugin-server.corestart.md) &gt; [elasticsearch](./kibana-plugin-server.corestart.elasticsearch.md)
## CoreStart.elasticsearch property
[ElasticsearchServiceStart](./kibana-plugin-server.elasticsearchservicestart.md)
<b>Signature:</b>
```typescript
elasticsearch: ElasticsearchServiceStart;
```

View file

@ -17,6 +17,7 @@ export interface CoreStart
| Property | Type | Description |
| --- | --- | --- |
| [capabilities](./kibana-plugin-server.corestart.capabilities.md) | <code>CapabilitiesStart</code> | [CapabilitiesStart](./kibana-plugin-server.capabilitiesstart.md) |
| [elasticsearch](./kibana-plugin-server.corestart.elasticsearch.md) | <code>ElasticsearchServiceStart</code> | [ElasticsearchServiceStart](./kibana-plugin-server.elasticsearchservicestart.md) |
| [savedObjects](./kibana-plugin-server.corestart.savedobjects.md) | <code>SavedObjectsServiceStart</code> | [SavedObjectsServiceStart](./kibana-plugin-server.savedobjectsservicestart.md) |
| [uiSettings](./kibana-plugin-server.corestart.uisettings.md) | <code>UiSettingsServiceStart</code> | [UiSettingsServiceStart](./kibana-plugin-server.uisettingsservicestart.md) |

View file

@ -4,7 +4,12 @@
## ElasticsearchServiceSetup.adminClient property
A client for the `admin` cluster. All Elasticsearch config value changes are processed under the hood. See [IClusterClient](./kibana-plugin-server.iclusterclient.md)<!-- -->.
> Warning: This API is now obsolete.
>
> Use [ElasticsearchServiceStart.legacy.client](./kibana-plugin-server.elasticsearchservicestart.legacy.md) instead.
>
> A client for the `admin` cluster. All Elasticsearch config value changes are processed under the hood. See [IClusterClient](./kibana-plugin-server.iclusterclient.md)<!-- -->.
>
<b>Signature:</b>

View file

@ -4,7 +4,12 @@
## ElasticsearchServiceSetup.createClient property
Create application specific Elasticsearch cluster API client with customized config. See [IClusterClient](./kibana-plugin-server.iclusterclient.md)<!-- -->.
> Warning: This API is now obsolete.
>
> Use [ElasticsearchServiceStart.legacy.createClient](./kibana-plugin-server.elasticsearchservicestart.legacy.md) instead.
>
> Create application specific Elasticsearch cluster API client with customized config. See [IClusterClient](./kibana-plugin-server.iclusterclient.md)<!-- -->.
>
<b>Signature:</b>

View file

@ -4,7 +4,12 @@
## ElasticsearchServiceSetup.dataClient property
A client for the `data` cluster. All Elasticsearch config value changes are processed under the hood. See [IClusterClient](./kibana-plugin-server.iclusterclient.md)<!-- -->.
> Warning: This API is now obsolete.
>
> Use [ElasticsearchServiceStart.legacy.client](./kibana-plugin-server.elasticsearchservicestart.legacy.md) instead.
>
> A client for the `data` cluster. All Elasticsearch config value changes are processed under the hood. See [IClusterClient](./kibana-plugin-server.iclusterclient.md)<!-- -->.
>
<b>Signature:</b>

View file

@ -15,7 +15,7 @@ export interface ElasticsearchServiceSetup
| Property | Type | Description |
| --- | --- | --- |
| [adminClient](./kibana-plugin-server.elasticsearchservicesetup.adminclient.md) | <code>IClusterClient</code> | A client for the <code>admin</code> cluster. All Elasticsearch config value changes are processed under the hood. See [IClusterClient](./kibana-plugin-server.iclusterclient.md)<!-- -->. |
| [createClient](./kibana-plugin-server.elasticsearchservicesetup.createclient.md) | <code>(type: string, clientConfig?: Partial&lt;ElasticsearchClientConfig&gt;) =&gt; ICustomClusterClient</code> | Create application specific Elasticsearch cluster API client with customized config. See [IClusterClient](./kibana-plugin-server.iclusterclient.md)<!-- -->. |
| [dataClient](./kibana-plugin-server.elasticsearchservicesetup.dataclient.md) | <code>IClusterClient</code> | A client for the <code>data</code> cluster. All Elasticsearch config value changes are processed under the hood. See [IClusterClient](./kibana-plugin-server.iclusterclient.md)<!-- -->. |
| [adminClient](./kibana-plugin-server.elasticsearchservicesetup.adminclient.md) | <code>IClusterClient</code> | |
| [createClient](./kibana-plugin-server.elasticsearchservicesetup.createclient.md) | <code>(type: string, clientConfig?: Partial&lt;ElasticsearchClientConfig&gt;) =&gt; ICustomClusterClient</code> | |
| [dataClient](./kibana-plugin-server.elasticsearchservicesetup.dataclient.md) | <code>IClusterClient</code> | |

View file

@ -0,0 +1,14 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
[Home](./index.md) &gt; [kibana-plugin-server](./kibana-plugin-server.md) &gt; [ElasticsearchServiceStart](./kibana-plugin-server.elasticsearchservicestart.md) &gt; [legacy](./kibana-plugin-server.elasticsearchservicestart.legacy.md)
## ElasticsearchServiceStart.legacy property
<b>Signature:</b>
```typescript
legacy: {
readonly createClient: (type: string, clientConfig?: Partial<ElasticsearchClientConfig>) => ICustomClusterClient;
readonly client: IClusterClient;
};
```

View file

@ -0,0 +1,19 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
[Home](./index.md) &gt; [kibana-plugin-server](./kibana-plugin-server.md) &gt; [ElasticsearchServiceStart](./kibana-plugin-server.elasticsearchservicestart.md)
## ElasticsearchServiceStart interface
<b>Signature:</b>
```typescript
export interface ElasticsearchServiceStart
```
## Properties
| Property | Type | Description |
| --- | --- | --- |
| [legacy](./kibana-plugin-server.elasticsearchservicestart.legacy.md) | <code>{</code><br/><code> readonly createClient: (type: string, clientConfig?: Partial&lt;ElasticsearchClientConfig&gt;) =&gt; ICustomClusterClient;</code><br/><code> readonly client: IClusterClient;</code><br/><code> }</code> | |

View file

@ -74,6 +74,7 @@ The plugin integrates with the core system via lifecycle events: `setup`<!-- -->
| [DiscoveredPlugin](./kibana-plugin-server.discoveredplugin.md) | Small container object used to expose information about discovered plugins that may or may not have been started. |
| [ElasticsearchError](./kibana-plugin-server.elasticsearcherror.md) | |
| [ElasticsearchServiceSetup](./kibana-plugin-server.elasticsearchservicesetup.md) | |
| [ElasticsearchServiceStart](./kibana-plugin-server.elasticsearchservicestart.md) | |
| [EnvironmentMode](./kibana-plugin-server.environmentmode.md) | |
| [ErrorHttpResponseOptions](./kibana-plugin-server.errorhttpresponseoptions.md) | HTTP response parameters |
| [FakeRequest](./kibana-plugin-server.fakerequest.md) | Fake request object created manually by Kibana plugins. |

View file

@ -45,7 +45,7 @@
- [UI Exports](#ui-exports)
- [How to](#how-to)
- [Configure plugin](#configure-plugin)
- [Handle plugin configuration deprecations](#handle-plugin-config-deprecations)
- [Handle plugin configuration deprecations](#handle-plugin-configuration-deprecations)
- [Use scoped services](#use-scoped-services)
- [Declare a custom scoped service](#declare-a-custom-scoped-service)
- [Mock new platform services in tests](#mock-new-platform-services-in-tests)
@ -55,7 +55,7 @@
- [Provide Legacy Platform API to the New platform plugin](#provide-legacy-platform-api-to-the-new-platform-plugin)
- [On the server side](#on-the-server-side)
- [On the client side](#on-the-client-side)
- [Updates an application navlink at runtime](#updates-an-app-navlink-at-runtime)
- [Updates an application navlink at runtime](#updates-an-application-navlink-at-runtime)
- [Logging config migration](#logging-config-migration)
Make no mistake, it is going to take a lot of work to move certain plugins to the new platform. Our target is to migrate the entire repo over to the new platform throughout 7.x and to remove the legacy plugin system no later than 8.0, and this is only possible if teams start on the effort now.
@ -1198,13 +1198,13 @@ In server code, `core` can be accessed from either `server.newPlatform` or `kbnS
| `request.getBasePath()` | [`core.http.basePath.get`](/docs/development/core/server/kibana-plugin-server.httpservicesetup.basepath.md) | |
| `server.plugins.elasticsearch.getCluster('data')` | [`context.core.elasticsearch.dataClient`](/docs/development/core/server/kibana-plugin-server.iscopedclusterclient.md) | |
| `server.plugins.elasticsearch.getCluster('admin')` | [`context.core.elasticsearch.adminClient`](/docs/development/core/server/kibana-plugin-server.iscopedclusterclient.md) | |
| `server.plugins.elasticsearch.createCluster(...)` | [`core.elasticsearch.createClient`](/docs/development/core/server/kibana-plugin-server.elasticsearchservicesetup.createclient.md) | |
| `server.plugins.elasticsearch.createCluster(...)` | [`core.elasticsearch.legacy.createClient`](/docs/development/core/server/kibana-plugin-server.elasticsearchservicestart.legacy.md) | |
| `server.savedObjects.setScopedSavedObjectsClientFactory` | [`core.savedObjects.setClientFactoryProvider`](/docs/development/core/server/kibana-plugin-server.savedobjectsservicesetup.setclientfactoryprovider.md) | |
| `server.savedObjects.addScopedSavedObjectsClientWrapperFactory` | [`core.savedObjects.addClientWrapper`](/docs/development/core/server/kibana-plugin-server.savedobjectsservicesetup.addclientwrapper.md) | |
| `server.savedObjects.getSavedObjectsRepository` | [`core.savedObjects.createInternalRepository`](/docs/development/core/server/kibana-plugin-server.savedobjectsservicestart.createinternalrepository.md) [`core.savedObjects.createScopedRepository`](/docs/development/core/server/kibana-plugin-server.savedobjectsservicestart.createscopedrepository.md) | |
| `server.savedObjects.getScopedSavedObjectsClient` | [`core.savedObjects.getScopedClient`](/docs/development/core/server/kibana-plugin-server.savedobjectsservicestart.getscopedclient.md) | |
| `request.getSavedObjectsClient` | [`context.core.savedObjects.client`](/docs/development/core/server/kibana-plugin-server.requesthandlercontext.core.md) | |
| `request.getUiSettingsService` | [`context.uiSettings.client`](/docs/development/core/server/kibana-plugin-server.iuisettingsclient.md) | |
| `request.getUiSettingsService` | [`context.core.uiSettings.client`](/docs/development/core/server/kibana-plugin-server.iuisettingsclient.md) | |
| `kibana.Plugin.deprecations` | [Handle plugin configuration deprecations](#handle-plugin-config-deprecations) and [`PluginConfigDescriptor.deprecations`](docs/development/core/server/kibana-plugin-server.pluginconfigdescriptor.md) | Deprecations from New Platform are not applied to legacy configuration |
| `kibana.Plugin.savedObjectSchemas` | [`core.savedObjects.registerType`](docs/development/core/server/kibana-plugin-server.savedobjectsservicesetup.registertype.md) | [Examples](./MIGRATION_EXAMPLES.md#saved-objects-types) |
| `kibana.Plugin.mappings` | [`core.savedObjects.registerType`](docs/development/core/server/kibana-plugin-server.savedobjectsservicesetup.registertype.md) | [Examples](./MIGRATION_EXAMPLES.md#saved-objects-types) |

View file

@ -22,7 +22,11 @@ import { IClusterClient, ICustomClusterClient } from './cluster_client';
import { IScopedClusterClient } from './scoped_cluster_client';
import { ElasticsearchConfig } from './elasticsearch_config';
import { ElasticsearchService } from './elasticsearch_service';
import { InternalElasticsearchServiceSetup, ElasticsearchServiceSetup } from './types';
import {
InternalElasticsearchServiceSetup,
ElasticsearchServiceSetup,
ElasticsearchServiceStart,
} from './types';
import { NodesVersionCompatibility } from './version_check/ensure_es_version';
const createScopedClusterClientMock = (): jest.Mocked<IScopedClusterClient> => ({
@ -63,6 +67,26 @@ const createSetupContractMock = () => {
return setupContract;
};
type MockedElasticSearchServiceStart = {
legacy: jest.Mocked<ElasticsearchServiceStart['legacy']>;
} & {
legacy: {
client: jest.Mocked<IClusterClient>;
};
};
const createStartContractMock = () => {
const startContract: MockedElasticSearchServiceStart = {
legacy: {
createClient: jest.fn(),
client: createClusterClientMock(),
},
};
startContract.legacy.createClient.mockReturnValue(createCustomClusterClientMock());
startContract.legacy.client.asScoped.mockReturnValue(createScopedClusterClientMock());
return startContract;
};
type MockedInternalElasticSearchServiceSetup = jest.Mocked<
InternalElasticsearchServiceSetup & {
adminClient: jest.Mocked<IClusterClient>;
@ -95,6 +119,7 @@ const createMock = () => {
stop: jest.fn(),
};
mocked.setup.mockResolvedValue(createInternalSetupContractMock());
mocked.start.mockResolvedValueOnce(createStartContractMock());
mocked.stop.mockResolvedValue();
return mocked;
};
@ -103,6 +128,7 @@ export const elasticsearchServiceMock = {
create: createMock,
createInternalSetup: createInternalSetupContractMock,
createSetup: createSetupContractMock,
createStart: createStartContractMock,
createClusterClient: createClusterClientMock,
createCustomClusterClient: createCustomClusterClientMock,
createScopedClusterClient: createScopedClusterClientMock,

View file

@ -37,7 +37,7 @@ import { ClusterClient, ScopeableRequest } from './cluster_client';
import { ElasticsearchClientConfig } from './elasticsearch_client_config';
import { ElasticsearchConfig, ElasticsearchConfigType } from './elasticsearch_config';
import { InternalHttpServiceSetup, GetAuthHeaders } from '../http/';
import { InternalElasticsearchServiceSetup } from './types';
import { InternalElasticsearchServiceSetup, ElasticsearchServiceStart } from './types';
import { CallAPIOptions } from './api_types';
import { pollEsNodesVersion } from './version_check/ensure_es_version';
@ -53,12 +53,16 @@ interface SetupDeps {
}
/** @internal */
export class ElasticsearchService implements CoreService<InternalElasticsearchServiceSetup> {
export class ElasticsearchService
implements CoreService<InternalElasticsearchServiceSetup, ElasticsearchServiceStart> {
private readonly log: Logger;
private readonly config$: Observable<ElasticsearchConfig>;
private subscription: Subscription | undefined;
private stop$ = new Subject();
private kibanaVersion: string;
createClient: InternalElasticsearchServiceSetup['createClient'] | undefined;
dataClient: InternalElasticsearchServiceSetup['dataClient'] | undefined;
adminClient: InternalElasticsearchServiceSetup['adminClient'] | undefined;
constructor(private readonly coreContext: CoreContext) {
this.kibanaVersion = coreContext.env.packageInfo.version;
@ -111,7 +115,7 @@ export class ElasticsearchService implements CoreService<InternalElasticsearchSe
const adminClient$ = clients$.pipe(map(clients => clients.adminClient));
const dataClient$ = clients$.pipe(map(clients => clients.dataClient));
const adminClient = {
this.adminClient = {
async callAsInternalUser(
endpoint: string,
clientParams: Record<string, any> = {},
@ -120,9 +124,9 @@ export class ElasticsearchService implements CoreService<InternalElasticsearchSe
const client = await adminClient$.pipe(take(1)).toPromise();
return await client.callAsInternalUser(endpoint, clientParams, options);
},
asScoped(request: ScopeableRequest) {
asScoped: (request: ScopeableRequest) => {
return {
callAsInternalUser: adminClient.callAsInternalUser,
callAsInternalUser: this.adminClient!.callAsInternalUser,
async callAsCurrentUser(
endpoint: string,
clientParams: Record<string, any> = {},
@ -136,6 +140,7 @@ export class ElasticsearchService implements CoreService<InternalElasticsearchSe
};
},
};
const dataClient = {
async callAsInternalUser(
endpoint: string,
@ -163,28 +168,39 @@ export class ElasticsearchService implements CoreService<InternalElasticsearchSe
};
const esNodesCompatibility$ = pollEsNodesVersion({
callWithInternalUser: adminClient.callAsInternalUser,
callWithInternalUser: this.adminClient.callAsInternalUser,
log: this.log,
ignoreVersionMismatch: config.ignoreVersionMismatch,
esVersionCheckInterval: config.healthCheckDelay.asMilliseconds(),
kibanaVersion: this.kibanaVersion,
}).pipe(takeUntil(this.stop$), shareReplay({ refCount: true, bufferSize: 1 }));
this.createClient = (type: string, clientConfig: Partial<ElasticsearchClientConfig> = {}) => {
const finalConfig = merge({}, config, clientConfig);
return this.createClusterClient(type, finalConfig, deps.http.getAuthHeaders);
};
return {
legacy: { config$: clients$.pipe(map(clients => clients.config)) },
adminClient,
dataClient,
esNodesCompatibility$,
createClient: (type: string, clientConfig: Partial<ElasticsearchClientConfig> = {}) => {
const finalConfig = merge({}, config, clientConfig);
return this.createClusterClient(type, finalConfig, deps.http.getAuthHeaders);
},
adminClient: this.adminClient,
dataClient,
createClient: this.createClient,
};
}
public async start() {}
public async start() {
if (typeof this.adminClient === 'undefined' || typeof this.createClient === 'undefined') {
throw new Error('ElasticsearchService needs to be setup before calling start');
} else {
return {
legacy: {
client: this.adminClient,
createClient: this.createClient,
},
};
}
}
public async stop() {
this.log.debug('Stopping elasticsearch service');

View file

@ -28,6 +28,9 @@ import { NodesVersionCompatibility } from './version_check/ensure_es_version';
*/
export interface ElasticsearchServiceSetup {
/**
* @deprecated
* Use {@link ElasticsearchServiceStart.legacy | ElasticsearchServiceStart.legacy.createClient} instead.
*
* Create application specific Elasticsearch cluster API client with customized config. See {@link IClusterClient}.
*
* @param type Unique identifier of the client
@ -50,6 +53,9 @@ export interface ElasticsearchServiceSetup {
) => ICustomClusterClient;
/**
* @deprecated
* Use {@link ElasticsearchServiceStart.legacy | ElasticsearchServiceStart.legacy.client} instead.
*
* A client for the `admin` cluster. All Elasticsearch config value changes are processed under the hood.
* See {@link IClusterClient}.
*
@ -61,6 +67,9 @@ export interface ElasticsearchServiceSetup {
readonly adminClient: IClusterClient;
/**
* @deprecated
* Use {@link ElasticsearchServiceStart.legacy | ElasticsearchServiceStart.legacy.client} instead.
*
* A client for the `data` cluster. All Elasticsearch config value changes are processed under the hood.
* See {@link IClusterClient}.
*
@ -72,6 +81,46 @@ export interface ElasticsearchServiceSetup {
readonly dataClient: IClusterClient;
}
/**
* @public
*/
export interface ElasticsearchServiceStart {
legacy: {
/**
* Create application specific Elasticsearch cluster API client with customized config. See {@link IClusterClient}.
*
* @param type Unique identifier of the client
* @param clientConfig A config consists of Elasticsearch JS client options and
* valid sub-set of Elasticsearch service config.
* We fill all the missing properties in the `clientConfig` using the default
* Elasticsearch config so that we don't depend on default values set and
* controlled by underlying Elasticsearch JS client.
* We don't run validation against the passed config and expect it to be valid.
*
* @example
* ```js
* const client = elasticsearch.createCluster('my-app-name', config);
* const data = await client.callAsInternalUser();
* ```
*/
readonly createClient: (
type: string,
clientConfig?: Partial<ElasticsearchClientConfig>
) => ICustomClusterClient;
/**
* A pre-configured Elasticsearch client. All Elasticsearch config value changes are processed under the hood.
* See {@link IClusterClient}.
*
* @example
* ```js
* const client = core.elasticsearch.client;
* ```
*/
readonly client: IClusterClient;
};
}
/** @internal */
export interface InternalElasticsearchServiceSetup extends ElasticsearchServiceSetup {
// Required for the BWC with the legacy Kibana only.

View file

@ -43,6 +43,7 @@ import {
ElasticsearchServiceSetup,
IScopedClusterClient,
configSchema as elasticsearchConfigSchema,
ElasticsearchServiceStart,
} from './elasticsearch';
import { HttpServiceSetup } from './http';
@ -93,6 +94,7 @@ export {
ElasticsearchError,
ElasticsearchErrorHelpers,
ElasticsearchServiceSetup,
ElasticsearchServiceStart,
APICaller,
FakeRequest,
ScopeableRequest,
@ -366,6 +368,8 @@ export interface CoreSetup<TPluginsStart extends object = object> {
export interface CoreStart {
/** {@link CapabilitiesStart} */
capabilities: CapabilitiesStart;
/** {@link ElasticsearchServiceStart} */
elasticsearch: ElasticsearchServiceStart;
/** {@link SavedObjectsServiceStart} */
savedObjects: SavedObjectsServiceStart;
/** {@link UiSettingsServiceStart} */

View file

@ -22,7 +22,7 @@ import { Type } from '@kbn/config-schema';
import { CapabilitiesSetup, CapabilitiesStart } from './capabilities';
import { ConfigDeprecationProvider } from './config';
import { ContextSetup } from './context';
import { InternalElasticsearchServiceSetup } from './elasticsearch';
import { InternalElasticsearchServiceSetup, ElasticsearchServiceStart } from './elasticsearch';
import { InternalHttpServiceSetup } from './http';
import {
InternalSavedObjectsServiceSetup,
@ -49,6 +49,7 @@ export interface InternalCoreSetup {
*/
export interface InternalCoreStart {
capabilities: CapabilitiesStart;
elasticsearch: ElasticsearchServiceStart;
savedObjects: InternalSavedObjectsServiceStart;
uiSettings: InternalUiSettingsServiceStart;
}

View file

@ -47,6 +47,7 @@ import { metricsServiceMock } from '../metrics/metrics_service.mock';
import { findLegacyPluginSpecs } from './plugins';
import { LegacyVars, LegacyServiceSetupDeps, LegacyServiceStartDeps } from './types';
import { LegacyService } from './legacy_service';
import { coreMock } from '../mocks';
const MockKbnServer: jest.Mock<KbnServer> = KbnServer as any;
@ -102,9 +103,8 @@ beforeEach(() => {
startDeps = {
core: {
capabilities: capabilitiesServiceMock.createStartContract(),
...coreMock.createStart(),
savedObjects: savedObjectsServiceMock.createInternalStartContract(),
uiSettings: uiSettingsServiceMock.createStartContract(),
plugins: { contracts: new Map() },
},
plugins: {},

View file

@ -258,6 +258,7 @@ export class LegacyService implements CoreService {
) {
const coreStart: CoreStart = {
capabilities: startDeps.core.capabilities,
elasticsearch: startDeps.core.elasticsearch,
savedObjects: {
getScopedClient: startDeps.core.savedObjects.getScopedClient,
createScopedRepository: startDeps.core.savedObjects.createScopedRepository,

View file

@ -141,6 +141,7 @@ function createCoreSetupMock() {
function createCoreStartMock() {
const mock: MockedKeys<CoreStart> = {
capabilities: capabilitiesServiceMock.createStartContract(),
elasticsearch: elasticsearchServiceMock.createStart(),
savedObjects: savedObjectsServiceMock.createStartContract(),
uiSettings: uiSettingsServiceMock.createStartContract(),
};
@ -165,6 +166,7 @@ function createInternalCoreSetupMock() {
function createInternalCoreStartMock() {
const startDeps: InternalCoreStart = {
capabilities: capabilitiesServiceMock.createStartContract(),
elasticsearch: elasticsearchServiceMock.createStart(),
savedObjects: savedObjectsServiceMock.createInternalStartContract(),
uiSettings: uiSettingsServiceMock.createStartContract(),
};

View file

@ -206,6 +206,7 @@ export function createPluginStartContext<TPlugin, TPluginDependencies>(
capabilities: {
resolveCapabilities: deps.capabilities.resolveCapabilities,
},
elasticsearch: deps.elasticsearch,
savedObjects: {
getScopedClient: deps.savedObjects.getScopedClient,
createInternalRepository: deps.savedObjects.createInternalRepository,

View file

@ -647,6 +647,8 @@ export interface CoreStart {
// (undocumented)
capabilities: CapabilitiesStart;
// (undocumented)
elasticsearch: ElasticsearchServiceStart;
// (undocumented)
savedObjects: SavedObjectsServiceStart;
// (undocumented)
uiSettings: UiSettingsServiceStart;
@ -774,11 +776,23 @@ export class ElasticsearchErrorHelpers {
// @public (undocumented)
export interface ElasticsearchServiceSetup {
// @deprecated (undocumented)
readonly adminClient: IClusterClient;
// @deprecated (undocumented)
readonly createClient: (type: string, clientConfig?: Partial<ElasticsearchClientConfig>) => ICustomClusterClient;
// @deprecated (undocumented)
readonly dataClient: IClusterClient;
}
// @public (undocumented)
export interface ElasticsearchServiceStart {
// (undocumented)
legacy: {
readonly createClient: (type: string, clientConfig?: Partial<ElasticsearchClientConfig>) => ICustomClusterClient;
readonly client: IClusterClient;
};
}
// @public (undocumented)
export interface EnvironmentMode {
// (undocumented)

View file

@ -177,19 +177,17 @@ export class Server {
const savedObjectsStart = await this.savedObjects.start({});
const capabilitiesStart = this.capabilities.start();
const uiSettingsStart = await this.uiSettings.start();
const pluginsStart = await this.plugins.start({
capabilities: capabilitiesStart,
savedObjects: savedObjectsStart,
uiSettings: uiSettingsStart,
});
const elasticsearchStart = await this.elasticsearch.start();
this.coreStart = {
capabilities: capabilitiesStart,
elasticsearch: elasticsearchStart,
savedObjects: savedObjectsStart,
uiSettings: uiSettingsStart,
};
const pluginsStart = await this.plugins.start(this.coreStart!);
await this.legacy.start({
core: {
...this.coreStart,