-
-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Labels
Description
Feature Request
Description
Implement the coordinator loop that calculates due fire times and dispatches work safely across multiple nodes.
Use Case
Guarantees each scheduled tick enqueues once even when multiple Ruby processes are running.
Proposed Solution
- Add
RailsCrons.start!to spawn a loop thread usingtick_interval. - Implement
RailsCrons.stop!and graceful shutdown onTERM/INT. - On each tick:
- For each registered cron, compute due fire times within
[now - window_lookback, now + window_lookahead]. - For each due time, try to obtain a distributed lease (see Lock Adapters). If acquired, dispatch.
- For each registered cron, compute due fire times within
- Expose
RailsCrons.tick!for manual single-tick execution (handy for tests/Rake tasks).
Alternatives Considered
Outsourcing to an external scheduler — rejected to keep the library self-contained yet agnostic to job systems.
Additional Context
The loop must be re-entrant and safe to call in tests; avoid global state that isn't resettable.
Checklist
- I have searched for a similar feature request and didn't find any duplicates.
- I have included all the required information.
- I have tagged the issue with the label "enhancement".
Metadata
Metadata
Assignees
Labels
Type
Projects
Status
Ready