mirror of
https://github.com/OMGeeky/exponential_backoff.git
synced 2025-12-27 06:29:35 +01:00
more logging
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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");
|
||||
}
|
||||
|
||||
@@ -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(())
|
||||
|
||||
Reference in New Issue
Block a user