bloom-web-core 0.1.1

Core functionality for the Bloom web framework
use sqlx::MySqlPool;

/// A scheduled job registration entry provided by the #[scheduled] macro.
///
/// This struct represents a scheduled job that can be spawned and run periodically.
/// Each job has a name and a spawn function that starts the scheduled task.
pub struct Scheduled {
    pub name: &'static str,
    pub spawn: for<'a> fn(&'a MySqlPool),
}

inventory::collect!(Scheduled);

/// Starts all registered scheduled jobs.
///
/// This function iterates through all scheduled jobs registered via the inventory
/// system and spawns them using the provided database pool.
///
/// # Arguments
/// * `pool` - The MySQL connection pool to provide to scheduled jobs
pub fn start_all(pool: &MySqlPool) {
    for job in inventory::iter::<Scheduled> {
        (job.spawn)(pool);
    }
}