Description:
Our app manages scheduling, and we're migrating some workloads to River, including updating rotations (e.g., advancing to the next person at a set time) which we're looking to leverage the ScheduledAt option. In app, everything is based on the now() value to avoid clock-drift issues. In our behavioral tests, we currently manipulate PostgreSQL's now() function (via proxying) to control time, but we’ve noticed that scheduled jobs don’t run when DB time advances. Looking deeper, it appears River’s scheduling relies on system time instead of database time.
Feature Request:
Would it be possible to expose a way to control time? The river.Config has a time property that takes a baseservice.TimeGenerator—would making it public (e.g., Time) be enough? This would help with:
- Testing: Simulating different time scenarios without modifying system time.
- Production: Keeping
ScheduledAt jobs aligned with database time to mitigate clock drift issues.
Potential Approaches:
- Make
Time Public: Allowing a custom time source to be set.
- Sync to DB Time: Providing an option for River to rely on PostgreSQL's
now().
Benefits:
- More reliable scheduling in both tests and production.
- Prevents early job execution due to clock drift.
- Simplifies simulating past and future time scenarios in tests.
I would love to hear your thoughts on this; thanks for considering it!
Description:
Our app manages scheduling, and we're migrating some workloads to River, including updating rotations (e.g., advancing to the next person at a set time) which we're looking to leverage the
ScheduledAtoption. In app, everything is based on thenow()value to avoid clock-drift issues. In our behavioral tests, we currently manipulate PostgreSQL'snow()function (via proxying) to control time, but we’ve noticed that scheduled jobs don’t run when DB time advances. Looking deeper, it appears River’s scheduling relies on system time instead of database time.Feature Request:
Would it be possible to expose a way to control time? The
river.Confighas atimeproperty that takes abaseservice.TimeGenerator—would making it public (e.g.,Time) be enough? This would help with:ScheduledAtjobs aligned with database time to mitigate clock drift issues.Potential Approaches:
TimePublic: Allowing a custom time source to be set.now().Benefits:
I would love to hear your thoughts on this; thanks for considering it!