Add pg-boss worker poc (#2991)

* Add pg-boss worker poc

* add Example job

* add retry limit

* rename MessageQueue
This commit is contained in:
Weiko
2023-12-14 18:57:25 +01:00
committed by GitHub
parent 468744298b
commit 36164ab59b
18 changed files with 196 additions and 41 deletions

View File

@ -1,9 +1,10 @@
import { Module } from '@nestjs/common';
import { FetchWorkspaceMessagesCommand } from 'src/workspace/messaging/commands/fetch-workspace-messages.command';
import { MessagingModule } from 'src/workspace/messaging/messaging.module';
@Module({
imports: [],
imports: [MessagingModule],
providers: [FetchWorkspaceMessagesCommand],
})
export class FetchWorkspaceMessagesCommandsModule {}

View File

@ -1,5 +1,7 @@
import { Command, CommandRunner, Option } from 'nest-commander';
import { MessagingProducer } from 'src/workspace/messaging/producers/messaging-producer';
interface FetchWorkspaceMessagesOptions {
workspaceId: string;
}
@ -9,11 +11,18 @@ interface FetchWorkspaceMessagesOptions {
description: 'Fetch messages of all workspaceMembers in a workspace.',
})
export class FetchWorkspaceMessagesCommand extends CommandRunner {
constructor(private readonly messagingProducer: MessagingProducer) {
super();
}
async run(
_passedParam: string[],
options: FetchWorkspaceMessagesOptions,
): Promise<void> {
console.log('fetching messages for workspace', options.workspaceId);
await this.messagingProducer.enqueueFetchMessages(
{ workspaceId: options.workspaceId },
options.workspaceId,
);
return;
}