mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 09:48:58 -04:00
[server/indexPatterns] expose indexPatternService getter/factory (#13012)
(cherry picked from commit 9389f0b71a
)
This commit is contained in:
parent
31aba72787
commit
947757a792
1 changed files with 25 additions and 7 deletions
|
@ -13,17 +13,35 @@ export function indexPatternsMixin(kbnServer, server) {
|
|||
*/
|
||||
getIndexPatternsService: {
|
||||
assign: 'indexPatterns',
|
||||
method(req, reply) {
|
||||
const dataCluster = req.server.plugins.elasticsearch.getCluster('data');
|
||||
const callDataCluster = (...args) => (
|
||||
dataCluster.callWithRequest(req, ...args)
|
||||
);
|
||||
|
||||
reply(new IndexPatternsService(callDataCluster));
|
||||
method(request, reply) {
|
||||
reply(request.getIndexPatternsService());
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Create an instance of the IndexPatternsService
|
||||
*
|
||||
* @method server.indexPatternsServiceFactory
|
||||
* @type {IndexPatternsService}
|
||||
*/
|
||||
server.decorate('server', 'indexPatternsServiceFactory', ({ callCluster }) => {
|
||||
return new IndexPatternsService(callCluster);
|
||||
});
|
||||
|
||||
/**
|
||||
* Get an instance of the IndexPatternsService configured for use
|
||||
* the current request
|
||||
*
|
||||
* @method request.getIndexPatternsService
|
||||
* @type {IndexPatternsService}
|
||||
*/
|
||||
server.addMemoizedFactoryToRequest('getIndexPatternsService', request => {
|
||||
const { callWithRequest } = request.server.plugins.elasticsearch.getCluster('data');
|
||||
const callCluster = (...args) => callWithRequest(request, ...args);
|
||||
return server.indexPatternsServiceFactory({ callCluster });
|
||||
});
|
||||
|
||||
server.route(createFieldsForWildcardRoute(pre));
|
||||
server.route(createFieldsForTimePatternRoute(pre));
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue