-
-
Notifications
You must be signed in to change notification settings - Fork 314
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
refact: rewriting scheduler logic #54
Conversation
@@ -306,23 +365,6 @@ func (s *Scheduler) Do(jobFun interface{}, params ...interface{}) (*Job, error) | |||
} | |||
} | |||
|
|||
if !j.startsImmediately { | |||
|
|||
if j.lastRun == s.time.Unix(0, 0) { |
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.
this was a workaround that had impact on the job scheduling logic and got removed
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.
Have looked at the code so far. Haven't seen the tests yet.
Co-authored-by: John Roesler <[email protected]>
…x/weekdays_scheduling
@arjunmahishi @JohnRoesler cleaned up tests and fixed monthly issues, good to go now :-) there are tests missing (startImmediately reschedule etc) but we didn't have a strong test suite for these before anyway, so what do you think about leaving these tests for a future PR? Our schedule method is now much more assertive, intelligent and readable IMO. Download the branch and let me know what you think. |
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.
LGTM
What does this do?
Time scheduling was spread between job registration and actual schedule calculation, which was confusing and made testing difficult. As a matter of fact, our weekdays logic wasn't working for some edge cases and we probably had some bugs out on .Month() calculation too, although I didn't check it explicitly.
This PR rewrites our next-run scheduling logic and cover it with different tests use cases, taking in consideration weekday schedules, weekdays schedules starting immediately and exact-time schedules.
Sorry for it being big. Most of the new lines are tests cases.
Which issue(s) does this PR fix/relate to?
This might fix #52. I cannot actually say this fixes it since I was not able to reproduce it, but nevertheless this PR fixes weekday logic.
List any changes that modify/break current functionality
None
Have you included tests for your changes?
Lots of, but might have missed something. Please bring it up if you can think of anything.