Crates.io | white_rabbit |
lib.rs | white_rabbit |
version | 0.1.1 |
source | src |
created_at | 2019-05-09 12:44:30.27526 |
updated_at | 2019-05-09 13:34:43.661431 |
description | Task scheduler, allowing timed execution, repeated or not. |
homepage | |
repository | https://github.com/lakelezz/white_rabbit.git |
max_upload_size | |
id | 133067 |
size | 21,243 |
by “The White Rabbit” 『Alice's Adventures in Wonderland』
white_rabbit
schedules your tasks and can repeat them!
One funny use case are chat bots, e.g. a remind me-command that might be repeated after a user-specified time.
We are using chrono's DateTime<Utc>
, enabling you to serialise and thus backup currently
running tasks, in case you want to shutdown/restart your application,
constructing a new scheduler is doable. However, please make sure your internal
clock is synced.
Everyone is welcome to contribute, check out
the CONTRIBUTING.md
for further guidance.
Let's have a look at a code-example:
use white_rabbit::{DateResult, Duration, Scheduler};
fn main() {
let mut scheduler = Scheduler::new(4);
scheduler.add_task_duration(Duration::seconds(5), |_| {
println!("I'm here!");
DateResult::Done
});
}
The scheduler sleeps when unneeded. Due to preemption or different implementations across operating systems, it may occur that the scheduler will sleep longer than intended.
Be aware, an incorrect system clock may lead to tasks being run earlier or later.
Add this to your Cargo.toml
:
[dependencies]
white_rabbit = "0.1.0"