Skip to content

Commit

Permalink
Refactor queue handling by removing WorkerNotification and updating j…
Browse files Browse the repository at this point in the history
…ob configurations in SendReportsToSubscribers
  • Loading branch information
simlarsen committed Sep 22, 2024
1 parent 9be007c commit 3809b45
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 25 deletions.
3 changes: 1 addition & 2 deletions Common/Server/Infrastructure/Queue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ import { ExpressRouter } from "../Utils/Express";

export enum QueueName {
Workflow = "Workflow",
Worker = "Worker",
WorkerNotification = "WorkerNotification",
Worker = "Worker"
}

export type QueueJob = Job;
Expand Down
2 changes: 1 addition & 1 deletion Common/Types/Events/Recurring.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ export default class Recurring extends DatabaseProperty {

if (nextDate.getTime() <= dateNow.getTime()) {
while (nextDate.getTime() <= dateNow.getTime()) {
nextDate = this.getNextDateInterval(startDate, rotation);
nextDate = this.getNextDateInterval(nextDate, rotation);
}
}

Expand Down
4 changes: 1 addition & 3 deletions Worker/Jobs/StatusPage/SendReportsToSubscribers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,12 @@ import StatusPageService from "Common/Server/Services/StatusPageService";
import QueryHelper from "Common/Server/Types/Database/QueryHelper";
import logger from "Common/Server/Utils/Logger";
import StatusPage from "Common/Models/DatabaseModels/StatusPage";
import { QueueName } from "Common/Server/Infrastructure/Queue";

RunCron(
"StatusPage:SendReportToSubscribers",
{
schedule: EVERY_MINUTE,
runOnStartup: false,
queueName: QueueName.WorkerNotification,
runOnStartup: false
},
async () => {
// get all scheduled events of all the projects.
Expand Down
19 changes: 0 additions & 19 deletions Worker/Routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,25 +133,6 @@ const WorkersFeatureSet: FeatureSet = {
{ concurrency: 100 },
);

// Job process.
QueueWorker.getWorker(
QueueName.WorkerNotification,
async (job: QueueJob) => {
const name: string = job.name;

logger.debug("Running Job: " + name);

const funcToRun: PromiseVoidFunction =
JobDictionary.getJobFunction(name);

const timeoutInMs: number = JobDictionary.getTimeoutInMs(name);

if (funcToRun) {
await QueueWorker.runJobWithTimeout(timeoutInMs, funcToRun);
}
},
{ concurrency: 100 },
);
} catch (err) {
logger.error("App Init Failed:");
logger.error(err);
Expand Down

0 comments on commit 3809b45

Please sign in to comment.