Easy Schedule
A flexible and powerful task scheduler built on Tokio, providing multiple scheduling options with advanced skip conditions and timezone support.
โจ Features
๐ Multiple Scheduling Types
- Wait - Execute once after a delay
- Interval - Execute repeatedly at fixed intervals
- At - Execute daily at specific times
- Once - Execute at an exact datetime
๐ซ Flexible Skip Conditions
- Date-based: Skip specific dates or date ranges
- Weekday-based: Skip specific weekdays or weekday ranges
- Time-based: Skip specific times or time ranges (including overnight ranges)
- Combinable: Use multiple skip rules together
๐ Advanced Features
- Timezone Support - Full timezone support with minute-level precision
- String Parsing - Create tasks from intuitive strings like
wait(5),at(14:30) - Cancellation - Comprehensive task cancellation support
- Next Run Time - Query when tasks will next execute
- Error Handling - Robust error handling with sensible defaults
- Async/Await - Full async support with Tokio integration
๐ Quick Start
Add to your Cargo.toml:
[]
= "0.11"
= { = "1", = ["full"] }
= { = "0.3", = ["macros"] }
๐ Usage
Basic Setup
use *;
use ;
async
Task Types
use *;
use ;
// Wait 30 seconds then execute once
let wait_task = Wait;
let scheduler = new;
// Execute every 60 seconds
let interval_task = Interval;
let scheduler = new;
// Execute daily at 9:00 AM
let at_task = At;
let scheduler = new;
// Execute once at specific datetime
let future = now_utc + minutes;
let once_task = Once;
let scheduler = new;
Skip Conditions
use *;
use time;
let skip_rules = vec!;
let task = Interval; // Every hour, with skips
let scheduler = new;
Next Run Time
use *;
let task = Interval;
let scheduler = new;
// Create a test task that implements Notifiable
;
let test_task = TestTask;
if let Some = scheduler.get_next_run_time else
Timezone Support
use *;
// Different timezone configurations
let utc_scheduler = with_timezone; // UTC
let tokyo_scheduler = with_timezone; // JST
let india_scheduler = with_timezone; // IST
// Or use minute offsets directly
let custom_scheduler = with_timezone_minutes; // UTC+5:30
๐ Task Types Reference
| Type | Description | Example |
|---|---|---|
Wait(seconds, skip) |
Execute once after delay | Task::Wait(30, None) |
Interval(seconds, skip) |
Execute repeatedly | Task::Interval(60, None) |
At(time, skip) |
Execute daily at time | Task::At(time!(14:30), None) |
Once(datetime, skip) |
Execute at exact datetime | Task::Once(datetime, None) |
๐ซ Skip Rules Reference
| Skip Type | Description | Example |
|---|---|---|
Date(date) |
Skip specific date | Skip::Date(date!(2024-12-25)) |
DateRange(start, end) |
Skip date range | Skip::DateRange(start, end) |
Day(weekdays) |
Skip weekdays (1=Mon, 7=Sun) | Skip::Day(vec![6, 7]) |
DayRange(start, end) |
Skip weekday range | Skip::DayRange(1, 5) |
Time(time) |
Skip specific time | Skip::Time(time!(12:00)) |
TimeRange(start, end) |
Skip time range | Skip::TimeRange(time!(22:00), time!(06:00)) |
๐ ๏ธ Advanced Usage
Custom Cancellation Logic
Multiple Skip Conditions
let complex_skips = vec!;
let task = Interval; // Every 30 minutes with conditions
๐งช Testing
Run the comprehensive test suite:
๐ License
- Apache License, Version 2.0, (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)