33800 Docs

← Retour

Proposition : NeedFinder - Traitement asynchrone via Webhooks

Date : 23/01/2026 23:45 Statut : TERMINÉ ✅

Contexte

Objectif

Passer d'un traitement synchrone (polling) à asynchrone (webhooks) pour :

Modifications

1. NeedFinder - Endpoint webhook

// POST /api/webhook/analysis
// Reçoit le résultat d'un job d'analyse
{
  job_id: string,
  status: "completed" | "failed",
  input_params: { post_id: string, ... },
  output_result: { response: string },
  error_message?: string
}

2. orchestrator-client.ts - Nouvelle fonction

export async function submitAnalysisJobAsync(
  postId: string,
  prompt: string,
  options: OllamaJobOptions
): Promise<string> {
  // Soumet avec callback_url, retourne job_id immédiatement
}

3. analyzer.ts - Mode async

export async function submitAnalysisBatch(limit: number): Promise<number> {
  // Soumet N jobs sans attendre, retourne nombre soumis
}

4. scheduler.ts - Batch processing

Avantages

Avant Après
25 posts/6h 100+ posts/6h (et traitement continu)
Bloquant Non-bloquant
1 job à la fois N jobs en parallèle

Risques

Plan d'implémentation

  1. [x] Proposition créée
  2. [x] Ajouter endpoint webhook analyse dans index.ts
  3. [x] Créer fonction submitAnalysisJobAsync
  4. [x] Modifier analyzer pour mode async
  5. [x] Ajouter webhook traduction (chaînage auto)
  6. [x] Ajouter champ analysis_status (pending/submitted/completed/failed)
  7. [x] Endpoint /api/analyze/all pour traitement complet
  8. [x] Tester et lancer

Commits : 9bc45a3, c4a9164, 096fd1d, fccbdab Pipelines : #288, #289, #290, #291