From 76504cdc286781901f020898a17d33972112e609 Mon Sep 17 00:00:00 2001 From: Syfaro Date: Wed, 12 Oct 2022 23:05:47 -0400 Subject: [PATCH] Use Postgres if database subscribe specified. --- bkapi/src/main.rs | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) 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"); };