Reduce useless updates to help avoid rate limiting
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Alex 2022-12-11 22:45:58 +01:00
parent 2e3442faa9
commit 5731ad022b
Signed by: lx
GPG key ID: 0E496D15096376BE

View file

@ -27,9 +27,6 @@ pub async fn dns_updater_task(
);
}
info!("DNS updater will start in 5 seconds");
tokio::time::sleep(Duration::from_secs(5)).await;
info!("DNS updater starting");
let mut config = Arc::new(DnsConfig::new());
@ -42,7 +39,13 @@ pub async fn dns_updater_task(
}
_ = must_exit.changed() => continue,
);
let new_config: Arc<DnsConfig> = rx_dns_config.borrow().clone();
// Always lag 15 seconds behind actual updates,
// to avoid sending too many at once and hitting rate limits
// TODO: retry regularly rate limits are hit
tokio::time::sleep(Duration::from_secs(15)).await;
let new_config: Arc<DnsConfig> = rx_dns_config.borrow_and_update().clone();
for (key, value) in new_config.entries.iter() {
// Skip entries that haven't changed