pub struct ScheduleTicker { /* private fields */ }Expand description
Periodic task that fires DB-persisted schedules.
§Examples
use std::sync::Arc;
use std::time::Duration;
use ironflow_api::schedule_ticker::ScheduleTicker;
use ironflow_api::schedule_sync::sync_handler_schedules;
use ironflow_engine::engine::Engine;
use ironflow_core::providers::claude::ClaudeCodeProvider;
use ironflow_store::memory::InMemoryStore;
use ironflow_store::store::Store;
use tokio_util::sync::CancellationToken;
let store: Arc<dyn Store> = Arc::new(InMemoryStore::new());
let engine = Arc::new(Engine::new(store.clone(), Arc::new(ClaudeCodeProvider::new())));
sync_handler_schedules(&engine, store.as_ref()).await?;
let ticker = ScheduleTicker::new(store)
.engine(engine)
.interval(Duration::from_secs(10));
tokio::spawn(ticker.run(CancellationToken::new()));Implementations§
Source§impl ScheduleTicker
impl ScheduleTicker
Sourcepub fn engine(self, engine: Arc<Engine>) -> Self
pub fn engine(self, engine: Arc<Engine>) -> Self
Publish Event::ScheduleOccurrencesMissed through this engine’s
event publisher whenever a schedule drops occurrences.
Without an engine, missed occurrences are only logged and counted.
Sourcepub async fn run(self, shutdown: CancellationToken)
pub async fn run(self, shutdown: CancellationToken)
Run the tick loop until shutdown is cancelled.
Store errors are logged per-schedule; the loop keeps going.
Sourcepub async fn tick(&self)
pub async fn tick(&self)
Fire every due schedule once.
The schedule’s catch-up policy decides which of its missed occurrences
run; all of them are fired atomically: a schedule whose firing fails
stays due and is retried on the next tick. A schedule whose next
occurrence cannot be computed fires its due run, then is disabled with
the reason in last_error.
Exposed for tests and for callers that drive the tick themselves.
Auto Trait Implementations§
impl !RefUnwindSafe for ScheduleTicker
impl !UnwindSafe for ScheduleTicker
impl Freeze for ScheduleTicker
impl Send for ScheduleTicker
impl Sync for ScheduleTicker
impl Unpin for ScheduleTicker
impl UnsafeUnpin for ScheduleTicker
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more