fix(CQ-ORCH-10): Make BullMQ job retention configurable via env vars
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
Replace hardcoded BullMQ job retention values (completed: 100 jobs / 1h, failed: 1000 jobs / 24h) with configurable env vars to prevent memory growth under load. Adds QUEUE_COMPLETED_RETENTION_COUNT, QUEUE_COMPLETED_RETENTION_AGE_S, QUEUE_FAILED_RETENTION_COUNT, and QUEUE_FAILED_RETENTION_AGE_S to orchestrator config. Defaults preserve existing behavior. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -45,17 +45,35 @@ export class QueueService implements OnModuleInit, OnModuleDestroy {
|
||||
password: this.configService.get<string>("orchestrator.valkey.password"),
|
||||
};
|
||||
|
||||
// Read retention config
|
||||
const completedRetentionAge = this.configService.get<number>(
|
||||
"orchestrator.queue.completedRetentionAgeSeconds",
|
||||
3600
|
||||
);
|
||||
const completedRetentionCount = this.configService.get<number>(
|
||||
"orchestrator.queue.completedRetentionCount",
|
||||
100
|
||||
);
|
||||
const failedRetentionAge = this.configService.get<number>(
|
||||
"orchestrator.queue.failedRetentionAgeSeconds",
|
||||
86400
|
||||
);
|
||||
const failedRetentionCount = this.configService.get<number>(
|
||||
"orchestrator.queue.failedRetentionCount",
|
||||
1000
|
||||
);
|
||||
|
||||
// Create queue
|
||||
this.queue = new Queue<QueuedTask>(this.queueName, {
|
||||
connection,
|
||||
defaultJobOptions: {
|
||||
removeOnComplete: {
|
||||
age: 3600, // Keep completed jobs for 1 hour
|
||||
count: 100, // Keep last 100 completed jobs
|
||||
age: completedRetentionAge,
|
||||
count: completedRetentionCount,
|
||||
},
|
||||
removeOnFail: {
|
||||
age: 86400, // Keep failed jobs for 24 hours
|
||||
count: 1000, // Keep last 1000 failed jobs
|
||||
age: failedRetentionAge,
|
||||
count: failedRetentionCount,
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user