Sometimes it is necessary to process jobs following a priority order. This is easily achieved by setting the "priority" option on the job payload.

The priorities range from 1 to 2 097 152. Where the lowest value has the largest priority, following the same schema used by processes in Unix. A job without priority (or priority 0) will have the highest priority and be processed before any other prioritized job.

The JobOpts interface with the added priority option would look like this:

interface JobOpts {
  priority: number; // an integer between 1 and 2_097_152
  // ... More opts
curl --location '' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer my-secret-token' \
--data '[{
	  "name": "paint-red",
          "data": {},
          "opts": {
            "priority": 5
	  "name": "paint-black",
          "data": {}

The above snippet will add one Job with priority 5, and another without priority. The job named "paint-black" even though it was added after the one called "paint-red" will be processed before, as jobs without priority will be processed before jobs with priority.

Last updated