Skip to content

Commit

Permalink
Add feature to disable kvkafka ingestion
Browse files Browse the repository at this point in the history
  • Loading branch information
Lun4m authored and intarga committed Oct 11, 2024
1 parent cd22851 commit 8c791fa
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 4 deletions.
3 changes: 3 additions & 0 deletions ingestion/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ edition.workspace = true

[features]
integration_tests = []
kafka = []
# TODO: remove this when finished with testing Obsinn ingestion
kafka_prod = []

[dependencies]
axum.workspace = true
Expand Down
1 change: 1 addition & 0 deletions ingestion/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ use std::{
use thiserror::Error;
use tokio_postgres::NoTls;

#[cfg(feature = "kafka")]
pub mod kvkafka;
pub mod permissions;
use permissions::{ParamPermitTable, StationPermitTable};
Expand Down
14 changes: 11 additions & 3 deletions ingestion/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
use bb8_postgres::PostgresConnectionManager;
use lard_ingestion::{kvkafka, permissions};
use std::sync::{Arc, RwLock};
use tokio_postgres::NoTls;

use lard_ingestion::permissions;

const PARAMCONV: &str = "resources/paramconversions.csv";

#[tokio::main]
Expand Down Expand Up @@ -50,8 +51,15 @@ async fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
let db_pool = bb8::Pool::builder().build(manager).await?;

// Spawn kvkafka reader
let kafka_group = args[1].to_string();
tokio::spawn(kvkafka::read_and_insert(db_pool.clone(), kafka_group));
#[cfg(feature = "kafka_prod")]
{
let kafka_group = args[1].to_string();
println!("Spawing kvkafka reader...");
tokio::spawn(lard_ingestion::kvkafka::read_and_insert(
db_pool.clone(),
kafka_group,
));
}

// Set up and run our server + database
lard_ingestion::run(db_pool, PARAMCONV, permit_tables).await
Expand Down
2 changes: 1 addition & 1 deletion integration_tests/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 8c791fa

Please sign in to comment.