occurrent
occurrent copied to clipboard
Implement "alarm clock" utility
An "alarm clock" would be a place to post stuff like "Notify me in 5 minutes that we need to escalate billing for this particular order". I.e. a message will be sent in 5 minutes and could be picked-up (by what)? "Order" in this case would contain all state needed to process the message.
A nice thing with this is that you can use the "alarm clock" for many use cases where you would normally need a (cron) job. For example, instead of a specific job that checks if an order has not been paid in payment 5 days, when the "alarm clock" can notify in 5 days instead.
Note that what we should persist to the AlarmClock is not commands or events, rather it should be a "Reminder". The alarm clock should then invoke a callback ((Reminder) -> Unit
) that let's one convert the Reminder into a "command".
Note that instead of writing something like this oneself, see https://github.com/johanhaleby/occurrent/issues/15. It would be good to have a utility such as "AlarmClock" or "Reminder" that wraps e.g. JobRunr and provides a level of indirection of dispatch and data.
Maybe call it Deadline instead?