From 3dc13d107c81519ee9ceab1f8d6d2a614b005384 Mon Sep 17 00:00:00 2001 From: Rogger Valverde Date: Thu, 5 Sep 2024 21:59:45 -0600 Subject: [PATCH] docs(bullmq-pro): add get group rate limit ttl section (#2761) --- README.md | 1 + docs/gitbook/bullmq-pro/changelog.md | 24 +++++++++++++++++++ .../bullmq-pro/groups/rate-limiting.md | 21 ++++++++++++++++ docs/gitbook/patterns/timeout-jobs.md | 3 --- tests/test_worker.ts | 13 ++++++++-- 5 files changed, 57 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 9e718318aa..a516c73ffd 100644 --- a/README.md +++ b/README.md @@ -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 | ✓ | ✓ | ✓ | ✓ | | ✓ | diff --git a/docs/gitbook/bullmq-pro/changelog.md b/docs/gitbook/bullmq-pro/changelog.md index 050406d4af..4479c8f36b 100644 --- a/docs/gitbook/bullmq-pro/changelog.md +++ b/docs/gitbook/bullmq-pro/changelog.md @@ -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) diff --git a/docs/gitbook/bullmq-pro/groups/rate-limiting.md b/docs/gitbook/bullmq-pro/groups/rate-limiting.md index f541972e54..a275c61136 100644 --- a/docs/gitbook/bullmq-pro/groups/rate-limiting.md +++ b/docs/gitbook/bullmq-pro/groups/rate-limiting.md @@ -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) diff --git a/docs/gitbook/patterns/timeout-jobs.md b/docs/gitbook/patterns/timeout-jobs.md index a70bc9845d..030a95e7e5 100644 --- a/docs/gitbook/patterns/timeout-jobs.md +++ b/docs/gitbook/patterns/timeout-jobs.md @@ -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. - - - diff --git a/tests/test_worker.ts b/tests/test_worker.ts index 34cd191905..ac2ac25134 100644 --- a/tests/test_worker.ts +++ b/tests/test_worker.ts @@ -585,8 +585,17 @@ describe('workers', function () { { connection, prefix }, ); - worker.on('completed', async () => { - await anotherWorker.close(); + await anotherWorker.waitUntilReady(); + + await new Promise((resolve, reject) => { + worker.once('completed', async () => { + try { + await anotherWorker.close(); + resolve(); + } catch (err) { + reject(err); + } + }); }); await worker.close();