perf(enrich): параллельная обработка очереди (3 трека) — быстрее покрывать живой набор
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -17,7 +17,8 @@ export class EnrichmentService {
|
||||
// Очередь обогащения с троттлингом (под лимиты Discogs/iTunes)
|
||||
private readonly queue: string[] = [];
|
||||
private running = false;
|
||||
private readonly throttleMs = 1500;
|
||||
private readonly throttleMs = 1000;
|
||||
private readonly concurrency = 3;
|
||||
|
||||
constructor(
|
||||
private readonly prisma: PrismaService,
|
||||
@@ -94,9 +95,8 @@ export class EnrichmentService {
|
||||
this.running = true;
|
||||
try {
|
||||
while (this.queue.length > 0) {
|
||||
const id = this.queue.shift();
|
||||
if (!id) continue;
|
||||
await this.enrichOne(id);
|
||||
const batch = this.queue.splice(0, this.concurrency);
|
||||
await Promise.all(batch.map((id) => this.enrichOne(id)));
|
||||
await this.sleep(this.throttleMs);
|
||||
}
|
||||
} finally {
|
||||
|
||||
Reference in New Issue
Block a user