feat: job queue (FIFO concurrency=1) for all Appium/ADB operations

- JobQueue class: single-worker, in-memory FIFO queue
- All Appium endpoints now return 202 + jobId (instead of blocking)
- GET /jobs/:jobId + GET /jobs for status polling
- Webhook receive stays instant (200), media-pull goes via queue
- Upload file cleanup via promise.finally()
- Logging: queue add/start/done/fail with timestamps
- README updated with queue architecture and migration guide
This commit is contained in:
Eddy de Vink 2026-07-22 22:10:06 +02:00
commit 7efe8792ab

View file

@ -347,6 +347,29 @@ curl -X POST http://127.0.0.1:3010/webhooks/whatsapp/incoming \
- `openChat(d, query)` — zoek chat via search, open 'm
- Finders gebruiken UiAutomator2 `new UiSelector()` via WebDriverIO
**Job queue (FIFO, concurrency=1):**
Alle Appium/ADB-operaties gaan door één centrale queue, omdat er maar één
fysieke telefoon is. Geen twee acties tegelijk op dezelfde UI-sessie.
- **Aanbieding:** endpoints geven meteen `202 { jobId }` terug, job wordt
achter de schermen verwerkt
- **Status:** `GET /jobs/:jobId` — pending / in_progress / done / failed
- **Overzicht:** `GET /jobs` — laatste 50 jobs
- **Webhook:** ontvangst gaat direct (200), alleen media-pull gaat via queue
- **Retry:** bij falen blijft de job op `failed`. De aanroeper moet zelf
opnieuw proberen.
- **Logging:** `[queue] +jobId (label) — N jobs waiting`, dan `▶` en `✔`/`✗`
- **Breaking change:** `getChats` en `fetchMessages` waren synchroon (data
direct in response). Nu geven ze ook `202 + jobId`. Poll `GET /jobs/:jobId`
tot `done` en check `result` voor de data.
```bash
# voorbeeld: job aanmaken, status pollen, resultaat uitlezen
JOB=$(curl -s http://localhost:3010/client/getChats/EdGpt | python3 -c "import sys,json; print(json.load(sys.stdin)['jobId'])")
sleep 5
curl -s http://localhost:3010/jobs/$JOB | python3 -m json.tool
```
---
## Troubleshooting