mirror of
https://github.com/docmost/docmost.git
synced 2025-11-19 02:21:13 +10:00
Implement BullMQ for background job processing
* new REDIS_URL environment variable
This commit is contained in:
1
apps/server/src/integrations/queue/constants/index.ts
Normal file
1
apps/server/src/integrations/queue/constants/index.ts
Normal file
@ -0,0 +1 @@
|
||||
export * from './queue.constants';
|
||||
@ -0,0 +1,7 @@
|
||||
export enum QueueName {
|
||||
EMAIL_QUEUE = '{email-queue}',
|
||||
}
|
||||
|
||||
export enum QueueJob {
|
||||
SEND_EMAIL = 'send-email',
|
||||
}
|
||||
36
apps/server/src/integrations/queue/queue.module.ts
Normal file
36
apps/server/src/integrations/queue/queue.module.ts
Normal file
@ -0,0 +1,36 @@
|
||||
import { Global, Module } from '@nestjs/common';
|
||||
import { BullModule } from '@nestjs/bullmq';
|
||||
import { EnvironmentService } from '../environment/environment.service';
|
||||
import { parseRedisUrl } from '../../helpers';
|
||||
import { QueueName } from './constants';
|
||||
|
||||
@Global()
|
||||
@Module({
|
||||
imports: [
|
||||
BullModule.forRootAsync({
|
||||
useFactory: (environmentService: EnvironmentService) => {
|
||||
const redisConfig = parseRedisUrl(environmentService.getRedisUrl());
|
||||
return {
|
||||
connection: {
|
||||
host: redisConfig.host,
|
||||
port: redisConfig.port,
|
||||
password: redisConfig.password,
|
||||
},
|
||||
defaultJobOptions: {
|
||||
attempts: 3,
|
||||
backoff: {
|
||||
type: 'exponential',
|
||||
delay: 10000,
|
||||
},
|
||||
},
|
||||
};
|
||||
},
|
||||
inject: [EnvironmentService],
|
||||
}),
|
||||
BullModule.registerQueue({
|
||||
name: QueueName.EMAIL_QUEUE,
|
||||
}),
|
||||
],
|
||||
exports: [BullModule],
|
||||
})
|
||||
export class QueueModule {}
|
||||
Reference in New Issue
Block a user