#task-scheduling #tokio #task #async #scheduler

easy-schedule

A flexible task scheduler built on Tokio with multiple scheduling options and skip conditions

6 releases

Uses new Rust 2024

new 0.2.2 Apr 6, 2025
0.2.1 Apr 6, 2025
0.1.2 Apr 6, 2025

#765 in Asynchronous

Download history 578/week @ 2025-04-01

578 downloads per month

MIT license

15KB
291 lines

Easy Schedule

Crates.io License

A flexible task scheduler built on Tokio with multiple scheduling options and skip conditions.

Features

  • Multiple scheduling types:
    • Delayed execution
    • Interval execution
    • Scheduled execution
    • One-time execution
  • Flexible skip conditions:
    • Skip specific dates
    • Skip date ranges
    • Skip weekdays
    • Skip specific times
    • Skip time ranges
  • Task cancellation support
  • Comprehensive logging

Quick Start

Add to your Cargo.toml:

[dependencies]
easy-schedule = "0.1"

Usage Example

use easy_schedule::{Scheduler, Task, Skip};
use std::sync::Arc;
use time::Time;

#[derive(Debug)]
struct MyTask;

impl ScheduledTask for MyTask {
    fn get_schedule(&self) -> Task {
        Task::At(Time::try_from_hms(12, 0, 0).unwrap(), None)
    }

    fn on_time(&self) {
        println!("Task executed at noon");
    }

    fn on_skip(&self) {
        println!("Task skipped");
    }
}

#[tokio::main]
async fn main() {
    let scheduler = Scheduler::new();
    scheduler.add_task(Arc::new(Box::new(MyTask))).await;
    scheduler.start().await;
}

License

Dual-licensed under MIT or Apache-2.0.

Dependencies

~4–11MB
~90K SLoC