Less spam on stdout
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Alex 2023-01-11 22:44:21 +01:00
parent 5f946d485c
commit 86c255dfea
Signed by: lx
GPG key ID: 0E496D15096376BE
2 changed files with 12 additions and 5 deletions

View file

@ -19,7 +19,7 @@ const CNAME_TARGET_METADATA_TAG: &str = "cname_target";
// ---- Extract DNS config from Consul catalog ---- // ---- Extract DNS config from Consul catalog ----
#[derive(Debug)] #[derive(Debug, Eq, PartialEq, Default)]
pub struct DnsConfig { pub struct DnsConfig {
pub entries: HashMap<DnsEntryKey, DnsEntryValue>, pub entries: HashMap<DnsEntryKey, DnsEntryValue>,
} }

View file

@ -129,6 +129,8 @@ async fn dump_config_on_change(
mut rx_dns_config: watch::Receiver<Arc<dns_config::DnsConfig>>, mut rx_dns_config: watch::Receiver<Arc<dns_config::DnsConfig>>,
mut must_exit: watch::Receiver<bool>, mut must_exit: watch::Receiver<bool>,
) { ) {
let mut prev_dns_config = Arc::new(dns_config::DnsConfig::default());
while !*must_exit.borrow() { while !*must_exit.borrow() {
select!( select!(
c = rx_dns_config.changed() => { c = rx_dns_config.changed() => {
@ -138,12 +140,17 @@ async fn dump_config_on_change(
} }
_ = must_exit.changed() => continue, _ = must_exit.changed() => continue,
); );
let new_dns_config = rx_dns_config.borrow_and_update().clone();
if new_dns_config != prev_dns_config {
println!("---- DNS CONFIGURATION ----"); println!("---- DNS CONFIGURATION ----");
for (k, v) in rx_dns_config.borrow().entries.iter() { for (k, v) in rx_dns_config.borrow().entries.iter() {
println!(" {} {}", k, v); println!(" {} {}", k, v);
} }
println!(); println!();
} }
prev_dns_config = new_dns_config;
}
} }
/// Creates a watch that contains `false`, and that changes /// Creates a watch that contains `false`, and that changes