lemmy uses clockwerk i believe, there's a few out there for rust.
Rust Programming
let mut scheduler = Scheduler::with_tz(chrono::Utc);
scheduler.every(10.minutes()).plus(30.seconds()).run(|| println!("Periodic task"));
scheduler.every(1.day()).at("3:20 pm").run(|| println!("Daily task"));
scheduler.every(Tuesday).at("14:20:17").and_every(Thursday).at("15:00").run(|| println!("Biweekly task"));
Damn, that a really ingenious and intuitive use of the builder pattern.
Kudos to the devs!
Scheduler
what library is it from?
The clokwerk crate.
@SuddenlyBlowGreen @nothingness I recently needed that, but fuzzy. Like I want a task ran anywhere between 1PM and 2PM. Can this be accomplished with the clockwerk crate?
You could schedule a task at 1 PM, then generate a random number between 0-60 inside that task, wait that many minutes, then launch the actual task.
Can you use async in your project?
If Yes, you can spawn a task that will listen on a channel. If you need to run them in parallel probably you can find a mpmc channel.
If you need for them to run at a specific time, spawn task ,tokio::time::sleep , run job, loop.
Don't know any crate just for this.