diff --git a/bkapi/src/main.rs b/bkapi/src/main.rs index 168d6d4..d12fe88 100644 --- a/bkapi/src/main.rs +++ b/bkapi/src/main.rs @@ -110,15 +110,7 @@ async fn main() { let tree_clone = tree.clone(); let config_clone = config.clone(); - if let Some(client) = client.clone() { - tracing::info!("starting to listen for payloads from nats"); - - tokio::task::spawn(async { - tree::listen_for_payloads_nats(config_clone, pool, client, tree_clone, sender) - .await - .unwrap_or_log(); - }); - } else if let Some(subscription) = config.database_subscribe.clone() { + if let Some(subscription) = config.database_subscribe.clone() { tracing::info!("starting to listen for payloads from postgres"); let query = config.database_query.clone(); @@ -128,6 +120,14 @@ async fn main() { .await .unwrap_or_log(); }); + } else if let Some(client) = client.clone() { + tracing::info!("starting to listen for payloads from nats"); + + tokio::task::spawn(async { + tree::listen_for_payloads_nats(config_clone, pool, client, tree_clone, sender) + .await + .unwrap_or_log(); + }); } else { panic!("no listener source available"); };