Skip to content

Commit

Permalink
GITBOOK-22: No subject
Browse files Browse the repository at this point in the history
  • Loading branch information
code-xhyun authored and gitbook-bot committed May 4, 2024
1 parent 134127d commit e0a1e8c
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 6 deletions.
1 change: 1 addition & 0 deletions gitbook/SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,4 @@
* [Manually working](docs/managing-jobs/manually-working/README.md)
* [Save](docs/managing-jobs/manually-working/save.md)
* [Unique](docs/managing-jobs/manually-working/unique.md)
* [RepeatEvery](docs/managing-jobs/manually-working/repeatevery.md)
11 changes: 5 additions & 6 deletions gitbook/docs/managing-job-processor/start.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,11 @@ The `start` method activates the job queue, beginning the regular processing of
```typescript
const pulse = new Pulse();

// Example of canceling all jobs with a specific priority
const query = { priority: { $lt: 0 } }; // Cancels all jobs with a negative priority
pulse.processEvery(100);

pulse.cancel(query)
.then(deletedCount => console.log(`${deletedCount} low priority jobs cancelled`))
.catch(error => console.error('Failed to cancel jobs:', error));
pulse.start(); // It should be in this position See NOTES section at the page

pulse.every('1 day', 'dailyReport', { reportId: 123 });
```


Expand All @@ -32,6 +31,6 @@ pulse.cancel(query)

### Notes

* **Pre-requisite**: `start` must be called after `processEvery` is set and ideally before scheduling any jobs with methods like `every` or `schedule`.
* **Pre-requisite**: `start` must be called after [config method](../setup-and-config/config/)(e.g. `processEvery)` is set and ideally before scheduling any jobs with methods like `every` or `schedule`.
* **Idempotence**: If `start` is called multiple times, subsequent calls will recognize that processing has already been initiated and will not create additional intervals.

41 changes: 41 additions & 0 deletions gitbook/docs/managing-jobs/manually-working/repeatevery.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# RepeatEvery



## `job.repeatEvery(interval, options?)`

{% hint style="info" %}
The `repeatEvery` method schedules a job to repeat at a defined interval. It includes options to specify starting and ending dates, skip specific days, and adjust for time zones, providing flexibility in how and when the job recurs.
{% endhint %}

### Example Usage

{% code fullWidth="false" %}
```typescript
job.unique({ 'data.type': 'email', 'data.userId': '12345' });
await job.save(); // If you want to save it
```
{% endcode %}

### Parameters

* **`interval`** (`string`): A human-readable string that specifies how often the job should run, such as `'5 minutes'`, `'2 hours'`, `'1 day'`.
* **`options`** (`JobOptions` - optional): Additional settings to further configure the repeating job:
* **`timezone`** (`string` - optional): The timezone in which to base the job's timing.
* **`startDate`** (`Date | number` - optional): A specific start date or timestamp from which the job should start repeating.
* **`endDate`** (`Date | number` - optional): A specific end date or timestamp after which the job should no longer repeat.
* **`skipDays`** (`string` - optional): A string representing days to skip, useful for setting jobs to run only on specific days of the week.
* **`skipImmediate`** (`boolean` - optional): If `true`, skips the immediate first execution of the job schedule.

\


### Returns

* **`Job`**: Returns the job instance, allowing for method chaining.

\




0 comments on commit e0a1e8c

Please sign in to comment.