@coya/task-manager
Advanced tools
Comparing version 0.1.0 to 0.1.1
{ | ||
"name": "@coya/task-manager", | ||
"version": "0.1.0", | ||
"version": "0.1.1", | ||
"description": "Scheduler for run tasks successively or simultaneously", | ||
@@ -5,0 +5,0 @@ "main": "js/TaskManager.js", |
@@ -23,3 +23,3 @@ # Task Manager | ||
const firstTask = new Task('firstTask', 10, function() { // processed every 10 seconds | ||
const firstTask = new Task('firstTask', 10, function() { | ||
console.log('hello'); | ||
@@ -29,3 +29,3 @@ return Promise.resolve(); | ||
const secondTask = new Task('secondTask', 5, function() { // processed every 5 seconds | ||
const secondTask = new Task('secondTask', 5, function() { | ||
console.log('hola'); | ||
@@ -35,10 +35,12 @@ return Promise.resolve(); | ||
const thirdTask = new Task('thirdTask', 2, function() { | ||
console.log('failure'); | ||
return Promise.reject(); | ||
}); | ||
const taskManager = new TaskManager(); | ||
taskManager.processAsynchronousTasks([firstTask, secondTask]) | ||
.then(function() { | ||
taskManager.getLogs().info('Task manager stopped.'); | ||
}, function(error) { | ||
taskManager.getLogs().error(error); | ||
process.exit(1); // cancel all other scheduled tasks | ||
taskManager.end(function() { | ||
console.log('All tasks have been stopped, task manager shutted down.'); | ||
}); | ||
taskManager.processAsynchronousTasks([firstTask, secondTask, thirdTask]); | ||
``` | ||
@@ -70,2 +72,3 @@ | ||
* timeInterval => interval in seconds between each task execution | ||
* runFunction => task function called by the scheduler, it must return a promise (this function can be passed to the Task constructor or be a member method of the inheriting class) | ||
* maxFailuresInARow (optional) => determine the number of failures in a row before the task will be taken out of the task list (default it is 5) | ||
* run => task function called by the scheduler, it must return a promise (this function can be passed to the Task constructor or be a member method of the inheriting class) |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
9955
71
0