Skip to main content

larust_queue/
prune.rs

1//! Prunes old `failed_jobs` history - see [`crate::sql_worker::prune_failed_jobs`]/
2//! [`crate::redis_worker::prune_failed_jobs`] for the two implementations.
3//! Unlike [`crate::dispatch`]/[`crate::worker`], this has no per-job
4//! correctness requirement at all - it's best-effort housekeeping, meant to
5//! be called periodically (see `larust_support::maintenance::clean`), not
6//! from the worker loop itself.
7
8use larust_core::AppError;
9
10/// Deletes/trims old entries from whichever `failed_jobs` store
11/// [`crate::queue_driver`] selects - see the two backend-specific
12/// implementations' own doc comments for the exact retention policy each
13/// uses (time-based for SQL, count-based for Redis).
14pub async fn prune_failed_jobs() -> Result<(), AppError> {
15    match crate::queue_driver() {
16        "redis" => crate::redis_worker::prune_failed_jobs().await,
17        _ => crate::sql_worker::prune_failed_jobs().await,
18    }
19}