Turnkeeper

A recurring job scheduler for Tokio with cron, interval and weekday/time schedules, retries and pluggable backends.

TurnKeeper is an asynchronous job scheduler for Rust that runs inside your Tokio application. You define jobs in code, hand them to the scheduler and it runs them on time, retries the ones that fail and tells you what it is doing.

Jobs can run at set weekday and time pairs, on a CRON expression, at a fixed interval, once at a given timestamp or only when triggered by hand. All times are UTC. A job's logic is an async function that returns true for success and false for failure. The job_fn! macro takes care of boxing and pinning it. Failed jobs are retried with exponential backoff by default or with a fixed delay. A panic inside a job is caught and treated like a failure.

Internally a coordinator task keeps the schedule in a priority queue and dispatches ready jobs to a pool of workers capped by max_workers. Because the coordinator does no job work itself, a slow or I/O-heavy job never holds up scheduling. Submission comes in async, blocking and non-blocking forms; try_add_job returns SubmitError::StagingFull when the buffer is full so callers get backpressure.

After a job is added you can cancel its lineage, change its schedule and retry settings with update_job and run it immediately with trigger_job_now. get_job_details, list_all_jobs and get_metrics_snapshot report schedules, next run times and counts of successes, failures, panics, retries and cancellations. Shutdown can wait for running jobs or cut them off after an optional timeout.

Unlike OS cron or a distributed task queue, TurnKeeper keeps jobs in-process next to your application state, with no broker to run.

[dependencies]
turnkeeper = { version = "1.2", features = ["full"] }
tokio = { version = "1", features = ["rt-multi-thread", "macros", "time"] }

Licensed under MPL-2.0. Source at https://github.com/excsn/turnkeeper and API docs at https://docs.rs/turnkeeper.