Skip to main content

vacuum_handler

Function vacuum_handler 

Source
pub fn vacuum_handler(threshold_percent: f64) -> VacuumHandler
Expand description

Returns a cron handler that checks DB health and vacuums if needed.

The handler extracts Service<Database> from the cron context. Register the Database in the service registry before building the scheduler.

ยงExample

use modo::cron::Scheduler;
use modo::db;
use modo::service::Registry;

let mut registry = Registry::new();
// registry.add(db.clone());

let scheduler = Scheduler::builder(&registry)
    .job("0 3 * * 0", db::vacuum_handler(20.0))?
    .start()
    .await;