I want to design a system that performs certain actions at a predefined time in the future.
i.e. at 2pm on April 10th 2020, do X
I'm looking for patterns that would ensure that the intended action is triggered at the right time & only triggered once.
Ideally, I think it would be best if the action has no knowledge of the scheduling system, and that the scheduling system has little to no knowledge of the action.
Therefore, the action should be idempotent, and handle that itself, then we can, to a certain extent ignore the triggered only once
requirement.
The scheduler would run off a data store containing records like:
{
action: <some way to know the correct action to perform>
trigger_after: <timestamp>
triggered: <boolean>
}
Then the scheduler would run every N seconds (however accurate you need it to be)
Then we trigger any jobs that match where trigger_after < now() and triggered = False
Then we update the triggered
status when the actions have been dispatched.
What am I missing? What patterns are out there that perform something similar?