3 releases (breaking)
Uses new Rust 2024
new 0.3.0 | Apr 26, 2025 |
---|---|
0.2.1 | Apr 25, 2025 |
0.2.0 |
|
0.1.0 | Apr 25, 2025 |
#86 in #syntax
134 downloads per month
12KB
relayr
🏃♂️ 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.
⸻
🖤 Features
✅ 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
⸻
📦 Installation
Add to your Cargo.toml:
relayr = "0.3.0"
This will bring in the core scheduler, inventory, and macro support.
⸻
🧪 Example
use relayr::prelude::*;
#[relayr::cron("1/1 * * * * *")]
async fn print_every_second(_: JobId) {
println!("🖤 Hello from relayr 0.3.0!");
}
#[tokio::main]
async fn main() {
relayr::run().await
}
✅ That’s it!
When relayr::run() starts
, it automatically picks up all functions decorated with #[relayr::cron(...)]
and schedules them.
⸻
🧠 How it Works
- 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.
⸻
📁 Repo & Contributions
📦 Crate: https://crates.io/crates/relayr
🛠️ Repo: https://github.com/dsplce-co/relayr
PRs welcome! Let’s make scheduled Rust ✨clean and effortless.
⸻
📄 License
MIT or Apache-2.0, at your option.
Dependencies
~10–43MB
~589K SLoC