Skip to content

Commit

Permalink
docs(guide): add description for moveToWait method
Browse files Browse the repository at this point in the history
  • Loading branch information
roggervalf committed Dec 31, 2024
1 parent 69b0980 commit 09383d9
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions docs/gitbook/patterns/manually-fetching-jobs.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,3 +96,24 @@ while (1) {
}
}
```

## Rate Limiting

If you want to move a job back to wait because your queue is rate limited.

```typescript
const worker = new Worker('my-queue', null, { connection, prefix });
const token = 'my-token';
await Job.create(queue, 'test', { foo: 'bar' });
const job = (await worker.getNextJob(token)) as Job;

await queue.rateLimit(60000);
await job.moveToWait(token);
```

## Read more:

- 💡 [Get Next Job API Reference](https://api.docs.bullmq.io/classes/v5.Worker.html#getNextJob)
- 💡 [Move To Completed API Reference](https://api.docs.bullmq.io/classes/v5.Job.html#moveToCompleted)
- 💡 [Move To Failed API Reference](https://api.docs.bullmq.io/classes/v5.Job.html#moveToFailed)
- 💡 [Move To Wait API Reference](https://api.docs.bullmq.io/classes/v5.Job.html#moveToWait)

0 comments on commit 09383d9

Please sign in to comment.