|
|
|
@ -47,12 +47,21 @@ function setup( apiConfig, esclient ){
|
|
|
|
|
operation.attempt((currentAttempt) => { |
|
|
|
|
const initialTime = debugLog.beginTimer(req); |
|
|
|
|
|
|
|
|
|
mgetService( esclient, cmd, function( err, docs ) { |
|
|
|
|
mgetService( esclient, cmd, function( err, docs, data) { |
|
|
|
|
const message = { |
|
|
|
|
controller: 'place', |
|
|
|
|
queryType: 'place', |
|
|
|
|
result_count: _.get(data, 'docs.length'), |
|
|
|
|
response_time: _.get(data, 'response_time', undefined), |
|
|
|
|
params: req.clean, |
|
|
|
|
retries: currentAttempt - 1 |
|
|
|
|
}; |
|
|
|
|
logger.info('elasticsearch', message); |
|
|
|
|
|
|
|
|
|
// returns true if the operation should be attempted again
|
|
|
|
|
// (handles bookkeeping of maxRetries)
|
|
|
|
|
// only consider for status 408 (request timeout)
|
|
|
|
|
if (isRequestTimeout(err) && operation.retry(err)) { |
|
|
|
|
logger.info(`request timed out on attempt ${currentAttempt}, retrying`); |
|
|
|
|
debugLog.stopTimer(req, initialTime, `request timed out on attempt ${currentAttempt}, retrying`); |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
@ -73,12 +82,6 @@ function setup( apiConfig, esclient ){
|
|
|
|
|
} |
|
|
|
|
// set response data
|
|
|
|
|
else { |
|
|
|
|
// log that a retry was successful
|
|
|
|
|
// most requests succeed on first attempt so this declutters log files
|
|
|
|
|
if (currentAttempt > 1) { |
|
|
|
|
logger.info(`succeeded on retry ${currentAttempt-1}`); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
res.data = docs; |
|
|
|
|
} |
|
|
|
|
logger.debug('[ES response]', docs); |
|
|
|
|