Commit 7566a9e9 authored by Tristan Cavelier's avatar Tristan Cavelier

jobMaker compatible with recovery

parent 669d28be
......@@ -36,15 +36,7 @@ function enableJobMaker(jio, shared, options) {
"options"
]);
// listeners
shared.rest_method_names.forEach(function (method) {
shared.on(method, function (param) {
if (param.deferred) {
// params are good
param.created = new Date();
param.tried = 0;
param.state = 'ready';
function addCommandToJob(param) {
param.command = {};
param.command.resolve = function () {
shared.emit('jobDone', param, arguments);
......@@ -60,10 +52,33 @@ function enableJobMaker(jio, shared, options) {
param.command.storage = function () {
return shared.createRestApi.apply(null, arguments);
};
param.modified = new Date();
}
// listeners
shared.rest_method_names.forEach(function (method) {
shared.on(method, function (param) {
if (param.deferred) {
// params are good
param.created = new Date();
shared.emit('job', param);
}
});
});
shared.on('job', function (param) {
// new or recovered job
param.state = 'ready';
if (typeof param.tried !== 'number' || !isFinite(param.tried)) {
param.tried = 0;
}
if (!param.created) {
param.created = new Date();
}
if (!param.command) {
addCommandToJob(param);
}
param.modified = new Date();
});
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment