relayr

Crates.iorelayr
lib.rsrelayr
version0.4.0
created_at2025-04-25 17:23:54.367824+00
updated_at2025-05-01 21:18:29.192052+00
descriptionCron scheduler with a delegated-flavour syntax
homepage
repository
max_upload_size
id1649261
size45,198
Dmndz (d14mndz)

documentation

README

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.4.0"

This will bring in the core scheduler, inventory, and macro support.

🧪 Example

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
}

✅ 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.

Commit count: 0

cargo fmt