Skip to content

Commit

Permalink
docs(bullmq-pro): add prioritized section (#2096)
Browse files Browse the repository at this point in the history
  • Loading branch information
roggervalf committed Jul 31, 2023
1 parent 3a656d9 commit a0f153c
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 1 deletion.
1 change: 1 addition & 0 deletions docs/gitbook/SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@
* [Concurrency](bullmq-pro/groups/concurrency.md)
* [Max group size](bullmq-pro/groups/max-group-size.md)
* [Pausing groups](bullmq-pro/groups/pausing-groups.md)
* [Prioritized intra-groups](bullmq-pro/groups/prioritized.md)
* [Batches](bullmq-pro/batches.md)
* [NestJs](bullmq-pro/nestjs/README.md)
* [Producers](bullmq-pro/nestjs/producers.md)
Expand Down
16 changes: 16 additions & 0 deletions docs/gitbook/bullmq-pro/groups/prioritized.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Prioritized intra-groups

BullMQ Pro supports priorities per group. A job is prioritized in a group when group and priority options are provided together.

```typescript
await myQueue.add('paint', { foo: 'bar' }, {
group: {
id: 'groupId',
priority: 10
}
});
```

{% hint style="info" %}
Standard prioritized jobs get more priority than grouped prioritized jobs
{% endhint %}
14 changes: 13 additions & 1 deletion docs/gitbook/guide/jobs/prioritized.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Jobs can also include a priority option. Using priorities, job's processing orde
Adding prioritized jobs is a slower operation than the other types of jobs, with a complexity O(log(n)) relative to the number of jobs in prioritized set in the Queue.
{% endhint %}

Note that the priorities go from 1 to MAX_INT, whereas a lower number is always a higher priority than higher numbers.
Note that the priorities go from 1 to 2 097 152, whereas a lower number is always a higher priority than higher numbers.

Jobs without a priority assigned will get the least priority.

Expand Down Expand Up @@ -47,6 +47,18 @@ await job.changePriority({
});
```

## Get Prioritized jobs

As prioritized is a new state. You must use **getJobs** or **getPrioritized** method as:

```typescript
const jobs = await queue.getJobs(['prioritized']);

const jobs2 = await queue.getPrioritized();
```

## Read more:

- 📋 [Faster Priority jobs](https://bullmq.io/news/062123/faster-priority-jobs/)
- 💡 [Change Priority API Reference](https://api.docs.bullmq.io/classes/v4.Job.html#changePriority)
- 💡 [Get Prioritized API Reference](https://api.docs.bullmq.io/classes/v4.Queue.html#getPrioritized)

0 comments on commit a0f153c

Please sign in to comment.