Node · jobs
API platform
The product API did HTTP, long jobs, and inbound webhooks in one request cycle. Reports timed out, a failed webhook was gone, and one shared key could touch every resource. The request path is now Fastify. Slow work is a BullMQ job the client polls.
REQUEST PATH, QUEUE, CACHE, KEYS
01Principles
- The request stays short. Slow work is a job with a status, not a longer timeout.
- Accept and process are different events. A webhook is stored before anyone tries to handle it.
- Invalidate on the write. A cache entry lives until the write that can make it wrong.
- A key is a scope. One credential does not open the whole API.
02System map
Rendering diagram…
03What fails on purpose
A long job does not hold the HTTP connection. The client polls the same id. If the worker dies, BullMQ retries the job. The status moves from queued to failed or completed.
A webhook handler that errors does not lose the delivery. The payload is already stored. The retry is another attempt on that record, with backoff. After the retry budget, the delivery sits failed and visible.
A cache miss is a slower read. The write that changes the aggregate deletes the key, and the next read rebuilds it.
A key without the scope for a resource gets nothing. The rate limit is per key, so one integration cannot spend the budget for the others.