main: Add a randomized delay before fetching feeds

This commit is contained in:
2024-11-26 21:34:21 +00:00
parent 24d824f759
commit 6dddbfb1e9
3 changed files with 7 additions and 0 deletions

View File

@ -63,6 +63,11 @@ async fn main() -> anyhow::Result<()> {
tokio::spawn(async move {
loop {
let delay = rand::random::<u64>() % (feed_config.delay / 5);
debug!("Adding randomized delay: {}", delay);
sleep(Duration::from_secs(delay)).await;
let feed: Option<_> = match fetch_and_parse_feed(&feed_config.url).await {
Ok(f) => Some(f),
Err(e) => {