[Step 1] use Observables on server search API#79874
Conversation
0d38bb3 to
7560f58
Compare
|
@elasticmachine merge upstream |
|
Pinging @elastic/kibana-app (Team:KibanaApp) |
|
@elasticmachine merge upstream |
|
@elasticmachine merge upstream |
lizozom
left a comment
There was a problem hiding this comment.
Looks good, added a couple comments
| const uiSettingsClient = await context.core.uiSettings.client; | ||
| search: (request, options, context) => | ||
| from( | ||
| new Promise<IEsSearchResponse>(async (resolve, reject) => { |
There was a problem hiding this comment.
We already have a promise returned from shimAbortPromise.
I guess you're creating this promise just as a temporary step, but I wanted to make sure.
There was a problem hiding this comment.
I will do it in next step
| search: < | ||
| SearchStrategyRequest extends IKibanaSearchRequest = IEsSearchRequest, | ||
| SearchStrategyResponse extends IKibanaSearchResponse = IEsSearchResponse | ||
| >( |
There was a problem hiding this comment.
Why did you have to get explicit here?
Doesn't the type come from SearchSourceDependencies?
There was a problem hiding this comment.
you are right, it comes from types, but please see the return statement of that method.
return this.search<SearchStrategyRequest, SearchStrategyResponse>(
we need somehow to get required generic types: SearchStrategyRequest, SearchStrategyResponse
| options: ISearchOptions, | ||
| context: RequestHandlerContext | ||
| ) => Observable<SearchStrategyResponse>; | ||
| cancel?: (context: RequestHandlerContext, id: string) => Promise<void>; |
There was a problem hiding this comment.
Should we return an Observable here too?
| return queryFactory.parse(request, esSearchRes); | ||
| return es | ||
| .search({ ...request, params: dsl }, options, context) | ||
| .pipe(mergeMap((esSearchRes) => queryFactory.parse(request, esSearchRes))); |
There was a problem hiding this comment.
I think you can use map instead of mergeMap here. Am I missing something?
There was a problem hiding this comment.
we should use mergeMap with promises. In case of map it returns unresolved promise
https://www.learnrxjs.io/learn-rxjs/operators/transformation/mergemap
https://stackblitz.com/edit/typescript-pnnsrq?file=index.ts&devtoolsheight=100
There was a problem hiding this comment.
Ah, so it can be change to a map when we get rid of Promises here?
stratoula
left a comment
There was a problem hiding this comment.
KibanaApp code review mainly, I tested it locally, it seems ok to me.
|
@elasticmachine merge upstream |
💚 Build SucceededMetrics [docs]
History
To update your PR or re-run it, just comment with: |
XavierM
left a comment
There was a problem hiding this comment.
LGTM, everything is working as expected on our side.
* use Observables on server search API * fix PR comments Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
…otphase-to-formlib * 'master' of github.com:elastic/kibana: (59 commits) [Security Solution][Resolver] Replace copy-to-clipboard with native navigator.clipboard (elastic#80193) [Security Solution] Reduce initial bundle size (elastic#78992) [Security Solution][Resolver] Fix Resize node box-shadow bug (elastic#80223) Move observability content (elastic#79978) skip flaky suite (elastic#79389) removing kibana_datatable` in favor of `datatable` (elastic#75184) [ML] Fixes for anomaly swim lane (elastic#80299) [Lens] Smokescreen lens test unskip (elastic#80190) Improved AlertsClient tests structure by splitting a huge alerts_client.tests.ts file into a specific files defined by its responsibility. (elastic#80088) [APM] React key warning when opening popover with external resources (elastic#80328) [Step 1] use Observables on server search API (elastic#79874) Apply back pressure in Task Manager whenever Elasticsearch responds with a 429 (elastic#75666) [Lens] Leverage original http request error (elastic#79831) [Security Solution][Case] Improve ServiceConnectorCaseParams type (elastic#80109) [SECURITY_SOLUTION] Fix query on alert histogram (elastic#80219) [DOCS] Update ingest node pipelines doc (elastic#79187) [Ingest Manager] Split up OpenAPI spec file (elastic#80107) [SECURITY_SOLUTION][ENDPOINT] Fix label on Trusted App create name field (elastic#80001) [Ingest Manager] Fix agent policy bump revision to create only one POLICY_CHANGE action (elastic#80081) Grid layout fixes (elastic#80305) ... # Conflicts: # x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/components/phases/shared/data_tier_allocation_field.tsx # x-pack/plugins/index_lifecycle_management/public/shared_imports.ts
Summary
This PR is a first step of refactoring of server side
Search APIto useObservableinstead ofPromise.What was done:
ISearchStrategy['search']method was changed:context: RequestHandlerContextargument was moved to the end. I need it to unify this interface with client in future.ISearchStrategy['search']method now returnsObservableinstead ofPromiseObservable. Temporary it was wrapped intofrom(new Promise())but it will be refactored in step 2;Checklist
Delete any items that are not applicable to this PR.
For maintainers