[Scheduler] Event scheduler implementation#1257
Merged
Conversation
mackal
reviewed
Feb 19, 2021
mackal
reviewed
Feb 19, 2021
mackal
reviewed
Feb 19, 2021
hgtw
reviewed
Feb 19, 2021
hgtw
reviewed
Feb 19, 2021
Contributor
Author
|
House build will be complete in 2 weeks; been a bit tied up but will get this one merged up soon after coming back to this one and making sure things are buttoned up |
649687d to
8cc78d1
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR is in draft and not final; will finalize database schema code changes after other merges
This initial implementation while fairly solid, is a first release and is easy to change for further use cases and needs down the line
This is something I've wanted for a long time as a server operator, but more specifically out of a now use case of PEQ having scheduled and rotated hot zones
Server Event Scheduler
The server has currently two process driven schedulers
Zone maintains state, world does not in the current implementation. For current every current zone event activation, there is an event deactivation event which undoes the state change.
World does not maintain state, it is used for single event triggers and supports cron expressions since the events can be kicked off on a routine basis
Event Loading
When world or zone boots, you will see the initial load of events. Zone will also reload if World has detected any changes to any of the scheduled events in the database once a minute
Event Changes
If new changes are made to the
server_scheduled_eventsstate table, world will pick it up every minute. If world detects that there are any data changes made to the table, it will notify all zone processes to reload their scheduled events. This makes it easy for server operators to add / modify events live while the server is onlineServer Scheduled Events Model
The database table model is represented as follows
Scheduling Methods
The way the scheduling schema works is by start end end times and vary slightly in triggering functionality depending on whether the event is stateless or stateful
Repeat Events (Stateless)
Stateless events can be triggered repeatedly such as a broadcast event by using a
cron_expression. You can also schedule a one time event by setting the start time and end time one minute apartRepeat Events (Stateful)
Events can start and end on intervals but you need to only use the unit of time (for example days) and let everything else be
0for columns. A0value will imply the current time when the scheduler ticsLet's take a hotzone rotation for example as shown in the table below. If I want to rotate 3 sets of hotzones within the month every month I can do it like this
Hotzone Group #1 starts on day 1 and ends on day 10
Hotzone Group #2 starts on day 10 and ends on day 20
Hotzone Group #3 starts on day 20 and ends on day 33 (Yes day 33 never happens but its an outer bounds)
This rotation will continue perpetually because of the wildcard mask-type declaration of the time data. Same thing could be achieved using different time formats, or different months
Example Schedule Data
Example of Content Flags being set for Halloween
Example of Rule Event Activation (Detail Logs)
When event deactivates
Example of Broadcasts Being sent from World
Both the cron expression event and regular event from the table above shown in the image below