Skip to content

Commit

Permalink
x-pack/watcher: create custom client only once
Browse files Browse the repository at this point in the history
  • Loading branch information
rudolf committed Mar 18, 2020
1 parent 06c19f5 commit 78fc4d2
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions x-pack/plugins/watcher/server/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ declare module 'kibana/server' {
}
}

import { once } from 'lodash';
import {
CoreSetup,
IScopedClusterClient,
Expand Down Expand Up @@ -52,11 +53,11 @@ export class WatcherServerPlugin implements Plugin<void, void, any, any> {
getLicenseStatus: () => this.licenseStatus,
};

const getWatcherEsClient = async () => {
const getWatcherEsClient = once(async () => {
const [coreStart] = await getStartServices();
const config = { plugins: [elasticsearchJsPlugin] };
return coreStart.elasticsearch.legacy.createClient('watcher', config);
};
});
http.registerRouteHandlerContext('watcher', (ctx, request) => {
return {
client: {
Expand Down

0 comments on commit 78fc4d2

Please sign in to comment.