mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 17:28:26 -04:00
x-pack/watcher: use Elasticsearch from CoreStart
This commit is contained in:
parent
7d12b7650f
commit
b621af9388
1 changed files with 12 additions and 7 deletions
|
@ -45,21 +45,26 @@ export class WatcherServerPlugin implements Plugin<void, void, any, any> {
|
|||
this.log = ctx.logger.get();
|
||||
}
|
||||
|
||||
async setup(
|
||||
{ http, elasticsearch: elasticsearchService }: CoreSetup,
|
||||
{ licensing }: Dependencies
|
||||
) {
|
||||
async setup({ http, getStartServices }: CoreSetup, { licensing }: Dependencies) {
|
||||
const router = http.createRouter();
|
||||
const routeDependencies: RouteDependencies = {
|
||||
router,
|
||||
getLicenseStatus: () => this.licenseStatus,
|
||||
};
|
||||
|
||||
const config = { plugins: [elasticsearchJsPlugin] };
|
||||
const watcherESClient = elasticsearchService.createClient('watcher', config);
|
||||
const getWatcherEsClient = async () => {
|
||||
const [coreStart] = await getStartServices();
|
||||
const config = { plugins: [elasticsearchJsPlugin] };
|
||||
return coreStart.elasticsearch.legacy.createClient('watcher', config);
|
||||
};
|
||||
http.registerRouteHandlerContext('watcher', (ctx, request) => {
|
||||
return {
|
||||
client: watcherESClient.asScoped(request),
|
||||
client: {
|
||||
callAsCurrentUser: async (...args) =>
|
||||
(await getWatcherEsClient()).asScoped(request).callAsCurrentUser(...args),
|
||||
callAsInternalUser: async (...args) =>
|
||||
(await getWatcherEsClient()).asScoped(request).callAsInternalUser(...args),
|
||||
},
|
||||
};
|
||||
});
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue