pgboss 0.1.0-rc5

Rust implementation of PgBoss job queueing service
Documentation
use crate::{Client, Error};
use serde::Serialize;

/// Results of maintenance round.
#[derive(Debug, Clone, Default, Serialize)]
#[non_exhaustive]
pub struct MaintenanceStats {
    /// Number of jobs that were timed out.
    pub expired: u32,
}

impl Client {
    /// Force maintenance operations.
    ///
    /// This will force operations that are normally performed on a schedule,
    /// such as expiration, archival, and dropping, returning [`MaintenanceStats`].
    pub async fn force_maintain(&self) -> Result<MaintenanceStats, Error> {
        let (expired_count,): (i64,) = sqlx::query_as(&self.stmt.fail_jobs_by_timeout)
            .fetch_one(&self.pool)
            .await?;
        Ok(MaintenanceStats {
            expired: expired_count as u32,
        })
    }
}