Skip to content

Commit 2e54f40

Browse files
committed
chore: wip
1 parent d7f794f commit 2e54f40

File tree

3 files changed

+20
-5
lines changed

3 files changed

+20
-5
lines changed

app/Jobs/ExampleJob.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,8 @@ import { Every } from '@stacksjs/types'
33
import { log } from '@stacksjs/cli'
44

55
export default new Job({
6-
name: 'Send Welcome Email', // optional, defaults to the file name
6+
name: 'Example Job', // optional, defaults to the file name
77
description: 'A demo cron job that runs every minute', // optional
8-
queue: 'default', // optional, defaults to 'default'
98
tries: 3, // optional, defaults to 3, in case of failures
109
backoff: 3, // optional, defaults to 3-second delays between retries
1110
rate: Every.Minute, // optional, '* * * * *' in cron syntax (overwrites the Scheduler's definition)

app/Jobs/ExampleJobTwo.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import { Job } from '@stacksjs/queue'
2+
import { Every } from '@stacksjs/types'
3+
import { log } from '@stacksjs/cli'
4+
5+
export default new Job({
6+
rate: Every.TwoMinutes, // optional, '* * * * *' in cron syntax (overwrites the Scheduler's definition)
7+
handle: () => { // action: 'SendWelcomeEmail', // instead of handle, you may target an action or `action: () => {`
8+
log.info('This cron job log this message every two minutes')
9+
log.info('Please note, any job may also be dispatched individually, or scheduled via ./app/Schedule')
10+
},
11+
})

storage/framework/core/types/src/cron-jobs.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,17 @@ export enum Every {
3535
// TenSeconds = '*/10 * * * * *',
3636
// ThirtySeconds = '*/30 * * * * *',
3737
Minute = '* * * * *',
38+
TwoMinutes = '*/2 * * * *',
39+
FiveMinutes = '*/5 * * * *',
40+
TenMinutes = '*/10 * * * *',
41+
FifteenMinutes = '*/15 * * * *',
42+
ThirtyMinutes = '*/30 * * * *',
3843
Hour = '0 * * * *',
3944
HalfHour = '0,30 * * * *',
4045
Day = '0 0 * * *',
41-
Month = '0 0 1 * *',
4246
Week = '0 0 * * 0',
47+
Weekday = '0 0 * * 1-5',
48+
Weekend = '0 0 * * 0,6',
49+
Month = '0 0 1 * *',
4350
Year = '0 0 1 1 *',
44-
FifthMinute = '*/5 * * * *',
45-
TenthMinute = '*/10 * * * *',
4651
}

0 commit comments

Comments
 (0)