Skip to content

Commit

Permalink
GITBOOK-199: change request with no subject merged in GitBook
Browse files Browse the repository at this point in the history
  • Loading branch information
manast authored and gitbook-bot committed Sep 2, 2024
1 parent 19f7490 commit c9373dd
Showing 1 changed file with 25 additions and 9 deletions.
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 withinthe 10 seconds it will not be affected by this change.

### Read more:

Expand Down

0 comments on commit c9373dd

Please sign in to comment.