Skip to content

ajmwagar/cronic

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

cronic

A cron-enabled task scheduler for async Rust

[dependencies]
cronic = "0.1"
tokio = { version = "1", features = ["full"] }
use cronic::Scheduler;
use std::error::Error;

#[tokio::main]
async fn main() -> Result<(), Box<dyn Error>> {
    Scheduler::new()
        .set_context(())
        .job("@hourly", &|_| {
            Box::pin(async {
                println!("Every hour!");
            })
        })
        .job("* * * * * *", &|_| {
            Box::pin(async {
                println!("Every second!");
            })
        })
        .job("0 * * * * *", &|_| {
            Box::pin(async {
                println!("Every minute!");
            })
        })
        .start()
        .await?;

    Ok(())
}

About

A cron-enabled scheduler for running async Rust tasks and functions.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages