Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

clean all redis before running any jobs #39

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/processors/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ export class Processors implements ProcessorInterface {
}

async reset() {
// Reset all the queues first
await Promise.all(_.map(this.processors, async(p) => await p.clean()));

const modes: Mode[] = await this.getRunningModes();
// Depending on the mode, we choose different processor to work on
modes.map(async (m) => {
Expand Down
4 changes: 4 additions & 0 deletions src/processors/lite.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ export class Lite implements ProcessorInterface {
return this;
};

async clean(): Promise<void> {
await this.queue.obliterate({ force: true });
}

// In lite mode, the reset does nothing other than just trigger the jobs. We can trigger it multiple time, it has no effect
async reset(): Promise<void> {
await this.queue.add({}, { jobId: NAME, repeat: { cron: config.cronJob.liteJobExpression}});
Expand Down
4 changes: 4 additions & 0 deletions src/processors/standard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ export class Standard implements ProcessorInterface {
return this;
}

async clean(): Promise<void> {
await this.queue.obliterate({ force: true });
}

// Reset and start the state sync until success
async reset() {
try {
Expand Down
4 changes: 4 additions & 0 deletions src/processors/zero.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ export class Zero implements ProcessorInterface {
async reset(): Promise<void> {
await this.queue.add({}, REPEAT_JOB_OPT);
}

async clean(): Promise<void> {
await this.queue.obliterate({ force: true });
}

async processEvent() {
const payloads = await this.zeroService.getPayloads();
Expand Down