From 78fc4d2e93c05b1fd014bd6fa31a608d6968ed43 Mon Sep 17 00:00:00 2001 From: Rudolf Meijering Date: Wed, 18 Mar 2020 13:47:37 +0100 Subject: [PATCH] x-pack/watcher: create custom client only once --- x-pack/plugins/watcher/server/plugin.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/x-pack/plugins/watcher/server/plugin.ts b/x-pack/plugins/watcher/server/plugin.ts index 88cecf533522..dcbc7e652687 100644 --- a/x-pack/plugins/watcher/server/plugin.ts +++ b/x-pack/plugins/watcher/server/plugin.ts @@ -10,6 +10,7 @@ declare module 'kibana/server' { } } +import { once } from 'lodash'; import { CoreSetup, IScopedClusterClient, @@ -52,11 +53,11 @@ export class WatcherServerPlugin implements Plugin { 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: {