feat(queue): auto clean up complete and fail jobs

This commit is contained in:
Ali BARIN
2022-11-27 19:25:10 +01:00
parent 4240849a2a
commit 2e391cc651
5 changed files with 36 additions and 5 deletions

View File

@@ -5,6 +5,7 @@ import { IJSONObject, ITriggerItem } from '@automatisch/types';
import actionQueue from '../queues/action';
import Step from '../models/step';
import { processTrigger } from '../services/trigger';
import { REMOVE_AFTER_30_DAYS_OR_150_JOBS, REMOVE_AFTER_7_DAYS_OR_50_JOBS } from '../helpers/remove-job-configuration';
type JobData = {
flowId: string;
@@ -32,7 +33,12 @@ export const worker = new Worker(
stepId: nextStep.id,
};
await actionQueue.add(jobName, jobPayload);
const jobOptions = {
removeOnComplete: REMOVE_AFTER_7_DAYS_OR_50_JOBS,
removeOnFail: REMOVE_AFTER_30_DAYS_OR_150_JOBS,
}
await actionQueue.add(jobName, jobPayload, jobOptions);
},
{ connection: redisConfig }
);