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

Fix TSVB rollup integration #56525

Merged
merged 3 commits into from
Feb 3, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,
})
);
});