-
-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(every): adding every N minutes or hours #31
base: main
Are you sure you want to change the base?
feat(every): adding every N minutes or hours #31
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Two things
- This should be two functions, one for minutes and one for hours
- The function promises something it can't deliver ie generate an event every so many minutes. This only works for factors of 60 or 24 depending on value.
Perhaps you should have an enum for the factors eg
enum MinuteFactor: Int {
case two = 2
case three = 3
case four = 4
case five = 5
case six = 6
case ten = 10
case twelve = 12
case quarterHour = 15
case twenty = 20
case halfHour = 30
}
func everyMinute(_ minute: MinuteFactor)
And something similar for hours. For the hours you could also add a start time eg
func everyHour(_ hour: HourFactor, startingHour: Int, minute: Int)
I need to re-think this PR a little bit. There's currently func called everyMinute which takes seconds, but does not work with fractions i.e everyMinute(second: 300) which would translate into every 5 minutes starting at 0-5-10-15-20...55 Would it be easier to expose a func that takes in a cron syntax and computes the schedule? |
The seconds parameter in
We don't support the full crontab syntax eg we don't support |
Understood, I thought of writing a Cron parser and expose mundane syntax such as @daily
@weekly
@monthly
@yearly
@minute and finally * 4 * * *
5 * * * *
* * * * * What do you think? |
This PR adds the followings:
Run a job every 5 minutes or 15, 30, 45 and so forth. Please note that all minutes or hours always start at 0
The same is true for every N hour