Jobs
The background job queue: what is pending, what failed, and running or cancelling one by hand.
KahunaCart does slow work in a queue: emails, exports, index rebuilds, provider syncs. These routes read the queue and act on one job. Queue health also rides along on GET /kahunacart/config. See Hardening.
List queued jobs
/api/v1/kahunacart/jobs
A page of the job queue, newest first: every job with its state — pending, running, complete, failed or cancelled — its arguments, when it was queued and started, how long it took, how many attempts of how many, the worker that held it and the last error, plus the counts per state. This is where a missing confirmation email is found.
Parameters
| Name | Type | Description |
|---|---|---|
| state optional | string |
One of:
pending, running, complete, failed, cancelled |
| type optional | string | One job type, e.g. order.confirmation_email |
| sort optional | string |
A column to sort the whole list by before it is paged; leave out for the usual order
One of:
id, type, state, attempts, queued, started, took, error |
| dir optional | string |
One of:
asc, descDefault:
asc |
| page optional | integer | |
| per_page optional | integer |
Run a job now
/api/v1/kahunacart/jobs/{id}/run
Release a job for the next worker tick, whatever it was waiting for; a failed job is granted one more attempt. Nothing runs inside the request. 409 when the job is running or already complete.
Parameters
| Name | Type | Description |
|---|---|---|
| id required | integer | Job id |
Cancel a job
/api/v1/kahunacart/jobs/{id}/cancel
Cancel a pending job outright, or ask a running one to stop: the flag is read at a transaction boundary, so a bulk change stops between orders and nothing half-written is left. The answer's outcome is cancelled or requested. 409 when the job has already finished.
Parameters
| Name | Type | Description |
|---|---|---|
| id required | integer | Job id |