-
Notifications
You must be signed in to change notification settings - Fork 53
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: Implement a generic task scheduler #653
feat: Implement a generic task scheduler #653
Conversation
9035771
to
74d2060
Compare
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.
Next stop: Implement craft timers
|
||
public override long NextTimestamp() | ||
{ | ||
return new DateTimeOffset(DateTime.Now.AddHours(1)).ToUnixTimeSeconds(); |
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.
I think I might need to be more careful with this. A long running server, this hour reset will eventually time drift. I might need to be more explicit and make it move to the next hour on the exact amount.
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.
Be careful with that, not in the hourly task, but in the daily/weekly ones, as hour changes such as daylight savings means that the time different wont be the exact same
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.
According to the MSDN, if we use DateTime
using Now
, it will account for DST based on that machines settings (needs automatic DST enabled on that machine). Will need to look and see how that can be utilized for future dates.
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.
Japan doesn't do DST, so there's an argument that not respecting it is part of the original vision. :^)
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 one is also interesting as it can be interpreted two ways. Does this mean "I always want to trigger this on the hour" or "I always want to trigger this after 60 minutes passes".
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.
With hours we're not going to have problems if we use AddHour or we add to the unix timestamp 60 * 60 * 1000. The problem is the daily task, which with DST it would be not 24 hours but 23/25 hours
de460c9
to
22b5634
Compare
22b5634
to
125f593
Compare
Implemented a light weight mechanism for scheduling recurring tasks. This can be used to implement, hourly, daily or weekly resets. There is also an intention to use the mechanism to check for seasonal events and turn on/off depending on the date.
- Treat the lowest server id as the head server. - Head server runs the timer task - When timer task fires, if individual channel actions are required, use the RPC manager to send an internal message. - Update the EpitaphWeeklyReward task to send a message to all channels. - Update migration values
- Move current hourly task implementation to NextTimeAmountTask - Implemented a new hourly task which occurs wgen transitioning from x:59 to y:00.
125f593
to
ccb4ebd
Compare
Enabled weekly reset as the default setting.
Implemented a light weight mechanism for scheduling recurring tasks. This can be used to implement, hourly, daily or weekly resets. There is also an intention to use the mechanism to check for seasonal events and turn on/off depending on the date.
Added example of a weekly reset for Epitaph Weekly rewards.
Checklist:
develop
branch