* [messaging] improve full-sync fetching strategy * fix * rebase * fix * fix * fix rebase * fix * fix * fix * fix * fix * remove deletion * fix setPop with memory storage * fix pgBoss and remove unnecessary job * fix throw * fix * add timeout to ongoing sync
32 lines
1.1 KiB
TypeScript
32 lines
1.1 KiB
TypeScript
import { Inject } from '@nestjs/common';
|
|
|
|
import { Command, CommandRunner } from 'nest-commander';
|
|
|
|
import { MessageQueue } from 'src/engine/integrations/message-queue/message-queue.constants';
|
|
import { MessageQueueService } from 'src/engine/integrations/message-queue/services/message-queue.service';
|
|
import { fetchAllWorkspacesMessagesCronPattern } from 'src/modules/messaging/commands/crons/fetch-all-workspaces-messages.cron.pattern';
|
|
import { FetchAllWorkspacesMessagesJob } from 'src/modules/messaging/commands/crons/fetch-all-workspaces-messages.job';
|
|
|
|
@Command({
|
|
name: 'fetch-all-workspaces-messages:cron:start',
|
|
description: 'Starts a cron job to fetch all workspaces messages',
|
|
})
|
|
export class StartFetchAllWorkspacesMessagesCronCommand extends CommandRunner {
|
|
constructor(
|
|
@Inject(MessageQueue.cronQueue)
|
|
private readonly messageQueueService: MessageQueueService,
|
|
) {
|
|
super();
|
|
}
|
|
|
|
async run(): Promise<void> {
|
|
await this.messageQueueService.addCron<undefined>(
|
|
FetchAllWorkspacesMessagesJob.name,
|
|
undefined,
|
|
{
|
|
repeat: { pattern: fetchAllWorkspacesMessagesCronPattern },
|
|
},
|
|
);
|
|
}
|
|
}
|