Skip to main content

Module scheduler

Module scheduler 

Source
Expand description

Background task scheduler — a @Scheduled-style runner for fixed-rate, fixed-delay, and cron-expression tasks.

§Example

use std::time::Duration;
use rust_web_server::scheduler::Scheduler;

Scheduler::new()
    // Runs every 60 s (interval measured from task start).
    .every(Duration::from_secs(60), || println!("tick"))
    // Waits 30 s after each run completes before starting the next.
    .after(Duration::from_secs(30), || println!("heartbeat"))
    // Fires at second 0 of every minute.
    .cron("0 * * * * *", || println!("every minute")).unwrap()
    // 10 s pause before the first run of the most recently added task.
    .initial_delay(Duration::from_secs(10))
    .start();

Re-exports§

pub use cron::CronSchedule;

Modules§

cron

Structs§

Scheduler
A @Scheduled-style background task runner.