* Update helpers to use correct multisearch types
The spec combined definitions for search and multisearch bodies in
https://github.com/elastic/elasticsearch-specification/pull/2960.
* Stop copying project files to Dockerfile
Slightly faster run times for codegen, hopefully.
(cherry picked from commit b2a490718d)
Co-authored-by: Josh Mock <joshua.mock@elastic.co>
This commit is contained in:
committed by
GitHub
parent
1fec78ed36
commit
3b6c2e1be6
@ -12,5 +12,3 @@ WORKDIR /usr/src/app
|
||||
|
||||
COPY package.json .
|
||||
RUN npm install
|
||||
|
||||
COPY . .
|
||||
|
||||
@ -25,6 +25,3 @@ USER ${BUILDER_UID}:${BUILDER_GID}
|
||||
# install dependencies
|
||||
COPY package.json .
|
||||
RUN npm install
|
||||
|
||||
# copy project files
|
||||
COPY . .
|
||||
|
||||
@ -41,7 +41,7 @@ export interface MsearchHelperOptions extends T.MsearchRequest {
|
||||
|
||||
export interface MsearchHelper extends Promise<void> {
|
||||
stop: (error?: Error | null) => void
|
||||
search: <TDocument = unknown>(header: T.MsearchMultisearchHeader, body: T.MsearchMultisearchBody) => Promise<MsearchHelperResponse<TDocument>>
|
||||
search: <TDocument = unknown>(header: T.MsearchMultisearchHeader, body: T.SearchSearchRequestBody) => Promise<MsearchHelperResponse<TDocument>>
|
||||
}
|
||||
|
||||
export interface MsearchHelperResponse<TDocument> {
|
||||
@ -362,7 +362,7 @@ export default class Helpers {
|
||||
// TODO: support abort a single search?
|
||||
// NOTE: the validation checks are synchronous and the callback/promise will
|
||||
// be resolved in the same tick. We might want to fix this in the future.
|
||||
search<TDocument = unknown> (header: T.MsearchMultisearchHeader, body: T.MsearchMultisearchBody): Promise<MsearchHelperResponse<TDocument>> {
|
||||
search<TDocument = unknown> (header: T.MsearchMultisearchHeader, body: T.SearchSearchRequestBody): Promise<MsearchHelperResponse<TDocument>> {
|
||||
if (stopReading) {
|
||||
const error = stopError === null
|
||||
? new ConfigurationError('The msearch processor has been stopped')
|
||||
@ -397,7 +397,7 @@ export default class Helpers {
|
||||
|
||||
async function iterate (): Promise<void> {
|
||||
const { semaphore, finish } = buildSemaphore()
|
||||
const msearchBody: Array<T.MsearchMultisearchHeader | T.MsearchMultisearchBody> = []
|
||||
const msearchBody: Array<T.MsearchMultisearchHeader | T.SearchSearchRequestBody> = []
|
||||
const callbacks: any[] = []
|
||||
let loadedOperations = 0
|
||||
timeoutRef = setTimeout(onFlushTimeout, flushInterval) // eslint-disable-line
|
||||
@ -490,7 +490,7 @@ export default class Helpers {
|
||||
}
|
||||
}
|
||||
|
||||
function send (msearchBody: Array<T.MsearchMultisearchHeader | T.MsearchMultisearchBody>, callbacks: any[]): void {
|
||||
function send (msearchBody: Array<T.MsearchMultisearchHeader | T.SearchSearchRequestBody>, callbacks: any[]): void {
|
||||
/* istanbul ignore if */
|
||||
if (running > concurrency) {
|
||||
throw new Error('Max concurrency reached')
|
||||
@ -508,7 +508,7 @@ export default class Helpers {
|
||||
}
|
||||
}
|
||||
|
||||
function msearchOperation (msearchBody: Array<T.MsearchMultisearchHeader | T.MsearchMultisearchBody>, callbacks: any[], done: () => void): void {
|
||||
function msearchOperation (msearchBody: Array<T.MsearchMultisearchHeader | T.SearchSearchRequestBody>, callbacks: any[], done: () => void): void {
|
||||
let retryCount = retries
|
||||
|
||||
// Instead of going full on async-await, which would make the code easier to read,
|
||||
@ -516,7 +516,7 @@ export default class Helpers {
|
||||
// This because every time we use async await, V8 will create multiple promises
|
||||
// behind the scenes, making the code slightly slower.
|
||||
tryMsearch(msearchBody, callbacks, retrySearch)
|
||||
function retrySearch (msearchBody: Array<T.MsearchMultisearchHeader | T.MsearchMultisearchBody>, callbacks: any[]): void {
|
||||
function retrySearch (msearchBody: Array<T.MsearchMultisearchHeader | T.SearchSearchRequestBody>, callbacks: any[]): void {
|
||||
if (msearchBody.length > 0 && retryCount > 0) {
|
||||
retryCount -= 1
|
||||
setTimeout(tryMsearch, wait, msearchBody, callbacks, retrySearch)
|
||||
@ -528,7 +528,7 @@ export default class Helpers {
|
||||
|
||||
// This function never returns an error, if the msearch operation fails,
|
||||
// the error is dispatched to all search executors.
|
||||
function tryMsearch (msearchBody: Array<T.MsearchMultisearchHeader | T.MsearchMultisearchBody>, callbacks: any[], done: (msearchBody: Array<T.MsearchMultisearchHeader | T.MsearchMultisearchBody>, callbacks: any[]) => void): void {
|
||||
function tryMsearch (msearchBody: Array<T.MsearchMultisearchHeader | T.SearchSearchRequestBody>, callbacks: any[], done: (msearchBody: Array<T.MsearchMultisearchHeader | T.SearchSearchRequestBody>, callbacks: any[]) => void): void {
|
||||
client.msearch(Object.assign({}, msearchOptions, { body: msearchBody }), reqOptions as TransportRequestOptionsWithMeta)
|
||||
.then(results => {
|
||||
const retryBody = []
|
||||
|
||||
Reference in New Issue
Block a user