From 5731ad022b62564d1364cb1928d261dac04f8914 Mon Sep 17 00:00:00 2001 From: Alex Auvolat Date: Sun, 11 Dec 2022 22:45:58 +0100 Subject: Reduce useless updates to help avoid rate limiting --- src/dns_updater.rs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/dns_updater.rs b/src/dns_updater.rs index e525f8a..98708ce 100644 --- a/src/dns_updater.rs +++ b/src/dns_updater.rs @@ -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 = 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 = rx_dns_config.borrow_and_update().clone(); for (key, value) in new_config.entries.iter() { // Skip entries that haven't changed -- cgit v1.2.3