diff --git a/gitbook/SUMMARY.md b/gitbook/SUMMARY.md index ef44eb5..6369cff 100644 --- a/gitbook/SUMMARY.md +++ b/gitbook/SUMMARY.md @@ -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) diff --git a/gitbook/docs/managing-job-processor/start.md b/gitbook/docs/managing-job-processor/start.md index d184699..0723189 100644 --- a/gitbook/docs/managing-job-processor/start.md +++ b/gitbook/docs/managing-job-processor/start.md @@ -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 }); ``` @@ -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. diff --git a/gitbook/docs/managing-jobs/manually-working/repeatevery.md b/gitbook/docs/managing-jobs/manually-working/repeatevery.md new file mode 100644 index 0000000..5d7aadd --- /dev/null +++ b/gitbook/docs/managing-jobs/manually-working/repeatevery.md @@ -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. + +\ + + + +