Pular para o conteúdo
#0774
Sqlite

The job queue is a key

Your product's export feature needs a job queue. The classic answer is a queue service: a broker to run, a client library, a dead-letter policy, a dashboard. Here the queue is a key. The API handler does POST /kv/exports/push with the job payload; a worker does POST /kv/exports/pop and gets the most recent job back, atomically removed. Two workers popping at once never receive the same element: the mutation happens inside the store, not in client code racing itself.

remove deletes a cancelled job by value or by index, and a JSON path targets queues nested inside larger state. It's last-in-first-out, it's inspectable with a GET, and its whole operational surface is the database you already had.

The job queue is an array with a URL.