Commit 83e5bf99 authored by Tristan Cavelier's avatar Tristan Cavelier

jobMaker compatible with recovery

parent 53d0f1e0
...@@ -36,15 +36,7 @@ function enableJobMaker(jio, shared, options) { ...@@ -36,15 +36,7 @@ function enableJobMaker(jio, shared, options) {
"options" "options"
]); ]);
// listeners function addCommandToJob(param) {
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';
param.command = {}; param.command = {};
param.command.resolve = function () { param.command.resolve = function () {
shared.emit('jobDone', param, arguments); shared.emit('jobDone', param, arguments);
...@@ -60,10 +52,33 @@ function enableJobMaker(jio, shared, options) { ...@@ -60,10 +52,33 @@ function enableJobMaker(jio, shared, options) {
param.command.storage = function () { param.command.storage = function () {
return shared.createRestApi.apply(null, arguments); 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.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