🚀 核心更新: - ✅ 完善 NestJS 企业级架构设计 - ✅ 优化配置中心和基础设施层 - ✅ 增强第三方服务集成能力 - ✅ 完善多租户架构支持 - 🎯 对标 Java Spring Boot 和 PHP ThinkPHP 📦 新增文件: - wwjcloud-nest 完整框架结构 - Docker 容器化配置 - 管理后台界面 - 数据库迁移脚本 🔑 Key: ebb38b43ec39f355f071294fd1cf9c42
43 lines
1.1 KiB
TypeScript
43 lines
1.1 KiB
TypeScript
import { Module, Global } from '@nestjs/common';
|
|
import { BullModule } from '@nestjs/bullmq';
|
|
import { ConfigModule, ConfigService } from '@nestjs/config';
|
|
|
|
/**
|
|
* 队列模块 - 基础设施层
|
|
* 基于 NestJS 官方文档实现
|
|
* 参考: https://docs.nestjs.cn/techniques/queues
|
|
* 使用 BullMQ 作为队列引擎
|
|
*/
|
|
@Global()
|
|
@Module({
|
|
imports: [
|
|
BullModule.forRootAsync({
|
|
imports: [ConfigModule],
|
|
inject: [ConfigService],
|
|
useFactory: async (configService: ConfigService) => {
|
|
const redisConfig = configService.get('redis');
|
|
|
|
return {
|
|
connection: {
|
|
host: redisConfig.host,
|
|
port: redisConfig.port,
|
|
password: redisConfig.password,
|
|
db: redisConfig.db,
|
|
},
|
|
defaultJobOptions: {
|
|
removeOnComplete: 10,
|
|
removeOnFail: 5,
|
|
attempts: 3,
|
|
backoff: {
|
|
type: 'exponential',
|
|
delay: 2000,
|
|
},
|
|
},
|
|
};
|
|
},
|
|
}),
|
|
],
|
|
exports: [BullModule],
|
|
})
|
|
export class QueueModule {}
|