training_data/apps/server/src/queue/queue.module.ts

36 lines
1.1 KiB
TypeScript
Raw Normal View History

2024-08-02 19:48:38 +08:00
import { BullModule } from '@nestjs/bullmq';
import { Logger, Module } from '@nestjs/common';
2024-12-30 08:26:40 +08:00
import { ConfigModule, ConfigService } from '@nestjs/config';
2024-08-02 19:48:38 +08:00
import { join } from 'path';
2025-02-24 08:51:44 +08:00
import { PostQueueService } from './models/post/post.queue.service';
2024-08-02 19:48:38 +08:00
@Module({
2024-12-30 08:26:40 +08:00
imports: [
ConfigModule.forRoot(), // 导入 ConfigModule
BullModule.forRootAsync({
imports: [ConfigModule],
useFactory: async (configService: ConfigService) => ({
connection: {
password: configService.get<string>('REDIS_PASSWORD'),
host: configService.get<string>('REDIS_HOST'),
port: configService.get<number>('REDIS_PORT', 6379),
},
}),
inject: [ConfigService],
}),
2025-01-03 09:24:46 +08:00
BullModule.registerQueue(
{
name: 'general',
processors: [join(__dirname, 'worker/processor.js')],
},
{
name: 'file-queue', // 新增文件处理队列
processors: [join(__dirname, 'worker/file.processor.js')], // 文件处理器的路径
2025-01-27 22:43:18 +08:00
},
2025-01-03 09:24:46 +08:00
),
2024-12-30 08:26:40 +08:00
],
2025-02-24 08:51:44 +08:00
providers: [Logger, PostQueueService],
2025-01-27 22:43:18 +08:00
exports: [],
2024-08-02 19:48:38 +08:00
})
2025-01-27 22:43:18 +08:00
export class QueueModule {}