( jobPayloads: DocumentProcessingPayload[], requestId: string )
| 472 | } |
| 473 | |
| 474 | async function dispatchInProcess( |
| 475 | jobPayloads: DocumentProcessingPayload[], |
| 476 | requestId: string |
| 477 | ): Promise<number> { |
| 478 | const results = await Promise.allSettled( |
| 479 | jobPayloads.map((p) => |
| 480 | processDocumentAsync(p.knowledgeBaseId, p.documentId, p.docData, p.processingOptions) |
| 481 | ) |
| 482 | ) |
| 483 | let dispatched = 0 |
| 484 | for (const r of results) { |
| 485 | if (r.status === 'fulfilled') dispatched++ |
| 486 | else |
| 487 | logger.error(`[${requestId}] Document dispatch failed`, { error: getErrorMessage(r.reason) }) |
| 488 | } |
| 489 | return dispatched |
| 490 | } |
| 491 | |
| 492 | export async function processDocumentAsync( |
| 493 | knowledgeBaseId: string, |
no test coverage detected