Closed aldanchenko closed 1 year ago
Hey @aldanchenko, I was just having a play around with this and ran into a similar issue when copying the example from the docs.
Your issue is that JobScheduler::new();
is returning a future, so you'll need to await
it and then unwrap()
or match
to get the JobSchedulerLocked
which is where the add
function is actually implemented. I managed to get this working with the following snippet. Hopefully it helps you too.
#[tokio::main]
async fn main() {
let mut scheduler = JobScheduler::new().await;
match scheduler {
Ok(mut sched) => {
let job = Job::new("1/1 * * * * *", |uuid, l| {
println!("Running every second");
}).unwrap();
sched.add(job).await.unwrap();
// ...
This is just after a few minutes of playing around, so there might be a more idiomatic approach that someone can suggest!
Hi @aldanchenko Thanks for the report, I've updated the README. Also thanks @sudo-jaa for helping.
Hello,
I'm trying to use tokio-cron-scheduler in my project. But receiving this error after compilation
My code is next
Maybe you could help with this?
Thanks in advance!
Alex