-
Notifications
You must be signed in to change notification settings - Fork 37
Description
Description
Rage::Deferred currently supports enqueuing one-off tasks and delayed tasks, but there is no built-in way to run tasks on a recurring schedule. Today, users who need periodic jobs (e.g. cleaning up expired records, refreshing caches, syncing data) have to reach for external tools like cron or a separate scheduling library.
The goal of this issue is to add native periodic task scheduling to Rage::Deferred, keeping it consistent with Rage's philosophy of collapsing backend concerns into a single runtime.
Proposed interface
# config/application.rb or config/environments/<environment>.rb
Rage.configure do
config.deferred.schedule do
every 1.hour, task: CleanupExpiredInvites
every 1.minute, task: ResetCache
end
endWhere CleanupExpiredInvites and ResetCache are standard Rage::Deferred::Task classes with a perform method.
Design considerations
These are open questions that should be addressed in the design proposal:
- First run timing. After boot, should the first run happen immediately or wait for the first interval to elapse?
- Leader election in multi-process deployments. If Rage is running multiple worker processes, only one process should own the scheduling responsibility to avoid duplicate task execution. Also, consider what happens when the leader process restarts — do timers reset?
- Overlap policy. What happens if a scheduled task is still running when the next interval fires?
- Arguments. Should
everysupport passing arguments to the task'sperformmethod?
Before You Start
This issue requires a design proposal before implementation. Please open a discussion or comment on this issue with a high-level plan that outlines:
- The public API (confirming or adjusting the interface above).
- How scheduling will be implemented (timer mechanism, which process owns it).
- The leader election strategy for multi-process deployments.
- How the edge cases above (overlap, first run, restarts) will be handled.
PRs without prior design discussion are unlikely to be accepted.
Tips
- Check the Deferred docs to understand how
Rage::Deferredworks, especially the WAL and task execution model. - Look at how
Rage::Cableselects a process to manage Redis subscriptions in multi-server setups. - Check the architecture doc that shows how Rage's core components interact with each other and outlines the design principles.
- Feel free to ask any questions or request help in the comments below!