Skip to content
This repository has been archived by the owner on Jul 26, 2024. It is now read-only.

Commit

Permalink
feat: set a connect_timeout for reqwest client
Browse files Browse the repository at this point in the history
Closes #253
  • Loading branch information
pjenvey committed Aug 23, 2021
1 parent 5fad141 commit 6a363f2
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/server/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ impl Server {
let metrics = metrics_from_opts(&settings)?;
let tiles_cache = cache::TilesCache::new(TILES_CACHE_INITIAL_CAPACITY);
let req = reqwest::Client::builder()
.connect_timeout(Duration::from_secs(settings.connect_timeout))
.user_agent(REQWEST_USER_AGENT)
.build()?;
let img_store = StoreImage::create(&settings, &req).await?;
Expand Down
8 changes: 6 additions & 2 deletions src/settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@ pub struct Settings {
pub documentation_url: String,
/// Operational trace header
pub trace_header: Option<String>,
/// a JSON list of location DMAs to never return (population less than 15K)
pub exclude_dma: Option<String>,
/// Timeout (in seconds) for only the connect phase of all outbound HTTP requests
pub connect_timeout: u64,

// TODO: break these out into a PartnerSettings?
/// Adm partner ID (default: "demofeed")
Expand All @@ -81,8 +85,7 @@ pub struct Settings {
pub adm_ignore_advertisers: Option<String>,
/// a JSON list of advertisers to allow for versions of firefox less than 91.
pub adm_has_legacy_image: Option<String>,
/// a JSON list of location DMAs to never return (population less than 15K)
pub exclude_dma: Option<String>,

// OBSOLETE:
pub sub1: Option<String>,
pub partner_id: Option<String>,
Expand Down Expand Up @@ -113,6 +116,7 @@ impl Default for Settings {
trace_header: Some("X-Cloud-Trace-Context".to_owned()),
// exclude for: Glendive, MT(798); Alpena, MI(583); North Platte, NE (740)
exclude_dma: Some("[798, 583, 740]".to_owned()),
connect_timeout: 2,
// ADM specific settings
adm_endpoint_url: "".to_owned(),
adm_partner_id: None,
Expand Down

0 comments on commit 6a363f2

Please sign in to comment.