Skip to content

Commit

Permalink
Merge branch 'master' into v6
Browse files Browse the repository at this point in the history
  • Loading branch information
roggervalf authored Sep 12, 2024
2 parents dbef80d + ce1b22e commit 8eed71d
Show file tree
Hide file tree
Showing 37 changed files with 760 additions and 94 deletions.
2 changes: 1 addition & 1 deletion .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

yarn npm-run-all pretty:quick lint:staged
npx npm-run-all pretty:quick lint:staged
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2018 taskforcesh
Copyright (c) 2018 BullForce Labs AB.

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
11 changes: 1 addition & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,16 +75,6 @@ Sign up at [Taskforce.sh](https://taskforce.sh)
better performance by utilizing all CPU cores available and faster and more memory efficient data structures. Read more <a href="https://www.dragonflydb.io/docs/integrations/bullmq">here</a> on how to use it with BullMQ.
</td>
</tr>
<tr>
<td>
<a href="https://dashboard.memetria.com/new?utm_campaign=BULLMQ">
<img src="https://www.memetria.com/images/logo/memetria-logo.svg" width=350 alt="Memetria for Redis" />
</a>
</td>
<td>
If you need high quality production Redis instances for your BullMQ project, please consider subscribing to <a href="https://dashboard.memetria.com/new?utm_campaign=BULLMQ">Memetria for Redis</a>, leaders in Redis hosting that works perfectly with BullMQ. Use the promo code "BULLMQ" when signing up to help us sponsor the development of BullMQ!
</td>
</tr>
</table>

# Used by
Expand Down Expand Up @@ -238,6 +228,7 @@ Since there are a few job queue solutions, here is a table comparing them:
| Group Support || | | | | |
| Batches Support || | | | | |
| Parent/Child Dependencies ||| | | | |
| Debouncing |||| | | |
| Priorities ||||| ||
| Concurrency |||||||
| Delayed jobs ||||| ||
Expand Down
1 change: 1 addition & 0 deletions docs/gitbook/SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@
* [Process Step Jobs](patterns/process-step-jobs.md)
* [Failing fast when Redis is down](patterns/failing-fast-when-redis-is-down.md)
* [Stop retrying jobs](patterns/stop-retrying-jobs.md)
* [Timeout jobs](patterns/timeout-jobs.md)
* [Redis Cluster](patterns/redis-cluster.md)

## BullMQ Pro
Expand Down
24 changes: 24 additions & 0 deletions docs/gitbook/bullmq-pro/changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,27 @@
## [7.15.1](https://github.com/taskforcesh/bullmq-pro/compare/v7.15.0...v7.15.1) (2024-09-06)


### Bug Fixes

* **worker:** fix close sequence to reduce risk for open handlers ([#2656](https://github.com/taskforcesh/bullmq/issues/2656)) ([8468e44](https://github.com/taskforcesh/bullmq/commit/8468e44e5e9e39c7b65691945c26688a9e5d2275))
* **flow:** validate parentData before ignoreDependencyOnFailure when stalled check happens ([#2702](https://github.com/taskforcesh/bullmq/issues/2702)) (python) ([9416501](https://github.com/taskforcesh/bullmq/commit/9416501551b1ad464e59bdba1045a5a9955e2ea4))

# [7.15.0](https://github.com/taskforcesh/bullmq-pro/compare/v7.14.1...v7.15.0) (2024-09-05)


### Bug Fixes

* **job:** consider passing stackTraceLimit as 0 ([#2692](https://github.com/taskforcesh/bullmq/issues/2692)) ref [#2487](https://github.com/taskforcesh/bullmq/issues/2487) ([509a36b](https://github.com/taskforcesh/bullmq/commit/509a36baf8d8cf37176e406fd28e33f712229d27))


### Features

* **queue-pro:** add getGroupRateLimitTtl method ([#250](https://github.com/taskforcesh/bullmq-pro/issues/250)) ([5a907d9](https://github.com/taskforcesh/bullmq-pro/commit/5a907d9ca1f4719ad835673fcf0773b5f64c2398))

### Performance Improvements

* **worker:** promote delayed jobs while queue is rate limited ([#2697](https://github.com/taskforcesh/bullmq/issues/2697)) ref [#2582](https://github.com/taskforcesh/bullmq/issues/2582) ([f3290ac](https://github.com/taskforcesh/bullmq/commit/f3290ace2f117e26357f9fae611a255af26b950b))

## [7.14.1](https://github.com/taskforcesh/bullmq-pro/compare/v7.14.0...v7.14.1) (2024-08-09)


Expand Down
21 changes: 21 additions & 0 deletions docs/gitbook/bullmq-pro/groups/rate-limiting.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,27 @@ const worker = new WorkerPro(
);
```

### Get Group Rate Limit Ttl

Sometimes is useful to know if our group is rate limited.

For this purpose, you can use the **`getGroupRateLimitTtl`** method like this:

```typescript
import { QueuePro } from '@taskforcesh/bullmq-pro';

const queue = new QueuePro('myQueue', { connection });
const groupId = '0';
const maxJobs = 100;

const ttl = await queue.getGroupRateLimitTtl(groupId, maxJobs);

if (ttl > 0) {
console.log('Group is rate limited');
}
```

## Read more:

* 💡 [Rate Limit Group API Reference](https://api.bullmq.pro/classes/v7.Worker.html#rateLimitGroup)
- 💡 [Get Group Rate Limit Ttl API Reference](https://api.bullmq.pro/classes/v7.Queue.html#getGroupRateLimitTtl)
51 changes: 50 additions & 1 deletion docs/gitbook/changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,53 @@
# [5.13.0](https://github.com/taskforcesh/bullmq/compare/v5.12.15...v5.13.0) (2024-09-11)


### Features

* **queue:** add getDebounceJobId method ([#2717](https://github.com/taskforcesh/bullmq/issues/2717)) ([a68ead9](https://github.com/taskforcesh/bullmq/commit/a68ead95f32a7d9dabba602895d05c22794b2c02))

## [5.12.15](https://github.com/taskforcesh/bullmq/compare/v5.12.14...v5.12.15) (2024-09-10)


### Bug Fixes

* **metrics:** differentiate points in different minutes to be more accurate ([#2766](https://github.com/taskforcesh/bullmq/issues/2766)) (python) ([7cb670e](https://github.com/taskforcesh/bullmq/commit/7cb670e1bf9560a24de3da52427b4f6b6152a59a))
* **pattern:** do not save offset when immediately is provided ([#2756](https://github.com/taskforcesh/bullmq/issues/2756)) ([a8cb8a2](https://github.com/taskforcesh/bullmq/commit/a8cb8a21ea52437ac507097994ef0fde058c5433))

## [5.12.14](https://github.com/taskforcesh/bullmq/compare/v5.12.13...v5.12.14) (2024-09-05)


### Performance Improvements

* **metrics:** save zeros as much as max data points ([#2758](https://github.com/taskforcesh/bullmq/issues/2758)) ([3473054](https://github.com/taskforcesh/bullmq/commit/347305451a9f5d7f2c16733eb139b5de96ea4b9c))

## [5.12.13](https://github.com/taskforcesh/bullmq/compare/v5.12.12...v5.12.13) (2024-09-03)


### Bug Fixes

* **repeat:** replace delayed job when updating repeat key ([88029bb](https://github.com/taskforcesh/bullmq/commit/88029bbeab2a58768f9c438318f540010cd286a7))

## [5.12.12](https://github.com/taskforcesh/bullmq/compare/v5.12.11...v5.12.12) (2024-08-29)


### Bug Fixes

* **flows:** throw error when queueName contains colon ([#2719](https://github.com/taskforcesh/bullmq/issues/2719)) fixes [#2718](https://github.com/taskforcesh/bullmq/issues/2718) ([9ef97c3](https://github.com/taskforcesh/bullmq/commit/9ef97c37663e209f03c501a357b6b1a662b24d99))

## [5.12.11](https://github.com/taskforcesh/bullmq/compare/v5.12.10...v5.12.11) (2024-08-28)


### Bug Fixes

* **sandboxed:** properly update data on wrapped job ([#2739](https://github.com/taskforcesh/bullmq/issues/2739)) fixes [#2731](https://github.com/taskforcesh/bullmq/issues/2731) ([9c4b245](https://github.com/taskforcesh/bullmq/commit/9c4b2454025a14459de47b0586a09130d7a93cae))

## [5.12.10](https://github.com/taskforcesh/bullmq/compare/v5.12.9...v5.12.10) (2024-08-22)


### Bug Fixes

* **flow:** remove debounce key when parent is moved to fail ([#2720](https://github.com/taskforcesh/bullmq/issues/2720)) ([d51aabe](https://github.com/taskforcesh/bullmq/commit/d51aabe999a489c285f871d21e36c3c84e2bef33))

## [5.12.9](https://github.com/taskforcesh/bullmq/compare/v5.12.8...v5.12.9) (2024-08-17)


Expand Down Expand Up @@ -61,7 +111,6 @@
### Bug Fixes

* **job:** consider passing stackTraceLimit as 0 ([#2692](https://github.com/taskforcesh/bullmq/issues/2692)) ref [#2487](https://github.com/taskforcesh/bullmq/issues/2487) ([509a36b](https://github.com/taskforcesh/bullmq/commit/509a36baf8d8cf37176e406fd28e33f712229d27))
* **job:** make sure json.dumps return JSON compliant JSON [python] ([#2683](https://github.com/taskforcesh/bullmq/issues/2683)) ([4441711](https://github.com/taskforcesh/bullmq/commit/4441711a986a9f6a326100308d639eb0a2ea8c8d))

# [5.12.0](https://github.com/taskforcesh/bullmq/compare/v5.11.0...v5.12.0) (2024-08-01)

Expand Down
Empty file removed docs/gitbook/do-not-commit-.md
Empty file.
4 changes: 4 additions & 0 deletions docs/gitbook/guide/flows/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,10 @@ The above call will return instances for all the jobs added to the queue.
Note that the parent queue does not need to be the same queue as the one used for the children.
{% endhint %}

{% hint style="warning" %}
If a jobId option is provided, make that it does not contain a colon **:** as this is considered a separator.
{% endhint %}

When the parent job is processed it is possible to access the results generated by its child jobs. For example, lets assume the following worker for the child jobs:

{% tabs %}
Expand Down
17 changes: 17 additions & 0 deletions docs/gitbook/guide/jobs/debouncing.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,23 @@ This mode is particularly useful for jobs that have a long running time or those
Any manual deletion will disable the debouncing. For example, when calling _job.remove_ method.
{% endhint %}

## Get Debounce Job Id

If you need to know which is the job id that started the debounce state. You can call **getDebounceJobId** method.

```typescript
const jobId = await myQueue.getDebounceJobId('customValue');
```

## Remove Debounce Key

If you need to stop debouncing before ttl finishes or before finishing a job. You can call **removeDebounceKey** method.

```typescript
await myQueue.removeDebounceKey('customValue');
```

## Read more:

- 💡 [Add Job API Reference](https://api.docs.bullmq.io/classes/v5.Queue.html#add)
- 💡 [Remove Debounce Key API Reference](https://api.docs.bullmq.io/classes/v5.Queue.html#removeDebounceKey)
34 changes: 25 additions & 9 deletions docs/gitbook/guide/jobs/repeatable.md
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ const myQueue = new Queue('Paint', { settings });
// Repeat job every 10 seconds
await myQueue.add(
'bird',
{ color: 'bird' },
{ color: 'green' },
{
repeat: {
pattern: 'RRULE:FREQ=SECONDLY;INTERVAL=;WKST=MO',
Expand All @@ -163,7 +163,7 @@ await myQueue.add(

await myQueue.add(
'bird',
{ color: 'bird' },
{ color: 'gray' },
{
repeat: {
pattern: 'RRULE:FREQ=SECONDLY;INTERVAL=;WKST=MO',
Expand Down Expand Up @@ -203,10 +203,10 @@ const myQueue = new Queue('Paint', { connection });
// Repeat job every 10 seconds
await myQueue.add(
'bird',
{ color: 'bird' },
{ color: 'gray' },
{
repeat: {
every: 1000,
every: 10_000,
key: 'colibri',
},
},
Expand All @@ -215,20 +215,36 @@ await myQueue.add(
// Repeat job every 10 seconds
await myQueue.add(
'bird',
{ color: 'bird' },
{ color: 'brown' },
{
repeat: {
every: 1000,
every: 10_000,
key: 'eagle',
},
},
);

```

{% hint style="warning" %}
While adding a new repeatable job with same key but different repeat options, you will override your previous record.
{% endhint %}
#### Updating repeatable job's options

Using custom keys allows to update existing repeatable jobs by just adding a new repeatable job using the same key, so for instance, if we wanted to change the repetition interval of the previous job that used the key "eagle" we could just a new job like this:

```typescript
// Repeat job every 25 seconds instead of 10 seconds
await myQueue.add(
'bird',
{ color: 'turquoise' },
{
repeat: {
every: 25_000,
key: 'eagle',
},
},
);
```

The code above will not create a new repeatable meta job, it will just update the existing meta job's interval from 10 seconds to 25 seconds. Note that if there is already a job delayed for running within the 10 seconds it will be replaced by a new job using the new repeatable job's settings.

### Read more:

Expand Down
53 changes: 53 additions & 0 deletions docs/gitbook/patterns/timeout-jobs.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# Timeout jobs

BullMQ does not provide a specific mechanism to timeout jobs, however this can be accomplished in many cases with a custom timeout code in the worker's process function.

The basic concept is to set up a timeout callback that will abort the job processing, and throw an UnrecoverableError (to avoid retries, although this may not alway be the desired behaviour, if so just throw a normal Error). Note how we specified the timeout as a property of the job's data, in case we want to have different timeouts depending on the job, but we could also have a fixed constant timeout for all jobs if we wanted.

```typescript
const worker = new Worker('foo', async job => {
let controller = new AbortController();
const timer = setTimeout(() => controller.abort(), job.data.timeout);

try {
await doSomethingAbortable(controller.signal);
} catch(err) {
if (err.name == "AbortError") {
throw new UnrecoverableError("Timeout");
} else {
throw err;
}
} finally {
clearTimeout(timer);
}
});
```

In this simple example we assume that doSomethingAbortable is an asynchronous function that can handle abort signals and abort itself gracefully.

Now let's see another case when we want to timeout a fetch call, it would look like this:

```typescript
const worker = new Worker("foo", async (job) => {
let controller = new AbortController();
const timer = setTimeout(() => controller.abort(), job.data.timeout);
try {
let response = await fetch("/slowserver.com", {
signal: controller.signal,
});
const result = await response.text();
} catch (err) {
if (err.name == "AbortError") {
throw new UnrecoverableError("Timeout");
} else {
throw err;
}
} finally {
clearTimeout(timer)
}
});
```

In this example we are aborting the fetch call using [AbortController](https://developer.mozilla.org/en-US/docs/Web/API/AbortController), which is the default mechanism provided by fetch to abort calls. Note that abort will even cause the async call to response.text() to also throw an Abort exception.

In summary, while it is possible to implement timeout in your jobs, the mechanism to do it may vary depending on the type of asynchronous operations your jobs is performing, but in many cases using AbortController in combination with a setTimeout is more than enough.
33 changes: 33 additions & 0 deletions docs/gitbook/python/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,39 @@

<!--next-version-placeholder-->

## v2.9.4 (2024-09-10)
### Fix
* **metrics:** Differentiate points in different minutes to be more accurate (#2766) (python) ([`7cb670e`](https://github.com/taskforcesh/bullmq/commit/7cb670e1bf9560a24de3da52427b4f6b6152a59a))
* **pattern:** Do not save offset when immediately is provided ([#2756](https://github.com/taskforcesh/bullmq/issues/2756)) ([`a8cb8a2`](https://github.com/taskforcesh/bullmq/commit/a8cb8a21ea52437ac507097994ef0fde058c5433))
* **repeat:** Replace delayed job when updating repeat key ([`88029bb`](https://github.com/taskforcesh/bullmq/commit/88029bbeab2a58768f9c438318f540010cd286a7))

### Documentation
* **bullmq-pro:** Add get group rate limit ttl section ([#2761](https://github.com/taskforcesh/bullmq/issues/2761)) ([`3dc13d1`](https://github.com/taskforcesh/bullmq/commit/3dc13d107c81519ee9ceab1f8d6d2a614b005384))

### Performance
* **metrics:** Save zeros as much as max data points ([#2758](https://github.com/taskforcesh/bullmq/issues/2758)) ([`3473054`](https://github.com/taskforcesh/bullmq/commit/347305451a9f5d7f2c16733eb139b5de96ea4b9c))

## v2.9.3 (2024-08-31)
### Fix
* **flows:** Throw error when queueName contains colon (#2719) fixes #2718 ([`9ef97c3`](https://github.com/taskforcesh/bullmq/commit/9ef97c37663e209f03c501a357b6b1a662b24d99))
* **sandboxed:** Properly update data on wrapped job (#2739) fixes #2731 ([`9c4b245`](https://github.com/taskforcesh/bullmq/commit/9c4b2454025a14459de47b0586a09130d7a93cae))
* **flow:** Remove debounce key when parent is moved to fail ([#2720](https://github.com/taskforcesh/bullmq/issues/2720)) ([`d51aabe`](https://github.com/taskforcesh/bullmq/commit/d51aabe999a489c285f871d21e36c3c84e2bef33))
* **flow:** Recursive ignoreDependencyOnFailure option ([#2712](https://github.com/taskforcesh/bullmq/issues/2712)) ([`53bc9eb`](https://github.com/taskforcesh/bullmq/commit/53bc9eb68b5bb0a470a8fe64ef78ece5cde44632))
* **job:** Throw error if removeDependencyOnFailure and ignoreDependencyOnFailure are used together ([#2711](https://github.com/taskforcesh/bullmq/issues/2711)) ([`967632c`](https://github.com/taskforcesh/bullmq/commit/967632c9ef8468aab59f0b36d1d828bcde1fbd70))
* **stalled:** Support removeDependencyOnFailure option when job is stalled ([#2708](https://github.com/taskforcesh/bullmq/issues/2708)) ([`e0d3790`](https://github.com/taskforcesh/bullmq/commit/e0d3790e755c4dfe31006b52f177f08b40348e61))
* **job:** Change moveToFinished return type to reflect jobData (#2706) ref #2342 ([`de094a3`](https://github.com/taskforcesh/bullmq/commit/de094a361a25886acbee0112bb4341c6b285b1c9))
* **connection:** Remove unnecessary process.env.CI reference ([#2705](https://github.com/taskforcesh/bullmq/issues/2705)) ([`53de304`](https://github.com/taskforcesh/bullmq/commit/53de3049493ef79e02af40e8e450e2056c134155))
* **worker:** Fix close sequence to reduce risk for open handlers ([#2656](https://github.com/taskforcesh/bullmq/issues/2656)) ([`8468e44`](https://github.com/taskforcesh/bullmq/commit/8468e44e5e9e39c7b65691945c26688a9e5d2275))

### Documentation
* **connection:** Add decode_responses warning [python] (#2745) fixes #2695 ([`188192c`](https://github.com/taskforcesh/bullmq/commit/188192c1b15e77013ad78a4904f099cd314b4b86))
* Update README.md sponsors ([`e7e7193`](https://github.com/taskforcesh/bullmq/commit/e7e7193bacf048162d7095ba003169ee81a3766e))
* Update copyright holder ([`13516c6`](https://github.com/taskforcesh/bullmq/commit/13516c6f5a982b44f3bb49024ec8d11a90c6c9ab))
* **debouncing:** Add remove debounce key sub-section ([#2724](https://github.com/taskforcesh/bullmq/issues/2724)) ([`b8d8886`](https://github.com/taskforcesh/bullmq/commit/b8d8886999dca42165c83ae1951edd293e8187dd))

### Performance
* **fifo-queue:** Use linked list structure for queue ([#2629](https://github.com/taskforcesh/bullmq/issues/2629)) ([`df74578`](https://github.com/taskforcesh/bullmq/commit/df7457844a769e5644eb11d31d1a05a9d5b4e084))

## v2.9.2 (2024-08-10)
### Fix
* **flow:** Validate parentData before ignoreDependencyOnFailure when stalled check happens (#2702) (python) ([`9416501`](https://github.com/taskforcesh/bullmq/commit/9416501551b1ad464e59bdba1045a5a9955e2ea4))
Expand Down
4 changes: 4 additions & 0 deletions docs/gitbook/python/introduction.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,3 +75,7 @@ async def main():
if __name__ == "__main__":
asyncio.run(main())
```

{% hint style="warning" %}
If Redis responses are in binary format, you should pass (decode_responses)[https://redis-py.readthedocs.io/en/latest/examples/connection_examples.html#By-default-Redis-return-binary-responses,-to-decode-them-use-decode_responses=True] option as *True*.
{% endhint %}
Loading

0 comments on commit 8eed71d

Please sign in to comment.