pub trait Job: Send + Sync {
// Required methods
fn schedule(&self) -> Schedule;
fn handle(&self);
// Provided methods
fn is_active(&self) -> bool { ... }
fn allow_parallel_runs(&self) -> bool { ... }
fn should_run(&self) -> bool { ... }
fn now(&self) -> DateTime<Utc> { ... }
}
Required Methods§
Provided Methods§
sourcefn is_active(&self) -> bool
fn is_active(&self) -> bool
Default implementation of is_active method will make this job always active
sourcefn allow_parallel_runs(&self) -> bool
fn allow_parallel_runs(&self) -> bool
In case your job takes longer to finish and it’s scheduled to start again (while its still running), default behaviour will skip the next run while one instance is already running. (if your OS has enough threads, and is spawning a thread for next job)
To override this behaviour and enable it to run in parallel
with other instances of self, return true
on this instance.
sourcefn should_run(&self) -> bool
fn should_run(&self) -> bool
Decide wheather or not to start running your job