Explorar o código

EAGLESIX-3077: Added code for interrupt as suggested per PR

David Aebersold %!s(int64=11) %!d(string=hai) anos
pai
achega
f027344447
Modificáronse 1 ficheiros con 3 adicións e 0 borrados
  1. 3 0
      lib/pipeline/documentSources/LimitDocumentSource.js

+ 3 - 0
lib/pipeline/documentSources/LimitDocumentSource.js

@@ -52,6 +52,9 @@ proto.coalesce = function coalesce(nextSource) {
 proto.getNext = function getNext(callback) {
 proto.getNext = function getNext(callback) {
 	if (!callback) throw new Error(this.getSourceName() + ' #getNext() requires callback');
 	if (!callback) throw new Error(this.getSourceName() + ' #getNext() requires callback');
 
 
+	if (this.expCtx instanceof Object && this.expCtx.checkForInterrupt && this.expCtx.checkForInterrupt() === false)
+		return callback(new Error("Interrupted"));
+
 	if (++this.count > this.limit) {
 	if (++this.count > this.limit) {
 		this.source.dispose();
 		this.source.dispose();
 		callback(null, DocumentSource.EOF);
 		callback(null, DocumentSource.EOF);