implement flush

This commit is contained in:
Alex Holliday committed 2025-06-27 13:45:18 +08:00
1 parent ca13185d84
commit 38f5c41272
1 file changed
+17 -1
@@ -18,6 +18,7 @@ class SuperSimpleQueue {
} }
init = async () => { init = async () => {
try {
this.scheduler = new Scheduler({ this.scheduler = new Scheduler({
logLevel: process.env.LOG_LEVEL, logLevel: process.env.LOG_LEVEL,
debug: process.env.NODE_ENV, debug: process.env.NODE_ENV,
@@ -28,6 +29,16 @@ class SuperSimpleQueue {
for (const monitor of monitors) { for (const monitor of monitors) {
await this.addJob(monitor._id, monitor); await this.addJob(monitor._id, monitor);
} }
return true;
} catch (error) {
this.logger.error({
message: "Failed to initialize SuperSimpleQueue",
service: SERVICE_NAME,
method: "init",
details: error,
});
return false;
}
}; };
addJob = async (monitorId, monitor) => { addJob = async (monitorId, monitor) => {
@@ -135,7 +146,12 @@ class SuperSimpleQueue {
}; };
flushQueues = async () => { flushQueues = async () => {
console.log("flush not implemented"); const stopRes = this.scheduler.stop();
const flushRes = this.scheduler.flushJobs();
const initRes = await this.init();
return {
success: stopRes && flushRes && initRes,
};
}; };
obliterate = async () => { obliterate = async () => {