Skip to content

Commit

Permalink
Merge pull request #57 from bgpkit/bugfix/#56-add-timeouts
Browse files Browse the repository at this point in the history
add 30s timeouts to page requests
  • Loading branch information
digizeph authored Aug 22, 2024
2 parents b6361f7 + bb992da commit 50d2220
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/cli/bootstrap.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
// https://spaces.bgpkit.org/broker/bgpkit_broker.sqlite3

use futures_util::StreamExt;
use indicatif::{ProgressBar, ProgressStyle};
use std::cmp::min;
use std::fs::File;
use std::io::Write;

use futures_util::StreamExt;
use indicatif::{ProgressBar, ProgressStyle};
use std::time::Duration;

pub async fn download_file(url: &str, path: &str, silent: bool) -> Result<(), String> {
let client = reqwest::Client::builder()
.user_agent("bgpkit-broker/3")
.timeout(Duration::from_secs(30))
.build()
.or(Err("Failed to create reqwest client".to_string()))?;

Expand Down
2 changes: 2 additions & 0 deletions src/crawler/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ use crate::BrokerError;
use chrono::{Datelike, NaiveDate, Utc};
use regex::Regex;
use scraper::{Html, Selector};
use std::time::Duration;

const SIZE_KB: u64 = u64::pow(1024, 1);
const SIZE_MB: u64 = u64::pow(1024, 2);
Expand Down Expand Up @@ -87,6 +88,7 @@ pub(crate) async fn fetch_body(url: &str) -> Result<String, BrokerError> {
let client = reqwest::Client::builder()
.user_agent("bgpkit-broker/3")
.pool_max_idle_per_host(0)
.timeout(Duration::from_secs(30))
.build()?;
let body = client.get(url).send().await?.text().await?;
Ok(body)
Expand Down

0 comments on commit 50d2220

Please sign in to comment.