Run invidual tasks on a seperate process
Task runner framework
A task is a single isolated module that exports an object with the following api:
// this is the "mytask" module// in the case of a non-deterministic error you simply// invoke the callback with one like in all node operationscallback'....';// and in the success casecallbacknull outcome someData: true ;moduleexports = myTask;
var runner = require'isolated-task-runner';runnerperformrequireresolve'myask' /* module to run: use require.resolve to use npm packages */1000 /* timeout in ms */somedata: true /* options to pass to task *//* result of task */;
The callback takes a standard node-style error object, a
boolean and an
Object. The error object is a standard node error callback object. The
boolean contains the outcome of the task. A
true value means that the
operation completely succeeded. A
false value means that the operation
failed and should be retried. The
Object contains information relevant
to status and reporting. The task running system will not make any choices
based on the contents of this
Your task is run in a totally separate process and has no direct access the memory in the process where it was started.
Each task may fail (process dies, on the sync exception, off the async exception) and it will be handled gracefully and passed to the task runner.
Tasks should only generate errors when they fail non-deterministically.
Deterministic failures should be noted by having an outcome of
An api call that fails because the connection died should generate an
error, where trying to comment on a bug that doesn't exist should have