more logging

This commit is contained in:
OMGeeky
2023-04-05 17:22:30 +02:00
parent c84d4081a2
commit 7d617dd051
3 changed files with 4 additions and 2 deletions

View File

@@ -1,6 +1,6 @@
[package]
name = "exponential_backoff"
version = "0.1.1"
version = "0.1.2"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

View File

@@ -40,4 +40,5 @@ async fn sleep_for_backoff_time(backoff_time: u64, with_extra_buffer_time: bool)
total_millis
);
tokio::time::sleep(std::time::Duration::from_millis(total_millis)).await;
info!("sleep_for_backoff_time->Done sleeping");
}

View File

@@ -126,13 +126,14 @@ async fn handle_e429(value: String) -> Result<(), Box<dyn Error>> {
format!("Could not convert the provided timestamp: {}", value),
))?;
let now = chrono::Local::now().naive_local();
info!("Twitch Exponential Backoff: Got a Rate Limit Exceeded (429) response from Twitch. Sleeping until {} (now: {})", timestamp, now);
if timestamp < now {
info!("Sleeping for 1 second (timestamp < now)");
sleep_for_backoff_time(1, true).await;
return Ok(());
}
let duration = timestamp - now;
let duration = duration.num_seconds() as u64;
info!("Sleeping for {} seconds", duration);
sleep_for_backoff_time(duration, true).await;
//TODO: test this somehow
Ok(())