Skip to content

Commit 010ac5e

Browse files
committed
feat(core): enhance scheduling capabilities with new frequency management
- Introduced ScheduleFrequency class to manage cron expressions and scheduling intervals. - Updated Schedule class to utilize ScheduleFrequency for defining scheduling options. - Enhanced scheduling methods to support more granular timing options, including hourly, daily, and custom intervals. - Removed deprecated ScheduleRun class to streamline scheduling logic. - Added support for pinging URLs before and after scheduled tasks, along with success and failure callbacks. - Improved error handling and logging within the scheduling process.
1 parent ae4c2d3 commit 010ac5e

File tree

6 files changed

+962
-208
lines changed

6 files changed

+962
-208
lines changed

integrations/sample-app/app/boot/sp/app.ts

Lines changed: 33 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -42,25 +42,48 @@ export class AppServiceProvider extends ServiceProvider {
4242
/**
4343
* Schedule Intent Command to run daily.
4444
*/
45-
Schedule.command('send:email').daily();
45+
Schedule.command('send:email')
46+
// .days([Schedule.MONDAY, Schedule.THURSDAY])
47+
.hourly()
48+
.timezone('America/Chicago')
49+
.between('8:00', '17:00')
50+
.run();
4651

4752
/**
4853
* Simple callback, with lifecycle methods `before` and `after`.
4954
*/
50-
Schedule.call(() => console.log('inside the schedule method'))
55+
Schedule.call(() => {
56+
console.log('inside the schedule method');
57+
})
5158
.purpose('sample scheduler')
5259
.before(() => console.log('this will run before the cron'))
53-
.after(() => console.log('this will run after the cron'))
54-
.everyFiveSeconds();
60+
.after((output: any) =>
61+
console.log('this will run after the cron', output),
62+
)
63+
.onSuccess((result) =>
64+
console.log('this will run on success the cron', result),
65+
)
66+
.onFailure((error) =>
67+
console.log('this will run on failure the cron', error),
68+
)
69+
// .pingBefore('https://webhook.site/79dcb789-869b-459d-9ba9-638aae449328')
70+
.thenPing('https://webhook.site/79dcb789-869b-459d-9ba9-638aae449328')
71+
.weekends()
72+
.everyTwoSeconds()
73+
.when(() => true)
74+
75+
.run();
5576

5677
/**
5778
* Running a job every day at 5AM.
5879
*/
59-
Schedule.job({
60-
job: 'process_abandoned_cart',
61-
data: { from: '2024-04-16', to: '2024-04-17' },
62-
})
63-
.purpose('cron dispatching job every day at 5AM')
64-
.at('5 AM');
80+
// Schedule.job({
81+
// job: 'process_abandoned_cart',
82+
// data: { from: '2024-04-16', to: '2024-04-17' },
83+
// })
84+
// .purpose('cron dispatching job every day at 5AM')
85+
// .everyFiveSeconds()
86+
// .weekends()
87+
// .run();
6588
}
6689
}

0 commit comments

Comments
 (0)