Module pruner

Module pruner 

Source
Expand description

The API for configuring the job pruner.

After jobs have completed, been cancelled, or discarded it is useful to be able to clean up.

Given the different ways in which jobs can finish it is often useful to be able to have fine grained control over how old jobs should be cleaned up. PrunerConfig enables such control.

When constructing PrunerConfig a cron::Schedule is provided to specify when the pruner should run.

Depending on the load/throughput of the system the pruner can be scheduled to run anywhere from once a year through to multiple times per hour.

PrunerConfig can have a number of individual Pruners configured, each one specific for cleaning up jobs matching specify criteria. This way fine grained control can be achieved to. For example, is is possible to configure the pruner to achieve all of the following:

  • clean up completed jobs for a single executor so there is only 10 completed jobs at a time,
  • clean up all completed jobs for all executors that are more than a month old,
  • clean up cancelled jobs that are a year old, and
  • keeping all discarded jobs indefinitely.

§Example

To remove all completed jobs more than a month old for both the RefreshWorker and EmailScheduler while only maintaining the last 200 discarded jobs for all executors expect the EmailScheduler and RefreshWorker, you could use the following config.

let config = PrunerConfig::new(cron::Schedule::from_str("0 0 * * * *").unwrap())
    .with_max_concurrency(Some(2))
    .with_pruner(
        Pruner::max_age(TimeDelta::days(31), JobStatus::Complete)
            .only::<RefreshWorker>()
            .and::<EmailScheduler>(),
    )
    .with_pruner(
        Pruner::max_length(200, JobStatus::Discarded)
            .except::<RefreshWorker>()
            .and::<EmailScheduler>(),
    );

Structs§

PruneSpec
The specification of a single pruner for consumption by the backend.
Pruner
Configuration for a single pruner.
PrunerConfig
Fine grained configuration for how jobs should be cleaned up.

Enums§

PruneBy
The strategy to prune by.
Spec
An exclusion/inclusion specification.