mvniekerk / tokio-cron-scheduler

Schedule tasks on Tokio using cron-like annotation
Apache License 2.0
519 stars 60 forks source link

[Feature] Add method to change schedule #71

Open JosiahParry opened 3 months ago

JosiahParry commented 3 months ago

It would be quite nice to be able to have a method that allows you to change the schedule of a job based on aUuid and a new cron schedule.

I can imagine a UI something like so:

let mut sched = JobScheduler::new().await?;

// Add basic cron job
let uuid = sched.add(
    Job::new("1/10 * * * * *", |_uuid, _l| {
        println!("I run every 10 seconds");
    })?
).await?;

let _ = sched.reschedule(&uuid, "10 * * * * *").await?;
mvniekerk commented 2 months ago

Interesting feature suggestion! Thank you for reporting.

JosiahParry commented 2 months ago

Of course! At present I've implemented this by removing the scheduled task and making a new one. It's a little bit roundabout but it works!