Files
dsc-api/src/configs/bullmq.config.ts
T
2025-03-09 23:16:00 +03:30

20 lines
755 B
TypeScript
Executable File

import { SharedBullAsyncConfiguration } from "@nestjs/bullmq";
import { ConfigService } from "@nestjs/config";
export function bullMqConfig(): SharedBullAsyncConfiguration {
return {
inject: [ConfigService],
useFactory: async (configService: ConfigService) => ({
connection: {
url: configService.getOrThrow<string>("REDIS_URI"),
},
defaultJobOptions: {
removeOnComplete: 2000, // Consider lower values in high-volume production
removeOnFail: 5000, // Consider lower values to reduce Redis memory usage
attempts: 3, // Reasonable default, adjust based on job criticality
backoff: { type: "exponential", delay: 2000 }, // Consider adding for better retry behavior
},
}),
};
}