psdev-task-manager 1.1.6 → 1.1.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -17,7 +17,7 @@ const {
|
|
|
17
17
|
} = require('./utils');
|
|
18
18
|
|
|
19
19
|
function taskManager() {
|
|
20
|
-
const
|
|
20
|
+
const processTaskWithDuration = (task, tasksConfig) =>
|
|
21
21
|
withDuration(
|
|
22
22
|
'processTask',
|
|
23
23
|
async () => {
|
|
@@ -82,6 +82,10 @@ function taskManager() {
|
|
|
82
82
|
},
|
|
83
83
|
console
|
|
84
84
|
);
|
|
85
|
+
const processTask = (...args) => {
|
|
86
|
+
const requestName = `processTask_${args[0].name}`; //To get success rate analysis per task
|
|
87
|
+
return withSuccessRateLogs(requestName, () => processTaskWithDuration(...args));
|
|
88
|
+
};
|
|
85
89
|
/**
|
|
86
90
|
* @description Processing tasks based on how many the cron job tick can handle and running them sequentially to be as safe as possible
|
|
87
91
|
* */
|
|
@@ -136,10 +140,7 @@ function taskManager() {
|
|
|
136
140
|
return {
|
|
137
141
|
schedule: insertNewTask,
|
|
138
142
|
scheduleInBulk: bulkInsertTasks,
|
|
139
|
-
processTask
|
|
140
|
-
const requestName = `processTask_${args[0].name}`; //To get success rate analysis per task
|
|
141
|
-
return withSuccessRateLogs(requestName, () => processTask(...args));
|
|
142
|
-
},
|
|
143
|
+
processTask,
|
|
143
144
|
runScheduledTasks: (...args) =>
|
|
144
145
|
withDuration('runScheduledTasks', () => runScheduledTasks(...args), console),
|
|
145
146
|
};
|
package/backend/tasks/utils.js
CHANGED
|
@@ -179,12 +179,14 @@ const filterScheduledTasksByStatus = (tasks, tasksConfig) => {
|
|
|
179
179
|
//Only include parent tasks that are in progress, to continue running next children
|
|
180
180
|
return isParentTask(task, taskConfig);
|
|
181
181
|
}
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
//
|
|
187
|
-
|
|
182
|
+
//TODO: need to rethink of this as some parent tasks we use only to schedule children,
|
|
183
|
+
// if (status === TASK_STATUS.FAILED) {
|
|
184
|
+
// // Exclude if it's a parent task, if parent task failed, we don't retry it anymore
|
|
185
|
+
// return !isParentTask(task, taskConfig);
|
|
186
|
+
// }
|
|
187
|
+
// // Include if status is PENDING
|
|
188
|
+
// return status === TASK_STATUS.PENDING;
|
|
189
|
+
return [TASK_STATUS.PENDING, TASK_STATUS.FAILED].includes(task.status);
|
|
188
190
|
};
|
|
189
191
|
const filtered = tasks.filter(task => {
|
|
190
192
|
const taskConfig = tasksConfig[task.name];
|