Expand description
Cron scheduler for simulated recurring events
This module provides a cron-like scheduler that integrates with the virtual clock to support time-based recurring events. It works alongside the ResponseScheduler to handle complex recurring schedules while ResponseScheduler handles one-time and simple interval responses.
§Usage
use mockforge_core::time_travel::{CronScheduler, CronJob, CronJobAction};
use std::sync::Arc;
let scheduler = CronScheduler::new(clock.clone());
// Schedule a job that runs every day at 3am
let job = CronJob {
id: "daily-cleanup".to_string(),
name: "Daily Cleanup".to_string(),
schedule: "0 3 * * *".to_string(), // 3am every day
action: CronJobAction::Callback(Box::new(|_| {
println!("Running daily cleanup");
Ok(())
})),
enabled: true,
};
scheduler.add_job(job).await?;Structs§
- CronJob
- A cron job definition
- Cron
Scheduler - Cron scheduler that integrates with the virtual clock
- Schedule
Enums§
- Cron
JobAction - Action to execute when a cron job triggers