4 stable releases
1.2.0 | Feb 8, 2025 |
---|---|
1.1.2 | Feb 8, 2025 |
1.0.0 | Feb 3, 2025 |
#346 in Asynchronous
407 downloads per month
19KB
288 lines
recurring-tasks -- Recurring Tasks Manager
Rust crate to build an app that (simply) runs recurring, periodic tasks -- effectively cronjobs, in a dedicated process. And will not run a task that is already (still) running.
Can support sub-second periods, but runs the risk of falling behind, depending on the system / environment this runs on/in.
Full, but easily digestible, examples are in the examples dir.
This is designed to be a very focused solution for building an app that has only one job: running various tasks repeatedly, forever. Look at (not mine, just shoutout) tokio-cron-scheduler crate for a much more elaborate approach, using crontab syntax.
Very important: in WSL2, Rust's Instant
does not properly track seconds for some reason, the virtual clock seems to be just a tiny bit slow relatively to the actual clock, so it will often accumulate 2-3 extra seconds on 20 sec periods... The only way around it if you encounter this is to use the feature system
. The default flag of instant
is more appropriate for production use, because system
runs the risk of panicing or just behaving strangely if the system clock changes, especially backwards (daylight savings changes, etc).
Docs.rs documentation.
Dependencies
~4–13MB
~145K SLoC