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';
|
2024-12-30 08:26:40 +08:00
|
|
|
import { PushService } from './push/push.service';
|
|
|
|
import { PushQueueService } from './push/push.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],
|
|
|
|
}),
|
|
|
|
BullModule.registerQueue({
|
|
|
|
name: 'general',
|
|
|
|
processors: [join(__dirname, 'worker/processor.js')],
|
|
|
|
})
|
|
|
|
],
|
|
|
|
providers: [Logger, PushService, PushQueueService],
|
|
|
|
exports: [PushService, PushQueueService]
|
|
|
|
|
2024-08-02 19:48:38 +08:00
|
|
|
})
|
|
|
|
export class QueueModule { }
|