Skip to content

Commit

Permalink
docs(repeatable): add example when removing repeatable jobs (#2257)
Browse files Browse the repository at this point in the history
  • Loading branch information
roggervalf authored Nov 1, 2023
1 parent 07855ad commit bc2d980
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
14 changes: 14 additions & 0 deletions docs/gitbook/guide/jobs/repeatable.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,20 @@ There are some important considerations regarding repeatable jobs:
- If there are no workers running, repeatable jobs will not accumulate next time a worker is online.
- repeatable jobs can be removed using the [removeRepeatable](https://api.docs.bullmq.io/classes/v4.Queue.html#removeRepeatable) method or [removeRepeatableByKey](https://api.docs.bullmq.io/classes/v4.Queue.html#removeRepeatableByKey).

```typescript
import { Queue } from 'bullmq';

const repeat = { pattern: '*/1 * * * * *' };

const myQueue = new Queue('Paint');

const job1 = await myQueue.add('red', { foo: 'bar' }, { repeat });
const job2 = await myQueue.add('blue', { foo: 'baz' }, { repeat });

const isRemoved1 = await myQueue.removeRepeatableByKey(job1.repeatJobKey);
const isRemoved2 = await queue.removeRepeatable('blue', repeat);
```

All repeatable jobs have a repeatable job key that holds some metadata of the repeatable job itself. It is possible to retrieve all the current repeatable jobs in the queue calling [getRepeatableJobs](https://api.docs.bullmq.io/classes/v4.Queue.html#getRepeatableJobs):

```typescript
Expand Down
4 changes: 2 additions & 2 deletions src/classes/queue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ export class Queue<
*
* @see removeRepeatableByKey
*
* @param name -
* @param name - job name
* @param repeatOpts -
* @param jobId -
* @returns
Expand All @@ -337,7 +337,7 @@ export class Queue<
*
* @see getRepeatableJobs
*
* @param key - to the repeatable job.
* @param repeatJobKey - to the repeatable job.
* @returns
*/
async removeRepeatableByKey(key: string): Promise<boolean> {
Expand Down

0 comments on commit bc2d980

Please sign in to comment.