shifted
ModuleUndocumented.
Contents
use utopia_schedule::Shifted;Rust
pub struct Shifted<T>Another trigger, every occurrence moved by a fixed number of seconds.
A fleet of schedules sharing an expression shares its due second, so
* * * * * across three thousand rows is three thousand dispatches at
:00 and nothing for the rest of the minute. Give each row an offset
derived from its id and the burst spreads across the minute while every
row keeps its slot across deploys.
The shift belongs to the schedule rather than to delivery, so an
occurrence's due is the moment it runs: the window that covers it
covers the shifted time and the watermark commits the shifted time. The
window is shifted back and the results forward, so occurrences still land
in exactly one window.
Rust
use php_std::datetime::{DateTime, Timestamp, TzInfo};
use utopia_schedule::{Cron, Shifted, Trigger};
let at = |s: &str| DateTime::parse(s.as_bytes(), None, &TzInfo::utc(), Timestamp { sec: 0, usec: 0 }).unwrap();
let spread = Shifted::new(Cron::new("*/15 * * * *")?, 40);
let due = spread.occurrences_between(&at("2026-08-18 03:00:00"), &at("2026-08-18 03:16:00"));
let due: Vec<_> = due.iter().map(|d| String::from_utf8(d.format(b"H:i:s")).unwrap()).collect();
assert_eq!(due, ["03:00:40", "03:15:40"]);