-
Notifications
You must be signed in to change notification settings - Fork 8.1k
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
[Watcher] Migrate to new ES client #97260
Merged
jloleysens
merged 14 commits into
elastic:master
from
jloleysens:watcher/migrate-legacy-es-client
Apr 30, 2021
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
2157b43
initial migration away from ILegacyScopedClusterClient to
jloleysens 9e96b76
re-instate ignore: [404]
jloleysens 9568b3f
remove use of ignore_unavailable
jloleysens cc3e31b
get the correct payload from the response
jloleysens 8ed2758
fix use of new licensePreRoutingFactory
jloleysens 87d64a4
Merge branch 'master' of github.com:elastic/kibana into watcher/migra…
jloleysens 9a429d5
fix jest tests
jloleysens 6184d47
Merge branch 'master' into watcher/migrate-legacy-es-client
kibanamachine 0a8f2d9
Merge branch 'master' into watcher/migrate-legacy-es-client
kibanamachine 82b522e
Merge branch 'master' into watcher/migrate-legacy-es-client
kibanamachine 7ecbc00
Merge branch 'master' into watcher/migrate-legacy-es-client
kibanamachine 1198c3b
address CJs feedback and re-add ignore_unavailable, clean up remainin…
jloleysens f4220e0
remove legacy client config
jloleysens 8c22010
undo renaming as part of destructuring assignment
jloleysens File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
246 changes: 0 additions & 246 deletions
246
x-pack/plugins/watcher/server/lib/elasticsearch_js_plugin.ts
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,29 +5,30 @@ | |
* 2.0. | ||
*/ | ||
|
||
import { ILegacyScopedClusterClient } from 'kibana/server'; | ||
import { ScrollResponse, Hit } from '@elastic/elasticsearch/api/types'; | ||
import { IScopedClusterClient } from 'kibana/server'; | ||
import { get } from 'lodash'; | ||
import { ES_SCROLL_SETTINGS } from '../../../common/constants'; | ||
|
||
export function fetchAllFromScroll( | ||
searchResuls: any, | ||
dataClient: ILegacyScopedClusterClient, | ||
hits: any[] = [] | ||
): Promise<any> { | ||
const newHits = get(searchResuls, 'hits.hits', []); | ||
const scrollId = get(searchResuls, '_scroll_id'); | ||
searchResults: ScrollResponse<unknown>, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nice typo catch! |
||
dataClient: IScopedClusterClient, | ||
hits: Hit[] = [] | ||
): Promise<ScrollResponse['hits']['hits']> { | ||
const newHits = get(searchResults, 'hits.hits', []); | ||
const scrollId = get(searchResults, '_scroll_id'); | ||
|
||
if (newHits.length > 0) { | ||
hits.push(...newHits); | ||
|
||
return dataClient | ||
.callAsCurrentUser('scroll', { | ||
return dataClient.asCurrentUser | ||
.scroll({ | ||
body: { | ||
scroll: ES_SCROLL_SETTINGS.KEEPALIVE, | ||
scroll_id: scrollId, | ||
}, | ||
}) | ||
.then((innerResponse: any) => { | ||
.then(({ body: innerResponse }) => { | ||
return fetchAllFromScroll(innerResponse, dataClient, hits); | ||
}); | ||
} | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like how these tests became clearer as a result of this migration!