implement flush
This commit is contained in:
1 parent
ca13185d84
commit
38f5c41272
1 file changed
+26
-10
@@ -18,15 +18,26 @@ class SuperSimpleQueue {
|
|||||||
}
|
}
|
||||||
|
|
||||||
init = async () => {
|
init = async () => {
|
||||||
this.scheduler = new Scheduler({
|
try {
|
||||||
logLevel: process.env.LOG_LEVEL,
|
this.scheduler = new Scheduler({
|
||||||
debug: process.env.NODE_ENV,
|
logLevel: process.env.LOG_LEVEL,
|
||||||
});
|
debug: process.env.NODE_ENV,
|
||||||
this.scheduler.start();
|
});
|
||||||
this.scheduler.addTemplate("test", this.helper.getMonitorJob());
|
this.scheduler.start();
|
||||||
const monitors = await this.db.getAllMonitors();
|
this.scheduler.addTemplate("test", this.helper.getMonitorJob());
|
||||||
for (const monitor of monitors) {
|
const monitors = await this.db.getAllMonitors();
|
||||||
await this.addJob(monitor._id, monitor);
|
for (const monitor of monitors) {
|
||||||
|
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;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -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 () => {
|
||||||
|
|||||||
Reference in new issue
Block a user