aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAlex Auvolat <alex@adnab.me>2022-12-11 22:45:58 +0100
committerAlex Auvolat <alex@adnab.me>2022-12-11 22:45:58 +0100
commit5731ad022b62564d1364cb1928d261dac04f8914 (patch)
tree227cae4c49b5169c0431ab07e19dbe7e1aa6b5cb /src
parent2e3442faa9625f706b4131417381d8fd2fb3bda3 (diff)
downloadD53-5731ad022b62564d1364cb1928d261dac04f8914.tar.gz
D53-5731ad022b62564d1364cb1928d261dac04f8914.zip
Reduce useless updates to help avoid rate limiting
Diffstat (limited to 'src')
-rw-r--r--src/dns_updater.rs11
1 files changed, 7 insertions, 4 deletions
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<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