mirror of
https://github.com/hibiken/asynqmon.git
synced 2025-09-17 04:04:28 +08:00
Add kill functionality to scheduled and retry tasks table
This commit is contained in:
@@ -17,6 +17,8 @@ import {
|
||||
BATCH_DELETE_DEAD_TASKS_SUCCESS,
|
||||
BATCH_DELETE_RETRY_TASKS_SUCCESS,
|
||||
BATCH_DELETE_SCHEDULED_TASKS_SUCCESS,
|
||||
BATCH_KILL_RETRY_TASKS_SUCCESS,
|
||||
BATCH_KILL_SCHEDULED_TASKS_SUCCESS,
|
||||
BATCH_RUN_DEAD_TASKS_SUCCESS,
|
||||
BATCH_RUN_RETRY_TASKS_SUCCESS,
|
||||
BATCH_RUN_SCHEDULED_TASKS_SUCCESS,
|
||||
@@ -26,6 +28,10 @@ import {
|
||||
DELETE_DEAD_TASK_SUCCESS,
|
||||
DELETE_RETRY_TASK_SUCCESS,
|
||||
DELETE_SCHEDULED_TASK_SUCCESS,
|
||||
KILL_ALL_RETRY_TASKS_SUCCESS,
|
||||
KILL_ALL_SCHEDULED_TASKS_SUCCESS,
|
||||
KILL_RETRY_TASK_SUCCESS,
|
||||
KILL_SCHEDULED_TASK_SUCCESS,
|
||||
LIST_ACTIVE_TASKS_SUCCESS,
|
||||
LIST_DEAD_TASKS_SUCCESS,
|
||||
LIST_PENDING_TASKS_SUCCESS,
|
||||
@@ -216,6 +222,40 @@ function queuesReducer(
|
||||
return { ...state, data: newData };
|
||||
}
|
||||
|
||||
case KILL_SCHEDULED_TASK_SUCCESS: {
|
||||
const newData = state.data.map((queueInfo) => {
|
||||
if (queueInfo.name !== action.queue) {
|
||||
return queueInfo;
|
||||
}
|
||||
return {
|
||||
...queueInfo,
|
||||
currentStats: {
|
||||
...queueInfo.currentStats,
|
||||
dead: queueInfo.currentStats.dead + 1,
|
||||
scheduled: queueInfo.currentStats.scheduled - 1,
|
||||
},
|
||||
};
|
||||
});
|
||||
return { ...state, data: newData };
|
||||
}
|
||||
|
||||
case KILL_RETRY_TASK_SUCCESS: {
|
||||
const newData = state.data.map((queueInfo) => {
|
||||
if (queueInfo.name !== action.queue) {
|
||||
return queueInfo;
|
||||
}
|
||||
return {
|
||||
...queueInfo,
|
||||
currentStats: {
|
||||
...queueInfo.currentStats,
|
||||
dead: queueInfo.currentStats.dead + 1,
|
||||
retry: queueInfo.currentStats.retry - 1,
|
||||
},
|
||||
};
|
||||
});
|
||||
return { ...state, data: newData };
|
||||
}
|
||||
|
||||
case DELETE_SCHEDULED_TASK_SUCCESS: {
|
||||
const newData = state.data.map((queueInfo) => {
|
||||
if (queueInfo.name !== action.queue) {
|
||||
@@ -253,6 +293,25 @@ function queuesReducer(
|
||||
return { ...state, data: newData };
|
||||
}
|
||||
|
||||
case BATCH_KILL_SCHEDULED_TASKS_SUCCESS: {
|
||||
const newData = state.data.map((queueInfo) => {
|
||||
if (queueInfo.name !== action.queue) {
|
||||
return queueInfo;
|
||||
}
|
||||
return {
|
||||
...queueInfo,
|
||||
currentStats: {
|
||||
...queueInfo.currentStats,
|
||||
dead: queueInfo.currentStats.dead + action.payload.dead_keys.length,
|
||||
scheduled:
|
||||
queueInfo.currentStats.scheduled -
|
||||
action.payload.dead_keys.length,
|
||||
},
|
||||
};
|
||||
});
|
||||
return { ...state, data: newData };
|
||||
}
|
||||
|
||||
case BATCH_DELETE_SCHEDULED_TASKS_SUCCESS: {
|
||||
const newData = state.data.map((queueInfo) => {
|
||||
if (queueInfo.name !== action.queue) {
|
||||
@@ -289,6 +348,24 @@ function queuesReducer(
|
||||
return { ...state, data: newData };
|
||||
}
|
||||
|
||||
case KILL_ALL_SCHEDULED_TASKS_SUCCESS: {
|
||||
const newData = state.data.map((queueInfo) => {
|
||||
if (queueInfo.name !== action.queue) {
|
||||
return queueInfo;
|
||||
}
|
||||
return {
|
||||
...queueInfo,
|
||||
currentStats: {
|
||||
...queueInfo.currentStats,
|
||||
dead:
|
||||
queueInfo.currentStats.dead + queueInfo.currentStats.scheduled,
|
||||
scheduled: 0,
|
||||
},
|
||||
};
|
||||
});
|
||||
return { ...state, data: newData };
|
||||
}
|
||||
|
||||
case DELETE_ALL_SCHEDULED_TASKS_SUCCESS: {
|
||||
const newData = state.data.map((queueInfo) => {
|
||||
if (queueInfo.name !== action.queue) {
|
||||
@@ -341,6 +418,25 @@ function queuesReducer(
|
||||
return { ...state, data: newData };
|
||||
}
|
||||
|
||||
case BATCH_KILL_RETRY_TASKS_SUCCESS: {
|
||||
const newData = state.data.map((queueInfo) => {
|
||||
if (queueInfo.name !== action.queue) {
|
||||
return queueInfo;
|
||||
}
|
||||
return {
|
||||
...queueInfo,
|
||||
currentStats: {
|
||||
...queueInfo.currentStats,
|
||||
dead:
|
||||
queueInfo.currentStats.pending + action.payload.dead_keys.length,
|
||||
retry:
|
||||
queueInfo.currentStats.retry - action.payload.dead_keys.length,
|
||||
},
|
||||
};
|
||||
});
|
||||
return { ...state, data: newData };
|
||||
}
|
||||
|
||||
case BATCH_DELETE_RETRY_TASKS_SUCCESS: {
|
||||
const newData = state.data.map((queueInfo) => {
|
||||
if (queueInfo.name !== action.queue) {
|
||||
@@ -376,6 +472,23 @@ function queuesReducer(
|
||||
return { ...state, data: newData };
|
||||
}
|
||||
|
||||
case KILL_ALL_RETRY_TASKS_SUCCESS: {
|
||||
const newData = state.data.map((queueInfo) => {
|
||||
if (queueInfo.name !== action.queue) {
|
||||
return queueInfo;
|
||||
}
|
||||
return {
|
||||
...queueInfo,
|
||||
currentStats: {
|
||||
...queueInfo.currentStats,
|
||||
dead: queueInfo.currentStats.dead + queueInfo.currentStats.retry,
|
||||
retry: 0,
|
||||
},
|
||||
};
|
||||
});
|
||||
return { ...state, data: newData };
|
||||
}
|
||||
|
||||
case DELETE_ALL_RETRY_TASKS_SUCCESS: {
|
||||
const newData = state.data.map((queueInfo) => {
|
||||
if (queueInfo.name !== action.queue) {
|
||||
|
@@ -6,6 +6,8 @@ import {
|
||||
BATCH_DELETE_DEAD_TASKS_SUCCESS,
|
||||
BATCH_DELETE_RETRY_TASKS_SUCCESS,
|
||||
BATCH_DELETE_SCHEDULED_TASKS_SUCCESS,
|
||||
BATCH_KILL_RETRY_TASKS_SUCCESS,
|
||||
BATCH_KILL_SCHEDULED_TASKS_SUCCESS,
|
||||
BATCH_RUN_DEAD_TASKS_SUCCESS,
|
||||
BATCH_RUN_RETRY_TASKS_SUCCESS,
|
||||
BATCH_RUN_SCHEDULED_TASKS_SUCCESS,
|
||||
@@ -15,6 +17,10 @@ import {
|
||||
DELETE_DEAD_TASK_SUCCESS,
|
||||
DELETE_RETRY_TASK_SUCCESS,
|
||||
DELETE_SCHEDULED_TASK_SUCCESS,
|
||||
KILL_ALL_RETRY_TASKS_SUCCESS,
|
||||
KILL_ALL_SCHEDULED_TASKS_SUCCESS,
|
||||
KILL_RETRY_TASK_SUCCESS,
|
||||
KILL_SCHEDULED_TASK_SUCCESS,
|
||||
RUN_ALL_DEAD_TASKS_SUCCESS,
|
||||
RUN_ALL_RETRY_TASKS_SUCCESS,
|
||||
RUN_ALL_SCHEDULED_TASKS_SUCCESS,
|
||||
@@ -68,6 +74,20 @@ function snackbarReducer(
|
||||
message: `Dead task ${action.taskKey} is now pending`,
|
||||
};
|
||||
|
||||
case KILL_SCHEDULED_TASK_SUCCESS:
|
||||
return {
|
||||
isOpen: true,
|
||||
// TODO: show only task id
|
||||
message: `Scheduled task ${action.taskKey} is now dead`,
|
||||
};
|
||||
|
||||
case KILL_RETRY_TASK_SUCCESS:
|
||||
return {
|
||||
isOpen: true,
|
||||
// TODO: show only task id
|
||||
message: `Retry task ${action.taskKey} is now dead`,
|
||||
};
|
||||
|
||||
case DELETE_SCHEDULED_TASK_SUCCESS:
|
||||
return {
|
||||
isOpen: true,
|
||||
@@ -85,6 +105,14 @@ function snackbarReducer(
|
||||
};
|
||||
}
|
||||
|
||||
case BATCH_KILL_SCHEDULED_TASKS_SUCCESS: {
|
||||
const n = action.payload.dead_keys.length;
|
||||
return {
|
||||
isOpen: true,
|
||||
message: `${n} scheduled ${n === 1 ? "task is" : "tasks are"} now dead`,
|
||||
};
|
||||
}
|
||||
|
||||
case BATCH_DELETE_SCHEDULED_TASKS_SUCCESS: {
|
||||
const n = action.payload.deleted_keys.length;
|
||||
return {
|
||||
@@ -99,6 +127,12 @@ function snackbarReducer(
|
||||
message: "All scheduled tasks are now pending",
|
||||
};
|
||||
|
||||
case KILL_ALL_SCHEDULED_TASKS_SUCCESS:
|
||||
return {
|
||||
isOpen: true,
|
||||
message: "All scheduled tasks are now dead",
|
||||
};
|
||||
|
||||
case DELETE_ALL_SCHEDULED_TASKS_SUCCESS:
|
||||
return {
|
||||
isOpen: true,
|
||||
@@ -120,6 +154,14 @@ function snackbarReducer(
|
||||
};
|
||||
}
|
||||
|
||||
case BATCH_KILL_RETRY_TASKS_SUCCESS: {
|
||||
const n = action.payload.dead_keys.length;
|
||||
return {
|
||||
isOpen: true,
|
||||
message: `${n} retry ${n === 1 ? "task is" : "tasks are"} now dead`,
|
||||
};
|
||||
}
|
||||
|
||||
case BATCH_DELETE_RETRY_TASKS_SUCCESS: {
|
||||
const n = action.payload.deleted_keys.length;
|
||||
return {
|
||||
@@ -134,6 +176,12 @@ function snackbarReducer(
|
||||
message: "All retry tasks are now pending",
|
||||
};
|
||||
|
||||
case KILL_ALL_RETRY_TASKS_SUCCESS:
|
||||
return {
|
||||
isOpen: true,
|
||||
message: "All retry tasks are now dead",
|
||||
};
|
||||
|
||||
case DELETE_ALL_RETRY_TASKS_SUCCESS:
|
||||
return {
|
||||
isOpen: true,
|
||||
|
@@ -72,6 +72,24 @@ import {
|
||||
RUN_SCHEDULED_TASK_BEGIN,
|
||||
RUN_SCHEDULED_TASK_SUCCESS,
|
||||
RUN_SCHEDULED_TASK_ERROR,
|
||||
KILL_SCHEDULED_TASK_BEGIN,
|
||||
KILL_SCHEDULED_TASK_SUCCESS,
|
||||
KILL_SCHEDULED_TASK_ERROR,
|
||||
KILL_ALL_SCHEDULED_TASKS_BEGIN,
|
||||
KILL_ALL_SCHEDULED_TASKS_SUCCESS,
|
||||
KILL_ALL_SCHEDULED_TASKS_ERROR,
|
||||
BATCH_KILL_SCHEDULED_TASKS_BEGIN,
|
||||
BATCH_KILL_SCHEDULED_TASKS_ERROR,
|
||||
BATCH_KILL_SCHEDULED_TASKS_SUCCESS,
|
||||
KILL_RETRY_TASK_BEGIN,
|
||||
KILL_RETRY_TASK_SUCCESS,
|
||||
KILL_RETRY_TASK_ERROR,
|
||||
KILL_ALL_RETRY_TASKS_BEGIN,
|
||||
KILL_ALL_RETRY_TASKS_SUCCESS,
|
||||
KILL_ALL_RETRY_TASKS_ERROR,
|
||||
BATCH_KILL_RETRY_TASKS_SUCCESS,
|
||||
BATCH_KILL_RETRY_TASKS_BEGIN,
|
||||
BATCH_KILL_RETRY_TASKS_ERROR,
|
||||
} from "../actions/tasksActions";
|
||||
import {
|
||||
ActiveTask,
|
||||
@@ -396,6 +414,7 @@ function tasksReducer(
|
||||
};
|
||||
|
||||
case RUN_SCHEDULED_TASK_BEGIN:
|
||||
case KILL_SCHEDULED_TASK_BEGIN:
|
||||
case DELETE_SCHEDULED_TASK_BEGIN:
|
||||
return {
|
||||
...state,
|
||||
@@ -411,6 +430,7 @@ function tasksReducer(
|
||||
};
|
||||
|
||||
case RUN_SCHEDULED_TASK_SUCCESS:
|
||||
case KILL_SCHEDULED_TASK_SUCCESS:
|
||||
case DELETE_SCHEDULED_TASK_SUCCESS:
|
||||
return {
|
||||
...state,
|
||||
@@ -423,6 +443,7 @@ function tasksReducer(
|
||||
};
|
||||
|
||||
case RUN_SCHEDULED_TASK_ERROR:
|
||||
case KILL_SCHEDULED_TASK_ERROR:
|
||||
case DELETE_SCHEDULED_TASK_ERROR:
|
||||
return {
|
||||
...state,
|
||||
@@ -438,6 +459,7 @@ function tasksReducer(
|
||||
};
|
||||
|
||||
case RUN_ALL_SCHEDULED_TASKS_BEGIN:
|
||||
case KILL_ALL_SCHEDULED_TASKS_BEGIN:
|
||||
case DELETE_ALL_SCHEDULED_TASKS_BEGIN:
|
||||
return {
|
||||
...state,
|
||||
@@ -448,6 +470,7 @@ function tasksReducer(
|
||||
};
|
||||
|
||||
case RUN_ALL_SCHEDULED_TASKS_SUCCESS:
|
||||
case KILL_ALL_SCHEDULED_TASKS_SUCCESS:
|
||||
case DELETE_ALL_SCHEDULED_TASKS_SUCCESS:
|
||||
return {
|
||||
...state,
|
||||
@@ -459,6 +482,7 @@ function tasksReducer(
|
||||
};
|
||||
|
||||
case RUN_ALL_SCHEDULED_TASKS_ERROR:
|
||||
case KILL_ALL_SCHEDULED_TASKS_ERROR:
|
||||
case DELETE_ALL_SCHEDULED_TASKS_ERROR:
|
||||
return {
|
||||
...state,
|
||||
@@ -469,6 +493,7 @@ function tasksReducer(
|
||||
};
|
||||
|
||||
case BATCH_RUN_SCHEDULED_TASKS_BEGIN:
|
||||
case BATCH_KILL_SCHEDULED_TASKS_BEGIN:
|
||||
case BATCH_DELETE_SCHEDULED_TASKS_BEGIN:
|
||||
return {
|
||||
...state,
|
||||
@@ -501,6 +526,20 @@ function tasksReducer(
|
||||
};
|
||||
}
|
||||
|
||||
case BATCH_KILL_SCHEDULED_TASKS_SUCCESS: {
|
||||
const newData = state.scheduledTasks.data.filter(
|
||||
(task) => !action.payload.dead_keys.includes(task.key)
|
||||
);
|
||||
return {
|
||||
...state,
|
||||
scheduledTasks: {
|
||||
...state.scheduledTasks,
|
||||
batchActionPending: false,
|
||||
data: newData,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
case BATCH_DELETE_SCHEDULED_TASKS_SUCCESS: {
|
||||
const newData = state.scheduledTasks.data.filter(
|
||||
(task) => !action.payload.deleted_keys.includes(task.key)
|
||||
@@ -516,6 +555,7 @@ function tasksReducer(
|
||||
}
|
||||
|
||||
case BATCH_RUN_SCHEDULED_TASKS_ERROR:
|
||||
case BATCH_KILL_SCHEDULED_TASKS_ERROR:
|
||||
case BATCH_DELETE_SCHEDULED_TASKS_ERROR:
|
||||
return {
|
||||
...state,
|
||||
@@ -535,6 +575,7 @@ function tasksReducer(
|
||||
};
|
||||
|
||||
case RUN_RETRY_TASK_BEGIN:
|
||||
case KILL_RETRY_TASK_BEGIN:
|
||||
case DELETE_RETRY_TASK_BEGIN:
|
||||
return {
|
||||
...state,
|
||||
@@ -550,6 +591,7 @@ function tasksReducer(
|
||||
};
|
||||
|
||||
case RUN_RETRY_TASK_SUCCESS:
|
||||
case KILL_RETRY_TASK_SUCCESS:
|
||||
case DELETE_RETRY_TASK_SUCCESS:
|
||||
return {
|
||||
...state,
|
||||
@@ -562,6 +604,7 @@ function tasksReducer(
|
||||
};
|
||||
|
||||
case RUN_RETRY_TASK_ERROR:
|
||||
case KILL_RETRY_TASK_ERROR:
|
||||
case DELETE_RETRY_TASK_ERROR:
|
||||
return {
|
||||
...state,
|
||||
@@ -577,6 +620,7 @@ function tasksReducer(
|
||||
};
|
||||
|
||||
case RUN_ALL_RETRY_TASKS_BEGIN:
|
||||
case KILL_ALL_RETRY_TASKS_BEGIN:
|
||||
case DELETE_ALL_RETRY_TASKS_BEGIN:
|
||||
return {
|
||||
...state,
|
||||
@@ -587,6 +631,7 @@ function tasksReducer(
|
||||
};
|
||||
|
||||
case RUN_ALL_RETRY_TASKS_SUCCESS:
|
||||
case KILL_ALL_RETRY_TASKS_SUCCESS:
|
||||
case DELETE_ALL_RETRY_TASKS_SUCCESS:
|
||||
return {
|
||||
...state,
|
||||
@@ -598,6 +643,7 @@ function tasksReducer(
|
||||
};
|
||||
|
||||
case RUN_ALL_RETRY_TASKS_ERROR:
|
||||
case KILL_ALL_RETRY_TASKS_ERROR:
|
||||
case DELETE_ALL_RETRY_TASKS_ERROR:
|
||||
return {
|
||||
...state,
|
||||
@@ -608,6 +654,7 @@ function tasksReducer(
|
||||
};
|
||||
|
||||
case BATCH_RUN_RETRY_TASKS_BEGIN:
|
||||
case BATCH_KILL_RETRY_TASKS_BEGIN:
|
||||
case BATCH_DELETE_RETRY_TASKS_BEGIN:
|
||||
return {
|
||||
...state,
|
||||
@@ -640,6 +687,20 @@ function tasksReducer(
|
||||
};
|
||||
}
|
||||
|
||||
case BATCH_KILL_RETRY_TASKS_SUCCESS: {
|
||||
const newData = state.retryTasks.data.filter(
|
||||
(task) => !action.payload.dead_keys.includes(task.key)
|
||||
);
|
||||
return {
|
||||
...state,
|
||||
retryTasks: {
|
||||
...state.retryTasks,
|
||||
batchActionPending: false,
|
||||
data: newData,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
case BATCH_DELETE_RETRY_TASKS_SUCCESS: {
|
||||
const newData = state.retryTasks.data.filter(
|
||||
(task) => !action.payload.deleted_keys.includes(task.key)
|
||||
@@ -655,6 +716,7 @@ function tasksReducer(
|
||||
}
|
||||
|
||||
case BATCH_RUN_RETRY_TASKS_ERROR:
|
||||
case BATCH_KILL_RETRY_TASKS_ERROR:
|
||||
case BATCH_DELETE_RETRY_TASKS_ERROR:
|
||||
return {
|
||||
...state,
|
||||
|
Reference in New Issue
Block a user