We're dsplce.co, check out our work on github.com/dsplce-co 🖤
🏃♂️ Effortless delegated cron jobs — scheduled tasks in Rust, made simple.
relayr makes it easy to register cron jobs across your codebase without manual boilerplate. Just annotate functions with a macro, and relayr will auto-discover and schedule them at runtime!
This crate is a wrapper around async-cron-scheduler to use it in a delegated flavour. If you aren't looking for the delegated way of defining your cron jobs it's probably better for you to use that.
⸻
✅ Register cron jobs with a simple macro
✅ Fully async
✅ No need to manually wire up each job
✅ Registration happens at compile time thanks to inventory
✅ Validates cron patterns at compile time
⸻
Add to your Cargo.toml:
relayr = "0.4"This will bring in the core scheduler, inventory, and macro support.
⸻
use relayr::prelude::*;
use chrono::Local;
#[relayr::cron("1/1 * * * * *")]
async fn print_every_second(_: JobId) -> anyhow::Result<()> {
println!("🖤 Hello from relayr 0.4.0!");
Ok(())
}
#[tokio::main]
async fn main() {
relayr::run::<Local>().await
}When relayr::run() starts, it automatically picks up all functions decorated with #[relayr::cron(...)] and schedules them.
⸻
- You annotate functions with
#[relayr::cron("cron pattern")]. - Under the hood, the macro registers your function in a global inventory.
- When
relayr::run()is called:- It spins up a scheduler.
- It iterates over all discovered Cron items.
- It inserts them into the scheduler automatically.
No manual wiring. No giant match blocks. Just clean, delegated jobs.
⸻
📦 Crate: https://crates.io/crates/relayr
🛠️ Repo: https://github.com/dsplce-co/relayr
PRs welcome! Let’s make scheduled Rust ✨clean and effortless.
⸻
MIT or Apache-2.0, at your option.