diff --git a/ingestion/Cargo.toml b/ingestion/Cargo.toml index 421b90ba..2dc4d205 100644 --- a/ingestion/Cargo.toml +++ b/ingestion/Cargo.toml @@ -5,6 +5,7 @@ edition.workspace = true [features] integration_tests = [] +kafka = [] [dependencies] axum.workspace = true diff --git a/ingestion/src/lib.rs b/ingestion/src/lib.rs index 4c4700db..11fb711a 100644 --- a/ingestion/src/lib.rs +++ b/ingestion/src/lib.rs @@ -16,6 +16,7 @@ use std::{ use thiserror::Error; use tokio_postgres::NoTls; +#[cfg(feature = "kafka")] pub mod kvkafka; pub mod permissions; use permissions::{ParamPermitTable, StationPermitTable}; diff --git a/ingestion/src/main.rs b/ingestion/src/main.rs index fcb7be6e..cabb6526 100644 --- a/ingestion/src/main.rs +++ b/ingestion/src/main.rs @@ -1,8 +1,11 @@ use bb8_postgres::PostgresConnectionManager; -use lard_ingestion::{kvkafka, permissions}; use std::sync::{Arc, RwLock}; use tokio_postgres::NoTls; +#[cfg(feature = "kafka")] +use lard_ingestion::kvkafka; +use lard_ingestion::permissions; + const PARAMCONV: &str = "resources/paramconversions.csv"; #[tokio::main] @@ -40,11 +43,13 @@ async fn main() -> Result<(), Box> { }); // Set up postgres connection pool - let manager = PostgresConnectionManager::new_from_stringlike("LARD_STRING", NoTls)?; + let manager = + PostgresConnectionManager::new_from_stringlike(std::env::var("LARD_STRING")?, NoTls)?; let db_pool = bb8::Pool::builder().build(manager).await?; // Spawn kvkafka reader let kafka_group = args[1].to_string(); + #[cfg(feature = "kafka")] tokio::spawn(kvkafka::read_and_insert(db_pool.clone(), kafka_group)); // Set up and run our server + database diff --git a/integration_tests/Cargo.toml b/integration_tests/Cargo.toml index 6c45d033..6e2e30ff 100644 --- a/integration_tests/Cargo.toml +++ b/integration_tests/Cargo.toml @@ -8,7 +8,7 @@ debug = [] [dependencies] lard_api = { path = "../api" } -lard_ingestion = { path = "../ingestion", features = ["integration_tests"] } +lard_ingestion = { path = "../ingestion", features = ["integration_tests", "kafka"] } chrono.workspace = true tokio.workspace = true tokio-postgres.workspace = true