Skip to content

Commit

Permalink
docs(bullmq-pro): add get group rate limit ttl section (#2761)
Browse files Browse the repository at this point in the history
  • Loading branch information
roggervalf authored Sep 6, 2024
1 parent 056b90d commit 3dc13d1
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 5 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -228,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
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)
3 changes: 0 additions & 3 deletions docs/gitbook/patterns/timeout-jobs.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,3 @@ const worker = new Worker("foo", async (job) => {
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.



13 changes: 11 additions & 2 deletions tests/test_worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -585,8 +585,17 @@ describe('workers', function () {
{ connection, prefix },
);

worker.on('completed', async () => {
await anotherWorker.close();
await anotherWorker.waitUntilReady();

await new Promise<void>((resolve, reject) => {
worker.once('completed', async () => {
try {
await anotherWorker.close();
resolve();
} catch (err) {
reject(err);
}
});
});

await worker.close();
Expand Down

0 comments on commit 3dc13d1

Please sign in to comment.