20 lines
755 B
TypeScript
Executable File
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
|
|
},
|
|
}),
|
|
};
|
|
}
|