Closed JosiahParry closed 2 months ago
Thank you for the bug report, let me get back to you.
Ok, I've changed the docs. Hopefully it makes it more obvious?
/// Create a new async one shot job.
///
/// This will schedule a job that is only run once after the duration has passed.
///
/// ```rust,ignore
/// let mut sched = JobScheduler::new();
///
/// let job = Job::new_one_shot_async(Duration::from_secs(16), |_uuid, _l| {
/// Box::pin(async move {
/// info!("I'm only run once async");
/// })
/// })
/// .unwrap();
/// sched.add(job)
/// tokio::spawn(sched.start());
/// ```
/// Above will run the code after 18 seconds, only once
Yes thank you for the clarification!
The Job struct has methods such as
new_one_shot()
andnew_one_shot_async()
which require a duration as their first argument.It is unclear what this argument does as it is not documented nor do the other methods document it.
Does it delay the start of the job?
For other methods such as
new_repeated()
the duration is inferrable—i.e. it is repeated after the duration, but it is not clear fornew_one_shot()
.I'd be happy to make a PR updating the documentation if you can clarify it here.
Thanks!