|
|
@ -70,22 +70,17 @@ function setup( apiConfig, esclient, query, should_execute ){ |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// if execution has gotten this far then one of three things happened:
|
|
|
|
// error handler, return immediately
|
|
|
|
// - the request didn't time out
|
|
|
|
|
|
|
|
// - maxRetries has been hit so we're giving up
|
|
|
|
|
|
|
|
// - another error occurred
|
|
|
|
|
|
|
|
// in either case, handle the error or results
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// error handler
|
|
|
|
|
|
|
|
if( err ){ |
|
|
|
if( err ){ |
|
|
|
if (_.isObject(err) && err.message) { |
|
|
|
req.errors.push(_.defaultTo(err.message, err)); |
|
|
|
req.errors.push( err.message ); |
|
|
|
return; |
|
|
|
} else { |
|
|
|
|
|
|
|
req.errors.push( err ); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
// set response data
|
|
|
|
|
|
|
|
else { |
|
|
|
// if execution has gotten this far then one of three things happened:
|
|
|
|
|
|
|
|
// - success! (the request didn't time out)
|
|
|
|
|
|
|
|
// - maxRetries has been hit so we're giving up (too many timeouts),
|
|
|
|
|
|
|
|
// docs will be empty
|
|
|
|
|
|
|
|
|
|
|
|
// log that a retry was successful
|
|
|
|
// log that a retry was successful
|
|
|
|
// most requests succeed on first attempt so this declutters log files
|
|
|
|
// most requests succeed on first attempt so this declutters log files
|
|
|
|
if (currentAttempt > 1) { |
|
|
|
if (currentAttempt > 1) { |
|
|
@ -112,9 +107,10 @@ function setup( apiConfig, esclient, query, should_execute ){ |
|
|
|
es_result_count: parseInt(messageParts[2].slice(17, -1)) |
|
|
|
es_result_count: parseInt(messageParts[2].slice(17, -1)) |
|
|
|
} |
|
|
|
} |
|
|
|
}}); |
|
|
|
}}); |
|
|
|
} |
|
|
|
|
|
|
|
logger.debug('[ES response]', docs); |
|
|
|
logger.debug('[ES response]', docs); |
|
|
|
next(); |
|
|
|
next(); |
|
|
|
|
|
|
|
|
|
|
|
}); |
|
|
|
}); |
|
|
|
debugLog.stopTimer(req, initialTime); |
|
|
|
debugLog.stopTimer(req, initialTime); |
|
|
|
}); |
|
|
|
}); |
|
|
|