coravel
coravel copied to clipboard
Allow for more dynamic scheduling
I have a setup, where I get an interval for running a cleanup job from my AppSettings, e.g. 2 for running every two hours.
There is a function for scheduling EverySeconds, that takes an int between 0 and 59. But I do not have a similar function for EveryHours or EveryMinutes which limits me. It would be great to have these functions or alternatively -and maybe even better - It would be nice to have a function that alows to schedule more dynamically, e..g.
.Every(3, Hours)
To schedule for EveryMinutes just use EverySeconds and multiple by 60. For hours just multiply by 3600. Seems simple enough to add your own extension method that does this for you if you need it to be "visually cleaner", but as far as functionality you can do what you need with EverySecond().
You can technically try this using the CRON method. That's how I've done it - works well. What do you think @kajbonfils ?
@falvarez1 I get System.ArgumentException: 'When calling 'EverySeconds(int seconds)', 'seconds' must be between 0 and 60' when calling EverySeconds with e.g. 3600.
@jamesmh I suppose that will work. I will give it a try. Still could be nice with an extension method as CRON syntax is jiberish to most people.
You can technically try this using the CRON method. That's how I've done it - works well. What do you think @kajbonfils ?
if there was some API for manage the Invocables. thats will be better ?
like:
API | For Use |
---|---|
Add | for dynamic add job to Scheduler not Run |
AddRun | for dynamic add job to Scheduler and Run immediately |
AddDelayRun | for dynamic add job to Scheduler and Delay Run |
Run/Pause | Run immediately/Pause:Stop Scheduler temporary until Call Run or Next Host Startup |
Enable/Disbale | Disbale : stop Scheduler from now until call Enable |
Delete | delete job from Scheduler |
GetAllJobs | return all jobs from Scheduler |
GetSchedule | return Schedule plan |
ChangeSchedule | change Schedule plan immediately for next time |
ChangeScheduleDelay | change Schedule plan Delay for next time |
ForceStop | Force stop the running job(if the job is running) |
This is still an issue here - the lack of EveryMinutes() and EveryHours() is limiting.