Set fetcher timeout to 3 minutes
This commit is contained in:
parent
d0b4d77519
commit
872fe8fef3
2 changed files with 8 additions and 1 deletions
|
@ -6,6 +6,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
|
||||||
|
|
||||||
## [Unreleased]
|
## [Unreleased]
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- Set fetcher timeout to 3 minutes.
|
||||||
|
|
||||||
## [1.14.0] - 2023-02-22
|
## [1.14.0] - 2023-02-22
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
|
|
@ -24,6 +24,7 @@ use crate::media::{save_file, SUPPORTED_MEDIA_TYPES};
|
||||||
use crate::webfinger::types::{ActorAddress, JsonResourceDescriptor};
|
use crate::webfinger::types::{ActorAddress, JsonResourceDescriptor};
|
||||||
|
|
||||||
const FETCHER_CONNECTION_TIMEOUT: u64 = 30;
|
const FETCHER_CONNECTION_TIMEOUT: u64 = 30;
|
||||||
|
const FETCHER_TIMEOUT: u64 = 180;
|
||||||
|
|
||||||
#[derive(thiserror::Error, Debug)]
|
#[derive(thiserror::Error, Debug)]
|
||||||
pub enum FetchError {
|
pub enum FetchError {
|
||||||
|
@ -51,12 +52,14 @@ pub enum FetchError {
|
||||||
|
|
||||||
fn build_client(instance: &Instance) -> reqwest::Result<Client> {
|
fn build_client(instance: &Instance) -> reqwest::Result<Client> {
|
||||||
let mut client_builder = Client::builder();
|
let mut client_builder = Client::builder();
|
||||||
let connect_timeout = Duration::from_secs(FETCHER_CONNECTION_TIMEOUT);
|
|
||||||
if let Some(ref proxy_url) = instance.proxy_url {
|
if let Some(ref proxy_url) = instance.proxy_url {
|
||||||
let proxy = Proxy::all(proxy_url)?;
|
let proxy = Proxy::all(proxy_url)?;
|
||||||
client_builder = client_builder.proxy(proxy);
|
client_builder = client_builder.proxy(proxy);
|
||||||
};
|
};
|
||||||
|
let timeout = Duration::from_secs(FETCHER_TIMEOUT);
|
||||||
|
let connect_timeout = Duration::from_secs(FETCHER_CONNECTION_TIMEOUT);
|
||||||
client_builder
|
client_builder
|
||||||
|
.timeout(timeout)
|
||||||
.connect_timeout(connect_timeout)
|
.connect_timeout(connect_timeout)
|
||||||
.build()
|
.build()
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue