Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[KP] Expose new es client #73651

Merged
merged 18 commits into from Jul 30, 2020
Merged

Conversation

mshustov
Copy link
Contributor

@mshustov mshustov commented Jul 29, 2020

Summary

This PR exposes new elasticsearch client to the plugins on the server-side. The new client is available via:

  • requestHandlerContext
router.get({ path: '...', validate: false }, async (context, request, response) => {
  const { body } = await context.core.elasticsearch.client.asInternalUser.search({..});
  //.. 
});
  • coreStart contract of the elasticsearch service:
start(code: CoreStart) {
  return {
    doSomething: async () => {
      const { body } = await context.core.elasticsearch.client.asInternalUser.search({..});
      return body;
    }
  }
}

Migration guide for the new elasticsearch client available in https://github.com/elastic/kibana/blob/master/src/core/MIGRATION_EXAMPLES.md#elasticsearch-client

The legacy client is going to be deprecated and removed in 7.x.

Checklist

Delete any items that are not applicable to this PR.

For maintainers

Dev Docs

Kibana provides the new elasticsearch client as a part of the elasticsearch service on the server-side. The legacy client is deprecated on and subject for removal in 7.x. Reference the provided migration guide to refactor your code https://github.com/elastic/kibana/blob/master/src/core/MIGRATION_EXAMPLES.md#elasticsearch-client

@mshustov mshustov added Team:Core Core services & architecture: plugins, logging, config, saved objects, http, ES client, i18n, etc release_note:plugin_api_changes Contains a Plugin API changes section for the breaking plugin API changes section. v7.10.0 labels Jul 29, 2020
@mshustov mshustov added this to Pending Review in kibana-core [DEPRECATED] via automation Jul 29, 2020
@mshustov mshustov marked this pull request as ready for review July 29, 2020 15:16
@mshustov mshustov requested review from a team as code owners July 29, 2020 15:16
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-platform (Team:Platform)

Copy link
Member

@joshdover joshdover left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, pretty simple expose change. Had one question about test coverage w/ security enabled, but it's possible we have similar coverage somewhere else that I am not aware of.

@@ -22,6 +22,7 @@ import { CatTasksParams } from 'elasticsearch';
import { CatThreadPoolParams } from 'elasticsearch';
import { ClearScrollParams } from 'elasticsearch';
import { Client } from 'elasticsearch';
import { ClientOptions } from '@elastic/elasticsearch';
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no idea why it's here. it's not used in the file

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤷‍♂️

@@ -22,6 +22,7 @@ import { CatTasksParams } from 'elasticsearch';
import { CatThreadPoolParams } from 'elasticsearch';
import { ClearScrollParams } from 'elasticsearch';
import { Client } from 'elasticsearch';
import { ClientOptions } from '@elastic/elasticsearch';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤷‍♂️

@kibanamachine
Copy link
Contributor

💚 Build Succeeded

Build metrics

✅ unchanged

History

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

@mshustov mshustov merged commit 585d58c into elastic:master Jul 30, 2020
kibana-core [DEPRECATED] automation moved this from Pending Review to Done (7.10) Jul 30, 2020
@mshustov mshustov deleted the expose-new-es-client branch July 30, 2020 17:12
mshustov added a commit to mshustov/kibana that referenced this pull request Jul 30, 2020
* mark legacy ES client types as deprecated

* expose es client to plugins and update mocks

* ElasticSearchClientMock --> ElasticsearchClientMock

* expose es client mocks

* expose es client via RequestHandlerContext

* convert test/plugin_functional/config into ts

* convert top_nav test into ts

* add an integration test for the es client

* update comments to refer to the new es client

* fix import paths. do not use extensions

temp

* update docs

* fix other refs

* add test for a custom client

* fix context

* add test for scoped client

* update docs
# Conflicts:
#	scripts/functional_tests.js
mshustov added a commit that referenced this pull request Jul 30, 2020
* mark legacy ES client types as deprecated

* expose es client to plugins and update mocks

* ElasticSearchClientMock --> ElasticsearchClientMock

* expose es client mocks

* expose es client via RequestHandlerContext

* convert test/plugin_functional/config into ts

* convert top_nav test into ts

* add an integration test for the es client

* update comments to refer to the new es client

* fix import paths. do not use extensions

temp

* update docs

* fix other refs

* add test for a custom client

* fix context

* add test for scoped client

* update docs
# Conflicts:
#	scripts/functional_tests.js
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release_note:plugin_api_changes Contains a Plugin API changes section for the breaking plugin API changes section. Team:Core Core services & architecture: plugins, logging, config, saved objects, http, ES client, i18n, etc v7.10.0
Projects
Development

Successfully merging this pull request may close these issues.

None yet

5 participants