Created
April 6, 2012 23:22
-
-
Save nlacasse/2323907 to your computer and use it in GitHub Desktop.
task manager
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
TaskManager.prototype.handle = function(result) { | |
var emitter, emitters, task_id, tm, _results; | |
tm = this; | |
if (result.identifier) { | |
if ((emitters = this.matchatron.take(result))) { | |
_results = []; | |
for (task_id in emitters) { | |
emitter = emitters[task_id]; | |
if (result.error) { | |
_results.push(emitter.emit("error", result.error, result)); | |
} else if (result.timeout) { | |
_results.push(emitter.emit("timeout")); | |
} else { | |
_results.push(emitter.emit("success", result)); | |
} | |
} | |
return _results; | |
} else { | |
return logger.debug("Received result with unmatchable identifier"); | |
} | |
} else { | |
logger.warn("Received result with no identifier"); | |
return logger.debug(JSON.stringify(result)); | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment