diff --git a/Cargo.lock b/Cargo.lock index 35ef8e9..44754f3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1295,7 +1295,7 @@ checksum = "3e2e65a1a2e43cfcb47a895c4c8b10d1f4a61097f9f254f183aee60cad9c651d" [[package]] name = "matrix-feedbot" -version = "0.1.2" +version = "0.1.4" dependencies = [ "anyhow", "chrono", diff --git a/Cargo.toml b/Cargo.toml index 5f0425e..7716b61 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "matrix-feedbot" -version = "0.1.3" +version = "0.1.4" edition = "2021" license = "GPL-3.0-or-later" authors = ["mirsal "] diff --git a/src/main.rs b/src/main.rs index 0108182..637f181 100644 --- a/src/main.rs +++ b/src/main.rs @@ -59,6 +59,7 @@ async fn main() -> anyhow::Result<()> { let handles: Vec> = config.feeds.clone().into_iter().map(|feed_config| { let state_db = Arc::clone(&state_db); let bcast_tx = bcast_tx.clone(); + let mut backoff: u64 = feed_config.delay; tokio::spawn(async move { @@ -80,10 +81,15 @@ async fn main() -> anyhow::Result<()> { }; let feed = if feed.is_none() { - debug!("Sleeping for {} seconds before refreshing this feed", feed_config.delay); - sleep(Duration::from_secs(feed_config.delay)).await; + backoff = max(backoff * 2, 6 * 3600); + error!("Backing off for {} seconds", backoff); + sleep(Duration::from_secs(backoff)).await; continue; } else { + if backoff != feed_config.delay { + debug!("Resetting exponential backoff timer"); + backoff = feed_config.delay; + } feed.unwrap() }; diff --git a/src/matrix.rs b/src/matrix.rs index 8d571a9..3effc84 100644 --- a/src/matrix.rs +++ b/src/matrix.rs @@ -98,7 +98,7 @@ pub async fn login_and_sync( client .matrix_auth() .login_username(username, password) - .initial_device_display_name("bender v0.1.3") + .initial_device_display_name("bender v0.1.4") .await?; info!("logged in as {username}");