woddle
An async, synchronized, database-backed Rust job scheduler
Note: woddle requires at least Rust 1.60.
Usage
[]
= "0.5"
# For connection pooling
# woddle = { version = "0.5", features = ["pool-mobc"] }
Features
- Scheduling by interval
- Scheduling via cron (quartz)
- Synchronization between multiple instances via PostgreSQL
- Fully asynchronous (currently only Tokio)
- Optional database connection pooling using mobc
Setup
use ;
use Duration;
async
Setup with Connection Pool
use Pool;
use ;
use ;
use ;
use Duration;
async
More Examples
Can be found in the examples folder.
And ran with:
RUST_LOG=info
On intervals and cron
You can configure several intervals, delays and cron scheduling using this library.
RunnerConfig
initial_delay- delays the start of the job runner, when it is initially started (defaults to None)
check_interval- defines in which time interval the job runner checks, if any jobs should be run (defaults to 60s)
JobConfig
interval- the time interval at which the job should be runcron- the cron schedule the job should be run at (using quartz cron expressions)
Either interval, or cron need to be set on every job, otherwise the job runner will exit with an error. One thing to keep in mind when choosing these values is, to give your jobs enough time to run and to set the check_interval accordingly.
For example, the minimum run time with a cron expression is every 1 second. If you choose this with a very low check_interval such as every 10 ms, you might run into trouble. In such a case, it's possible that the job is run several times within the same second due to rounding issues.
So any run intervals in the low seconds, with sub-second checking intervals, might lead to inconsistencies and are out of scope of this library.