Skip to content

Commit

Permalink
Fix TSVB rollup integration (#56525)
Browse files Browse the repository at this point in the history
  • Loading branch information
flash1293 authored Feb 3, 2020
1 parent 1e325e4 commit b566ba3
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* under the License.
*/

import { RequestHandlerContext } from 'src/core/server';
import { KibanaRequest, RequestHandlerContext } from 'src/core/server';
import _ from 'lodash';
import { first, map } from 'rxjs/operators';
import { getPanelData } from './vis_data/get_panel_data';
Expand Down Expand Up @@ -57,13 +57,15 @@ export type GetVisData = (
export function getVisData(
requestContext: RequestHandlerContext,
options: GetVisDataOptions,
framework: Framework
framework: Framework,
request?: PublicMethodsOf<KibanaRequest>
): Promise<GetVisDataResponse> {
// NOTE / TODO: This facade has been put in place to make migrating to the New Platform easier. It
// removes the need to refactor many layers of dependencies on "req", and instead just augments the top
// level object passed from here. The layers should be refactored fully at some point, but for now
// this works and we are still using the New Platform services for these vis data portions.
const reqFacade: any = {
...(request || {}),
payload: options,
getUiSettingsService: () => requestContext.core.uiSettings.client,
getSavedObjectsClient: () => requestContext.core.savedObjects.client,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export const visDataRoutes = (
);
}
try {
const results = await getVisData(requestContext, request.body, framework);
const results = await getVisData(requestContext, request.body, framework, request);
return response.ok({ body: results });
} catch (error) {
return response.internalError({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ import { once } from 'lodash';
import { elasticsearchJsPlugin } from '../../client/elasticsearch_rollup';

const callWithRequest = once(server => {
const config = { plugins: [elasticsearchJsPlugin] };
const cluster = server.plugins.elasticsearch.createCluster('rollup', config);

return cluster.callWithRequest;
const client = server.newPlatform.setup.core.elasticsearch.createClient('rollup', {
plugins: [elasticsearchJsPlugin],
});
return (request, ...args) => client.asScoped(request).callAsCurrentUser(...args);
});

export const callWithRequestFactory = (server, request) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,10 @@ export const registerRollupSearchStrategy = (kbnServer, server) =>
RollupSearchCapabilities
);

addSearchStrategy(new RollupSearchStrategy(server));
addSearchStrategy(
new RollupSearchStrategy({
...server,
newPlatform: kbnServer.newPlatform,
})
);
});

0 comments on commit b566ba3

Please sign in to comment.