armature-cron

Crates.ioarmature-cron
lib.rsarmature-cron
version0.1.1
created_at2025-12-26 22:38:38.594112+00
updated_at2025-12-29 00:50:30.720904+00
descriptionScheduled task execution for Armature applications
homepagehttps://pegasusheavy.github.io/armature
repositoryhttps://github.com/pegasusheavy/armature
max_upload_size
id2006366
size89,880
Joseph R. Quinn (quinnjr)

documentation

README

armature-cron

Cron job scheduling for the Armature framework.

Features

  • Cron Expressions - Standard cron syntax
  • Named Jobs - Identify and manage jobs
  • Async Tasks - Non-blocking job execution
  • Error Handling - Job failure callbacks
  • Timezone Support - Schedule in any timezone

Installation

[dependencies]
armature-cron = "0.1"

Quick Start

use armature_cron::CronScheduler;

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let scheduler = CronScheduler::new();

    // Run every minute
    scheduler.add("cleanup", "* * * * *", || async {
        println!("Running cleanup...");
        Ok(())
    })?;

    // Run daily at midnight
    scheduler.add("daily_report", "0 0 * * *", || async {
        generate_report().await
    })?;

    // Run every Monday at 9am
    scheduler.add("weekly_email", "0 9 * * MON", || async {
        send_weekly_digest().await
    })?;

    scheduler.start().await?;
    Ok(())
}

Cron Syntax

┌───────────── minute (0-59)
│ ┌───────────── hour (0-23)
│ │ ┌───────────── day of month (1-31)
│ │ │ ┌───────────── month (1-12)
│ │ │ │ ┌───────────── day of week (0-6, Sun=0)
│ │ │ │ │
* * * * *

License

MIT OR Apache-2.0

Commit count: 0

cargo fmt