diff --git a/src/bgworker/mod.rs b/src/bgworker/mod.rs index 9b2d64f55..be6b43b92 100644 --- a/src/bgworker/mod.rs +++ b/src/bgworker/mod.rs @@ -403,6 +403,7 @@ impl Queue { Self::Sqlite(pool, _, _) => { sqlt::clear_jobs_older_than(pool, age_days, Some(status)).await } + #[cfg(feature = "bg_redis")] Self::Redis(_, _, _) => { tracing::error!("clear jobs for redis provider not implemented"); Err(Error::string("clear jobs not supported for redis provider")) diff --git a/src/cli.rs b/src/cli.rs index d733f2aa0..d380c8003 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -106,6 +106,7 @@ enum Commands { #[clap(value_parser = parse_key_val::)] params: Vec<(String, String)>, }, + #[cfg(any(feature = "bg_redis", feature = "bg_pg", feature = "bg_sqlt"))] /// Managing jobs queue. Jobs { #[command(subcommand)] @@ -424,6 +425,7 @@ impl From for RunDbCommand { } } +#[cfg(any(feature = "bg_redis", feature = "bg_pg", feature = "bg_sqlt"))] #[derive(Subcommand)] enum JobsCommands { /// Cancels jobs with the specified names, setting their status to @@ -572,6 +574,7 @@ pub async fn main() -> crate::Result<()> { run_db::(&app_context, command.into()).await?; } } + #[cfg(any(feature = "bg_redis", feature = "bg_pg", feature = "bg_sqlt"))] Commands::Jobs { command } => handle_job_command::(command, &environment).await?, Commands::Routes {} => { let app_context = create_context::(&environment).await?; @@ -738,6 +741,7 @@ pub async fn main() -> crate::Result<()> { let app_context = create_context::(&environment).await?; run_task::(&app_context, name.as_ref(), &vars).await?; } + #[cfg(any(feature = "bg_redis", feature = "bg_pg", feature = "bg_sqlt"))] Commands::Jobs { command } => handle_job_command::(command, &environment).await?, Commands::Scheduler { name, @@ -796,6 +800,7 @@ fn create_root_span(environment: &Environment) -> tracing::Span { tracing::span!(tracing::Level::DEBUG, "app", environment = %environment) } +#[cfg(any(feature = "bg_redis", feature = "bg_pg", feature = "bg_sqlt"))] async fn handle_job_command( command: JobsCommands, environment: &Environment, diff --git a/src/tests_cfg/mod.rs b/src/tests_cfg/mod.rs index aff53c0ce..f32873b37 100644 --- a/src/tests_cfg/mod.rs +++ b/src/tests_cfg/mod.rs @@ -2,5 +2,6 @@ pub mod app; pub mod config; #[cfg(feature = "with-db")] pub mod db; +#[cfg(any(feature = "bg_pg", feature = "bg_sqlt"))] pub mod queue; pub mod task; diff --git a/src/tests_cfg/queue.rs b/src/tests_cfg/queue.rs index 7122cc35d..8d59105fc 100644 --- a/src/tests_cfg/queue.rs +++ b/src/tests_cfg/queue.rs @@ -1,7 +1,8 @@ -use std::path::PathBuf; - +#[cfg(any(feature = "bg_pg", feature = "bg_sqlt"))] use crate::bgworker; +use std::path::PathBuf; +#[cfg(feature = "bg_pg")] /// # Panics /// /// This function will panic if it fails to prepare or insert the seed data, causing the tests to fail quickly @@ -36,6 +37,7 @@ pub async fn postgres_seed_data(pool: &sqlx::PgPool) { } } +#[cfg(feature = "bg_sqlt")] /// # Panics /// /// This function will panic if it fails to prepare or insert the seed data, causing the tests to fail quickly