SEARCH-438

- code refactoring
This commit is contained in:
Keerthi Niranjan 2017-11-20 12:20:19 +05:30
parent 1cbc443024
commit 68742808cf
2 changed files with 16 additions and 4 deletions

View File

@ -7,7 +7,7 @@ let makeBoundTimedCollector = function(isIndexing, timeout, callback) {
if (!timer){ if (!timer){
timer = setTimeout(function(){ timer = setTimeout(function(){
if (!isIndexing) { if (!isIndexing) {
flush(getQueue()) flush(getQueue());
} }
}, timeout); }, timeout);
} }
@ -28,11 +28,11 @@ let makeBoundTimedCollector = function(isIndexing, timeout, callback) {
} }
function getQueue(){ function getQueue(){
return messagesData return messagesData;
} }
function resetQueue(){ function resetQueue(){
messagesData = [] messagesData = [];
} }
}; };

View File

@ -140,6 +140,7 @@ class Search {
if (err) { if (err) {
log.send(logLevels.ERROR, 'Error indexing the batch ->' + err); log.send(logLevels.ERROR, 'Error indexing the batch ->' + err);
reject(new Error(err)); reject(new Error(err));
return;
} }
resolve(res); resolve(res);
}); });
@ -156,6 +157,7 @@ class Search {
if (err) { if (err) {
log.send(logLevels.ERROR, 'Error merging the index ->' + err); log.send(logLevels.ERROR, 'Error merging the index ->' + err);
reject(new Error(err)); reject(new Error(err));
return;
} }
libSymphonySearch.symSERemoveFolder(this.batchIndex); libSymphonySearch.symSERemoveFolder(this.batchIndex);
resolve(res); resolve(res);
@ -163,12 +165,22 @@ class Search {
}); });
} }
/**
* Batching the real time
* messages for queue and flush
* @param {Object} message
*/
batchRealTimeIndexing(message) { batchRealTimeIndexing(message) {
this.collector(message); this.collector(message);
} }
/**
* Returns the current state of the
* real-time indexing
* @returns {boolean}
*/
checkIsRealTimeIndexing() { checkIsRealTimeIndexing() {
return this.isRealTimeIndexing return this.isRealTimeIndexing;
} }
/** /**